🎯 TOP 15 PYTHON ASSIGNMENTS (QUESTIONS ONLY)
✅ 1. Variable Assignment
Create three variables:
name, age, and country, assign values, and print them in a sentence.
✅ 2. Identify Data Types
Given the values:
45, 3.14, "Hello", True, [1,2,3], (4,5), {1: "A"}
Print each value and its data type.
✅ 3. String Reverse
Write a Python program to reverse a string without using slicing.
✅ 4. String Count
Ask the user for a string and count how many vowels it contains.
✅ 5. Convert Data Types
Convert:
-
integer → string
-
string → integer
-
float → integer
Print all outputs.
✅ 6. List Operations
Given a list nums = [10, 20, 30, 40, 50]:
-
Remove the last element
-
Add a new element
60 -
Replace 20 with 200
-
Print the final list
✅ 7. Remove All Elements From List
Write a program to empty a list using 3 different methods.
✅ 8. Find Maximum & Minimum
From a list of numbers: [12, 45, 3, 67, 2, 99, 4]
Print the highest and lowest number.
✅ 9. Sum of Digits
Input a number and calculate the sum of its digits.
Example: 123 → 1+2+3 = 6
✅ 10. Swap Two Variables
Swap the values of two variables without using a third variable.
✅ 11. List of Even Numbers
Take a list from the user and print only even numbers.
✅ 12. String Formatting
Create a sentence using f-string that includes:
name, course, year.
✅ 13. Count Item in List
Given: fruits = ["apple", "banana", "apple", "orange", "apple"]
Count how many times "apple" appears.
✅ 14. Convert List to String
Convert list ['P', 'y', 't', 'h', 'o', 'n'] into a single string.
✅ 15. Check Data Type Input
Ask user to enter anything and program should print Whether it is:
-
Number
-
String
-
Float
-
List
(Use type conversion and conditions)
✅ ANSWERS BELOW (SOLUTIONS)
1. Variable Assignment
2. Identify Data Types
3. String Reverse
4. String Count
5. Convert Data Types
6. List Operations
7. Remove All Elements From List
8. Find Maximum & Minimum
9. Sum of Digits
10. Swap Two Variables
11. List of Even Numbers
12. String Formatting
13. Count Item in List
14. Convert List to String
15. Check Data Type Input
No comments:
Post a Comment