Basic Python Programs
Basic Python Programs
Write a program that takes an integer input from the user and prints whether the
number is odd or even.
python
# Example Input: 4
Write a program to calculate the sum of all natural numbers up to a given number `n`.
python
# Example Input: 5
# Example Output: 15
python
python
# Example Input: 3
Calculate the simple interest given the principal amount, rate of interest, and time
period.
python
python
7. Factorial of a Number:
# Example Input: 5
8. Reverse a String:
python
Write a program that takes a list of numbers as input and prints the maximum and
minimum values.
python
python
# Example Output: 3
11. Fibonacci Sequence:
Write a program to print the first `n` numbers in the Fibonacci sequence.
python
# Example Input: 5
python
# Example Input: 7
python
python
# Example Input: 153
Write a program to merge two sorted lists into a single sorted list.
python
python
# Example Output: 5
python
python
python
# Example Input: [[1, 2], [3, 4]], [[5, 6], [7, 8]]
Implement the bubble sort algorithm to sort a list of numbers in ascending order.
python