Skip to content

Commit 4363eae

Browse files
author
ashegde
committed
feat(example): input output
1 parent 665eede commit 4363eae

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

codes/session_4/inputOutput.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Open terminal > python3 inputOutput.py
2+
# Start typing below commands and see the output
3+
4+
x = 10 * 45
5+
y = 20 * 90
6+
7+
s = 'The value of x is ' + repr(x) + ' , and y is ' + repr(y)
8+
9+
print(s)
10+
11+
for a in range(1, 10):
12+
print(repr(a).rjust(2), repr(a*a).rjust(3), end=' ')
13+
print(repr(a*a*a).rjust(4))
14+
15+
print('\n\n')
16+
17+
for b in range(1, 10):
18+
print('{0:2d} {1:3d} {2:4d}'.format(b, b*b, b*b*b))
19+
20+
print('\n\n')
21+
22+
import math
23+
print('The value of PI is approximately %5.3f' % math.pi)
24+
25+
print('I love working on {} as well as {}!'.format('JavaScript', 'Python'))
26+
27+
print('I love working on {0} as well as {1}!'.format('JavaScript', 'Python'))
28+
29+
print('I love working on {1} as well as {0}!'.format('JavaScript', 'Python'))
30+
31+
print('My name is {name}, and I\'am a {job}'.format(name='Ashwin', job='Software Engineer'))
32+
33+
print('My name is {name}, and I love working in {0}, and {1}'.format('JavaScript', 'Python', name='Ashwin'))
34+
35+
table = {'Ashwin': 'Engineer', 'Saju': 'Architect', 'Ajay': 'Manager'}
36+
37+
for name, role in table.items():
38+
print('{0:10} -> {1:10s}'.format(name, role))

0 commit comments

Comments
 (0)