-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPrint Functions.py
More file actions
183 lines (110 loc) · 5.65 KB
/
Print Functions.py
File metadata and controls
183 lines (110 loc) · 5.65 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
'''Print Statement Examples:'''
'''
Print statement values are encased with round brackets '()' on each end of the 'print' statement's value. \
Quotation marks (" ") denote what kind of 'print' statement value it is. If the value is a string, then no \
quotation marks are used inside the 'print' statement's value. However, quotation marks are used within the \
'print' statement's string value instead. Note: double quotation marks (" ") or single quotation marks (' ') \
can be used in 'print' statements, string values, tuples and lists alike. If the value is not a string, then \
quotation marks are used inside the 'print' statement's value itself, such as these two 'print' statement examples below.
'''
# Print statement examples:
# Double Quotation marks (" ")
print("Hello World!")
# Single Quotation marks (' ')
print('Hello World!')
# Print statement string examples:
# Double Quotation marks (" ")
my_string_example="Hello World!"
print(my_string_example)
# Single Quotation marks (' ')
my_string_example='Hello World!'
print(my_string_example)
'''Fancy Print Statement Examples:'''
'''
All 'print' statements and all 'input' statements also support the '\n' line-break implementer, which acts like a normal \
line-break in between sentences. The '\n' line-break implementer can also be implemented into string values, tuple values \
and list values alike. From here on, the '\n' line-break implementer will be implemented into all 'print' statements, \
'input' statements, string values, tuple values and list values. The '\n' line-break implementer makes the screen printout \
much more cleaner and nicer looking with actual line-breaks in between sentences. Note: two '\n\n' or more '\n\n\n' \
line-break implementers can be implemented at once within a single 'print' statement.
'''
# Here are some 'print' statement examlples of the '\n' line-break implementer.
print('\nHello World!')
print('\n\nHello World!')
print('\n\n\nHello World!')
print('\n\n\n\nHello World!')
print('Hello world!\nHello world!\nHello world!\nHello world!')
# The upper() fuction turns the words 'hello world!' into the words 'HELLO WORLD!'
# example:
print('\nhello world!'.upper())
# The title() function turns the words 'hello world!' into the words 'Hello World!'
# example:
print('\nhello world!'.title())
# The lower() function turns the words 'HELLO WORLD!' into the words 'hello world!'
# example:
print('\nHELLO WORLD!'.lower())
# Make 'print' statement values in reverse by omitting the slice '[::]' emitter.
print('\nHello World!'[::-1])
'''----------------------------------------------------------------'''
# Try these 'print' statement value in reverse program examples, while using other
# combined functions.
print('\nhello world!'[::-1].upper())
print('\nhello world!'[::-1].title())
print('\nHELLO WORLD!'[::-1].lower())
# The slice [::] emitter can be omitted into tuples, lists, dictionaries and 'print'
# statements, such as in these 'print' statement program examples:
# The slice [::] emitter takes one to three positive or negative values. The 'print'
# statement's string value 'HELLO WORLD!' is sliced. When slicing a 'print' statement's
# string value, the values can be sliced from left to right, or from right to left. For
# example, the 'print' string value 'HELLO WORLD!' looks like these sliced 'print' string
# value examples:
# 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
# H,E,L,L,O, ,W,O,L,R,D,!
# -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1
# H,E,L,L,O, ,W,O,L,R,D,!
# [ start value : end value : step value ]
# Note: step values must start at 1 not 0
# empty slice: no values
print('HELLO WORLD!'[:])
# Screen output: HELLO WORLD!
# slice start value 0
print('HELLO WORLD!'[0:])
# Screen output: HELLO WORLD!
# slice end value -1
print('HELLO WORLD! '[:-1])
# Screen output: HELLO WORLD!
# slice start and slice end values 1 and -2
print('HELLO WORLD! '[1:-2])
# Screen output: ELLO WORLD
# slice start, slice end and slice step 2
print('HELLO WORLD!'[0:-1:2])
# Screen output: HLOWRD
'''----------------------------------------------------------------'''
# In this example, the start and end slice emitter values are positive. Notice how the
# screen output shows 'HE'.
# slice start and slice end values 0 and 2
print('HELLO WORLD! '[0:2])
# Screen output: HE
'''----------------------------------------------------------------'''
# In this example, the start and end slice emitter values are negative. Notice how the
# screen output shows 'D!'.
# slice start and slice end values -3 and -1
print('HELLO WORLD! '[-3:-1])
# Screen output: D!
# Make this 'print' statement print 'Hello World!' 3 times.
print('Hello World! '*3)
'''----------------------------------------------------------------'''
# Make this 'print' statement print 'Hello World!' go in the top, middle of the screen.
# Note: use an emty space in between the single quotation marks (' '*45)
print(' '*45+'Hello World!')
# Try these 'print' statement program examples:
print('Hello World! '*3+'Python')
print('Python '*3+'Hello World!')
print('Python '*45+'Hello World!')
print('Python '*45)
# The 'len' function counts how many characters, including spaces there are inside of
# a 'print' statement. The length of these two words "Hello World!", including the
# space in between 'Hello' and 'World!' are counted. For example: "Hello World!"
# including one space is twelve characters long. The printout on the screen will only
# show the number "12", not the actual words "Hello World!".
print(len('Hello World!'))