Python Programs
Python Programs
Output:
Enter the first number 5
Enter the second number 10
Sum is 15
Output:
Enter the first number 5
Enter the second number 10
Enter the third number 15
Average is 10
Output:
Enter Principle : 5000
Enter Rate : 10
Enter Time : 5
Simple Interest is 2500
4. Write a program to find if a given number is odd or even.
n = int(input(“Enter any number : ”))
if n%2==0:
print(n, “ is Even”)
else:
print(n, “ is Odd”)
Output:
Enter any number : 5
5 is Odd
Output:
Enter radius of circle 5
Area of Circle is 78.5
Output:
Enter temperature in Celsius 50
Temperature in Fahrenheit is 122
Output:
Enter Length of Rectangle: 10
Enter Breadth of Rectangle: 5
Perimeter = 30
8. Write a program to find the greatest of three numbers
n1 = int(input("Enter First Number: "))
n2 = int(input("Enter Second Number: "))
n3 = int(input("Enter Third Number: "))
if n1>n2 and n1>n3:
print(" Largest =", n1)
if n2>n1 and n2>n3:
print(" Largest =", n2)
if n3>n1 and n3>n2:
print(" Largest =", n3)
Output:
Enter First Number: 10
Enter Second Number: 15
Enter Third Number: 20
Largest = 20
Output:
Enter your age: 18
You are eligible for voting
10. Write a program to check whether the entered number is positive, negative
or zero.
x = int(input ("Enter the number"))
if x>0:
print("x is positive ")
elif x<0:
print("x is negative ")
elif x==0:
print("x is zero")
else:
print("Error")
Output:
Enter the number 0
x is zero
Output:
Enter numbers between 0 to 5: 0
Zero
Output:
The First 10 natural Numbers:
1
2
3
4
5
6
7
8
9
10
Output:
Enter any number: 10
10
20
30
40
50
60
70
80
90
100
Output:
5
10
15
20
25
30
35
40
45
50
Output:
Descending numbers from 10 to 1:
10
9
8
7
6
5
4
3
2
1
Output:
Even numbers between 1 to 20 are
2
4
6
8
10
12
14
16
18
20
Output:
The First 10 Natural Numbers Square are :
4
9
16
25
36
49
64
81
100
Output:
Odd numbers between 1 to 20 are
1
3
5
7
9
11
13
15
17
19
Output:
***** Calculator *****
1. Addition
2. Subtraction
3. Multiplication
4. Division
Enter Your Choice (1-4): 1
Enter First Numbers: 15
Enter Second Numbers: 15
Result = 30
------------------------
Output:
***** Fruit Name *****
A
B
C
D
Enter Your Choice (A-D): D
Dragon Fruit
------------------------