-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
103 lines (72 loc) · 2.25 KB
/
main.py
File metadata and controls
103 lines (72 loc) · 2.25 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
"""
simple-python-example
A program that is meant to be used as an example in class
"""
import os
from message import Message
def print_message_from_file(filename):
"""
Prints a message from contents for a <fieldset>
Arguments:
filename - A string giving the name of the files that is in the current
directory
Returns:
Returns no value, prints the message to stdout
"""
with open(filename, "r") as f_to_read:
message = f_to_read.read()
print("This is the message")
print("{}".format(message))
def print_separator(num_chars=45):
"""
Prints a separator of lines
Arguments:
num_chars: number of hyphens to put in the print_separator
Returns:
No Value, prints the separator to stdout
"""
print("{}".format("".join(["-" for x in range(0, num_chars)])))
def main():
"""
The main function that runs the program
"""
for i in range(0, 10):
print("Hello World!#{}".format(i))
sample_list = [0, 1, 2, 3, 4,
5, 6, 7, 8, 9]
print_separator()
for i in sample_list:
print("Hello List!#{}".format(i))
print_separator()
sample_list_comp = [x for x in range(0, 1)]
for i in sample_list_comp:
print("Hello Comprehension!#{}".format(i))
print_separator()
sample_dictionary = {"english": "hat",
"french": "chapeau"}
for k, val in sample_dictionary.items():
print("The word in {} is {}".format(k, val))
print_separator()
filename = os.path.join(os.getcwd(), "message.txt")
print("The File is at {}".format(filename))
print_message_from_file(filename)
print_separator()
msg = Message("... this is in class.")
msg.print_message()
print_separator()
print("{}".format(msg))
print_separator()
msg_add = msg + " | adding a string"
msg_add.print_message()
print_separator()
msg2 = Message("... adding a message class")
msg_add = msg + msg2
msg_add.print_message()
print_separator()
try:
num = 6.003432
msg_add = msg + num
except Exception as e_msg:
print("There was an exception {}".format(str(e_msg)))
if __name__ == "__main__":
main()