Can we write the keywords in capital letters?
No
What function do you use to display output?
print()
What is the keyword you use to check for an alternate condition in case the 'if' condition fails?
elif
What are the two loops we use in python?
while and for
Keyword used to represent a String
str
What is the keyword used for decimal values in python?
float
What is the function used to take input from the user?
input()
What is condition you check for a number n to be even?
n%2==0
What does the code do?
n = 6
c=0
while c<=n:
print(c)
c+=1
0 1 2 3 4 5
s = "Hello World!"
print(s[1:5])
ello
What would be the data type of the variable that holds the keyword True
Boolean
What function do you use to check the data type of the variable?
type()
if False and (10 / 1 > 2) or True :
print("A")
else:
print("B")
A
What are the 3 factors applied on loop variable?
Initialization, condition and updation
s = "Happy Halloween"
What should I type to get the word "Halloween" printed on output screen
print(s[6:]) or print(s[6:15])
False is not True evaluates to?
True
What is the default data type of the value that input() takes?
String
a, b, c = 5, 10, 15
if a > 0:
if b < 5:
print("First")
elif c == 15:
print("Second")
else:
print("Third")
else:
print("Fourth")
Second
i=1
while i<=5:
print(5//i)
i+=1
5 2 1 1 1
x = "abc"
y = "def"
print(x*2**1 + y)
abcabcdef
What is the keyword used for conditional statements other than if-else?
match and case
What is the output?
x = 82
y = 26
print("x+y")
x+y
What will you see on the output screen?
x = 5
y = 10
if not (x > 2 and y < 5) or y == 10:
print("Passed")
else:
print("Failed")
Syntax Error
x = 3
y = 0
while x < 15:
x = x * 2
y = y + x
print(x,y)
24 42
What does s[::-1] do to the string s?
Reverses the string