0% found this document useful (0 votes)
5 views18 pages

Introduction to Python Programming

This document is a practical guide for an introductory Python programming course, covering essential topics such as variables, constants, data types, and Python syntax. It highlights the ease of learning Python for beginners and provides instructions on how to run Python programs using various methods, including online compilers and IDEs. Additionally, it outlines rules for naming conventions and the importance of comments in programming.

Uploaded by

ayman2kkid
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views18 pages

Introduction to Python Programming

This document is a practical guide for an introductory Python programming course, covering essential topics such as variables, constants, data types, and Python syntax. It highlights the ease of learning Python for beginners and provides instructions on how to run Python programs using various methods, including online compilers and IDEs. Additionally, it outlines rules for naming conventions and the importance of comments in programming.

Uploaded by

ayman2kkid
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python

ITC1023: Computer Programing(2019/2020)


Practical

By: [Link]
Python
01 Introduction
Unit - 01
Agenda

1. Intoduction

2. The Easiest Way to Run Python

3. Variables

4. Constants

5. Rules and Naming Convention for Variables and constants

6. Python Comments

7. Data types

8. Python Type Conversion and Type Casting

9. Python Input, Output and Import (Read/ Print)

10. Python Operators


Intoduction
What is a programming?

programming languages is used to communicate computer

Programming Languages

Low Level Language Middle Level Language High Level Language


(Machine Language) (Assemply Language) (Human Language)

Java, C#,
Pyhton
Intoduction
Why python is a good choices for biggners?

1. Easiest to Learn because of easy to use syntax.

Java Python

Public class AddTwoIntegers{ a = 10


public static void main(String[] args){ b = 20
int a = 10; sum = a + b
int b = 20;
print(“The sum is: ”, sum)
int sum = a + b;
[Link](“The sum is: “ + sum);
}
}
Intoduction
Why python is a good choices for biggners?

2. Popularity and applications. Python is used in


1. Meachine Learning
2. Web Development
3. Data Analysis
4. Scientific Research
5. Automation
The Easiest Way to Run Python
1. Programize Python Online Compiler
Link: [Link]
The Easiest Way to Run Python
2. Using Thonny IDE.

Steps:

I. Download Thonny IDE. ( [Link] )

II. Run the installer to install Thonny on your


computer.

III. Go to: File > New. Then save the file with .py
extension. For example, [Link],
[Link], etc.

IV. You can give any name to the file. However,


the file name should end with .py.

V. Then Go to Run > Run current script or


simply click F5 to run it.
The Easiest Way to Run Python
3. Install Python Separately and Run Python in
Immediate mode

Steps:

I. Download the latest version of Python.


([Link]

II. Run the installer file and follow the steps to


install Python

III. During the install process, check Add Python


to environment variables. This will add
Python to environment variables, and you can
run Python from any part of the computer.

IV. Once you finish the installation process, you


can run Python.
The Easiest Way to Run Python

V. Once Python is installed, typing python in the command line will invoke the interpreter in
immediate mode.

VI. We can directly type in Python code, and press Enter to get the output.

VII. Run the installer file and follow the steps to install Python
Your first Python Program
1. Type the following code in any text editor or an IDE and save it as hello_world.py

2. Then, run the file. You will get the following output.
Python Variables
 A variable is a named location used to store data in the memory.

 It is helpful to think of variables as a container that holds data that can be changed later in
the program. For example,
number = 10

 Here, we have created a variable named number. We have assigned the value 10 to the
variable.

 Let see another example,


number = 10
number = 1.1
Initially, the value of number was 10. Later, it was changed to 1.1.
Python Variables
 Assigning values to Variables in Python

Output
Python Constants
 A constant is a type of variable whose value cannot be changed.

 It is helpful to think of constants as containers that hold information which cannot be


changed later.

 Assigning value to constant in Python

 In Python, constants are usually declared and assigned in a module.

 Here, the module is a new file containing variables, functions, etc which is imported to
the main file.

 Inside the module, constants are written in all capital letters and underscores separating
the words.
Python Constants
 Declaring and assigning value to a constant

1. Create a [Link]: Output

2. Create a [Link]:

1. In the above program, we create a [Link]


module file.
2. Then, we assign the constant value to PI, GRAVITY
and TOTAL_NUM.
3. After that, we create a [Link] file and import the
constant module.
4. Finally, we print the constant value.
Rules and Naming Convention for
Variables and constants
1. Constant and variable names should have a combination of letters in lowercase (a to z) or
uppercase (A to Z) or digits (0 to 9) or an underscore (_). For example:
• snake_case
• MACRO_CASE
• camelCase
• CapWords

2. Create a name that makes sense. For example, vowel makes more sense than v.

3. If you want to create a variable name having two words, use underscore to separate them. For
example:
• my_name
• current_salary
Rules and Naming Convention for
Variables and constants
4. Use capital letters possible to declare a constant. For example:
• PI
• G
• MASS
• SPEED_OF_LIGHT
• TEMP

5. Never use special symbols like !, @, #, $, %, etc.

6. Don't start a variable name with a digit.


Python Comments
 Comments are very important while writing a program.

 They describe what is going on inside a program, so that a person looking at the source code
does not have a hard time figuring it out.

 In Python, we use the hash (#) symbol to start writing a comment.

 Multi-line comments

You might also like