PSU COMPUTER SCIENCE 101 COMPLETE
PREPARATION GUIDE WITH
PYTHON/PROGRAMMING LOGIC AND
PROBLEM SOLVING
◉ function.
Answer: named series of statements
◉ function call.
Answer: Invoking a function's name
Ex:
def skirmish(attack, defend):
skirmish( x, y+2 ) assigns x=attack, y+2 = defend
return x+y returns sum of values of x and y
◉ def.
Answer: Creates a new function
,◉ Function creation.
Answer: def functionName ( argument1, argument2, ... ) :
#code inside function is indented
return output
◉ return.
Answer: causes execution to jump back to where the original call
occurred, returning execution to the next statement after the call.
◉ When reading a program that contains a while loop, one can easily
tell what code might be repeated as the while loop repeats..
Answer: All of the following code that is indented further than the
'while'
◉ What would be contained within: list( range(1, 10, 3) )?.
Answer: (1,4,7)
◉ Syntax error.
Answer: Does not follow rules of Python language
Examples: Mismatched quotes or parentheses
Improper indentation
,◉ Semantic error.
Answer: Gives an output, but not the one you intend.
Ex: 53//13 instead of 53/13
◉ Run-time error.
Answer: Operation cannot execute successfully
examples : Divide by zero
Attempt to access 10th element in list of 5 elements
◉ Logic error.
Answer: Program runs correctly but results do not meet
programmer's expectations
◉ What is the Central Processing Unit (CPU) (also called Processor).
Answer: Fetches and follows a set of simple instructions
◉ What is Main Memory?.
Answer: Stores the executing program and its data in RAM
◉ What is Secondary Memory?.
, Answer: Stores permanent records (files). Non-volatile
◉ What is ALU (Arithmetic and Logic Unit)?.
Answer: Performs math operations
◉ What is the Control Unit?.
Answer: Coordinates all of the computer's operations
◉ What is a bit?.
Answer: Represents two values, 0 and 1
◉ What is the Byte size limits?.
Answer: 0 and 255
0 = all bits off
255 = all bits on
◉ What is the most important coding scheme?.
Answer: ASCII (American Standard Code for Information
Interchange)
◉ Why is ASCII limited?.
Answer: Defines codes for only 128 characters
PREPARATION GUIDE WITH
PYTHON/PROGRAMMING LOGIC AND
PROBLEM SOLVING
◉ function.
Answer: named series of statements
◉ function call.
Answer: Invoking a function's name
Ex:
def skirmish(attack, defend):
skirmish( x, y+2 ) assigns x=attack, y+2 = defend
return x+y returns sum of values of x and y
◉ def.
Answer: Creates a new function
,◉ Function creation.
Answer: def functionName ( argument1, argument2, ... ) :
#code inside function is indented
return output
◉ return.
Answer: causes execution to jump back to where the original call
occurred, returning execution to the next statement after the call.
◉ When reading a program that contains a while loop, one can easily
tell what code might be repeated as the while loop repeats..
Answer: All of the following code that is indented further than the
'while'
◉ What would be contained within: list( range(1, 10, 3) )?.
Answer: (1,4,7)
◉ Syntax error.
Answer: Does not follow rules of Python language
Examples: Mismatched quotes or parentheses
Improper indentation
,◉ Semantic error.
Answer: Gives an output, but not the one you intend.
Ex: 53//13 instead of 53/13
◉ Run-time error.
Answer: Operation cannot execute successfully
examples : Divide by zero
Attempt to access 10th element in list of 5 elements
◉ Logic error.
Answer: Program runs correctly but results do not meet
programmer's expectations
◉ What is the Central Processing Unit (CPU) (also called Processor).
Answer: Fetches and follows a set of simple instructions
◉ What is Main Memory?.
Answer: Stores the executing program and its data in RAM
◉ What is Secondary Memory?.
, Answer: Stores permanent records (files). Non-volatile
◉ What is ALU (Arithmetic and Logic Unit)?.
Answer: Performs math operations
◉ What is the Control Unit?.
Answer: Coordinates all of the computer's operations
◉ What is a bit?.
Answer: Represents two values, 0 and 1
◉ What is the Byte size limits?.
Answer: 0 and 255
0 = all bits off
255 = all bits on
◉ What is the most important coding scheme?.
Answer: ASCII (American Standard Code for Information
Interchange)
◉ Why is ASCII limited?.
Answer: Defines codes for only 128 characters