What does the following code print out? def thing(): print('Hello'); print('There') - answer
Hello There
"In the following code (numbers added) which will be the last line to execute
successfully? (1) astr = Hello Bob ; (2) istr = int(astr); (3) print First , istr; (4) astr = 123 ;"
- answer1
What is the output of the following code? print(7%3) - answer1
Which of these operators is not a comparison or logical operator? - answer=
The + operator works with strings, but it is not addition in the mathematical sense. This
is called _____________. - answer concatenation
What is the Python reserved word that we use in two-way if tests to indicate the block of
code that is to be executed if the logical test is false? - answer else
You look at the following text: if x == 6 : print( Is 6 ) print( Is Still 6 ) print( Third 6 ). It
looks perfect but Python is giving you an Indentation Error on the second print
statement. What is the most likely reason? - answerindent/space problem
What does the get method do if the specified key is not found in the dictionary? -
answerIt returns a default value.
A __________ is a collection of items in a particular order. - answerlist
Assume the variable x has been initialized to an integer value (e.g., x = 3). What does
the following statement do? x = x + 2 - answerRetrieves the current value for x, adds 2
to it and then assigns the sum back to x
In Python, _______________ indicate a list, and individual elements in the list are
separated by __________ . - answersquare brackets [ ],commas ,
you can overload the attribute's value by making it private - answertuple
"In Python, you can change an attribute s value in all but one of these ways." -
answeryou can overload the attribute's value by making it private
The random function generates true random numbers not pseudorandom numbers. -
answerFALSE
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller julianah420. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $12.99. You're not tied to anything after your purchase.