Skip to content

Commit fbba6c9

Browse files
author
Amogh Singhal
authored
Create string_concatenation_and _formatting.py
1 parent e1859aa commit fbba6c9

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
names = ['Harish', 'Kaushik', 'Satyam', 'Sijil']
2+
3+
# for name in names:
4+
# # print('Hello there, '+ name)
5+
# print(''.join(['Hello there, '+ name]))
6+
7+
# useful for concatenating multiple strings
8+
print(', '.join(names))
9+
10+
# import os
11+
12+
# location_of_file = 'C:\\Users\\Amogh S\\Desktop\\Intermediate Python'
13+
# file_name = 'example.txt'
14+
15+
# print(location_of_file, file_name)
16+
17+
# with open(os.path.join(location_of_file, file_name)) as f:
18+
# print(f.read())
19+
20+
who = 'Kaushik'
21+
how_many = '12'
22+
23+
# Kaushik bought 12 mangoes today !
24+
print(who, 'bought', how_many, 'apples today!')
25+
print('{} bought {} apples today!'.format(who, how_many))
26+
27+
# using zero-based indexing to access inputs as parameters
28+
# mandatory in Python 2.X
29+
print('{0} bought {1} apples today!'.format(who, how_many))
30+
print('{1} bought {0} apples today!'.format(who, how_many))

0 commit comments

Comments
 (0)