Python Assignment 1
Python Assignment 1
Ans 1.
a=int(input('Enter the first no.'))
b=int(input('Enter the second no.'))
c=a+b
f=a/b
print('The quotient when the given nos. are divided = ',f)
g=a%b
print('The remainder when the given nos. are divided = ',g)
h=a//b
print('The integer quotient when the given nos. are divided = ',h)
OUTPUT
Enter the first no. 5
Enter the second no.6
The sum of the given nos. = 11
Ans 2.
p = float(input("Enter the principal amount: "))
r = float(input("Enter the rate of interest (in %): "))
t = float(input("Enter the time (in years): "))
s=(p*r*t)/100
print('Simple Interest = ',s)
OUTPUT
OUTPUT
Enter the first side: 5
Enter the second side: 7
Enter the third side: 10
The area of the triangle = 132.0
Ans 5.
a=float(input("Enter the temperature in Fahrenheit: "))
b=(a-32)*5/9
print('The temperature in Celcius = ',b)
OUTPUT
Enter the temperature in Fahrenheit: 98
The temperature in Celcius = 36.666666666666664
Ans 6.
a=int(input('Enter the time (in minutes): '))
h=a//60
m=a%60
print('Time: ',h,'hours and',m,'minutes')
OUTPUT
Enter the time (in minutes): 90
a=int(input("Enter a no."))
b=int(input("Enter a no."))
print(id(a))
print(id(b))
c=a
a=b
b=c
print(id(a))
print(id(b))
OUTPUT
Enter a no.7
Enter a no.8
140729610095224
140729610095256
140729610095256
140729610095224
Ans 9.
a=int(input('Enter a no.'))
a=b=c
print(id(a))
print(id(b))
print(id(c))
OUTPUT
Enter a no.10
140729610095224
140729610095224
140729610095224
Ans 10.
a=input('Write any sentence: ')
print(a,'#')
OUTPUT
Write any sentence: You are pretty
You are pretty #
Ans 11.
a=int(input('Enter mathematics mark: '))
b=int(input('Enter english mark: '))
c=int(input('Enter science mark: '))
d=int(input('Enter social studies mark: '))
#b)"Opportunities don't happen. You create them." Try not to become a person of "success"
but try to become a person of "value"
Ans 13.
a=input('Enter you name: ')
b=int(input('Enter no. of times you want the name to repeat: '))
print(a*b)
OUTPUT
Enter you name: Vani
Enter no. of times you want the name to repeat: 6
VaniVaniVaniVaniVaniVani
Ans 14.
a=input('Enter you first subject: ')
b=input('Enter you second subject: ')