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!
- Print "Hello, World!"
Write a Python program to print "Hello, World!" to the console.
- Sum of Two Numbers
Write a Python program that takes two numbers as input and prints their sum.
- Odd or Even
Write a Python program to check if a number entered by the user is odd or even.
- Factorial of a Number
Write a Python program to find the factorial of a number entered by the user.
- Palindrome Checker
Write a Python program to check whether a given string is a palindrome (reads the same forwards and backwards).
- Fibonacci Sequence
Write a Python program to print the Fibonacci sequence up to a specified number.
- Prime Number
Write a Python program to check if a number is prime or not.
- Count Vowels in a String
Write a Python program that takes a string as input and counts the number of vowels in it.
- List Sorting
Write a Python program that sorts a given list of numbers in ascending order.
- Find Largest Number in a List
Write a Python program to find the largest number in a given list of numbers.
- Reverse a String
Write a Python program that takes a string and prints it in reverse order.
- Sum of Digits in a Number
Write a Python program to find the sum of digits of a number entered by the user.
- 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.
- Convert Celsius to Fahrenheit
Write a Python program to convert temperature from Celsius to Fahrenheit.
- List Comprehension
Write a Python program that uses list comprehension to create a list of squares of numbers from 1 to 10.
- Dictionary Operations
Write a Python program to create a dictionary, add a new key-value pair, and print the dictionary.
- 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).
- Merge Two Lists
Write a Python program to merge two lists into a single list.
- Find Common Elements Between Two Lists
Write a Python program that finds common elements between two lists.
- Remove Duplicates from a List
Write a Python program that removes duplicate elements from a list and returns a new list with unique elements.