# College Board Pseudo code
# Calling Procedures:
procName(arg1, arg2,...)
# Defining Procedures
procedure procName (parameter1, parameter2, ...){
<block of statements>
RETURN expression
}
# Defining Functions in python
#
# def function_name(parameter1, parameter2, etc..):
# code here...
#
# return return_value;
# return the value of parameter1 plus parameter2;
def add(parameter1, parameter2): # creates a function that takes in two parameters
solution = parameter1 + parameter2; # sets solution to the sum of parameter1 and parameter2
return solution; # return solution
print(add(5, 5)); # prints the return value of subtract(5,5)
# Code Here
# Defining Classes
class person:
def __init__(self, name, age, ): # constructor
self.name = name; # instance variable
self.age = age; #instance variable
def getName(self): # method to create get name
return self.name;
def getAge(self): # method to create get age
return self.age;
def setName(self, name): # method to create set name
self.name = name;
def setAge(self, age): # method to create set age
self.age = age;
def yearOlder(self): # method to increment age by 1
self.age += 1;
def __str__(self): # method that returns a string when the object is printed
return (f"My name is {self.name} and I am {self.age} years old.")
Person1 = person("John Doe", 15);
print(Person1)
print(Person1);
import turtle
pen = turtle.Turtle(); # pen is the instance of Turtle which has methods that do certain actions
# Necessary methods:
# .forward(50) - moves the pen forward 50 units
# .right(angle) - turns the pen angle degrees right
# OR
# .left(angle) - turns the pen angle degrees left
def shape(sides):
# code here...
# set each side to be 50 units long
# The interior angle of each angle is equal to ((sides-2)*180)/sides
# ask user for sides and pass as argument for the function
class student:
def __init__(self, parameters...):
#code here...
pass; #don't include
def getName(self): # method to create get name
#code here...
pass; #don't include
def getGrade(self): # method to create get grade
#code here...
pass; #don't include
def getEmail(self): # method to create get email
#code here...
pass; #don't include
def setName(self, name): # method to set name
#code here...
pass; #don't include
def setAge(self, age): # method to set age
#code here...
pass; #don't include
def setEmail(self, email): # method to set email
#code here...
pass; #don't include
def __str__(self): # method that returns a string when the object is printed
#code here...
pass; #don't include
#format :"My name is {name}. My email is {email}. My grade is {grade}"
#create an instance of the class corresponding to you then print the instance using: print(object)