Eduarn – Online & Offline Training with Free LMS for Python, AI, Cloud & More

Sunday, December 7, 2025

🎯 TOP 15 PYTHON ASSIGNMENTS (QUESTIONS ONLY) - By Eduarn

 

🎯 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

name = "John" age = 25 country = "India" print(f"My name is {name}, I am {age} years old from {country}.")

2. Identify Data Types

values = [45, 3.14, "Hello", True, [1,2,3], (4,5), {1: "A"}] for v in values: print(v, type(v))

3. String Reverse

s = "Python" rev = "" for ch in s: rev = ch + rev print(rev)

4. String Count

text = input("Enter a string: ") vowels = "aeiouAEIOU" count = 0 for ch in text: if ch in vowels: count += 1 print("Vowel count:", count)

5. Convert Data Types

num = 10 print(str(num)) print(int("20")) print(int(5.98))

6. List Operations

nums = [10, 20, 30, 40, 50] nums.pop() nums.append(60) nums[1] = 200 print(nums)

7. Remove All Elements From List

a = [1, 2, 3] a.clear() b = [4, 5, 6] del b[:] c = [7, 8, 9] c[:] = [] print(a, b, c)

8. Find Maximum & Minimum

numbers = [12, 45, 3, 67, 2, 99, 4] print(max(numbers), min(numbers))

9. Sum of Digits

num = 123 total = 0 for digit in str(num): total += int(digit) print(total)

10. Swap Two Variables

a = 10 b = 20 a, b = b, a print(a, b)

11. List of Even Numbers

lst = [1,2,3,4,5,6,7,8] even = [x for x in lst if x % 2 == 0] print(even)

12. String Formatting

name = "Alex" course = "Python" year = 2025 print(f"{name} is studying {course} in {year}.")

13. Count Item in List

fruits = ["apple", "banana", "apple", "orange", "apple"] print(fruits.count("apple"))

14. Convert List to String

chars = ['P', 'y', 't', 'h', 'o', 'n'] print("".join(chars))

15. Check Data Type Input

data = input("Enter something: ") try: val = int(data) print("It is an Integer") except: try: val = float(data) print("It is a Float") except: print("It is a String")

No comments:

Post a Comment

5 Key Roles in AI Development Pipeline Every Student and Professional Must Know | Learn AI Hands-On with Eduarn

  Most people think “AI is built by one person.” Reality check: AI products are never created by a single person . Behind every AI-powered ...