final exam Flashcards
(38 cards)
What naming convention do you use for variables and functions?
snake_case
What naming convention do you use for classes?
CamelCase / PascalCase
What naming convention do you use for constants?
UPPERCASE with underscores
What’s the maximum line length
79 characters
How many spaces do you use for indentation
4 spaces
How many lines do you use between functions
2 blank lines
What are ints?
Whole numbers
What are floats?
Decimal numbers
What are strings?
Text
What are bools?
true/false values
What are lists?
A group of data types, mutable (changeable) and ordered in brackets []
What are classes?
Templates for objects
What are objects?
Instances of classes
What is inheritance in classes?
When classes inherit properties from other classes
What are conditionals?
If, else, elif statements
What’s the difference between a for and while loop?
A for loop runs a certain number of times; A while loop runs while a condition is true
What are the powers of two?
1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024
How do you go from binary to number?
Add up the power of 2s for each position with a one (start with 1 and go from the right).
How do you go from number to binary?
Write out powers of 2 (start with the largest one that’s smaller than the number), placing a 1 or 0 based on if the number is bigger/thesame or smaller. Subtract it if it’s bigger/the same.
What is the role of the CPU
Processing
What is the role of RAM
Temporary storage
What is the role of ROM
Permanent storage
What is the role of GPU
Graphics processing
How do you initialize pygame?
import pygame
pygame.init()