Skip to content

Commit aacdf24

Browse files
authored
Merge pull request easyawslearn#2 from Patelvijaykumar/python_operator
Python operator
2 parents 0d8abea + e125ef4 commit aacdf24

3 files changed

Lines changed: 106 additions & 3 deletions

File tree

#8_Python_Assignment_Compound_Operator.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,32 @@
1414
# >>= x >>= 5 x = x >> 5
1515
# <<= x <<= 5 x = x << 5
1616

17-
x=5
18-
#output=a+
19-
print ("a+ output is :",(x += 5),)
17+
a = 10
18+
b = 20
19+
c = 0
20+
21+
print ("a value is ",a)
22+
print ("b value is ",b)
23+
print ("c value is ",c)
24+
25+
c = a + b
26+
print (" Value of c is (c=a+b) ", c)
27+
28+
c += a
29+
print (" Value of c is (c +=a)", c)
30+
31+
c *= a
32+
print (" Value of c is (c *=a)", c)
33+
34+
c /= a
35+
print (" Value of c is (c /=a)", c)
36+
37+
c = 2
38+
c %= a
39+
print (" Value of c is (c %=a)", c)
40+
41+
c **= a
42+
print (" Value of c is (c **= a) ", c)
43+
44+
c //= a
45+
print (" Value of c is (c //=a)", c)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# A set is an unordered collection of Unique elements.
2+
seta=set('abcd')
3+
print (seta)
4+
5+
l = ['apple','banana','orange','graps']
6+
print ("object type is", type(l),)
7+
b=set(l) # converted List into set objects
8+
print ("Object Type is ", type(b),)
9+
10+
s = {'apple','banana','orange','graps'}
11+
print ("object type is", type(s),)
12+
c=set(s) # converted List into set objects
13+
print ("Object Type is ", type(c),)
14+
15+
16+
example=set('abcdefg')
17+
print ("define variable",example)
18+
19+
example.add('z')
20+
print ("define variable",example)
21+
22+
d=example.copy()
23+
print("copy set example",d)
24+
25+
example.remove('a')
26+
print("removed a element from example set",example)
27+
28+
list1 = [1, 2, 3]
29+
list2 = [5, 6, 7]
30+
set1 = set(list2)
31+
set2 = set(list1)
32+
33+
# Update method
34+
set1.update(set2)
35+
36+
# Print the updated set
37+
print("set update example",set1)
38+
39+
example.discard ('c')
40+
print ("discard c example",example)
41+
42+
example.clear()
43+
print ("clear example",example)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# The frozenset() is an inbuilt function is Python which takes an iterable object as input and makes them immutable.
2+
# Simply it freezes the iterable objects and makes them unchangeable.
3+
4+
# Python program to understand frozenset() function
5+
6+
# set declaration
7+
number = {1, 2, 3, 4, 5, 6, 7, 8, 9}
8+
9+
print ("Object type of number is ",type(number))
10+
# converting Sets to frozenset
11+
fnumber = frozenset(number)
12+
print ("object type of fnumber is ",type(fnumber))
13+
14+
# printing details
15+
print("frozenset Object is : ", fnumber)
16+
17+
# Python program to understand use
18+
# of frozenset function
19+
20+
# creating a dictionary
21+
info = {"fname": "vijay", "age": 30, "sex": "Male",}
22+
23+
# making keys of dictionary as frozenset
24+
key = frozenset(info)
25+
26+
# printing keys details
27+
print('The frozen set is:', key)
28+
29+
# Python program to understand
30+
# use of frozenset function
31+
32+
# below line will generate error
33+
#TypeError: 'frozenset' object does not support item assignment
34+
fnumber[1] = "11"

0 commit comments

Comments
 (0)