-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmypy_tutorial.py
More file actions
41 lines (26 loc) · 813 Bytes
/
Copy pathmypy_tutorial.py
File metadata and controls
41 lines (26 loc) · 813 Bytes
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
from typing import Union
flag : bool = True
def greet(name : str) -> None:
"""Say hello to everyone"""
print("Hi " + name)
greet("Manchester")
greet("Steven")
def myAbs(x : float) -> float:
"""Take the absolute of the floating-point input"""
if x < 0:
return (-x)
else:
return (x)
myAbs(12)
def greetAll(names : list[str]) -> None:
for name in names:
greet(name)
greetAll(["Alice", "John", "Joe"])
#greetAll([12, 12])
some_data : tuple[int, bool, str] = (41, True, "Manchester")
#some_other_data : tuple[int, bool, str] = (41, 232132, "Manchester")
def myDiv(x : float, y : float) -> Union[float, None]:
if y != 0: return x/y
else: return None
myDict : dict[str, Union[float, str]] = {"temp": 273.0, "units": "Kelvin"}
#reveal_type(len)