Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

#1.Accept numbers from a user and print it.

num=int(input("Enter a Number :"))


print("you entered a number",num)

Enter a Number :1131


you entered a number 1131

# 2. Display three string “Name”, “Is”, “James” as “Name ** Is ** Ja


s1="Name"
s2="Is"
s3="James"
print(s1+"**"+s2+"**"+s3)

Name**Is**James

# 3.Convert Decimal number to octal and print it


dec=int(input("enter a decimal number : "))
print("The actal equivalent of",dec,"is",oct(dec))

enter a decimal number : 100


The actal equivalent of 100 is 0o144

# 4.Display float number with 2 decimal places using print() functio


print("The value of PI is approximately 3.1415926535")
print("The value of PI rounded to 2 decimal place is",round(3.141592

The value of PI is approximately 3.1415926535


The value of PI rounded to 2 decimal place is 3.14
# 5.Print all factors of a given number provided by the user.
num=int(input("Enter a number :"))
print("The factors of", num ,"are :")
for i in range(1,num+1):
if num%i==0:
print(i)

Enter a number :1131


The factors of 1131 are :
1
3
13
29
39
87
377
1131

# 6.Accept any three string from user and print it.


s1=input("enter the first string :")
s2=input("enter the second string :")
s3=input("enter the third string :")
print("The three strings are :",s1,s2,s3)

enter the first string :This is the


enter the second string :Book of
enter the third string :Ramayana
The three strings are : This is the Book of Ramayana

# 7.Format variables using a string.format() method. Hint: total m


total_money=1200
quantity=4
price=450
print("I have {0} dollars so I can buy {1} footballs for {2} dollars

I have 1200 dollars so I can buy 4 footballs for 450 dollars eac
# 8.Write a program to find the volume of the cylinder. Also find the
import math
radius =float(input("Enter the radius of the cylinder(in cm) :"))
height =float(input("Enter the height of the cylinder(in cm) :"))
volume=math.pi*radius**2*height
cost_per_litre=40
volume_in_litres=volume/1000
cost=volume_in_litres*cost_per_litre

print("The volume of the cylinder is",volume,"cubic centimetres.")


print("The cost of the milk is ",cost ,"rupees.")

Enter the radius of the cylinder(in cm) :10


Enter the height of the cylinder(in cm) :7
The volume of the cylinder is 2199.1148575128555 cubic centimetr
The cost of the milk is 87.96459430051422 rupees.

You might also like