Professional Documents
Culture Documents
8
Name: Dhruv Dholariya Roll No: 20BEC024
Date: 11/11/2021
Aim: Programming using Python
Objectives:
1. To write programs to perform the given task by applying Python
language concepts
Pre Lab Quiz:
1. Describe the various operators available in the Python
There are seven types of operators in python.
a) Arithmetic Operators: For basic arithmetic operations (+,-
,*,/)
b) Relational Operators: For comparison between two
variables (==,!=,<,>,<=,>=)
c) Assignment Operators: For assigning values to variables
(=,+=,*=,-=,/=,etc)
d) Logical Operators: For logical operations (and, or, not)
e) Membership Operators: For checking whether a value is
present in other given set of values (in, not in)
f) Identity Operators: For checking whether two values are
identical or not (is, is not)
g) Bitwise Operators: For bit by bit operation (&, |, ~, ^, <<,
>>)
Requirements:
Any installed Linux Distribution, any text editor, Python or any IDE like
anaconda-Spider
Python Installation:
if select == 1:
print(number_1, "+", number_2, "=",
add(number_1, number_2))
elif select == 2:
print(number_1, "-", number_2, "=",
subtract(number_1, number_2))
elif select == 3:
print(number_1, "*", number_2, "=",
multiply(number_1, number_2))
elif select == 4:
print(number_1, "/", number_2, "=",
divide(number_1, number_2))
else:
print("Invalid input")
# take inputs
num1 = 2
num2 = 3
num3 = 6
num4 = 8
num5 = 10
# calculate average
avg = (num1 + num2 + num3 + num4 + num5) / 5
Task 3 :-
import random
input = [0, 1]
e = random.choices(input, weights=(7/8,1/8), k=8)
strings = [str(i) for i in e]
a_string = "".join(strings)
e = int(a_string)
print("e =", e)