Skip to content

Commit 2ebe537

Browse files
authored
Merge pull request #4 from Patelvijaykumar/python_module_ranmon_and_math
added string concatenation and repetition example
2 parents bfd7300 + e9012a0 commit 2ebe537

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

Diff for: Python-String/string-concatation.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#Python String concatation Example
2+
3+
a = "Python"
4+
b = "scripting"
5+
6+
print (a+b)
7+
#output
8+
#Pythonscripting
9+
10+
# Adding space in two word
11+
print (a+" "+b)
12+
#Python scripting
13+
14+
#Adding new line between words
15+
print (a+'\n'+b)
16+
#Python
17+
#scripting
18+
19+
#concatation using Join
20+
print (' '.join([a, b]))
21+
#Python scripting
22+
23+
24+
#two String join
25+
print (' '.join(["Hello", "World"]))
26+
#Hello World
27+
28+
#Join using different character
29+
print (','.join(['apple','banana','strawberry']))
30+
#apple,banana,strawberry
31+
32+
x="hello"
33+
y="world"
34+
result = x+y
35+
print (result)
36+
#helloworld
37+
38+
result = 'Hello' +' ' +'World'
39+
print (result)
40+
#hello world

Diff for: Python-String/string-repatation.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#Python String Repetation and swaping Example
2+
3+
a = "Python"
4+
5+
print ( a * 5)
6+
7+
x= "Python"
8+
y= "Shell"
9+
10+
print (x,y)
11+
#python shell
12+
13+
14+
#swaping value x to y and y to x
15+
x,y=y,x
16+
print (x,y)
17+
#Shell Python
18+
19+
# using triple quotes
20+
print('''Hello, "What's there?"''')
21+
22+
# escaping single quotes
23+
print('Hello, "What\'s there?"')
24+
25+
# escaping double quotes
26+
print("Hello, \"What's there?\"")

0 commit comments

Comments
 (0)