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:

•print

•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)

How to write Python programs using "print,int,and input" statements.



Python program 2 :

Ask the user to enter two numbers and display total as answer.

SOLUTION:

a=int(input("enter 1st number: "))


b=int(input("enter 2nd number:"))


print("The sum of 1st and 2nd number is: ", a+b)

How to write Python programs using "print,int,and input" statements.



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)

How to write Python programs using "print,int,and input" statements.



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

How to write Python programs using "print,int,and input" statements.



Python program 5 :

Task the user to enter a number over 100 and then enter a number under 10 and tell them how many times the smaller number goes into the larger number in a user-friendly format.

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")

How to write Python programs using "print,int,and input" statements.



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.


SOLUTION:

a=int(input("boys participated"))


b=int(input("girls participated"))


c=int(input("total bill"))


d=int(c/a*.6)


e=int(c/b*.4)


print("c")


print("boys perhead",d)


print("girls perhead",e)

How to write Python programs using "print,int,and input" statements.
Course Software:

Alternative Tool:

Notepad++, Spyder, PyCharm, Anaconda, Visual Code (VS Code), Visual Studio, etc.

Use Online Python compiler to do more practice and apply all these python programs practically.