Variable

age = 16
print("You are "+ str(age) +" years old.")
You are 16 years old.

Data Types

age = 16
isFalling = False
firstName = "Beijan"
print(str(age) + " is an integer")
print(str(isFalling) + " is a boolean")
print(firstName + " is a string")
16 is an integer
False is a boolean
Beijan is a string

Changeing Variables

var1 = 10
var2 = var1
var1 = 7
print(str(var2))
10

Data Abstraction

schedule = ["Engineering", "Physics 1", "Calculus", "Computer Science"]
print(schedule[1])
Physics 1

Hack 1

# Variable 1: Integer

numStudents = 26
print (numStudents)

# Variable 2: List

groupMates = ["Nikki", "Monika", "Ankit", "Varun"]
print (groupMates)

# Variable 3: Boolean
dogsbeatcats = True
print (dogsbeatcats)

# Variable 4: String

car = "Tesla"
print (car)

26
['Nikki', 'Monika', 'Ankit', 'Varun']
True
Tesla

Hack 2

# Integer: a numerical value as a variable
age = 16
print("You are "+ str(age) +" years old.")

# List: a set of value in one variable
schedule = ["Engineering", "Physics 1", "Calculus", "Computer Science"]
print(schedule[1])

# Boolean: a variable that represents a true or a False
raining = False
print("An example of a boolean is, "+ str(raining))

# String: a collection of characters in a variable
name = "Beijan"
print("Hello my name is "+ name)

# List with JSON
import json
ages = [15,16,17,18]
#print shows what kind of variable ages is
print(type(ages))
#json.dumps turn integers into strings in lists to be able to print them out
ages = json.dumps(ages)
print(ages)
print(type(ages))

You are 16 years old.
Physics 1
An example of a boolean is, False
Hello my name is Beijan
<class 'list'>
[15, 16, 17, 18]
<class 'str'>