PF 7
PF 7
Course_id:22DC101A
Section:S-33
Id:2200090067
Name: p aakash
Pre-Lab:
a) Program to generate a random color hex, a random alphabetical string, random value between two
integers (inclusive) and a random multiple of 7 between 0 and 70. Use random.randint()import random
def random_color_hex():
return color_hex
def random_alphabetical_string(length):
letters = 'abcdefghijklmnopqrstuvwxyz'
return result
def random_multiple_of_7():
In-lab:
a) Program to generate a random integer between 0 and 6-excluding 6, random integer between 5
and 10-excluding 10, random integer between 0 and 10, with a step of 3 and random date
between two dates, Use random.randrange()
import random
from datetime import datetime, timedelta
random_int_1 = random.randrange(0, 6)
print("Random Integer between 0 and 5 (excluding 6):", random_int_1)
random_int_2 = random.randrange(5, 10)
print("Random Integer between 5 and 9 (excluding 10):", random_int_2)
random_int_3 = random.randrange(0, 11, 3)
print("Random Integer between 0 and 10 with a step of 3:", random_int_3)
start_date = datetime(2023, 1, 1)
end_date = datetime(2023, 12, 31)
output:
import copy
shallow_copy = copy.copy(original_list)
shallow_copy[0] = 10
original_list[2][0] = 30
output: