Page 277 - Ai_C10_Flipbook
P. 277
[1]: mytuple=("Amit","Shweta","Peter","Zoya")
Marks=(89,92,93,78,89)
Class10=(101,"Neha",89.5,102,"Shushil",92)
• Set: A set is a collection of unique elements that is both mutable and unordered. Sets are defined using curly
brackets {} with elements separated by commas. Each element in a set must be unique. Sets are commonly used
for tasks that involve mathematical operations like union, intersection, and difference.
[1]: mySet = {21, 52, 33, 54, 95}
• Maps: Maps are unordered data type used for mapping keys with its corresponding value.
✶ Dictionary: In Python, a dictionary is a data type that stores a collection of Key:Value pairs. Each key is
unique within the dictionary, and it maps to a corresponding value. Dictionary is represented by curly braces
{} with each pair separated by a comma (,). Dictionaries are mutable, meaning they can be modified after
their creation.
[1]: person = {'name': 'Yash', 'Department': 'Sales', 'city': 'Delhi'}
Operators
Operators are used to perform operations on variables and values. Let us study in detail about the commonly
used operators in Python.
Arithmetic Operators
Arithmetic operators are used to perform mathematical operations on variables and values. Arithmetic operators
used in Python are:
Name Symbol Purpose Example Output
Exponential ** First number raised to the 2**5 32
power second number. 3.5**3 42.875
Multiplication * Multiplies two values 5*4 20
Note, string * int repeats the 3.5*2 7.0
string that many times. "Bye"*2 ByeBye
Division / Divides two numbers and 9/3 3.0
returns decimal value. 6.0/3 2.0
6/3.0 2.0
17/2 8.5
Floor division // Divides two numbers and 17//3 5
returns integer value. -18//5 -4
23//6 3
Remainder % Returns the remainder of the 17%3 2
division. 3%5 3
Addition + Adds two numbers 10+4 14
Note: With strings it 2.5+4 6.5
concatenates two values. "Good"+"Morning" "GoodMorning"
Advance Python (Practical) 275

