-
Notifications
You must be signed in to change notification settings - Fork 0
/
Script6.py
63 lines (47 loc) · 1.1 KB
/
Script6.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
''' Sequence Assignments '''
nudge = 1
wink = 2
A,B = nudge,wink #Tuple Assignments
print(A,B)
[C,D] = [nudge,wink] # List Assignment
print(C,D)
# Advanced sequence assignment patterns
string = 'SPAM'
a,b,c,d = string
print(a,b)
a , b , c = string[0],string[1],string[2]
print(a,b,c)
#with the help of loop
for (a,b,c) in [(1,2,3),(4,5,6)]:
print(a,b,c)
# Extended Sequence Unpacking in Python 3
'''Extended Unpacking in action '''
seq = [1,2,3,4]
a,b,c,d = seq
print(a,b,c,d)
''' Boundary cases'''
print(seq)
a,b,c,*d = seq
print(a,b,c,d)
# Applications to for loops
for (a,*b,c) in [(1,2,3,4),(5,6,7,8)]:
print(a,b,c)
#Multiple-Target Assignments
a=b=c='Spam'
print(a,b,c)
'''Augmented Assignments'''
x = 1
x=x+1 # Traditional
print(x)
x += 1
print(x) #Augmented
'''Expression Statements'''
span(eggs,ham) #Function calls
spam.ham(eggs) #Method calls
spam #printing variables in the interactive interpreter
print('a,b,c,sep=''') #printing operations in Python 3.0
yield x**2 # Yield expression Statements
''' Expression statements and in Place changes '''
L = [1,2]
L.append(3)
print(L)