1. Create a simple calculator program that can perform basic arithmetic operations such as addition, subtraction, multiplication, and division.
2. Write a program that generates a random number and asks the user to guess it. Provide feedback to the user if their guess is too high or too low.
3. Create a program that converts temperature from Celsius to Fahrenheit and vice versa.
4. Write a program that takes a list of numbers as input and calculates the sum, average, maximum, and minimum of the numbers.
5. Implement a simple text-based game such as a number guessing game or a word guessing game.
Multiple Choice Questions (MCQs):
1. Which of the following data types is immutable in Python? a) List b) Tuple c) Dictionary d) Set
2. What is the output of the following code snippet? ```python x = 5 y = 2 print(x ** y) ``` a) 10 b) 25 c) 7 d) 32
3. What does the `range()` function in Python return? a) A list of numbers b) A tuple of numbers c) An iterator of numbers d) A dictionary of numbers
4. What is the correct way to create a function in Python? a) def my_function(): b) function my_function(): c) define my_function(): d) func my_function():
5. What does the `len()` function in Python return? a) The length of a string b) The length of a list c) The length of a tuple d) All of the above
0
Google Gemini AI
11 hours ago
MCQs on Python Basics
1. Which of the following is the correct syntax for defining a variable in Python? (a) var = value (b) variable: value (c) variable := value (d) set variable = value
2. What is the output of the following Python code? ```python a = 5 b = 3 print(a + b) ``` (a) 8 (b) "8" (c) 8.0 (d) "35"
3. Which of the following data types is used to represent a sequence of characters? (a) Int (b) Float (c) String (d) Boolean
4. What is the purpose of the `input()` function in Python? (a) To get user input (b) To print a message to the console (c) To define a variable (d) To convert a string to a number
5. Which of the following operators is used for string concatenation? (a) + (b) - (c) - (d) /
6. What is the output of the following Python code? ```python my_list = [1, 2, 3] my_list.append(4) print(my_list) ``` (a) [1, 2, 3, 4] (b) [4, 1, 2, 3] (c) 1234 (d) None
7. Which of the following control flow statements is used for repetitive tasks? (a) If statement (b) For loop (c) While loop (d) Break statement
8. What is the purpose of the `break` statement in Python? (a) To terminate a loop (b) To skip an iteration of a loop (c) To define a variable (d) To call a function
9. Which of the following is the correct syntax for writing a function in Python? (a) def function_name(): (b) function function_name: (c) function := function_name (d) set function_name =
10. What is the difference between a local variable and a global variable in Python? (a) Local variables are accessible within a function, while global variables are accessible outside of a function. (b) Global variables are accessible within a function, while local variables are accessible outside of a function. (c) There is no difference between local and global variables in Python. (d) Local variables are only visible in the current block, while global variables are visible throughout the entire module.