1/46
Flashcards covering the basics of input, processing, output, and turtle graphics in Python.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Algorithm
A set of well-defined logical steps that must be taken to perform a task.
Pseudocode
Informal language that has no syntax rule used to create model program, which can be translated directly into actual code in any programming language
Flowchart
Diagram that graphically depicts the steps in a program.
print function
Displays output on the screen.
String Literal
A string that appears in the actual code of a program and must be enclosed in single (') or double (") quote marks.
Comments
Notes of explanation within a program ignored by Python interpreter.
Variable
Name that represents a value stored in the computer memory.
Assignment statement
Used to create a variable and make it reference data.
Garbage collection
Removal of values that are no longer referenced by variables.
Data types
Categorize value in memory (e.g., int, float, str).
Numeric literal
Number written in a program. No decimal point considered int, otherwise, considered float.
input function
Built-in function that reads input from keyboard and returns the data as a string.
Nested function call
function1(function2(argument)), value returned by function2 is passed to function1
Math expression
Performs calculation and gives a value.
Math operator
Tool for performing calculation.
Operands
Values surrounding operator and can be a variable.
Exponent operator
Raises a number to a power (x ** y = xy).
Remainder operator
Performs division and returns the remainder (a.k.a. modulus operator).
Multiline continuation character
Allows to break a statement into multiple lines
String Concatenation
To append one string to the end of another string; use the + operator.
Named constant
Name that represents a value that does not change during the program's execution
Magic Number
An unexplained numeric value that appears in a program’s code.
Turtle
Python's turtle graphics system displays a small cursor known as a turtle. You can use Python statements to move the turtle around the screen, drawing lines and shapes.
turtle.forward(n)
Statement to move the turtle forward n pixels.
turtle.right(angle)
Statement to turn the turtle right by angle degrees.
turtle.left(angle)
Statement to turn the turtle left by angle degrees.
turtle.setheading(angle)
Statement to set the turtle's heading to a specific angle.
turtle.penup()
Statement to raise the pen so the turtle does not draw as it moves.
turtle.pendown()
Statement to lower the pen so the turtle draws as it moves.
turtle.circle(radius)
Statement to draw a circle with a specified radius.
turtle.dot()
Statement to draw a simple dot at the turtle's current location.
turtle.pensize(width)
Statement to change the width of the turtle's pen, in pixels.
turtle.pencolor(color)
Statement to change the turtle's drawing color.
turtle.bgcolor(color)
Statement to set the window's background color.
turtle.setup(width,height)
Statement to set the size of the turtle's window, in pixels.
turtle.reset()
Statement that erases all drawings, resets color to black, and resets turtle position.
turtle.clear()
Statement that erases all drawings but does not change turtle position or color.
turtle.clearscreen()
Statement that erases all drawings, resets color to black, resets turtle position, and resets background color to white.
turtle.goto(x, y)
Statement to move the turtle to a specific location.
turtle.speed(speed)
Command to change the speed at which the turtle moves. The speed argument is a number in the range of 0 through 10.
turtle.hideturtle()
Command to hide the turtle, does not change the way graphics are drawn, it simply hides the turtle icon.
turtle.showturtle()
Command to display the turtle.
turtle.write(text)
Statement to display text in the turtle's graphics window.
turtle.begin_fill()
Command used before drawing a shape to fill it with color.
turtle.end_fill()
Command used after drawing a shape to fill it with the current fill color.
turtle.numinput('Input', 'Enter your age')
Command used to get input with a dialog box.
turtle.done()
Command used at the end of a turtle graphics program to keep the graphics window open.