0% found this document useful (0 votes)
0 views21 pages

Additional Python Programs For Practice

The document outlines a series of Python programming exercises, each requiring the user to write code for various tasks such as printing messages, performing arithmetic operations, and manipulating strings and numbers. Each task includes a brief description, a placeholder for the code, and an expected output. The exercises cover fundamental programming concepts suitable for beginners.

Uploaded by

jiddu1717
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views21 pages

Additional Python Programs For Practice

The document outlines a series of Python programming exercises, each requiring the user to write code for various tasks such as printing messages, performing arithmetic operations, and manipulating strings and numbers. Each task includes a brief description, a placeholder for the code, and an expected output. The exercises cover fundamental programming concepts suitable for beginners.

Uploaded by

jiddu1717
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

PYTHON PROGRAMS

1. Write a program to print "Hello, World!" to the console.


Code:

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:

4. Write a program to print numbers from 1 to 10 using a loop.


Code:

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:

11.Write a program that converts a temperature from Celsius to Fahrenheit.


Code:

Output:
12.Write a program that calculates the simple interest based on user input for
principal, rate, and time.
Code:

Output:

13.Write a program that converts a given number of minutes to hours and


minutes.

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:

You might also like