Module Assignment 2 Data Types, Operators, Variables Assignment - Answer
Module Assignment 2 Data Types, Operators, Variables Assignment - Answer
https://colab.research.google.com/drive/1aK89thB9E22qU3rksOfTERLJ6DEk43fo?usp=sharing
Data Types
Please implement it by using Python.
1. Construct 2 lists containing all the available data types (integer, float, string, complex
and Boolean) and do the following..
concated_list = list1+list2
print(concated_list)
frequency = {}
frequency[element] = concated_list.count(element)
reversed_list = concated_list[::-1]
2.Create 2 Sets containing integers (numbers from 1 to 10 in one set and 5 to 15 in other
set)
not_common_elements = set1.symmetric_difference(set2)
set1.discard(7)
set2.discard(7)
3.Create a data dictionary of 5 states having state name as key and number of covid-19
cases as values.
covid_cases["Nepal"] = 200000
Operators
Please implement by using Python
B. “When I divide 5 with 3, I get 1. But when I divide -5 with 3, I get -2”—How would
you justify it?
x = 399
y = 543
result = x * 31 + y * 15
positive_div = 5 // 3
negative_div = -5 // 3
a=5
b=3
c = 10
a /= b
c *= 5
3. A. How to check the presence of an alphabet ‘S’ in the word “Data Science” . B. How can
you obtain 64 by using numbers 4 and 3
A. How to check the presence of an alphabet ‘S’ in the word “Data Science”
result = 4 ** 3
b.5age=55
#not valid
Age_1 = 100
# Deleting variables
Age1 = 5
del Age1