BestFood = "ramen"
print(BestFood)
age = 16
print(age)
ramen
16
Siblings = 2
EatingFood = False
firstName = "Josh"
print(str(Siblings) + " is an integer")
print(str(EatingFood) + " is a boolean")
print(str(firstName) + " is a string")
2 is an integer
False is a boolean
Josh is a string
num1 = 1
num2 = 32
num3 = 44
num3 = num1
num1 = num2
num2 = num3
print(str(num1))
print(str(num2))
print(str(num3))
age = 15
newAge = age
newAge = 17
print(str(newAge))
32
1
1
17
classes = ("3D Animation", "Ap calc", "AHug", "APCSP")
print(classes[1])
Ap calc
A variable is not static, it is changable.
- list is ordered sequence of elements
- strings are ordered sequence of characters Index mostly starts at zero but on the ap exam they want you to start at 1.
friendsAge = (3, 4, 5, 6, 7, 8)
newFriendsAge = (16, 16, 16, 15, 16)
friendsAge = newFriendsAge
print(str(friendsAge))
(16, 16, 16, 15, 16)
import json
lst = [1,2,3,4,5]
print(type(lst))
a = json.dumps(lst)
print(a)
print(type(a))
<class 'list'>
[1, 2, 3, 4, 5]
<class 'str'>
# variable 1
numStudents = 26
print("Variable 1) " + str(numStudents) + " is a integer")
#variable 2
car = "Tesla"
print("Variable 2) " +str(car) + " is a string")
#variable 3
groupMates = ["Nikki", "Monika", "Ankit", "Varun"]
print("Variable 3) " +str(groupMates) + " is a list")
#Variable 4
dogsbeatcats = True
print("Variable 4) " +str(dogsbeatcats) + " is a boolean")
Variable 1) 26 is a integer
Variable 2) Tesla is a string
Variable 3) ['Nikki', 'Monika', 'Ankit', 'Varun'] is a list
Variable 4) True is a boolean
import json
team = ["Josh", "Ethan", "Matthew", "Lindsay"]
FavoriteFood = "ramen"
age = 16
ILoveVideoGames = True
teamStr = json.dumps(team)
user = input("How many members are in your team?")
if int(user) == len(team):
print("We have the same amount of members")
elif user != len(team):
print("we do not have the same members")
print(teamStr)
print(FavoriteFood)
print(age)
print(ILoveVideoGames)
We have the same amount of members
["Josh", "Ethan", "Matthew", "Lindsay"]
ramen
16
True
Reflection:
Data Abstraction:
-
Data abstraction simplifies complex problems by focusing on essential details.
-
It involves hiding unnecessary details and exposing what’s relevant.
-
Data structures, like arrays and linked lists, help organize and manage data.
-
Abstract data types (ADTs) provide high-level structures for common tasks.
-
Encapsulation keeps data private and enforces rules through methods.
-
Abstraction simplifies code, promotes reusability, and enhances readability.
-
It’s a key concept in computer science for building efficient and maintainable software.