Python Programming Problems
Python Programming Problems
........................................................................................................................................Q1. Write a Python program to print any word.
print("Hello Python") # Print(): It shows text or numbers on the screen.
Output: Hello Python
---------------------------------------------------------------------------------------------------------------
Q2. Write a Python program to input two numbers from the user and print their sum.
#input two numbers from the user.
a=int(input("Enter the first number:"))
b=int(input("Enter the second number:"))
sum=a+b
print("sum of two numbers=",sum) #print( ) function is used to display output to console or screen.
Output:
Enter the first number: 20
Enter the second number: 40
sum of two numbers=60
Q3. Write a Python program to input two numbers from the user and print their product.
a=int(input("Enter the first number:"))
b=int(input("Enter the second number:"))
product=a*b
print("multiply of two numbers=",product #print( ) function is used to display output to console or screen.
Output:
Enter the first number: 20
Enter the second number: 40
multiply of two numbers=800
Q4. Write a Python program to swap the values of two numbers using third variable.
a=int(input("Enter the first number:"))
b=int(input("Enter the second number:"))
c=a # a=10
Comments
Post a Comment