-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChapter 2 - Variables.py
More file actions
28 lines (22 loc) · 896 Bytes
/
Chapter 2 - Variables.py
File metadata and controls
28 lines (22 loc) · 896 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
# CHAPTER 2
# Variable = a container for a value. Behaves as the value that it contains
# string data type is a series of characters
first_name = "Bro"
last_name = "Code"
full_name = first_name + " " + last_name
print("Hello " + full_name)
# print(type(first_name)) # to know the type of the variable
# integer data type is for whole numbers
age = 21
age += 1
print("Your age is " + str(age)) # str() is an example of method to use in typecasting
# print(type(age)) # to know the type of the variable
# float data type is for numbers with decimal values
height = 250.5
print("Your height is " + str(height) + " cm")
# print(type(height)) # to know the type of the variable
# boolean data type is a variable to store True or False
# useful in conditional statements e.g if, else-if
human = True
print("Are you a human? " + str(human))
# print(type(human)) # to know the type of the variable