Skip to content

Commit 7bbc13a

Browse files
committed
added string example
1 parent 23a3eac commit 7bbc13a

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

Diff for: Python-String/String-example1.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Python String Variable Demostration
2+
3+
# Declaration
4+
5+
#String Declaration with single quote for single line display
6+
x= ''
7+
print (x)
8+
9+
#String Declaration with double quote for single line display
10+
x= " "
11+
print (x)
12+
13+
#String Declaration with multi line print with single quote
14+
x = '''Hello
15+
This is Python Multiline
16+
demo
17+
'''
18+
print (x)
19+
20+
21+
#String Declaration with multi line print with double quote
22+
x = """Hello
23+
This is Python Multiline
24+
demo
25+
"""
26+
print (x)
27+
28+
#How print works
29+
x= 'hello'
30+
#variable will br printed
31+
print (x)
32+
33+
#x as a string will be printted
34+
print ('x')
35+
36+
#x as a string will be printted
37+
print ("x")
38+
39+
#variable x will be printed in string conversation
40+
print (str(x))
41+
42+
#repr() representation that has all information
43+
print (repr(x))

Diff for: Python-String/String-example2.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Python String Variable Demostration
2+
3+
# Declaration
4+
x="python"
5+
6+
#condition in string with small latter
7+
print ('t' in x)
8+
9+
10+
#condition in string with capital latter
11+
print ('T' in x)
12+
13+
#String print
14+
print (x)
15+
16+
# String lenght printed
17+
print (len(x))
18+
19+
#How to add new line in print
20+
x= "Python\nTest"
21+
print(x)
22+
23+
#How to add new line in print
24+
x= 'Python\nTest'
25+
print(x)
26+
27+
#How to avoide special character
28+
x = r'Python\nTest'
29+
print (x)

0 commit comments

Comments
 (0)