






























































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Learn Python programming fast with this concise guide to key terms, core concepts, and coding principles. Covers data types, control flow, functions, object-oriented programming, and common syntax rules—perfect for 2024/2025 beginners, students, and coding bootcamp learners. Python Programming, Coding Basics, Object-Oriented Programming, Programming Concepts
Typology: Exams
1 / 70
This page cannot be seen from the preview
Don't miss anything!































































Description Crack your Python exams with this ultimate cheat sheet! Inside, you’ll find hundreds of essential programming definitions, loop structures, syntax rules, functions, data types, and more—clearly explained and student-friendly. Whether you're a beginner or brushing up for finals, this guide is your shortcut to Python success. 🎯 Download now and turn confusion into clarity—one concept at a time!
Algorithm: Answer: A set of specific steps for solving a category of problems Token: Answer: Basic elements of a language(letters, numbers, symbols) High-level language: Answer: A programming language like python that is designed to be easy for humans to read and write. Low-level language: Answer: A programming language that is designed to be easy for a computer to execute; also called machine language or assembly language Keyword: Answer: Define the language's syntax rules and structure, and they cannot be used as variable names Statement: Answer: Instruction that the python interpreter can execute Operators: Answer: Special tokens that represent computations like addition, multiplication and division Modulus operator: Answer: %, works on integers (and integer expressions) and gives the remainder when the first number is divided by the second
Answer: A function that returns a boolean value. The only possible values of the bool type are false and true. None: Answer: A special python value. One use in python is that it is returned by functions that do not execute a return statement with a return argument. Block: Answer: A group of consecutive statements with the same indentation. Boolean expression: Answer: An expression that is either true or false. Conditional statement: Answer: A statement that controls the flow of execution depending on some condition. In python the keywords if, elif, and else are used for conditional statements. Conditional statement: Answer: One program structure within another, such as a conditional statement inside a branch of another conditional statement Type conversion: Answer: An explicit function call that takes a value of one type and computes a corresponding value of another type. Definite iteration: Answer: A loop where we have an upper bound on the number of times the body will be executed. Definite iteration is usually best coded as a for loop Increment: Answer: Both as a noun and as a verb, increment means to increase by 1.
Iteration: Answer: Repeated execution of a set of programming statements. Nested loop: Answer: A loop inside the body of another loop. Trace: Answer: To follow the flow of execution of a program by hand, recording the change of state of the variables and any output produced. Aliases: Answer: Multiple variables^ that contain references to the same object. Clone: Answer: To create a new object that has the same value as an existing object. Copying a reference to an object creates an alias but doesn't clone the object. Compound data type: Answer: A data type that^ is itself made up of elements that are themselves values. Decrement: Answer: To subtract one from a variable. Dictionary: Answer: A collection of key/value pairs that maps from keys to values. Exception: Answer: Raised by the runtime system if something goes wrong while the program is running. File:
Answer: On a robot, internal sensing mechanisms. On a human, a sense of the relative positions of different parts of ones own body. Recursion: Answer: The process of calling the currently executing function. Robot: Answer: Mechanism or an artificial entity that can be guided by automatic controls. Sequence: Answer: A data type that is made up of elements organized linearly, with each element accessed by an integer index. Short circuit evaluation: Answer: When a boolean expression is evaluated the evaluation starts at the left hand expression and proceeds to the right, stopping when it is no longer necessary to evaluate any further to determine the final outcome. Slice: Answer: A copy of part of a sequence specified by a series of indices. Traverse: Answer: To repeat an operation on all members of a set from the start to the end. Argument: Answer: A value provided to a function when the function is called. This value is assigned to the corresponding parameter in the function. Integer division:
Answer: An operation that divides one integer by another and yields an integer. Integer division yields only the whole number of times that the numerator is divisible by the denominator and discards any remainder. Element: Answer: One of the values in a list (or other sequence). The bracket operator selects elements of a list. Lambda: Answer: (it is also a keyword used to create such an anonymous function.) Module: Answer: A file containing definitions and statements^ intended to be imported by other programs. What is the disadvantage of coding in one long sequence structure? Answer: If parts of the duplicated code have to be corrected, the correction has to be made many times. What type of loop structure repeats the code a specific number of times? Answer: Count-controlled loop What type of loop structure repeats the code based on the value of the boolean expression? Answer: Condition-controlled loop What is the format for the while clause in python? Answer: While condition : statement What are the values that the variable num contains through the iterations of the following for loop? Answer: For num in range(2, 9, 2) 2, 4, 6, 8
In python, the variable in the for clause is referred to as the _____ because it is the target of an assignment at the beginning of each loop iteration. Answer: Target variable Which of the following represents an example to calculate the sum of the numbers (accumulator)? Answer: Total += number True/false: a better way to repeatedly perform an operation is to write the statements for the task once, and then place the statements in a loop that will repeat the statements as many times as necessary. Answer: True True/false: in flowcharting, the decision structure and the repetition structure both use the diamond symbol to represent the condition that is tested. Answer: True True/false: the first line in the while loop is referred to as the condition clause. Answer: True True/false: in python, an infinite loop usually occurs when the computer accesses the wrong memory address. Answer: False True/false: both of the following for clauses would generate the same number of loop iterations: for num in range(4): for num in range(1,5): Answer: False
True/false: the integrity of a program's output is only as good as the integrity of its input. For this reason the program should discard input that is invalid and prompt the user to enter correct data. Answer: True True/false: in a nested loop, the inner loop goes through all of its iterations for every single iteration of an outer loop. Answer: True True/false: to get the total number of iterations of a nested loop, multiply the number of iterations of all the loops. Answer: True A(n) ?? Structure causes a statement or set of statements to execute repeatedly. Answer: Repetition A(n) ??-controlled loop causes a statement or set of statements to repeat as long as a condition is true. Answer: Condition The while loop is known as a(n) ?? Loop because it tests conditions before performing an iteration. Answer: Pretest In python, you would use the ?? Statement to write a count-controlled loop. Answer: For A(n) ?? Total is a sum of numbers that accumulates with each iteration of a loop. Answer: Running A(n) ?? Is a special value that marks the end of a sequence of items. Answer: Sentinel
What is the largest value that can be stored in one byte? Answer:^255 The smallest storage location in a computer's memory? Answer: Bit The disk drive is a secondary storage device that stores data by _____ encoding it onto a spinning circular disk. Answer: Magnetically A _____ has no moving parts, and operates faster than a traditional disk drive. Answer: Solid state drive True/false: a computer is a single device that performs different types of tasks for its users. Answer: False True/false: the cpu is able to quickly access data stored at any random location in rom. Answer: False True/false: all programs are normally stored in rom and loaded into ram as needed for processing. Answer: False True/false: the instruction set for a microprocessor is unique and is typically understood only by the microprocessors of the same brand. Answer: True True/false: the cpu understands instructions written in a binary machine language. Answer: True
True/false: the main reason for using secondary storage is to hold data for long periods of time, even when the power supply to the computer is turned off. Answer: True True/false: ram is a volatile memory used for temporary storage while a program is running. Answer: True True/false: the python language uses a compiler, which is a program that both translates and executes the instructions in a high level language. Answer: False A(n) _______________ is a set of instructions that a computer follows to perform a task. Answer: Program The term _______________ refers to all of the physical devices that a computer is made of. Answer: Hardware The _______________ is the part of a computer that actually runs programs and is the most important component in a computer. Answer: Cpu _______________ are small central processing unit chips. Answer: Micro processors Main memory is commonly known as _______________. Answer: Ram _______________ is a type of memory that can hold data for long periods of time, even when there is no power to the computer. Answer: Secondary storage
In a print statement, you can set the _____ argument to a space or empty string to stop the output from advancing to a new line. Answer: End After the execution of the following statement, the variable sold will reference the numeric literal value as a(n) _____ data type: sold = 256. Answer: Float After the execution of the following statement, the variable price will reference the value _____. Price = int(68.549) Answer: 68 The output of the following print statement is: Answer: print 'i'm ready to begin' I'm ready to begin If value1 is 2.0 and value2 is 12, what is the output of the following command? Answer: Print(value1 * value2)
The _____ built-in function is used to read a number that has been typed on the keyboard. Answer: Input() What is the output of the following print statement? Answer: Print('the path is d:\sample\test.') The path is d:\sample\test What symbol is used to mark the beginning and end of a string? Answer: Quotation
True/false: according to the behavior of integer division, when an integer is divided by an integer, the result will be a float. Answer: False True/false: python allows programmers to break a statement into multiple lines. Answer: True True/false: python formats all floating-point numbers to two decimal places when outputting using the print statement. Answer: False True/false: computer programs typically perform three steps: input is received, some process is performed on the input, and output is produced. Answer: True True/false: in python, print statements written on separate lines do not necessarily output on separate lines. Answer: True True/false: the \t escape character causes the output to skip over to the next horizontal tab. Answer: True The % symbol is the remainder operator and it is also known as the _______________ operator. Answer: Modulus A(n) _______________ character is a special character that is preceded with a backslash, appearing inside a string literal. Answer: Escape
Which logical operators perform short-circuit evaluation? Answer: Or, and True/false: the if statement causes one or more statements to execute only when a boolean expression is true. Answer: True Boolean variable can reference one of two values: _____. Answer: True or false True/false: the python language is not sensitive to block structuring of code. Answer: False True/false: python allows you to compare strings, but it is not case sensitive. Answer: False . True/false: nested decision structures are one way to test more than one condition. Answer: True True/false: the not operator is a unitary operator and it must be a compound expression. Answer: False True/false: short-circuit evaluation is performed with the not operator. Answer: False True/false: expressions that are tested by the if statement are called boolean expressions. Answer: True True/false: decision structures are also known as selection structures. Answer: True
True/false: an action in a single alternative decision structure is performed only when the condition is true. Answer: True The _______________ statement is used to create a decision structure. Answer: If In flowcharting, the _______________ symbol is used to represent a boolean expression. Answer: Diamond A(n) _______________ decision structure provides only one alternative path of execution. Answer: Single alternative In a decision structure, the action is _______________ executed because it is performed only when a certain condition is true. Answer: Conditionally A(n) _______________ operator determines whether a specific relationship exists between two values. Answer: Relational A(n) _______________ statement will execute one block of statements if its condition is true, or another block if its condition is false. Answer: If/else Python provides a special version of a decision structure known as the _______________ statement, which makes the logic of the nested decision structure simpler to write Answer: If elif else The logical _______________ operator reverses the truth of a boolean expression.