Python Notes
Python Notes
Data
types :
1 .
int >
-
.
2 float >
-
1.
3
.
string >* -
4 .
boolean > True/False
-
O
. Condition
e 5 1= 6 >
- True
.
g
.
13 25 >
- False
3 = = 4 >
-
False
.
"Hello world
"
Hello World" == >
- true
Advanced level :
different the
components in order to achieve results
they wanted
.
here fundermental
are some
components :
1 .
If else statement
Structure :
indition
elifestation :
action
else :
Action
2 . for Loop
It creates an
loop for a fixed and given amount of timeliteration
.
e.
g .
for i in
range
(0 , 3) :
(str(i)
print
Output : 0 12
variable Which
"
It's a for loop inside another for loop . Just like the movie Inception.
for i in (0 3) :
e
g .: range ,
.
for ; in
range (0 ,
4) :
print (i ,
j
Note that the 2nd iteration of the first for leep (i) will only begin after
the last iteration of the second for
loop (j)
times
which
implies the code above should 12 run
in total
= N for loop (XI) runy , -A for loop run ni ,
E* run 3x4 =
12 a
While
3 .
loop
fulfilled
It create a
loop that will
keep running forever until given condition is
While
structure : datin
C .
G
. While is-raining ==
True :
use Umbrella
Array
-
List :
12/0741-5/9/100
Index : 0 1 2 3 4 5
list -
1 =
[ 12 , 0 ,
4 , -5 , 9 ,
100]
**** -
E program List XGREEEP X 2 :
list. 1 = [ 12 , 0
,
4 ,
-
5 ,
9
,
100]
for i in
range
(o , 6) :
#
list [[i]-
= list 1ti] - 2
print (list - 1)
Output : [24, 0
,
8 , -10 , 18 , 2007
Exercise :
line1 :
line 2 :
line3 :