Foundation Course in Python
Foundation Course in Python
Python
Assessment 1
Assessment 1:
Q1. Which of below statements are valid and will print foo’bar
A) Print ('foo\'bar‘)
B) Print ('foo''bar‘)
C) Print ("foo'bar“)
D) Print ('foo'bar‘)
E) Print ("""foo'bar""“)
A) Print ('foo\'bar‘)
B) Print ('foo''bar‘)
C) Print ("foo'bar“)
D) Print ('foo'bar‘)
E) Print ("""foo'bar""“)
A) Float
B) Integer
C) String
D) List
Assessment 1:
Q2. What is the data type of print(type(10))
A) Float
B) Integer
C) String
D) List
Assessment 1:
Q3. What is the data type of print(type[10]))
A) Float
B) Integer
C) String
D) List
Assessment 1:
Q3. What is the data type of print(type[10]))
A) Float
B) Integer
C) String
D)List
Assessment 1:
Q4. What is the data type of print(type(“10”))
A) Float
B) Integer
C) String
D) List
Assessment 1:
Q4. What is the data type of print(type(“10”))
A) Float
B) Integer
C) String
D) List
Assessment 1:
Q5. What is the output of below code:
str1 = "PYnative"
print(str1[1:4], str1[:5], str1[4:], str1[0:-1], str1[:-1])
str1 = "PYnative"
print(str1[1:4], str1[:5], str1[4:], str1[0:-1], str1[:-1])
a) P8
Y 16
b) P
12
c) Y
16
Assessment 1:
Q7. What is the output of below code:
a) P8
Y 16
b) P
12
c) Y
16
Assessment 1:
Q8. What is the output of below code:
aList = [10, 20, 30, 40, 50, 60, 70, 80]
print(aList[2:5])
print(aList[:4])
print(aList[3:])
a) We can remove the item from tuple but we cannot update items of the
tuple
b) We cannot delete the tuple
c) We cannot remove the items from the tuple
d) We cannot update items of the tuple.
Assessment 1:
Q11. Select true statements regarding the Python tuple
a) We can remove the item from tuple but we cannot update items of the
tuple
b) We cannot delete the tuple
c) We cannot remove the items from the tuple
d) We cannot update items of the tuple.
Assessment 1:
Q12. Write a Python program to print the following string in same format:
Note: Check for quotes, new line and tabs.
Example:
Name=“John”
Output should be “nhoJ”
Assessment 1:
Q15. Write a Python program to display the first and last colors from the following list.
a) True
b) False
Quiz:
Q3. if -3: will evaluate to
a) True
b) False
Quiz:
Q4. What is the value of x
x=0
while (x < 100):
x=x+2
print(x)
a) 101
b) 99
c) None of the above, this is an infinite loop
d) 100
Quiz:
Q4. What is the value of x
x=0
while (x < 100):
x=x+2
print(x)
a) 101
b) 99
c) None of the above, this is an infinite loop
d) 100
Quiz:
Q5. What is the output of the following if statement
a, b = 12, 5
if a + b:
print('True')
else:
print('False')
a) True
b) False
Quiz:
Q5. What is the output of the following if statement
a, b = 12, 5
if a + b:
print('True')
else:
print('False')
a) True
b) False
Loops:
FOR LOOP
For Loop:
A for loop is used for iterating over a sequence (that is
either a list, a tuple, a dictionary, a set, or a string).