Learn data science and machine learning by building real-world projects on Jovian

# aarohi-nuniwal/practical-copy1

3 months ago
In [3]:
``````#WAP to implement mathematical calculator (add, subtract, multiply and divide two
#numbers)
a=float(input("Enter first number: "))
b=float(input("Enter second number: "))
sum= a+b
difference= a-b
product= a*b
quotient= a/b
print(sum)
print(difference)
print(product)
print(quotient)

``````
```Enter first number: 23 Enter second number: 15 38.0 8.0 345.0 1.5333333333333334 ```
In [4]:
``````#wap to input length in meters and convert it into centimetres
a=int(input("Enter length in meters: "))
b= a*100
print (b)``````
```Enter length in meters: 100 10000 ```
In [5]:
``````#WAP to input length and breadth of a rectangle and find area and perimeter
a=float(input("Enter length in meters: "))
Perimeter= 2*(a+b)
print(Perimeter)
Area= a*b
print(Area)
``````
```Enter length in meters: 12 Enter breadth in meters: 4 32.0 48.0 ```
In [6]:
``````#WAP to input marks of a student in 3 subjects find total and percentage
#assuming maximum marks for each paper is 100
a=float(input("Enter marks in English: "))
b=float(input("Enter marks in Physics: "))
c=float(input("Enter marks in Biology: "))
Total= a+b+c
print(Total)
Percentage= (Total)/3
print(Percentage)
``````
```Enter marks in English: 23 Enter marks in Physics: 46 Enter marks in Biology: 78 147.0 49.0 ```
In [62]:
``````#WAP to swap the value of two variables
a =float(input("Enter first number: "))
b = float(input("Enter second number: "))
z=a
a=b
b=z
print(a)
print(b)
``````
```Enter first number: 12 Enter second number: 21 21.0 12.0 ```
In [24]:
``````#WAP to find average of three numbers
a=float(input("Enter first number: "))
b=float(input("Enter second number: "))
c=float(input("Enter third number: "))
Average= (a+b+c)/3
print(Average)

``````
```Enter first number: 2 Enter second number: 3 Enter third number: 4 3.0 ```
In [8]:
``````#WAP to input the cost price and profit to be obtained of an item. Calculate and display
#the selling price

a=float(input("Enter cost price: "))
b=float(input("Enter profit: "))
SP= a+b
print(SP)

``````
```Enter cost price: 120 Enter profit: 20 140.0 ```
In [12]:
``````#WAP to input the radius of a circle and calculate the area and circumference
Circumfrence= 44/7*(r)
Area= 22/7 * (r)**2
print(Area)
print(Circumfrence)

``````
```Enter radius in metre: 7 154.0 44.0 ```
In [15]:
``````# WAP to input the height of a person in inches and convert it to feet and inches

a= int(input("Enter height in inches: "))
b= a//12
c= a%12
print (b)
print(c)

``````
```Enter height in inches: 122 10 2 ```
In [21]:
``````#. Write a Python script to input the values of Principal, Rate, and Time and calculate
#Simple Interest and Compound Interest
a= float(input("Enter Principal: "))
b= float(input("Enter Rate: "))
c= float(input("Enter Time: "))
SI= a*b*c/100
CI= a*(1+b)**c - a
print (SI)
print(CI)

``````
```Enter Principal: 100 Enter Rate: 10 Enter Time: 2 20.0 12000.0 ```
In [24]:
``````#WAP to input age of a person and check whether he is eligible to vote or not
if (a>= 18):
print("you are eligible to vote")
elif (a< 18):
print("you are not eligible to vote")

``````
```Enter your current age: 21 you are eligible to vote ```
In [27]:
``````#WAP to input two numbers and find the greatest number.
a=int(input("Enter first number: "))
b=int(input("Enter second number: "))
if a> b:
print("first number is greater than second number")
elif a< b:
print("Second number is greater than first number")
else:
print("both numbers are equal")``````
```Enter first number: 12 Enter second number: 9 first number is greater than second number ```
In [34]:
``````#WAP to input three numbers and find the greatest number
a=int(input("Enter first number: "))
b=int(input("Enter second number: "))
c=int(input("Enter third number: "))
if a>b and a>c:
print("First number is the greatest")
elif b>a and b>c:
print("Second number is the greatest")
elif c>a and c>b:
print("Third number is greatest")``````
```Enter first number: 12 Enter second number: 8 Enter third number: 81 Third number is greatest ```
In [41]:
``````#WAP to input a number and check whether it comes between 25 and 51
if a<51 and a>25:
print("Your number lies between 25 and 51")
else:
print("Your number does not lie between 25 and 51")

``````
```Enter your number23 Your number does not lie between 25 and 51 ```
In [46]:
``````#WAP to input a number and check whether it is even or odd
b= a%2
if (b==0):
else:

``````
```Enter your number13 Your number is odd ```
In [48]:
``````#WAP to input a year and check whether it is a leap year or not
a=int(input("Enter year"))
b= a%4
if b==0:
print("It's a leap year")
else:
print("It's not a leap year")

``````
```Enter year2000 It's a leap year ```
In [51]:
``````#WAP to input a number and check whether it is a multiple of 5 or not
b= a%5
if b==0:
print("It's a multiple of 5")
else:
print("It's not a multiple of 5")``````
```Enter your number10 It's a multiple of 5 ```
In [53]:
``````#Accept the temperature in degree Celsius of water and check whether it is boiling or not
a=int(input("Enter temperature in Celsius: "))
b= a/100
if b==1:
print("The water is ready to boil")
else:
print("Water will not boil")

``````
```Enter temperature in Celsius: 100 The water is ready to boil ```
In [58]:
``````#Write a program to accept a number from 1 to 12 and display name of the month and
#days in that month like 1 for January and number of days 31 and so on
if a==1:
print("January 31")
elif a==2:
print("February 28/29")
elif a==3:
print("March 31")
elif a==4:
print("April 30")
elif a==5:
print("May 31")
elif a==6:
print("June 30")
elif a==7:
print("July 31")
elif a==8:
print("August 31")
elif a==9:
print("September 30")
elif a==10:
print("October 31")
elif a==11:
print("November 30")
elif a==12:
print("December 31")
else:
print("Enter a number from 1 to 12")

``````
```Enter your number12 December 31 ```
In [61]:
``````#Write a program to accept percentage from the user and display the grade
if a>90 and a<=100:
print("A")
elif a> 80 and a<= 90:
print("B")
elif a>= 60 and a<= 80:
print("C")
elif a<60 and a>=0:
print("D")
else:
print("Input should be from 1 to 100")

``````
```Enter your percentage: 99.9 A ```
In [ ]:
`` ``