Class 1 Python
Class 1 Python
In [ ]:
2. variables
3. identifiers
4. Reserved words
7. Comments
Hello World!
1. int - any value without a decimal point eg 10, -99, 100, 200
4. None - null
5. Bool - True/False
6. complex - any value that can be represented in the form of a+bj where a is real and b is imaginary
In [1]: print(10)
Out [1]: 10
In [3]: print(-100.2)
-100.2
In [5]: print(True)
In [6]: print(11+2j)
(11+2j)
It's a cat
1. Abbas
2. Huzefa
In [34]: a=10.2
In [35]: print(type(a))
<class 'float'>
Literals and Varibales
a = 10
a -> var
= -> operator
10 -> literal/values
In [9]: a=10
print(a)
b=20.2
print(b)
b=20
print(b)
10
20.2
20
identifier - it is used in python for naming varibales, class name, function name, object name
Rules
In [10]: abc123=10
print(abc123)
10
In [11]: abc*123=10
print(abc*123)
In [12]: 123abc=10
print(123abc)
In [15]: addp=10
Addp=20
print(addp)
print(Addp)
10
20
print(keyword.kwlist)
['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', '
In [19]: True_1=10
print(True_1)
10
Statments - unit of code that performs an action and will not give you output
In [20]: 10+20+30
Out [20]: 60
In [21]: a=10
In [24]: print('1')
print('2')
if 10<10.2:
print('3')
print('4')
if 15<10:
print("Hello from inner if!")
print('5')
print('6')
1
2
3
4
5
6
7. comments
1. it can be used to explain the python code
In [ ]: pi = 3.14
r = 11
a = r*r
print(a)
pi = 3.14
r = 11 #side of sqaure
a = r*r #area of sqaure
print(a)
In [25]: """
Hello Abbas
Hello again
"""
a=10
print(a)
10
In [ ]: