forked from aiti-ghana-2012/Lab_Python_01
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab01.txt
More file actions
121 lines (120 loc) · 2.42 KB
/
Copy pathLab01.txt
File metadata and controls
121 lines (120 loc) · 2.42 KB
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
niilogoligi@niilogoligi-Satellite-C655:-~/Documents/tenacite/Lab_Python_01
Python 2.7.3 (default, Apr 20 2012, 22:44:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print "----------Exercise 1----------"
----------Exercise 1----------
>>> x
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'x' is not defined
>>> 56thnumber
File "<stdin>", line 1
56thnumber
^
SyntaxError: invalid syntax
>>> length
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'length' is not defined
>>> !Tayo
File "<stdin>", line 1
!Tayo
^
SyntaxError: invalid syntax
>>> NUMBER
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'NUMBER' is not defined
>>> Android_phone1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'Android_phone1' is not defined
>>> this variable
File "<stdin>", line 1
this variable
^
SyntaxError: invalid syntax
>>> print "----------Exercise 2----------"
----------Exercise 2----------
>>> a=False
>>> type(a)
<type 'bool'>
>>> b=3.7
>>> type(b)
<type 'float'>
>>> c='Alex'
>>> type(c)
<type 'str'>
>>> d=7
>>> type(d)
<type 'int'>
>>> e='True'
>>> type(e)
<type 'str'>
>>> f=17
>>> type(f)
<type 'int'>
>>> g='17
File "<stdin>", line 1
g='17
^
SyntaxError: EOL while scanning string literal
>>> h=True
>>> type(h)
<type 'bool'>
>>> i='3.14159'
>>> type(i)
<type 'str'>
>>> j="---add---"
>>> type(j)
<type 'str'>
>>> a=False
>>> b=True
>>> c=False
>>> b and c
False
>>> b or c
True
>>> not a and b
True
>>> (a and b)or not c
True
>>> not b and not (a or c)
False
>>> not ((not b or not a) and c) or a
True
>>> print "----------Exercise 3----------"
----------Exercise 3----------
>>> 5/2
2
>>> 5/2.0
2.5
>>> 5.0/2
2.5
>>> 7*(1/2)
0
>>> 7* (1/2.0)
3.5
>>> 5**2
25
>>> 5.0**2
25.0
>>> 5**2.0
25.0
>>> 1/3
0
>>> 1/3.0
0.3333333333333333
>>> Print "---------- Exercise 4 ----------"
File "<stdin>", line 1
Print "---------- Exercise 4 ----------"
^
SyntaxError: invalid syntax
>>> print "---------- Exercise 4 ----------"
---------- Exercise 4 ----------
>>> first_name = "Nathaniel"
>>> last_name = "Yebuah"
>>> date_of_birth = "i was born on October 21 1990"
>>> first_name+' '+last_name+'.'+date_of_birth
'Nathaniel Yebuah.born on October 21 1990'