-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path00_python_basics.py
83 lines (54 loc) · 1.72 KB
/
00_python_basics.py
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
# Python from NON Programmers
# Variables -- holds modifiable data
wallet_int = 10 # example of integer available
wallet_float = 9.9 # example of float variable
wallet_str = "test" # example of string variable
wallet_boolean = True # example of boolean variable ( booleans can only be True or False)
# Access the value or status of a variable by using print statement
print(wallet_float)
day_1 = 8
# Ints ( integer ) and Floats -- holds modifiable number values
temp_1 = -15 # ints and floats cand have negative numbers
height = 180.5 # example of float
print(height / temp_1) # arithmetic operations can be done using ints and floats
# Strings -- refers to words and sentences, requires the usage of " " or ' '
shirt = "blue"
print(shirt)
# use \' or \" to tell the program not to treat the marks as string ender.
store = 'this is a really "nice" string to test\'s'
movie = "Shawshank Redemption"
# Variables in Strings
day = 21
month = "October"
temp = 65
print(f"Today is {day} of {month} and there are {temp} degrees")
# Boolean -- represents the state of True or False
light_is_on = True
if light_is_on:
print("The light is on")
# Comparison and Else
light_is_on = False
if light_is_on:
print("The light is on")
else:
print("no light")
weight = 115
if weight < 119:
print("you are good")
else:
print("kinda heavy :d")
age_target = 38
if age_target < 18:
print("You are a child")
else:
print("You are an adult")
# ODD / EVEN exercise
# number var
# return True if odd and return False if even
def your_code():
number = 7
if number % 2 == 0:
return False
else:
return True
your_code()