forked from easyawslearn/Python-Tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_string_formating.py
More file actions
68 lines (53 loc) · 1.47 KB
/
python_string_formating.py
File metadata and controls
68 lines (53 loc) · 1.47 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
#######################################
####### Pyhton String Formating Example
#######################################
example="hello"
print ("center 5 function example")
string=example.center(5)
print(string)
#output is
#center 5 function example
#hello
print ("center 7 function example")
print(example.center(7))
#output is
# center 7 function example
# hello
print ("center 9 function example")
print(example.center(9))
#output is
# center 9 function example
# hello
print ("center 9 with * function example")
print(example.center(9,'*'))
#output is
# center 9 with * function example
# **hello**
print ("left justification example output is")
print(example.ljust(7))
# ljustification example output is
# hello
print ("left justification with * example output is")
print(example.ljust(7,'*'))
# ljustification with * example output is
# hello**
print ("right justification example output is")
print(example.rjust(7))
# right justification example output is
# hello
print ("right justification with * example output is")
print(example.rjust(7,'*'))
# right justification with * example output is
# **hello
print ("Zfilling 5 example output is")
print(example.zfill(5))
# Zfilling 5 example output is
# hello
print ("Zfilling 7 example output is")
print(example.zfill(7))
# Zfilling 7 example output is
# 00hello
print ("Zfilling 9 example output is")
print(example.zfill(9))
# Zfilling 9 example output is
# 0000hello