QUESTIONS & ANSWERS(RATED A+)
What command should you type in the interpreter to check your Python installation?
- ANSWERpython
What do you call a saved file containing Python instructions? - ANSWERA module
How can you write the expression "n = n * 2" using short-hand operators? -
ANSWERn *= 2
Which string function do you call when you want to convert the first letter in the string
to uppercase? - ANSWERstr.capitalize()
Which function do you call to check the number of items in a list? - ANSWERlen()
Which operator is used to concatenate two lists? - ANSWER+ (plus)
Which function do you call when you want to append an element at the end of a list?
- ANSWERlist.append()
What is the name of the output you get when an error occurs in your program? -
ANSWERStack trace or traceback
What is the output of running the following script?
>>> print(5*4) - ANSWER20
What are variables? - ANSWERThey refer to values in a memory
Which function can be used to convert strings to integers? - ANSWERint()
What is the syntax for assigning a variable, x, to the value 8? - ANSWERx = 8
What type of value is returned by the input function? - ANSWERString
How do you write an inline comment in Python? - ANSWER>>>print(ans) # this is
answer
What is the output of the following script?
>>> a, b, c = 1, 2, 3
>>> print(a)
>>> print(b)
>>> print(c) - ANSWER1
2
3
, Which function should you use to convert an integer into a binary number? -
ANSWERbin()
What is the order of operations while evaluating an expression? -
ANSWERPEMDAS
What is the output of the following script?
>>> string = "championship"
>>> print(string[0:5]) - ANSWERchamp
What is the output of the following script?
>>> fruits = ["apples", "bananas", "strawberries", "mangoes", "pears"]
>>>print(fruits[3]) - ANSWERmangoes
How many values do Boolean data types contain? - ANSWER2
Which of the following best describes a software engineering process used by most
successful programmers? - ANSWERDesign a solution carefully; document the
design; then code accordingly
Everyone can figure out that 90 minutes after 2:15 PM is 3:45 PM. We know the
value 45 is correct because - ANSWER(15 + 90) % 60 = 45
The primary difference between / and // in Python 3 is that - ANSWER// always
results in an integer; / may result in fractions or decimals
When is it appropriate to get an input with "int(input___))" instead of merely
"input(___)"? - ANSWERWhen the input should be a number and not a string
To get the first item from a list named 'names', use - ANSWERnames[0]
What would be displayed by the following code sequence?
a = [1, 2, 3]
b =a
a.append(4)
b.append(4)
print(b) - ANSWER[1, 2, 3, 4, 4]
If one wishes to use square brackets to access elements in a dictionary, within the
square brackets one must put - ANSWERa key value to search for
Which of these is not automatically available for lists in Python? -
ANSWERaverage(list) -- compute the average of values
_+1
_+2
_+3