Quiz for:
Python Programming Course Notes

Question 1

How do you create an instance of a class in Python?

Question 2

How do you define a function in Python?

Question 3

How do you access the second element in a 2D list?

Question 4

Which function would you use to get the absolute value of a number?

Question 5

Which statement is true about 'while' loops in Python?

Question 6

What does the following code do? ```python def raise_to_power(base_num, pow_num): result = 1 for index in range(pow_num): result *= base_num return result ```

Question 7

What will the following code output? ```python import math print(math.sqrt(36)) ```

Question 8

How do you concatenate strings in Python?

Question 9

What is the function of 'r' mode in file handling?

Question 10

What will the following code output? ```python def translate(phrase): translation = '' for letter in phrase: if letter in 'AEIOUaeiou': translation += 'g' else: translation += letter return translation print(translate('Hello')) ```

Question 11

What will the output of this code be? ```python phrase = 'Draft Academy' print(phrase.index('A')) ```

Question 12

How can you handle missing keys in Python dictionaries?

Question 13

Which version of Python is recommended for future development and why?

Question 14

What functions can be used to change the case of a string?

Question 15

In the context of inheritance, what will be the output of this program? ```python class Chef: def make_chicken(self): print('The chef makes a chicken') class ChineseChef(Chef): def make_special_dish(self): print('The chef makes orange chicken') myChineseChef = ChineseChef() myChineseChef.make_chicken() ```