Python Ex 02

Python Exercises: 20 Questions

Here are 20 Python programming exercises for you to practice various Python concepts such as data types, loops, functions, and more. Try solving each one and improve your skills!

  1. Print "Hello, World!"
    Write a Python program to print "Hello, World!" to the console.
  2. Sum of Two Numbers
    Write a Python program that takes two numbers as input and prints their sum.
  3. Odd or Even
    Write a Python program to check if a number entered by the user is odd or even.
  4. Factorial of a Number
    Write a Python program to find the factorial of a number entered by the user.
  5. Palindrome Checker
    Write a Python program to check whether a given string is a palindrome (reads the same forwards and backwards).
  6. Fibonacci Sequence
    Write a Python program to print the Fibonacci sequence up to a specified number.
  7. Prime Number
    Write a Python program to check if a number is prime or not.
  8. Count Vowels in a String
    Write a Python program that takes a string as input and counts the number of vowels in it.
  9. List Sorting
    Write a Python program that sorts a given list of numbers in ascending order.
  10. Find Largest Number in a List
    Write a Python program to find the largest number in a given list of numbers.
  11. Reverse a String
    Write a Python program that takes a string and prints it in reverse order.
  12. Sum of Digits in a Number
    Write a Python program to find the sum of digits of a number entered by the user.
  13. Count Occurrences of a Word
    Write a Python program that takes a string and a word as input, and counts how many times the word appears in the string.
  14. Convert Celsius to Fahrenheit
    Write a Python program to convert temperature from Celsius to Fahrenheit.
  15. List Comprehension
    Write a Python program that uses list comprehension to create a list of squares of numbers from 1 to 10.
  16. Dictionary Operations
    Write a Python program to create a dictionary, add a new key-value pair, and print the dictionary.
  17. Check Armstrong Number
    Write a Python program to check if a number is an Armstrong number (a number that is equal to the sum of its digits raised to the power of the number of digits).
  18. Merge Two Lists
    Write a Python program to merge two lists into a single list.
  19. Find Common Elements Between Two Lists
    Write a Python program that finds common elements between two lists.
  20. Remove Duplicates from a List
    Write a Python program that removes duplicate elements from a list and returns a new list with unique elements.