Take the name from the user and greet him in this form - Hello, username
Solution
name = input('Enter Your Name : ')
print('Hello,', name)
Take input of the length and breadth of a rectangle from the user and print the area of it.
Solution
length = float(input('Enter the length : '))
breadth = float(input('Enter the breadth : '))
area = length * breadth
print('Area :', area)
Body mass index (BMI) is a measure of body fat based on height and weight that applies to adult men and women. The Table below shows how healthy you are with respect to your BMI.
The Formula That we use For BMI is :
bmi=weight(kgs)/height(cms)2∗10000
Take Weight and height from the user and Calculate BMI.​
Solution
First we will take weight and height from user with the help of user input.
weight = int(input('Enter your weight : '))
height = int(input('Enter your height : '))
Then we will calculate BMI , Now say if we want only two decimal values , we can use round() Function.
bmi = round(weight / height ** 2 * 10000)
print('Your BMI is',bmi)
4. Take Principle, Rate, and Interest From User and Calculate Simple Interest.
Formulae For Simple Interest is:
SimpleInterest=Principle∗Rate∗Time/100
Solution
principle = int(input('Enter the amount : '))
rate = int(input('Rate : '))
time = int(input('Time : '))
simple_interest = principle * rate * time / 100
print('Simple Interest is',simple_interest)
5. Your task is to take name and age and location from user and print the following message :
Hello Everyone , I am xyz and i am xyz years old and i live in xyz.
Solution
name = input('Enter your name : ')
age = input('What is your age ? ')
location = input('Where do you live ? ')
print('Hello Everyone , I am' ,name, 'and i am', age, 'years old and i live in', location,'.')
6. Suppose there are many N numbers of people in the Army. We need to distribute them in G groups. Take the number of people from users and the Number of Groups and tell how many are left without Group.
Solution
n = int(input('Number of Army People : '))
g = int(input('How many groups do we need ? '))
rest = n%g
print('Remaining People :',rest)
7.Take Temperature in Fahrenheit and convert it into Celsius.
Formula: C = 5/9 * ( F - 32 )
Solution
# Ask user for temperature in Fahrenheit
fahrenheit = float(input("Enter temperature in Fahrenheit: "))
# Convert to Celsius
celsius = (fahrenheit - 32) * 5/9
# Print result
print(fahrenheit,' degrees Fahrenheit is equal to',celsius,'degrees Celsius.")
Take two variables from user value and power and print the solution value raised to power.
Such as value = 3 and power = 2 then solution is 9
Solution
value = int(input('Enter the Number : '))
power = int(input('Enter the power : '))
solution = value ** power
print('Solution is', solution)
Tom had y amount in his bank and jeff withdrew x amount where x is always less than y. Print the remaining balance in Tom's account. Take x and y from the user.
Solution
y = int(input("Enter Tom's account balance : "))
x = int(input('Enter withdrawal amount : '))
balance = y - x
print('Remaining balance :', balance)
Take the base and height of a triangle from the user and calculate the area of the triangle.
area=(base * height)*1/2
Solution
base=int(input('Enter the base of the triangle:'))
height=int(input('Enter the height of the triangle:'))
area=(base*height)*1/2
print('Area of the triangle is',area)
Take 5 numbers from the user and calculate average of those numbers.
(average=sum of data/number of data)
Solution
num1=int(input('Enter first number:'))
num2=int(input('Enter first number:'))
num3=int(input('Enter first number:'))
num4=int(input('Enter first number:'))
num5=int(input('Enter first number:'))
average=(num1+num2+num3+num4+num5)/5
print('Average of the numbers',average)
Take the sides of a triangle and check whether it follows Pythagoras' theorem.
sq. of base + sq. of height=sq. of hypotenuse
Solution
base=int(input('Enter base of the triangle:'))
height=int(input('Enter height of the triangle:'))
hypotnuse=int(input('Enter hypotnuse of the triangle:'))
result=base**2 + height **2
print('pythagoras theorem:',result==hypotnuse**2)
Take the length and breadth of a rectangle and find the perimeter of the rectangle
perimeter= 2 * (length + breadth)
Solution
length=int(input('Enter length of the rectangle:'))
breadth=int(input('Enter breadth of the rectangle:'))
perimeter= 2* (length + breadth)
print('Perimeter of the rectangle with sides', length,'and',breadth,' will be', perimeter)
Take the side of a cube in cm and calculate the volume of the cube.
volume= side * side * side
Solution
side=int(input('Enter side of a cube:')
volume= side ** 3
print('Volume of the cube:',volume,'cubic cm')
Take the length, breadth, and height of a cuboid in cm and calculate the volume of the cuboid.
volume= length * breadth * height
Solution
length= int(input('Enter length of the cuboid:'))
breadth=int(input('Enter breadth of the cuboid:'))
height= int(input('Enter height of the cuboid:'))
volume= length * breadth * height
print('Volume of the cuboid:',volume,'cubic cm')
Take the radius and height of a cylinder and calculate the total surface area.
total_surface_area= 2*3.14* radius *height + 2* 3.14 * sq. of radius
Solution
radius= int(input('Enter radius of the cylinder:'))
height= int(input('Enter height of the cylinder:'))
pi=3.14
total_surface_area = 2*pi*radius*height + 2*pi*radius**2
print('the total surface area of the cylinder is',total_surface_area)
Take the radius and height of a cone and calculate the volume of it.
volume= (3.14 * sq of radius * height) * 1/3
Solution
radius= int(input('Enter radius of the cone:'))
height= int(input('Enter height of the cone:'))
pi=3.14
volume= (pi * radius **2 *height)*1/3
print('Volumeof the cone',volume)
Take the radius and length of a cone and calculate the total surface area of it.
total_surface_area= 3.14*radius*(radius + length)
Solution
radius= int(input('Enter radius of the cone:'))
length= int(input('Enter length of the cone:'))
pi=3.14
total_surface_area= pi * radius (radius + length)
print('total surface area of the cone:',total_surface_area)