Lab 1 - Python
Lab 1 - Python
SECTION 1
Python
One of the world's most popular
programming languages.
Simple syntax
Powerful Allows developers to
similar to the
development write programs with
English language
libraries include fewer lines than
and so easy to
AI, ML etc some other
learn
programming
languages.
Python's abilities
1- Download latest
version of python from:
“www.python.org”
Variables
What is variables?
• In Python, variables are like storage spaces where we can keep
information in our program.
• Computer's memory locations are having a number or address,
internally represented in binary form.
100
• It stores the values in a randomly chosen
108
memory location.
• Python's built-in id() function returns the 116
124
address where the object is stored.
132 A
140
148
156
Variables Declaration in python
• High level languages like Python make it possible to give a suitable
alias or a label to refer to the memory location.
• A Python variable is created automatically when you assign a value to
it.
• The equal sign (=) is used to assign values to variables.
4
Printing Python Variables
String Formatting (f-string):
Python 3.6 and later versions support f-strings, which provide a concise and
readable way to embed variables in strings.
In earlier Python versions, you can use the % operator for string formatting
Printing Python
Variables
Printing multiple lines:
1. Implicit casting
• Python automatically converts one data type to another when needed.
2. Explicit casting
• You explicitly convert a data type to another using predefined functions like:
• Int()
• float()
• str()
Python Type Casting
◾ input() → Data type of input data is String so if you want to change it use TYPE CASTING.
USER INPUT
Example: Write a program to read the user first name and last name then, print Hello to the
username.
USER INPUT
EX
◾ Write a program to read two number from user and calculate
summation.
solution
EX
◾ Write a program to read the user first ,middle and last name
then, print Hello to the username in the format like the
following:
“ Hello, Ahmed Mohamed Saad ”