top of page

Python | Assignment


Assignment

data handling assignment final
.pdf
Download PDF • 553KB

#Program By eboostup.com
#Assignment
#15
a,b=bool(0),bool(0.0)
c,d=str(0),str(0.0)
print(len(a),len(b))
print(len(c),len(d))

'''Error=object of type 'bool' has no len() '''

#16
s="12345"
n1=int(s[4])
n2=int(s[3])
n3=int(s[2])
n4=int(s[1])
n5=int(s[0])
print(n1+n2+n3+n4+n5)

#17
a=True
b=0<5
print(a==b)
print(a is b)
c=str(a)
d=str(b)
print(c==d)
print(c is d)
e=input("Enter : ")
print(c==e)
print(c is e)
print( "Output = " ,'''
         True
         True
         True
         True
         Enter : True
         True
         False''')

#18
#(a)
name="HariT"
print(name)
name[2]='R'
print(name)
print('''TypeError: 'str' object does not support item assignment''')

#(b)
a=bool(0)
b=bool(1)
print(a==false)
print(b==true)
print('''NameError: name 'false' is not defined''')

#(c)
print(type(int("123")))
print(type(int("Hello")))
print(type(str("123.0")))
print('''ValueError: invalid literal for int() with base 10: 'Hello' ''')

#(d)
pi=3.14
print(type(pi))
print(type("3.14"))
print(type(float("3.14")))
print(type(float("three point fourteen")))
print('''ValueError: could not convert string to float: 'three point fourteen' ''')

#(e)
print("Hello"+2)
print("Hello"+"2")
print("Hello"*2)
print('''TypeError: can only concatenate str (not "int") to str''')

#(f)
print("Hello"/2)
print("Hello" /2)
print('''TypeError: unsupported operand type(s) for /: 'str' and 'int' ''')

#19
#(a)
x,y,z=True,False,False
a=x or (y and z)
b=(x or y)and z
print(a,b)
print("Output :"," True False")

#(b)
x,y='5',2
z=x+y
print(z)
print("Output :"," TypeError: can only concatenate str (not "int") to str")

#(c)
s='Sipo'
s1=s+'2'
s2=s*2
print(s1)
print(s2)
print("Output :",'''Sipo2
         SipoSipo''')

#(d)
w,x,y,z=True,4,-6,2
result= -(x+z)<y or x **z <10
print(result)
print("Output :"," False")

#20
probability = int (input("Type a number between 0 and 1: "))
print("Out of 150 tries, the odds are that only", (probability * 150), "will succeed. ")

#21
'''Possible outcomes of the above code is option (a) & (d).

 

Minimum value:- 100

Maximum value:- 995'''

#22
'''Option (a) the possible outcomes of the above code.

 

Max value:- 90

Min value :- 0'''

#23
'''Option (a) & (c) are the possible outcomes of the above code.

 

Max value: - nearly equal to 10, but not 10.

Min value:- 0.0'''

#24
'''Option (c) is correct.'''

#13
import random
import statistics

start = int(input("Enter Start :-"))
stop = int(input("Enter stop :- "))
step = int(input("Enter step :- "))

a = random.randrange(start,stop,step)
b = random.randrange(start,stop,step)
c = random.randrange(start,stop,step)
d = random.randrange(start,stop,step)
e = random.randrange(start,stop,step)
f = random.randrange(start,stop,step)

print( "Numbers are =",a,b,c,d,e,f )
print("Mean = ", statistics.mean( ( a,b,c,d,e,f ) ) )
print("Mode = ", statistics.mode( ( a,b,c,d,e,f ) ) )
print("Median =", statistics.median( ( a,b,c,d,e,f ) ) )

#14
import random
count = 1
while count <= 3 :
    num = random.randint(100,999)
    if num % 5 == 0 :
        print (num)
        count += 1

#15
import random
count = 1
while count <= 6 :
    num = random.randint(100000,999999)
    print("OTP =",num)
    count += 1

#16
import random
print("OTP" , random.randint(100000,999999) )
print("OTP" , random.randint(100000,999999) )
print("OTP" , random.randint(100000,999999) )
print("OTP" , random.randint(100000,999999) )
print("OTP" , random.randint(100000,999999) )
print("OTP" , random.randint(100000,999999) )

#17
side1 = int(input("Enter side one :"))
side2 = int(input("Enter side two :"))
angle = int(input("Enter the angle :")) #Angle is not require to solve this Question
print("Biggest side :-" , (side1**2 + side2**2 )**0.5 )

#18
area = int(input("Enter the area :-"))
radius = ( area / (4 * 3.14 ) ) **0.5
print("Radius =", radius)

#19
string = input("Enter the String :-")
print(string * len(string))

#20
r = 8
h = 15
print( "Volume of cylender :-" , 3.14 * r ** 2 * h )

#21
side = int (input("Enter side :- "))
area =  ( 3**0.5 / 2 ) * side * side
print("Area = ", area)

#22
rad = int (input("Enter the radius :-"))
volume = (4/3) * 3.14 * rad ** 3
print ("Volume = ", volume)

#23
p = float(input("Enter principal amount :-"))
r = float(input("Enter Rate :-"))
t = int(input("Enter time :-"))
si = (p * r * t ) /100
print("amount payable =" , si + p )

#24
p = float(input("Enter principal amount :-"))
r = float(input("Enter Rate :-"))
t = int(input("Enter time :-"))

com = p * ( (1 + (r / 100 ))** t ) - p

print("amount payable =" , com + p )

#25
a = int(input("Enter a :-"))
b = int(input("Enetr b :-"))
formula = a ** 3 + b ** 3 + 3 * (a ** 2) * b + 3 * a * (b ** 2)
print(formula)

print("Powered By eboostup.com")



Comentários

Avaliado com 0 de 5 estrelas.
Ainda sem avaliações

Adicione uma avaliação
bottom of page