Unit 3 Advance Python - Sample Viva Study Material
Unit 3 Advance Python - Sample Viva Study Material
• % Remainer/Modulus 6%5
• ** Exponent 6**2
Working of Logical Operators
• (4==4) or (5==8) gives True
• 5>8 or 5<2 gives false
• (4==4) and (5==8) gives false
• 8>5 and 2<5 gives true
• Not(5>2) gives false
• Not(3==5) gives true
Operator Precedence
Python Indentation
• Static Typing
• Datatype is attached with a variable
Multiple Assignments
• Assigning same value to multiple variables
• A=b=c=10
• Assigning multiple values to multiple
variables
• x,y,z=10,20,30
• x,y=y,x (swaps values)
DATA TYPES
• NUMBER – Integers, Long integers, Boolean, Float
• STRING – ‘boy’ “girl” “1234G”
• LIST: [1,2,3,4,5] or a=[‘a’, ‘e’, ‘I’ , ‘o’, ‘u’] o4r z= [‘Neha’,
102, 79.5]
GETTING USER INPUT
• Str=input(“Enter your name:”) Enter your name: Jiva
Hello Jiva
• Print(“Hello”, str)
Range(12,18) = [12,13,14,15,16,17]
Range(0,10,2) = [0,2,4,6,8]
Range(5,0,-1)=[5,4,3,2,1]
• For<variable> in <sequence>:
statements_to_repeat
For a in [1,4,7]:
Print(a)
For val in range(3,18)
print(val)
The while loop
A while loop is a conditional loop that will repeat the instructions
within itself as long as a conditional remains true.
While <logicalexpression>
loop-body
A=5
While a>0:
print(“hello”, a)
a=a-3
Print(“loop over!!”)