1/58
Programming Basics
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Computer Program
Set of instructions executing sequentially
Input
A program takes in data from a file, keyboard, touchscreen, network, etc. for computation
Process
A program performs computations on input data, such as adding two values like x+y
Output
A program puts that data somewhere, such as to a file, screen, or network
Variables
Containers that store values that vary as programs are able to update these containers with new values
Flowchart
A graphical language for creating or viewing computer programs and how they operate
Statements
In a program, there is a list of statements that carries out some action and is executed sequentially
Interpreter
A computer program that directly executes (runs) instructions (statements) written in a program
Character
Any letter (a-z, A-Z), digit (0-9), space, or symbol (~,!,@,etc.)
String literal
Text characters within double quotes (“this is a string”)
Newline
Special two-character sequence \n whose appearance in an output string literal causes the cursor to move to the next output line
Pseudocode
Text that resembles a program in a real programming language, but is simplified to human understanding
Integrated Development Environment (IDE)
Environment where code development is done
Scripting Languages
Languages that allow programs to execute without the need for compilation
Script
A program whose instructions are executed by another program called an interpreter
Python
A scripting language created by Guido Van Rossum that was designed for simplicity and readability, while providing as much power and flexibility as other scripting languages like Perl
open-source language
the community of users participate in defining the language and creating new interpreters
Python Interpreter
A computer program that executes code written in the Python programming language
Interactive Interpreter
A program that allows the user to execute one line of code at a time
Code
Textual representation of a program
Line
Row of text
Prompt
The statement “>>>” is displayed by the interactive interpreter to indicate code is ready to be processed
Expressions
code that returns a value when some computation is performed using variables
Assignment
storing a value to a variable using “=”
print()
function that displays variables or expression values
Comments
statements used to explain portions of code to a human reader
Syntax Error - definition
An error made when violating a programming language’s rules in implemented statements that are combined to create a program
Syntax Error - occurance
The interpreter will create a message when encountering a syntax error, that will report the line number where the issue is located, and provides the programmer information as to what type of error is occurring
Runtime Errors
A program’s syntax may be correct, but the program attempts an impossible operations, such as dividing by zero or multiplying strings together
Crash
A runtime error stops the execution of the program and the abrupt termination of a program
Logic Error
A part of the written program is logically flawed and results in bugs, which is a logic error that occurs when the desired output of the program differs from the actual output of the program
Indentation Error
The lines of the program are not properly indented
Value Error
An invalid value is used
Name Error
The program tries to use a variable that does not exist
Type Error
An operation uses incorrect types
A logic error is often called a bug
True
The Python interpreter is a computer program that executes code written in the Python programming language.
True
The input obtained by input() is any text that a user typed, including numbers, letters, or special characters like # or @. Such text in a computer program is called a string.
True
Programs commonly get input values, then perform some processing on that input and then put output values to a screen or elsewhere.
True
Expressions
__________ are code that return a value when evaluated; for example, the code wage * hours * weeks is an expression that computes a number. The symbol * is used for multiplication.
Whitespace
Any space, tab, or newline is called __________________.
Variable
In Python, a new __________ is created by performing an assignment using the = symbol, such as salary = wage * hours * weeks.
Text in string literals may have letters, numbers, spaces, or symbols like @ or #.
True
Syntax errors are found before the program is ever run by the interpreter.
True
Programming is largely about problem solving: Creating a methodical solution to a given task.
True
Print()
the __________ function displays variables or expression values.
Type
Strings and integers are each an example of a __________, which determines how a value can behave.
Compared to flowcharts, pseudocode may be easier to create (just by typing) and to share than graphics.
True
String Literal
Text enclosed in quotes is known as a(n)
Most coding activities strictly require a student program's output to exactly match the expected output, including whitespace.
True
A program can have variables, each being a name that can hold a value, like a variable x holding the value 7.
True
The interpreter will generate a message when encountering a syntax error.
True
In Python, the value of a variable can be printed out via:
print(variable_name) (without quotes).
True
Algorithm
A sequence of instructions that solves a problem is called a(n)
input()
In Python, reading input is achieved using the __________ function.
In Python, a programmer can add end=' ' inside of print() to keep the output of a subsequent print statement on the same line separated by a single space. Ex: print('Hello', end=' ')
True
Just because the program loads and executes does not mean that the program is correct.
True
In Python, each call to print() generally outputs on a new line.
True
Adding a string inside the parentheses of input() displays a prompt to the user before waiting for input and is a useful shortcut to adding an additional print statement line.
True