Short summarys of lessons/flash cards to remember

AP Computer Science Flashcards

AP Computer Science Flashcards

# Variables
age_value = 15
name_value = "Alex"
print(name_value)
print(age_value)
# Output:
# Alex
# 15
        
# Naming Styles
user_one = "John"
UserTwo = "Doe"
print(user_one)
print(UserTwo)
# Output:
# John
# Doe
        
# Data Types
number_int = 42
decimal_float = 3.14
print(number_int)
print(decimal_float)
# Output:
# 42
# 3.14
        
# Lists
group_names = ["Alice", "Bob", "Charlie"]
print(group_names[1])
# Output:
# Bob
        
# Dictionaries
student_data = {"name": "Chris", "age": 17}
print(student_data["name"])
# Output:
# Chris
        
# Operators
a = 10
b = 5
print(a + b)  # Addition
print(a * b)  # Multiplication
# Output:
# 15
# 50
        
# Integers
num_one = 10
num_two = -5
print(num_one)
print(num_two)
# Output:
# 10
# -5
        
# Floats
pi_value = 3.14159
print(pi_value)
# Output:
# 3.14159
        
# Strings
message = "Hello, World!"
print(message)
# Output:
# Hello, World!
        
# Booleans
is_active = True
print(is_active)
# Output:
# True
        
# None Type
variable = None
print("Value:", variable)
if variable is None:
    print("It's None!")
# Output:
# Value: None
# It's None!
        
# Mathematical Expressions
x = (5 + 3) * 2
y = 12 / 4 - 1
print("x =", x)  # Output: 16
print("y =", y)  # Output: 2.0
        
# Python Strings
greeting = "Welcome to Python!"
print(greeting)
# Output:
# Welcome to Python!

# Multi-line Strings
multiline_message = """This is a
multi-line string."""
print(multiline_message)
# Output:
# This is a
# multi-line string.
        
/* JavaScript Strings */
let greeting = "Hello from JavaScript!";
console.log(greeting);
// Output:
// Hello from JavaScript!

// Multi-line Strings
let multilineMessage = `This is a
multi-line string.`;
console.log(multilineMessage);
// Output:
// This is a
// multi-line string.
        
# If/Else Statements
# Python Example
age = 18
if age >= 18:
    print("You are an adult.")
else:
    print("You are a minor.")
# Output:
# You are an adult.

# JavaScript Example
let age = 16;
if (age >= 18) {
    console.log("You are an adult.");
} else {
    console.log("You are a minor.");
}
// Output:
// You are a minor.