1/115
Flashcards covering key concepts, definitions, and programming fundamentals from the COSC 1436 lecture notes.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Software
Invisible instructions that control hardware and make it perform specific tasks.
Python file extension
.py
Bus
The subsystem that interconnects a computer's components.
What is the output of print(0 + 1 + 2)?
3
What is wrong with the statement: print(Howdy)?
Missing quotation marks around 'Howdy'.
Compiler
A program that translates source code into machine code.
Source Code
The human-readable instructions written by a programmer.
Interpreter
A program that executes instructions written in a programming language directly.
Machine Code
Native language consisting of binary instructions for a CPU.
Operating System
Software that manages computer hardware and software resources.
Bit
The smallest unit of data in a computer, represented as either 0 or 1.
Byte
A data unit consisting of 8 bits.
Kilobyte (KB)
Approximately 1000 bytes.
Gigabyte (GB)
Approximately 1 billion bytes.
ASCII
A character encoding standard for electronic communication.
True or False: Every Python statement must end with a semicolon.
False.
Screen resolution
Specifies the number of pixels in the horizontal and vertical dimensions of a display.
Machine language
The native code that consists of binary instructions.
True or False: Software is the physical aspect of a computer.
False.
Memory
A location where a program and its data must be moved before execution by the CPU.
Input Device
Keyboard.
Output Device
Printer.
Both Input and Output Device
Touchscreen.
True or False: Higher screen resolution produces a sharper image.
True.
True or False: Python can run on Mac, Unix, and Windows.
True.
True or False: Python is case sensitive.
True.
True or False: Python is a compiled language only.
False.
Guido van Rossum
Who developed Python around 1990?
Runtime error
An error that occurs during the execution of a program.
Syntax error
An error caused by incorrect code structure.
Logic error
An error where the code runs but produces incorrect results.
True or False: Indentation does not matter in Python.
False.
Gigahertz
The unit commonly used to measure CPU speed.
True or False: Memory is volatile while storage devices are permanent.
True.
Script mode
Allows running programs from a file.
Interactive mode
Allows running Python commands in a prompt.
print('Programming is fun')
The correct statement to print the phrase Programming is fun.
System analysis
The purpose is to identify system inputs and outputs.
System design
The purpose is to develop a process for transforming inputs to outputs.
IPO
Input Process Output.
Pseudocode
Describes algorithms using natural language.
Algorithms
Describe steps to solve a problem.
True or False: The Software Development Life Cycle includes stages such as requirements, design, testing, and maintenance.
True.
True or False: 'import' is an illegal identifier.
True.
camelCase identifiers
Examples include amtDollar, dollarAmt, dollarAmount, amountDollar.
Illegal variable names
sixth#place, 1stplace.
9 // 2, 9 / 2, 9 % 2, 9 ** 2
Results are 4, 4.5, 1, 81 respectively.
Output of print(2 + 3 * 2 + 7 // 2 - 10)
1.
Operands and operator in expression 12 + 7
Operands are 12 and 7; operator is +.
answer = 1 + 2
In Python, assigns the sum of 1 and 2 to the variable answer.
Value stored in price after executing price = int(68.549)
68.
Statement to read float input and store in x
x = float(input()).
Data types for: 123.456, int(123.456), '123.456', '123', 123, 123.0
float, int, string, string, int, float.
Output of: val = 99 and val += 1; print('The value is', 'val') and print('The value is', val)
'The value is val' and 'The value is 100'.
Output of print(round(value1 * value2)) for value1 = 2.0 and value2 = 12.2
24.
17 = x causes an error because
Cannot assign a literal value.
True or False: value = $3,450 is a valid Python statement.
False.
Output of: a,b = 5,6 ; a,b = b,a ; print(a,b)
6 5.
Why does multiplying two input() values cause an error without conversion?
input() returns strings.
Output of the Boolean expression not(x < y or z > x) and y < z with x=5, y=3, z=8
False.
Evaluate: x < y or z > x with values x=5, y=3, z=8
True.
Truth table results for the OR operator
Combinations where any true gives true.
Truth table results for the AND operator
Only true when both subexpressions are true.
True or False: an ifelifelse chain is the same as a nested if.
False.
if choice is not equal to 10
The if statement to check this condition.
ifelse statement
Executes one block if a condition is true and another if false.
,
Relational operators and their meanings.
Logical operator that requires both subexpressions to be true
and.
NOT a logical operator
if.
Condition checking if y is between 10 and 50 inclusive
if y >= 10 and y <= 50.
Operators that perform shortcircuit evaluation
and/or.
Value of z after the code: if x>=y: z=x+y else: z=y%x with x=10 and y=40
0.
Evaluate: a==4 or b>2 with a=2, b=4, c=6
True.
Output of if x != 10 statement that prints messages
'This is false!' then 'This is all folks!'.
Statement that assigns a random integer from 1 to 50 to number
number = random.randint(1,50).
True or False: if speed >=55 or speed <=65 checks if speed is between 55 and 65 correctly.
False.
Message printed if score = -1 in the validation example
Score is not valid.
Grade assigned if score=85 using multiple independent if statements for grade assignment
D.
Symbol marking the beginning and end of a string
Quotation marks.
Output of: print(2 * 'Hcc') and print('Welcome to ' + 'Hcc')
HccHcc and Welcome to Hcc.
Output of print('x' + 'y')
xy.
Evaluate: 'HCC' in s1 where s1='Welcome to Hcc' and 'come' not in s1
False, False.
Evaluate slices s1[-4:] and s1[3:] for s1='Welcome'
'come' and 'come'.
Output of swapping s1='smith' and s2='Mary' then printing s1 and s2.capitalize()
Mary Smith.
Output of: print('One', end='') print('Two') print('Three')
OneTwo then Three.
What does round(result) and format(result,'.2f') print for interestRate=0.77 and billAmount=10
8 and 7.700.
Difference between printing 3.246 and format(3.246,'.2f')
format rounds the display.
True or False: \n prints a literal capital N.
False.
Statement that prints 20%
print(format(0.2,'.0%')).
Two valid ways to print: The cat said "meow"
Using escape characters or different quotes.
Argument that prevents print from automatically moving to the next line
end argument.
Algebraic expression equivalent to math.pow(4,3)
4^3.
Function that returns the largest integer less than or equal to its argument
floor.
Expressions equivalent to math.hypot(x,y)
sqrt(x^2 + y^2).
True or False: math.ceil(x) returns the smallest integer greater than or equal to x.
True.
Two ways to fix print('COSC' + 1436)
Convert number to string or write 'COSC1436'.
True or False: chr(random.randint(0,127)) always generates a lowercase letter.
False.
True or False: repeat.upper() == 'Y' checks for either 'y' or 'Y'.
True.
For loop that prints the sum of numbers from 1 to 5
for number in range(1,6): total += number.
What is displayed after the loop: for num in range(0,20,5): num+=num; print(num)
30.