Data Programming Final
what arithmetic operators cannot be used with strings ?
-
What will the following Python program print out? smallest_so_far = -1 for the_num in [9, 41, 12, 3, 74, 15]: if the_num < smallest_so_far: smallest_so_far = the_num print smallest_so_far
-1
what is the result of 1 + 2** 3/4 * 5
11
Comparison operators
>, <, ==, !=, >=, <= is, is not
chained conditional
A condition statement where there are more than two possibilities and more than two branches need
Program
A set of instructions that specifies a computation.
if the logical condition is false then the indented statement is executed.
False
when the evaluation of stops because the overall value is know it is called short cutting the evaluation.
Flase
What is the iteration variable in the following Python program? friends = ["Jack", "Zero", "Sally"] for friend in friends: print ("Happy Halloween, "+friend) print("Done!")
Friends
what does the continue statement do ?
Jumps to the top of the loop and starts the next iteration
where in the computer is a variable such as x is stored? X=23 EX
Main Memory
Semantics
Meaning of the program
what contains machine code
Python Interpretor
What is not a low level language
Source Code
parsing
To examine a program and analyze the syntactic structure.
to be a programmer what skills do you need
To tell a story by combining words and sentences to convey an idea to a reader. To know the vocabulary and grammer of the language.
A break statement can stop a while loop even if the while loop condition is true
True
A string is a sequence of characters.
True
The output of the following code is: o >>> str1 = 'hello' >>> str1[-1:]
True
To read a string you use the following function: input("Enter a string")
True
functions must be defined and called separately
True
the for loop does not require an indexing variable to set beforehand
True
the looping structures we are using include for and while loops
True
the range function returns a sequence of number starting from 0 and increments by 1 and ends at a specified number.
True
reserved words
Words that have a special meaning and cannot be changed
Suppose s is "\t\tWorld\n", what is s.strip() ?
World
assignment state consist of
a variable on the left hand side and a expression on the right hand side of the equal sign
three logical operators
and, or, not
What does the following code print ? fruits = ["apple", "banana", "cherry"] for x in fruits: print(x)
apple banana cherry
what does the code print ? for x in "banana": print(x)
banana
Output
displays the result of a program or stores them in a file.
Languages like java php, and python ________
do not rely on compilers to run programs.
what is the output of "hello" +1+2+3
error
what does the break statement do ?
exits the currently executing loop
Reserved words can be used as variables
false
The output of the following is: ABC. DEF >>>print("abc. DEF".capitalize())
false
The range() function defaults to increment the sequence by 2, however it is possible to specify the increment value by adding a second parameter: range(30, 1)
false
a function is defined using the reserved word define
false
input numbers do not be converted from a string to perform mathematical operations on them
false
numbers can never be converted into strings
false
the output of the following statement is: "abcd"[2:]
false
the return value of a function cannot be assigned to a variable
false
to get a python system to run it has to be saved in a program file.
false
What is not a reserved word
help
python evaluates a logical expression like >= 2 and (x/y) > 2 how is it evaluated
left to right
what is the function in this line Biggest.value=max("hello world'")
max
Programming best practice
name variables using mnemonic identities so it is easier to remember what is stored in them
variable
named location in memory where a programmer can store data
What is the output when following statement is executed ? >>>print('new' 'line')
newline
Build a better you
online source available through Georgia Southern to help in this class.
arguments of the function are also called
parameters
what produces an error message because of the type
print('123' + 1)
which statement will cause an era
print('y');
print('hello world')
puts phrase hello world on the screen
What does the following code print out? adj = ["red", "big"] fruits = ["apple", "banana"] for x in adj: for y in fruits: print(x, y)
red apple red banana big apple big banana
the result of a function is called a
return value
What would you use to check whether string s1 contains another string s2,
s1__contains__(s2)
which of these would concatenate two strings to a third ?
s3 =s1.__add__(s2)
To retrieve the character at index 3 from string s="Hello" what command do we execute?
s__getitem__(3)
to return the length of string s what command do we execute ?
s__len__()
three types of errors
semantic, syntax, logic
A line can be called
sentence or a statement
building blocks of a code
sequential execution, input output, conditional execution.
function of secondary memory in a computer
store information for the long term even beyond a power cycle.
Say s="hello" what will be the return value of type(
str
The format function, when applied on a string returns :
str
what type of data does an input function return
string
what does the following code print out ? i = 1 while True: if i % 3 == 0: break print(i) i + = 1
syntax error
String is a data type in python.
true
The output of the following statement is: abc >>>"a"+"bc"
true
a string can contain numbers and still be a string
true
a while loop will execute as long as the condition is true
true
any known zero number is interpreted as "true"
true
attempting to index beyond the length of a string will give you an error
true
built in functions are treated as reserved words
true
in most cases the inner loop will be executed one time for each iteration of the outer loop
true
the Boolean expression after the if statement is called a conditional.
true
the types of functions in python are the ones that are built in and the ones that we make
true
type
type of data being stored into a variable, literal, or constant
Which is not a rule for naming variables ?
variables must contain two characters
a function that does not return a value
void
useful part of a traceback
what kind of error it was
which word indicates the start of an indefinite loop ?
while