0% found this document useful (0 votes)
99 views4 pages

Module - 2 ASSIGNMENT: Please Implement by Using Python

The document contains Python code examples demonstrating various data types, sets, dictionaries, and operators. It shows how to create and manipulate lists, sets, and dictionaries. It also includes examples of arithmetic, logical, and comparison operators in Python such as division, modulo, power, and deletion. The code samples provide the output to demonstrate how each Python concept works.

Uploaded by

lalith kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views4 pages

Module - 2 ASSIGNMENT: Please Implement by Using Python

The document contains Python code examples demonstrating various data types, sets, dictionaries, and operators. It shows how to create and manipulate lists, sets, and dictionaries. It also includes examples of arithmetic, logical, and comparison operators in Python such as division, modulo, power, and deletion. The code samples provide the output to demonstrate how each Python concept works.

Uploaded by

lalith kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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