-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCr9.py
125 lines (113 loc) · 2.22 KB
/
Cr9.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> b=1
>>> b
1
>>> while b<=10:
print('b')
b+=1
b
b
b
b
b
b
b
b
b
b
>>> b=1
>>> b
1
>>> while b<=10:
print(b)
b+=1
1
2
3
4
5
6
7
8
9
10
>>> g1=['bread', 'milk', 'meat', 'beef']
>>> g1
['bread', 'milk', 'meat', 'beef']
>>> for food in g1:
print('I want' + food)
I wantbread
I wantmilk
I wantmeat
I wantbeef
>>> ages={'dad':42, 'mom':48, 'lisa':7}
>>> ages
{'dad': 42, 'mom': 48, 'lisa': 7}
>>> for item in ages:
print(item)
dad
mom
lisa
>>> for item in ages:
print(item, ages[item])
dad 42
mom 48
lisa 7
>>> while 1:
name = input('Enter name: ')
if name == 'quit': break
Enter name: greg
Enter name: tom
Enter name: lisa
Enter name: bucky
Enter name: quit
>>> def whatsup(x):
return 'whats up' + x
print whatsup('tony')
SyntaxError: invalid syntax
>>> print(whatsup('tony'))
Traceback (most recent call last):
File "<pyshell#32>", line 1, in <module>
print(whatsup('tony'))
NameError: name 'whatsup' is not defined
>>> def whatsup(x):
return 'whats up' + x
print(whatsup('tony'))
SyntaxError: invalid syntax
>>> print('whatsup('tony')')
SyntaxError: invalid syntax
>>> print('whatsup(tony)')
whatsup(tony)
>>> print('whatsup(noob)')
whatsup(noob)
>>> print ('whats up noob')
whats up noob
>>> def plusten(y):
return y+10
print('plusten 44')
SyntaxError: invalid syntax
>>> print("plusten"+44)
Traceback (most recent call last):
File "<pyshell#43>", line 1, in <module>
print("plusten"+44)
TypeError: can only concatenate str (not "int") to str
>>> print('plusten + 44')
plusten + 44
>>> print(plusten(44))
Traceback (most recent call last):
File "<pyshell#45>", line 1, in <module>
print(plusten(44))
NameError: name 'plusten' is not defined
>>> print('plusten(44)')
plusten(44)
>>> def plusten(y):
return y+10
print(plusten44)
SyntaxError: invalid syntax
>>> print('plusten'(44))
Traceback (most recent call last):
File "<pyshell#50>", line 1, in <module>
print('plusten'(44))
TypeError: 'str' object is not callable
>>>