Payload: Getting Started with Python (Python Basics)
Easy
1. Calculate the Area of a Circle
Write a Python program that calculates the area of a circle given its radius.
o Input:
5
o Output:
78.54
(Hint: Use the formula: πr²)
2. Convert Celsius to Fahrenheit
Write a Python program that converts a temperature from Celsius to Fahrenheit.
o Input:
0
o Output:
32
(Hint: Use the formula: (C × 9/5) + 32)
Medium
3. Remove Duplicates from a List
Write a Python program that removes duplicate elements from a list of integers.
o Input:
[1, 2, 2, 3, 4, 4, 5]
o Output:
[1, 2, 3, 4, 5]
4. Count Vowels in a String
Write a Python program to count the number of vowels (a, e, i, o, u) in a given string,
ignoring case.
o Input:
"Python Programming"
o Output:
4
5. Find the Second Largest Number in a List
Write a Python program to find the second largest number in a list of integers.
o Input:
[12, 45, 67, 23, 89, 90]
o Output:
89
6. Capitalize First Letter of Each Word
Write a Python program to capitalize the first letter of every word in a given sentence.
o Input:
"hello world from python"
o Output:
"Hello World From Python"
7. Reverse a String
Write a Python program to reverse a given string.
o Input:
"Innovation"
o Output:
"noitavonnI"
Hard
8. Palindrome Check
Write a Python program to check if a given string is a palindrome (reads the same forward
and backward).
o Input:
"madam"
o Output:
True
9. Find All Prime Numbers Below a Given Number
Write a Python program that returns all prime numbers less than a given number n.
o Input:
20
o Output:
[2, 3, 5, 7, 11, 13, 17, 19]
10. Generate Fibonacci Sequence
Write a Python program to generate the first n numbers of the Fibonacci sequence.
• Input:
7
• Output:
[0, 1, 1, 2, 3, 5, 8]
11. Binary Search Algorithm
Write a Python program to implement the binary search algorithm for a sorted list of
integers.
• Input:
List: [1, 3, 5, 7, 9, 11, 13]
Target: 9
• Output:
Found at index 4
12. Calculate Factorial Using Recursion
Write a Python program to calculate the factorial of a given number using recursion.
• Input:
5
• Output:
120
13. Matrix Transposition
Write a Python program to find the transpose of a matrix (rows become columns and vice
versa).
• Input:
[[1, 2, 3], [4, 5, 6]]
• Output:
[[1, 4], [2, 5], [3, 6]]
14. Longest Word in a Sentence
Write a Python program to find the longest word in a given sentence.
• Input:
"Exploration of Python programming"
• Output:
"Exploration"
15. Check for Balanced Parentheses
Write a Python program to check if a given string containing parentheses is balanced or not.
• Input:
"(())"
• Output:
True
• Input:
"(()"
• Output:
False