Steps to solve the program
1. Take two numbers as input.
2. Add the two numbers using the + operator.
3. Print the result.
Program:
num1 = 30
num2 = 40
print("Addition of num1+num2 :", num1+num2)
Output:
Addition of num1+num2 : 70
Online Learning Platform
Steps to solve the program
1. Take two numbers as input.
2. Add the two numbers using the + operator.
3. Print the result.
Program:
num1 = 30
num2 = 40
print("Addition of num1+num2 :", num1+num2)
Output:
Addition of num1+num2 : 70
In this python if else program, we will accept marks from the user allot the stream based on the marks.
marks = int(input("Enter marks: "))
if 85 <= marks <101:
print("Stream alloted: Science")
elif 70 <= marks < 85:
print("Stream alloted: Commerce")
elif 35 <= marks < 70:
print("Arts")
elif 0 < marks < 35:
print("Stream alloted: Fail")
else:
print("Invalid marks")
Output :
Enter marks: 88
Stream alloted: Science
Python program to check given number is divided by 3 or not.
If else program to get all the numbers divided by 3 from 1 to 30.
If else program to assign grades as per total marks.
Python program to check the given number divided by 3 and 5.
Python program to print the square of the number if it is divided by 11.
Python program to check given number is a prime number or not.
accept two numbers and mathematical operations from users
In this python if else program, we will accept two numbers and mathematical operations from users and perform mathematical operations according to it.
Arithmetic operations in Maths:
Addition (Finding the Sum; ‘+’)
Subtraction (Finding the difference; ‘-‘)
Multiplication (Finding the product; ‘×’ )
Division (Finding the quotient; ‘÷’)
num1 = int(input("Enter 1st number: "))
num2 = int(input("Enter 2nd number: "))
operation = input("Enter operation of your choice")
if operation == "+":
print(num1+num2)
elif operation == "-":
print(num1-num2)
elif operation == "/":
print(num1/num2)
elif operation == "*":
print(num1*num2)
else:
print("Invalid operation")
Output :
Enter 1st number: 30
Enter 2nd number: 45
Enter operation of your choice: +
75
Python program to accept marks from the user allot the stream based on the following criteria.
Python program to check given number is divided by 3 or not.
If else program to get all the numbers divided by 3 from 1 to 30.
If else program to assign grades as per total marks.
Python program to check the given number divided by 3 and 5.
Python program to print the square of the number if it is divided by 11.
In this python if else program, accept the temperature in Fahrenheit and check whether the water is boiling or not.
To convert temperatures in degrees Fahrenheit to Celsius, subtract 32 and multiply by .5556 (or 5/9). To convert temperatures in degrees Celsius to Fahrenheit, multiply by 1.8 (or 9/5) and add 32.
temp = int(input("Enter temperature of water in Fahrenheit: "))
if temp != 212:
print("Water is not boiling")
else:
print("Water is boiling")
Output :
Enter temperature of water in Fahrenheit: 190
Water is not boiling
Python program to accept marks from the user allot the stream based on the following criteria.
Python program to check given number is divided by 3 or not.
If else program to get all the numbers divided by 3 from 1 to 30.
If else program to assign grades as per total marks.
Python program to check the given number divided by 3 and 5.
In this python if else program, we will find the lowest number between three numbers.
num1 = 45
num2 = 23
num3 = 68
if num1
Output :
Lowest numbner: 23
In this python if else program, we will check whether the given citizen is a senior citizen or not depending on the age.
Condition:
If the age is greater than 60 then the person is a Senior Citizen.
age = int(input("Enter age of a citizen: "))
if age > 60:
print("The given citizen is a senior citizen")
else:
print("The given citizen is not a senior citizen")
Output :
Enter age of a citizen: 70
The given citizen is a senior citizen
In this python if else program, we will accept the city name and display its monuments take Pune and Mumbai as cities.
city = input("Enter city name: ").lower()
if city == "pune":
print("Shaniwar vada\nLal mahal\nSinhgad fort")
elif city == "mumbai":
print("Getway of India\nGandhi statue\nAjanta cave")
else:
print("Invalid city")
Output :
Enter city name: pune
Shaniwar vada
Lal mahal
Sinhgad fort
In this python if else program, we will take input from the user between 1 to 7 and print the day according to the number.
Criteria:
1 – Sunday
2- Monday
3 – Tuesday
4 – Wednesday
5 – Thursday
6 – Friday
7 – Saturday
num = int(input("Enter a number: "))
if num == 1:
print("Sunday")
elif num == 2:
print("Monday")
elif num == 3:
print("Tuesday")
elif num == 4:
print("Wednesday")
elif num == 5:
print("Thursday")
elif num == 6:
print("Friday")
elif num == 7:
print("Saturday")
else:
print("Invalid number")
Output :
Enter a number: 5
Thursday
In this python if else program, we will accept the car price of a car and display the road tax to be paid depending on the car price.
amount = int(input("Enter car price: "))
if amount <= 500000:
print("Tax payable: ",15000)
elif 500000 < amount <= 1000000:
print("Tax payable: ",50000)
else:
print("Tax payable: ",80000)
Output :
Enter car price: 1200000
Tax payable: 80000
In this python if else program, we will display 1/0 if the user gives Hello/Bye as output.
iput = input("Enter your choice: ")
if iput == "Hello":
print(1)
elif iput == "Bye":
print(0)
else:
print("Invalid choice")
Output :
Enter your choice: Bye
0