forked from Devin24054/PythonDocs2122
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01_assignment.py
More file actions
46 lines (37 loc) · 1.21 KB
/
Copy path01_assignment.py
File metadata and controls
46 lines (37 loc) · 1.21 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
# Luke Thompson
# Assignment examples
# You can assign "values" to "variables"
#by using an equals (right side goes into left side)
x=5
# When Python reads a variable name, it replaces it
# with the variable's stored value
y = x + 5
# There are four different primitive datatypes
# Integers: any whole number, positive or negative
age = 16
# Float: any number with a decimal, positive or negative
grade = 98.6
# String: a string of human-readable characters
name = "Chris"
# numbers in a string are not numbers, they are letters
favoriteNumber = "6\'9"
# Boolean: True or false
# True is 1 in binary, false is 0. True is any value that is not false or empty. True is HIGH voltage, false is LOW
isSmart = True
# You can output to the console by using "print"
print(age)
print(grade)
print(name)
print(isSmart)
print(favoriteNumber)
# You can concatonate similar values together
print("My name is " + name)
# You can use functions to convert datatypes
print("and my age is " + str(age))
# Dont forget! If you want to convert a value permanently
# You must assign the converted value to a variable
age = str(age)
# You can convert back and forth with int(), str(), bool(), and float()
print(int(age))
print(float(age))
print(bool(age))