In this article you will learn Python Print() function.How to use Python Print function and much more.
Learn basic python programs that are must to understand python programming language using following statements:
•int
•input
These are the simple python programs for practice.We have listed six basic python programs and their solutions in which these statements are used.You can also learn how to use print statement from programiz and can also from w3schools.
Python programs and their solutions
Python program 1 :
Ask for the user’s first name and then ask for their surname and display the output message as Hello [First Name] [Surname].
SOLUTION:
first_name=input("enter your first name: ")
surname=input("enter your surname: ")
print("hello", first_name , surname)
Python program 2 :
SOLUTION:
a=int(input("enter 1st number: "))
b=int(input("enter 2nd number:"))
print("The sum of 1st and 2nd number is: ", a+b)
Python program 3 :
Ask for the total price of the bill, then ask how many diners there are and then display the dinner share of each person must pay.
SOLUTION:
x=int(input("Enter total price of the bill: "))
y=int(input("Enter number of diners:"))
print("the share on each person is: ", x/y)
Python program 4 :
Write a program that will ask for a number of days and then will show how many hours, minutes and seconds are in that number of days.
SOLUTION:
seconds=86400
minutes=1440
hours=24
days=int(input("Enter number of days: "))
print("The number of hours in", days, "days are:", days*hours )
print("The number of minutes in", days, "days are:", days*minutes )
print("The number of seconds in", days, "days are:", days*seconds
Python program 5 :
SOLUTION:
a=int(input("Enter the larger number (Above 100) : "))
b= int(input("Enter the smaller number(under 10) : "))
result = a/b
print("The number you have entered is" , result , "times greater then the no u entered")
Python program 6 :
Write a program that asks how many boys are at dinner, then how many girls are at dinner, and for the total bill of dinner.
Then display the dinner share of each boy and girl has to pay.
Where girl should not pay more than 60% of boy per head cost.
0 Comments