Additional Python Programs For Practice
Additional Python Programs For Practice
Output:
2. Write a program that asks the user to enter two numbers and prints their
sum.
Code:
Output:
3. Write a program that asks the user to enter a number and prints whether the
number is even or odd.
Code:
Output:
Output:
5. Write a function to calculate the factorial of a number and use it to print the
factorial of a user-provided number.
Code:
Output:
6. Write a program to concatenate two strings provided by the user and display
the result in both uppercase and lowercase.
Code:
Output:
7. Write a program that asks the user to enter a string and prints the string
reversed.
Code:
Output:
8. Write a program that asks the user to enter the base and height of a triangle
and prints the area.
Code:
Output:
9. Write a program that asks the user to enter the side length of a square and
prints the area.
Code:
Output:
10.Write a program that asks the user to enter the length and width of a
rectangle and prints the perimeter.
Code:
Output:
Output:
12.Write a program that calculates the simple interest based on user input for
principal, rate, and time.
Code:
Output:
Code:
Output:
14.Write a program that asks the user to enter a year and prints whether it is a
leap year or not.
Code:
Output:
15.Write a program that asks the user to enter a number and prints the number
reversed.
Code:
Output:
16.Write a program that asks the user to enter a string and prints the count of
each character.
Code:
Output:
17.Write a program that asks the user to enter a number and prints whether it is
an Armstrong number or not.
Code:
Output:
18.Write a program that asks the user to enter a number and prints whether it is
a prime number or not.
Code:
Output:
19.Write a program that asks the user to enter two numbers and prints all prime
numbers between those two numbers.
Code:
Output:
20.Write a program that asks the user to enter a number and prints the sum of
its digits.
Code:
Output:
21.Write a program that asks the user to enter a list of numbers and prints the
largest number.
Code:
Output:
22.Write a program that asks the user to enter a string and checks if it is a
palindrome.
Code:
Output:
23.Write a program that asks the user for a number n and prints the first n
numbers in the Fibonacci sequence.
Code:
Output:
24.Write a program that asks the user to enter a number and prints its
multiplication table up to 10.
Code:
Output:
25.Write a program that calculates the Greatest Common Divisor (GCD) of two
numbers
Code:
Output:
26.Write a program that asks the user to enter a number and prints whether it is
positive, negative, or zero.
Code:
Output:
27.Write a program that asks the user to enter two numbers and prints all even
numbers between those two numbers.
Code:
Output:
28.Write a program that asks the user to enter a string and prints the number of
vowels in the string.
Code:
Output:
29.Write a program that asks the user to enter a list of numbers and prints the
sum of the numbers.
Code:
Output:
30.Write a program that asks the user to enter a list of numbers and prints the
smallest number.
Code:
Output:
31. Write a Python program to create a simple calculator that allows the user to
perform addition, subtraction, multiplication, and division operations on two
numbers.
Code:
Output: