forked from Dev-AI-Bootcamp/Mastering-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
45 lines (34 loc) · 1.05 KB
/
main.py
File metadata and controls
45 lines (34 loc) · 1.05 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
name: str = "Your name here"
age: int = 52
height: float = 1.82
is_student: bool = False
print (f"My name is {name}, I am {age} years old, my height is {height} meters, and I am {'a student' if is_student else 'not a student'}.")
for i in range(4, 15):
print(f"I'm counting and I'm up to {i}")
# This is a comment
# and next is a function
def greet(username: str) -> str:
var_not_used = 42 # This variable is not used
if not username:
return "Hello, World!"
else:
return f"Hello, {username}!"
def SimpleGreet(username):
return "Hello, " + username + "!"
# a little object oriencted programming example
class Dog:
species = "Canis familiaris"
def __init__(self, name: str, age: int):
self.name = name
self.age = age
def bark(self) -> str:
return "Woof!"
# common wait to start a program only if it's not loaded as a module
def main():
greet(name)
SimpleGreet(name)
charly = Dog("Charly", 3)
print(charly.name)
print(charly.bark())
if __name__ == "__main__":
main()