



























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




























◉ 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
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
◉ What is unicode?. Answer: It is becoming standard. Compatible with ASCII. Can represent characters for another language ◉ What is the operating system?. Answer: Allocates computer's resources and allows communication between user and computer ◉ What is an algorithm?. Answer: A set of well-defined steps for performing a task or solving a problem ◉ What is a program?. Answer: A set of instructions a computer follows to perform a task. An algorithm that has been transferred into a programming language so the computer can "understand" and perform the steps ◉ What is high-level language?. Answer: Designed to be easy for humans to read and to write programs in, but too complicated for the computer to understand ◉ What is complied language?.
◉ What is the input function?. Answer: Prompts the user to store data in a variable as a string ◉ What is the float function?. Answer: Converts from string to floating point number Float number: 5. ◉ What is the int function?. Answer: Converts from string to integer number Integer number: 5 ◉ What is the eval function?. Answer: Detects if input was a floating point number or an integer number and converts from string to float or int ◉ Turtle graphics: How to import? pensize: penup: bicolor('__'):. Answer: import turtle to import turtle
add direction and distance/angle: (turtle.____) change the line thickness lifts the pen up (won't draw) changes the background color ◉ What is a 1 branch statement?. Answer: If statement ◉ What is a 2 branch statement?. Answer: If - else statement ◉ What is a multiway branch statement?. Answer: If - elif - else statement ◉ What is nesting?. Answer: When one control structure is inside of another control structure ◉ What is a Boolean variable?. Answer: Can use a variable to store true or false ◉ What does the built-in function require?.
Answer: Collection of values that may be changed ◉ How do you slice a list?. Answer: Use colons ◉ How many loops are there and what are they?. Answer: 2 kinds of loops: while and for ◉ While loop details. Answer: The condition may be a relational expression, a combination of relational expressions, a boolean value. Must have someway to stop ◉ For loop details. Answer: A predefined list, or one created using the range function ◉ What is the return function?. Answer: Statement that causes the function to end and sends a value or values back to the function call ◉ What is a local variable?. Answer: A variable that is created within a function
◉ What is a global variable?. Answer: A variable that can be accessed and used by any function ◉ What does append method do?. Answer: Will add a value to the end of a list without specifying the length of the list ◉ What is tuples?. Answer: A collection of values like lists, however, the elements (members) of the tuples cannot be changed (immutable) ◉ What is the split function?. Answer: Can divide up a string into a list of words ◉ What is the concatenation operator?. Answer: Can be used to combine 2 strings (+) ◉ What is the repetition operator?. Answer: Creates new string with original string repeated (*) ◉ What is tkinter?.
Answer: 4 ◉ abc = 37812. print(format(abc,',.3f ')). Answer: 37,812. ◉ What would be output by the following code segment? numbbottles = numbbottles = numbbottles + 5 print(numbbottles). Answer: 17 ◉ What is stored in the variable xyz after the following statement is executed? abc = 3 + 5 * 2 ** 3. Answer: 43 ◉ In Python, every if must have a matching else. Answer: False ◉ Given the statement below, which is the last operation that is performed?
abc = 3 + 5 * 2 ** 3 - 8. Answer: subtraction ◉ Which of the following describes the two types of numeric values in Python?. Answer: integers and floating point numbers ◉ Given the assignments abc = 45 xyz = 75 Which of the following expressions would evaluate to true?. Answer: xyz>abc or abc> ◉ What would be output by the following code segment? xyz = 'bob' print(type(xyz)). Answer: ◉ Which of the following is not a relational operator?. Answer: A.== B.> C.>=
◉ A ______________ control structure is used to only execute statements one time when a certain condition is met. Answer: decision/branch ◉ Assuming all the variables in the expression below contain values, which operation is performed first? A = 4 - b > c or d <= 8. Answer: ????? ◉ You can use an ______________ to create a dual alternative (2-way branch) structure. Answer: if-else ◉ Suppose I asked the user to enter a value between - 1 and 1 (including - 1 and 1) for the variable abc. If I wanted to use a while loop to prompt the user to re-enter the value when it was outside of the range, which of the following should be the first line of the loop?. Answer: while abc < - 1 or abc > 1 ◉ How many times would "Python is fun" be printed by the following code segment jkl = 4 for jkl in [4.4, 7, 3.9, 1, 10, 8]: print('Python is fun').
Answer: 0 ◉ How many times would "Python is fun" be printed by the following code segment jkl = 4 for jkl in range(10, - 4, - 3) print('Python is fun'). Answer: 0 ◉ The built-in format function requires ________ parameters (arguments), the value and how to format that value.. Answer: 2 ◉ The first line of a function definition which contains the function name and parameter list is called the function _____________________________. Answer: heading or header ◉ The portion of code that tells the computer to execute the function is called the function _________. Answer: call
◉ Variables that can be accessed and used by any function are said to have ______scope.. Answer: global ◉ A function in Python can return more than 1 value.. Answer: True ◉ Given the list declaration below which command would print 18.5? mylist = [2.3, 9.4, 18.5, 20.9, 17.6]. Answer: print(mylist[2]) ◉ Given the list declaration mylist = [2.3, 9.4, 18.5, 20.9, 17.6] what would be output by the statement print(mylist[-2:-4:-1]). Answer: [20.9, 18.5] ◉ In Python the values of a list must be all the same data type.. Answer: True
◉ Given the list ABC = [3.4, 10.7, 8.8, 12.7, 5.3, 7.2], what would be output by the following two statements? z = 12.7 in ABC print (z). Answer: 4 ◉ The ______________ method will add a value to the end of a list without specifying the length of the list.. Answer: .append ◉ Python allows the use of negative indices (subscripts). Answer: true ◉ Given the list twoDlist = [['Sam', 45, 76, 88, 99, 72], ["Ally",66,99,84, 82, 96], ['John', 58, 78, 90, 93, 70], ['Marie', 77, 73, 85, 88, 92], ['Bob', 81, 83, 85, 91, 88], ['Grace', 92, 95,87, 82, 90]] What would be output by the statement print(twoDlist(-3))?. Answer: the "marie" one