Requirements for variables

-Not too complicated -Not too simple

Popcorn Hack 1

FavoriteFood= "Favorite Food: Popcorn"
print(FavoriteFood)
Favorite Food: Popcorn

Data Types

-Integer: Mathematical numbers -Boolean: True or false statements -String (text): Text based info

Popcorn Hack 2

Number = 82
Happy = True
Name = "Aidan Delgado"
print(str(Number) + " is an integer")
print(str(Happy) + " is a boolean")
print((Name) + " is a string")
82 is an integer
True is a boolean
Aidan Delgado is a string

Changing values

currentScore= 17
highscore= currentScore
highscore-20
print(str(highscore))
17
num1=24
num2=65
num3=12
num1=num1
num2=num2
num3=num3
print(str(num1))
print(str(num2))
print(str(num3))

Strings and lists

-String: an ordered sequence of characters -Lists: an ordered sequence of elements, each element is a variable

CurrentClasses=("Calculus AB", "Physics", "Ceramics", "CompSci", "World History")
print ("My second period class is " + (CurrentClasses[1]))
My second period class is Physics

Data Abstraction - Lists

-Can help with not having to define each variable of a list

Json

Helps connect frontend and backend


Homework Hacks

Hack 1

  • Integer: Variable 1 (numStudents)
  • List: Variable 3 (groupMates)
  • Boolean: Variable 4 (dogsbeatcats)
  • String: Variable 2 (car)

Hack 2

#Integer
FavoriteNumber= 7
print(FavoriteNumber)

#String
Ethnicity="Mexican"
print(Ethnicity)

#List
ScrumTeam=["Miguel","Aidan","Patrick","Kaiyu"]
print(ScrumTeam)

#Boolean
ILoveHomework=False
print(ILoveHomework)
7
Mexican
['Miguel', 'Aidan', 'Patrick', 'Kaiyu']
False

List Conversion to Json


import json
ScrumTeam=["Miguel","Aidan","Patrick","Kaiyu"]
print(type(ScrumTeam))
a=json.dumps(ScrumTeam)
print(a)
print(type(a))

<class 'list'>
["Miguel", "Aidan", "Patrick", "Kaiyu"]
<class 'str'>