# Computer Science Python Test

30 Questions | Total Attempts: 317  Settings  This test covers the first four introductory chapters on Python programming.

• 1.
The following codes all have one error.  In your answer describe the problem and how to fix it.  (5 PTS each)
• 2.
#NiceSquareSpiral.pyimport turtle   colors=['red', 'purple', 'blue',        'green', 'yellow', 'orange']t=turtle.pen()t.speed(0)turtle.bgcolor('black')for x in range(360):    t.pencolor(colors[x%4])    t.width(x/100+1)    t.forward(x)            t.left(88)
• 3.
Import turtlet = turtle.Pen()turtle.bgcolor("black")t.speed(0)sides = 3colors = ["red", "yellow", "blue", "orange", "green", "purple"]for x in range(360):t.pencolor(colors[x%sides])t.forward(x * 3 / sides + x)t.left(360/sides + 1)t.width(x*sides/100)
• 4.
SquareSpiral1.pyimport turtlet = turtle.Pen()t.speed(0)for x in range(100):    t.forward(2*x)    t.left(90)
• 5.
# AtlantaPizza.py # Ask the person how many pizzas they want, get the number with eval()number_of_pizzas = eval(input("How many pizzas do you want? ")) # Ask for the menu cost of each pizzacost_per_pizza = eval(input("How much does each pizza cost? ") # Calculate the total cost of the pizzas as our subtotalsubtotal = number_of_pizzas * cost_per_pizza # Calculate the sales tax owed, at 8% of the subtotaltax_rate = 0.08     # Store 8% as the decimal value 0.08sales_tax = subtotal * tax_rate # Add the sales tax to the subtotal for the final totaltotal = subtotal + sales_tax # Show the user the total amount due, including taxprint("The total cost is \$", total)print("This includes \$", subtotal, "for the pizza and")print("\$", sales_tax, "in sales tax.")
• 6.
What program do you run to enter the Python editor?
• A.

Windows

• B.

Python

• C.

Idle

• D.

Interactive Mode

• 7.
The >>> symbol in Python is known as the _______.
• A.

Prompt

• B.

Cursor

• C.

Whack

• D.

Float

• 8.
Within Python, there are two different modes.  Which mode is instant and runs a line of code the second the user presses 'enter'?
• A.

Editor

• B.

Shell

• C.

Loop

• D.

Interactive mode

• 9.
What file extension do all files created in Python end in?  (Example: an audio file might end in a FLAC or MP3 file extension)
• A.

EXE

• B.

BAT

• C.

PY

• D.

DLL

• 10.
While coding, programmers often make notes to themselves or other programmers.  These notes left behind by programmers are called comments.  When adding a comment, what symbol must the programmer add to tell Python to overlook this line in the code?
• A.

#

• B.

>>>>

• C.

()

• D.

[]

• 11.
"Reserved words" in Python are also known as _______.  These words and reserved by Python for particular functions.  When these words are typed they change to a different color in the code.
• A.

Shortcuts

• B.

Index

• C.

Variables

• D.

Keywords

• 12.
Turtle is a _________ built into Python that performs drawing functions.
• A.

Program

• B.

Command

• C.

Module

• D.

Keyword

• 13.
If a programmer wishes to use Turtle, what line of code should they first type to enable it?
• A.

T = turtle

• B.

Import turtle

• C.

Turtle

• D.

Turtle.Pen

• 14.
In the following statement identify the variable.t = turtle.Pen
• A.

T

• B.

=

• C.

Turtle.Pen

• D.

""

• 15.
What is a value?
• A.

A type that represents sequences of characters.

• B.

One of the basic units of data, like a number or string, that a program manipulates.

• C.

A program stored in a file (usually one that will be interpreted).

• D.

The structure of a program.

• 16.
What is a string?
• A.

A category of values. The types we have seen so far are integers (type int), floatingpoint numbers (type float), and strings (type str).

• B.

A programming statement that allows a block of code to be repeated as long as a condition is true.

• C.

A sequence of characters, which can include letters, numbers, symbols, punctuation, and spacing.

• D.

A named value that can change

• 17.
What is a loop?
• A.

A part of a program that can execute repeatedly.

• B.

A file or set of files with related variables, functions, and classes that can be reused in other programs.

• C.

A symbol or set of symbols that represents an action or comparison and returns a result, such as +, -, *, //, , ==, and so on.

• D.

An input variable to a function, specified in the function’s definition

• 18.
What is an operator?
• A.

A variable containing information about a single instance of a class, such as a single sprite from the Sprite class.

• B.

A special, reserved word that means something in a particular programming language.

• C.

An input variable to a function, specified in the function’s definition.

• D.

A symbol or set of symbols that represents an action or comparison and returns a result, such as +, -, *, //, , ==.

• 19.
The values the operator is applied to are called _____.
• A.

Intergers

• B.

Types

• C.

Operands

• D.

Variables

• 20.
When giving a value to a variable it is known as a ________.
• A.

Script

• B.

Assignment statement

• C.

Semantics

• D.

Parse

• 21.
("What is your name?") is a _________.
• A.

String

• B.

Loop

• C.

Operator

• D.

Variable

• 22.
[] indicates a _____.
• A.

Loop

• B.

String

• C.

Value

• D.

List

• 23.
A whole number such as 6 is seen in Python as what type?
• A.

String

• B.

Float

• C.

Interger

• D.

Operand

• 24.
The number 3.5 is seen in Python as this type.
• A.

String

• B.

Float

• C.

Interger

• D.

Operand

• 25.
This type of loop runs for a set length or range.
• A.

For

• B.

While

• C.

If

• D.

Nested

Related Topics Back to top