Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

print('Q1-----------------------------------------')

my_str = 'google.com'
print(len(my_str))

print('\nQ2-----------------------------------------')
my_lst = [23,65,78,9,0]
print(sum(my_lst))

print('\nQ3-----------------------------------------')
def my_lst(items):
tot = 1
for x in items:
tot *= x
return tot
print(my_lst([3,6,8,9,2]))

print('\nQ4-----------------------------------------')
my_lst = [23,65,78,9,0]

print(max(my_lst))

print('\nQ5-----------------------------------------')
x = 2
print(type(x))

print('\nQ6-----------------------------------------')
x = '2.'
print(type(x))

print('\nQ7-----------------------------------------')
x = ('2.')
print(type(x))

print('\nQ8-----------------------------------------')
s = 'HelloWorld'
print(s[:4])

print('\nQ9-----------------------------------------')
s = 'HelloWorld'
print(s[4:-3])

print('\nQ10-----------------------------------------')
str1='Welcome'
str2='to'
str3='Upflairs'
str4='_'
print(str1+str4+str2+str4+str3)

print('\nQ11-----------------------------------------')
str1=('WELCOME TO THE UPFLAIRS PVT. LTD.')
print(str1.lower())

print('\nQ12-----------------------------------------')
str1=('Upflair')
c = str1[:1]
d = c.lower()
print(d+str1[1:])

print('\nQ13-----------------------------------------')
str1=' Team work is the secret '
print(str1[4:-4])

print('\nQ14-----------------------------------------')
a=(1,2,3,4)
print(a[1:-1])

print('\nQ15-----------------------------------------')

a = (1,2,2,2,3,4,2)
print(a.count(2))

print('\nQ16-----------------------------------------')
a =(1,2,2,2,3,4,2)
print(5 in a)

##print('\nQ17-----------------------------------------')
##a = (1,2,3,4)
##del(a[2])
##print(a)

print('\nQ18-----------------------------------------')
a = {1,2,3,4,5}
b = {3,4,5,6,7,8}
c = a and b
print(c,'intersection of elements')

print('\nQ19-----------------------------------------')
my_lst = [23,65,23,9,0,9,14]
my_lst = set (my_lst)
print(type(my_lst))

print('\nQ20-----------------------------------------')
groups = {'solo':1,'duo':2}
del groups['duo']
print(groups)

print('\nQ21-----------------------------------------')
groups = {'solo':1,'duo':2}
groups['trio']=3
print(groups)

print('\nQ22-----------------------------------------')
groups = {'solo':1,'duo':2}
groups['brand'] = groups['duo']
del groups['duo']
print(groups)

print('\nQ23-----------------------------------------')
colors = {'red':' #FF0000', 'green':'#008000', 'blue':'#0000FF'}
colors_list = colors.values()
print(colors_list)

print('\nQ24-----------------------------------------')
color_mapping = {'red':'#FF0000', 'green':'#008000', 'blue':'#0000FF'}
colors = list(colors.values())
sum_colors = 0
for col in colors:
temp = col.replace('#','0x')
sum_colors = sum_colors + int(temp, 16)

colors_hex = str(hex(sum_colors)).replace('0x','#')

colors_hex_new = str(hex(sum(map(lambda x: int(x.replace('#','0x'), 16),


color_mapping.values())))).replace('0x','#').upper()

print(colors_hex.upper(), colors_hex_new)

print('\nQ25-----------------------------------------')
a=['red','blue','green']
b=[1,2,3]
d = dict (zip(a,b))
print(d)

You might also like