0% found this document useful (0 votes)
3 views

Copy of Questions to Answer python.ipynb - Colab

The document contains a series of Python programming exercises that cover various topics such as printing statements, user input, arithmetic operations, unit conversions, area calculations, simple interest, summation of even and odd numbers, and leap year determination. Each exercise includes code snippets and sample outputs demonstrating the expected functionality. The exercises are designed to help learners practice and understand basic programming concepts in Python.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Copy of Questions to Answer python.ipynb - Colab

The document contains a series of Python programming exercises that cover various topics such as printing statements, user input, arithmetic operations, unit conversions, area calculations, simple interest, summation of even and odd numbers, and leap year determination. Each exercise includes code snippets and sample outputs demonstrating the expected functionality. The exercises are designed to help learners practice and understand basic programming concepts in Python.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Q 1.

Write a program in python that prints"The whole world is interdependent and a constant stream
of thought has throughout ages enriched the common heritage of mankind".

print("The whole world is interdependent and a constant stream of thought has throughout age

The whole world is interdependent and a constant stream of thought has throughou

Q 2..Write a program in python that asks the user for their favorite color and then displays "Your
favorite color is [color]!"

Your_name = input("Enter your name=")


Your_Favourite_colour = input("Enter your favourite colour=")
print("Hello",Your_name,".Your favourite colour is",Your_Favourite_colour)

Enter your name=Mritunjoy Sarkar


Enter your favourite colour=Red
Hello Mritunjoy Sarkar .Your favourite colour is Red

Q. 3.Write a program in python that takes two numbers from the user and prints their sum, division,
multiplication, substraction, reminder..

a=int(input("Enter value for a="))


b=int(input("Enter value for b="))
p=a+b
q=a-b
r=a*b
s=a/b
x=a**2+b**2
y=a**(1/2)+b**(1/2)
e=2.71
z=e**a+e**b

print("The sum of variables is", p)


print("The substraction of variables is",q)
print("The multiplication of variables is",r)
print("The divison of variables is",s)
print("Sum of square of the variables is",x)
print("Sum of square root of the variables is",y)
print("Sum of exponents is",z)

Enter value for a=4


Enter value for b=4
The sum of variables is 8
The substraction of variables is 0
The multiplication of variables is 16
The divison of variables is 1.0
Sum of square of the variables is 32
Sum of square root of the variables is 4.0
Sum of exponents is 107.87160962
Q. 4.Write a program in python that converts kilometers to miles, celcius to fahrenheit,electronvolt
to joule.

Km=int(input("Enter value for Km="))


mi=Km*0.621371
print ("The entered value in miles",mi)

Enter value for Km=25252580369


The entered value in miles 15691221116.465899

Cel=int(input("Enter value for Cel="))


Fr= (Cel*(9/5))+32
print("The entered value in Fahrenheit is",Fr)

Enter value for Cel=10


The entered value in Fahrenheit is 50.0

eV=int(input("Enter value for eV="))


J=1.6*10**(-19)*eV
print("The entered value in Joule is",J)

Enter value for eV=10


The entered value in Joule is 1.6000000000000002e-18

Q. 5.Write a program in python to calculate the area of a circle. Take the radius as input from the
user.

R=int(input("Enter the value of R="))

Area=3.14*R**2
print ("Area of the cricle is",Area)

Enter the value of R=60


Area of the cricle is 11304.0

Q. 6.Write a program in python that calculates simple interest given the principal amount, rate, and
time.

Amount=int(input("Enter the value of Amount ="))


Rate=int(input("Enter the value of Rate ="))
time=int(input("Enter the value of time in years="))
Simple_intrest=(Amount*Rate*time)/100
print (" Simple interest is" ,Simple_intrest)

Enter the value of Amount =1000


Enter the value of Rate =4
Enter the value of time in years=5
Simple interest is 200.0

Q. 7. Write a program in python that prints the sum of the first twenty integer,even and odd
numbers.

x=int(input("Enter the number of how many first even numbers you want to sum:"))
R=2*x+1
T=0
for i in range(2,R,2):
T=T+i
print("the sum of the first",x,"even numbers is ",T)

Enter the number of how many first even numbers you want to sum:20
the sum of the first 20 even numbers is 420

y=int(input("Enter the number of how many first odd numbers you want to sum:"))
R=2*y+1
W=0
for i in range(1,R,2):
W=W+i
print("the sum of the first",y,"odd numbers is",W)

Enter the number of how many first odd numbers you want to sum:20
the sum of the first 20 odd numbers is 400

Q. 8. Write a program in python that takes a year from the user and prints wheather it is leap year or
not.

year=int(input("Enter the year="))


a = year%100
if a==0:
if (year%400)==0:
print("It is leap year")
else:
print("It is not a leap year")
else:
if(year% 4)==0:
print("It is leap year")
else:
print("It is not a leap year")

Enter the year=3050


It is not a leap year

You might also like