Python Practice Question For The M1
Python Practice Question For The M1
Python Practice Question For The M1
10 Write a program that keeps asking the user for input until they enter 'exit'.
11 Create a list of integers and print the sum of all elements.
12 Add an element to a list and print the updated list
13 Access and print the second element of a tuple.
14 Create a set of unique numbers and print it
OR
Add an element to a set and print the updated set.
15 Reverse a string and print it
OR
count the number of vowels in a string.
16 Create a dictionary with three key-value pairs and print it.
OR
Access and print the value associated with a specific key in a dictionary
17 Remove an element from a list and print the updated list.
Sort a list of numbers in ascending order.
18 Write a Python program that calculates the factorial of a number using
a for loop
19 reate a simple calculator that performs addition, subtraction, multiplication,
or division based on user input.
20 Find the maximum and minimum values in a list.
OR
Create a list of squares of numbers from 1 to 10.
21 Create a program that generates Fibonacci numbers up to n using loops.
22 Calculate the area of a rectangle given its length and width via user input.
23 Write a program that checks if a year is a leap year.
24 Write a program that assigns grades based on scores (A, B, C, D, F).
25 Create a variable `x`, assign it your favorite number, and print it.
OR
Swap the values of two variables and print them.