Program to get the Average of given numbers.

In this basic Python program, we will get the Average of given numbers.

Steps to solve the program
  1. Take three numbers as input.
  2. The average is calculated by adding the numbers divided by the total numbers ( i.e a+b+c/3).
  3. Print the output.

    Program :
a = 30
b = 20
c = 40

print("Average of Three Numbers : ", (a + b + c)/3)

Output :

Average of Three Numbers : 30.0


Program to repeat a given string 5 times.

In this Python basic program, we will repeat a given string 5 times.

Steps to solve the program
  1. Take a string as input.
  2. To repeat the string 5 times multiply the given string by 5.
  3. Print the output

Program:

str1 = "SQATools"
n1 = 5

print("Result: ", str1*n1)

Output:

Result: SQAToolsSQAToolsSQAToolsSQAToolsSQATools


Program to multiply two numbers.

In this python basic program, we will multiply two numbers using the * operator.

Steps to solve the program

1. Take two numbers as input.
2. Multiply two numbers using the “*” operator.
3. Print the result.

Programs

num1 = 20
num2 = 40

print("Multiplication of num1*num2 :", num1 * num2)

Output

Multiplication of num1*num2 : 800


Program to subtract two integers.

In this Python basic program, we will subtract two integers using the – operator.

Steps to solve the program

1. Take two numbers as input.
2. Subtract the two numbers using the “–” operator.
3. Print the result

Program:

num1 = 80
num2 = 20

print("Subtraction of num1 - num2 :", num1 - num2)

Output:

Subtraction of num1- num2 : 60


Program to add two integers

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



Accept marks from the user allot the stream based on marks

In this python if else program, we will accept marks from the user allot the stream based on the marks.

Steps to solve the program
  1. Accepts the marks from the user.
  2. Using if-else statements allot the stream based on marks.
  3. Print the output.
				
					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
				
			

Related Articles

accept two numbers and mathematical operations from users

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; ‘÷’)

Steps to solve the program
  1. Take two numbers and a mathematical operation of your choice (+,-,*,/) as input.
  2. Using if-else statements perform the corresponding operations on numbers.
  3. Print the output.
				
					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
				
			

Related Articles

accept the temperature in Fahrenheit and check whether the water is boiling or not.

accept marks from the user allot the stream

Accept the temperature in Fahrenheit and check whether the water is boiling

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.

Steps to solve the program
  1. Take the temperature in Fahrenheit as input through the user.
  2. The boiling temperature of water in Fahrenheit is 212.
  3. Using an if-else statement check whether the input temperature is equal to 212.
  4. Print the respective output.
				
					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
				
			

Related Articles

find the lowest number between three numbers.

accept two numbers and mathematical operations from users 

Find the lowest number between three numbers.

In this python if else program, we will find the lowest number between three numbers.

Steps to solve the program
  1. Take three numbers as input.
  2. Using nested if-else statements find the lowest number among them.
  3. If num1 is less than num2 create a nested if-else statement to check whether the num1 is less than num2 if yes then num1 is the lowest number.
  4. If num2 is less than num1 create a nested if-else statement to check whether the num2 is less than num3 if yes then num2 is the lowest number.
  5. Else num3 is the lowest number.
  6. Print the respective output.
				
					num1 = 45
num2 = 23
num3 = 68

if num1<num2:
    if num1<num3:
        print("Lowest numbner: ",num1)
elif num2<num1:
    if num2<num3:
        print("Lowest numbner: ",num2)
else:
    print("Lowest number: ",num3)
				
			

Output :

				
					Lowest numbner:  23
				
			

Related Articles

check whether the citizen is a senior citizen or not.

accept the temperature in Fahrenheit and check whether the water is boiling or not.

Check whether the given citizen is a senior citizen

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.

Steps to solve the program
  1. Take the age of a citizen as input through the user.
  2. Using an if-else statement determine whether the citizen is a senior citizen or not.
  3. If the age is greater than 60 then only the citizen is a senior citizen.
  4. Print the output.
				
					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
				
			

Related Articles

accept the city name and display its monuments

find the lowest number between three numbers.