Future Bilingual School for Girls
IT Class work- Python
Answer the following;
1. In Python “Hello” is same as ‘ hello’
True
False
2. What is the correct syntax to output “Hello World: in pythn
Print(hello world)
Print (“hello world”)
P(hello world)
3. What is the sign of multiplication In python?
+
/
-
*
4. Write a program to multiply three numbers
5.Write a program to display Kuwait is a beautiful country
6.Write a program to add 5 number
Variables
A variable is a reserved memory area (memory address) to store value.
Creating a variable
We can assign a value to the variable at that time variable is created. We can use
the assignment operator = to assign a value to a variable.
Example:
name = "John"
age = 25
salary = 25800.60
print(name)
print(age)
print(salary)
Different types of Variables
1. Number
Integer variable
The int is a data type that returns integer type values (signed integers); they are
also called ints or integers.
Example:
age = 28
print(age)
print(type(age))
Float variable
Floats are the values with the decimal point dividing the integer and the fractional
parts of the number. Use float data type to store decimal values.
Example:
salary = 10800.55
print(salary)
print(type(salary))
Complex type
The complex is the numbers that come with the real and imaginary part. A
complex number is in the form of a+bj, where a and b contain integers or floating-
point values.
a = 3 + 5j
print(a)
print(type(a))
String variable
In Python, a string is a set of characters represented in quotation marks. Python
allows us to define a string in either pair of single or double quotation marks. For
example, to store a person’s name we can use a string type.
str = 'PYnative'
print(str)
Get the data type of variable
No matter what is stored in a variable (object), a variable can be any type
like int, float, str, list, tuple, dict, etc. There is a built-in function called type() to get
the data type of any variable.
Example:
a = 100
print(type(a))
b = 100.568
print(type(b))
str1 = "PYnative"
print(type(str1))
my_list = [10, 20, 20.5, 100]
print(type(my_list))
my_set = {'Emma', 'Jessa', 'Kelly'}
print(type(my_set))
my_tuple = (5, 10, 15, 20, 25)
print(type(my_tuple))
my_dict = {1: 'William', 2: 'John'}
print(type(my_dict))