Assignment 3 Solution
Assignment 3 Solution
Enter 3 numbers.
Calculate and display sum, product and average of all numbers.
Output:
Output:
Output:
Enter 3 numbers: 13 9 30
3 entered numbers are: 13 9 30
Modified values of variables: 18 7 1.5
Quotient = a/b
Reminder = a%b
print('Quotient: ', Quotient)
print('Reminder: ', Reminder)
Output:
Enter 2 numbers: 17 4
Quotient: 4.25
Reminder: 1
Display the values and datatype of the above variables quotient and reminder.
Output:
Enter a number.
Display cube of the enterend number.
Divide the entered number by 5 and display the quotient as an integer.
import math
Output:
Enter a number: 4
Cube = 64 quotient = 0
list1 = ['apple','blueberry','mango','orange','lemon']
Output:
Output:
True
False
a = 10
b = 18
id(a) == id(b)
Output:
False
Enter two number in a and b. (Use:- map(),input(),split() functions)
Find factorial of a and b.
Also display addition of factorial of a and b.
import math
fact1 = math.factorial(n1)
fact2 = math.factorial(n2)
add = fact1 + fact2
Output:
Enter 2 numbers: 4 2
1st Number: 4 Factorial: 24
2nd Number: 2 Factorial: 2
Addition : 26
import random
print(random.randint(45, 60))
print(random.random())
print(random.randint(70, 150))
Output:
53
0.5586154456049517
137
import random
print(random.choice(planetTuple))
Output:
Neptune
print(type(studentDict))
Output:
<class 'dict'>
del studentDict
Output:
mytuple = ('apple',)
mylist = [10, 32, 30, 77, 9, 15]
myset1 = set(mylist)
print(myset1)
myset2 = set()
print(type(myset2))
Output: