Module - 2 ASSIGNMENT: Please Implement by Using Python

You might also like

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

Module – 2 ASSIGNMENT

Data Types
Please implement by using Python.

list1=["name",10,10.5,"2i+j"]

list2=["lalith",20,30.5,"3i+j"]

list3=list1+list2

print(list3)

# output ['name', 10, 10.5, '2i+j', 'lalith', 20, 30.5, '3i+j']

B) countOfelement=d.count('lalith')

countOfelement1=d.count(True)

C) reversing the list

list3.reverse()

print(list3)

# output ['3i+j', 30.5, 20, 'lalith', '2i+j', 10.5, 10, 'name']

1. 2) Create 2 Sets containing integers (numbers from 1 to 10 in one set and 5 to 15 in other set)
a. Find the common elements in above 2 Sets.
b. Find the elements that are not common.
c. Remove element 7 from both the Sets.

Set1={1,2,3,4,5,6,7,8,9,10}

Set 2={4,5,6,7,8,9,10,11,12,13}

Set3=set1.intersection(set2)

print("Common Elements in set1 & set_2 are :-", set1)

Qset=set1 ^ set2

print("Not common elements in the list are :-", Qset)


Rset=set1.remove(7)

Uset=set2.remove(12)

print("After deleting 4th element:- ", set1)

print("After deleting 5th element:- ", set2)

1. Create a data dictionary of 5 states having state name as key and number of covid-19 cases as
values.
a. Print only state names from the dictionary.
b. Update another country and it’s covid-19 cases in the dictionary.

dict1={'Andhra Pradesh ':666, 'Telangana':444,’UP’:575,'Punjab':888,Harayana:333}

print("State's & Covid cases :-", dict1)

dictKeys=dict1.keys()

print("key values :-", dictKeys)

dict2={'Mexico':760000}

print("dict2:- ", dict2)

dict1.update(dict2)

print("Updated Covid Cases:- ", dict1)

Operators
Please implement by using Python

1. A. Write an equation which relates 399, 543 and 12345


B. “When I divide 5 with 3, I got 1. But when I divide -5 with 3, I got -2”—How would you justify
it.

2. a=5,b=3,c=10.. What will be the output of the following:

A. a/=b

B. c*=5

a=5
b=3

c=a%b

print(c)

a1=-5

b1=3

c1=a1%b1

print(c1)

a=5

b=3

c=10

digit1=4

digit2=3

pow_digit=4**3

pow_digit1=pow(4,3)

print("pow_digit :-", pow_digit , "pow_digit1:- ", pow_digit1)

a=”name”

del a

print(a)

Age1=5 ---> possible

5Age=55 ---> Not possible


Age_1=100 --> possible

age@100 --> not possible

You might also like