• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 3 out of 16 pages
Exam (elaborations)

Python Test 2

Document preview thumbnail
Preview 3 out of 16 pages

PYTHON TEST 2 What Python statement would you like me to run? - CORRECT ANSWERS-(Chapter 1) When Python is running in the interactive mode and displaying the chevron prompt () - what question is Python asking you? 20 - CORRECT ANSWERS-(Chapter 1) What will the following program print out: x = 15 x = x + 5 print x .py - CORRECT ANSWERS-(Chapter 1) Python scripts (files) have names that end with: for - CORRECT ANSWERS-(Chapter 1) Which of these words is a reserved word in Python ? quit() - CORRECT ANSWERS-(Chapter 1) What is the proper way to say "good-bye" to Python? Central Processing Unit - CORRECT ANSWERS-(Chapter 1) Which of the parts of a computer actually execute the program instructions? A sequence of instructions in a programming language - CORRECT ANSWERS- (Chapter 1) What is "code" in the context of this course? Secondary Memory - CORRECT ANSWERS-(Chapter 1) A USB memory stick is an example of which of the following components of computer architecture? The computer did not understand the statement that you entered - CORRECT ANSWERS-(Chapter 1) What is the best way to think about a "Syntax Error" while programming? Random steps - CORRECT ANSWERS-(Chapter 1) Which of the following is not one of the programming patterns covered in Chapter 1? # This is a test - CORRECT ANSWERS-(Chapter 2) Which of the following is a comment in Python? 123abc - CORRECT ANSWERS-(Chapter 2) What does the following code print out? hours - CORRECT ANSWERS-(Chapter 2) Which of the following variables is the "most mnemonic"? stop - CORRECT ANSWERS-(Chapter 2) Which of the following variables is the "most mnemonic"? Retrieve the current value for x, add two to it and put the sum back into x - CORRECT ANSWERS-(Chapter 2) What does the following statement do? x = x + 2 Parenthesis () - CORRECT ANSWERS-(Chapter 2) Which of the following elements of a mathematical expression in Python is evaluated first? 2 - CORRECT ANSWERS-(Chapter 2) What is the value of the following expression? 42 % 10 5 - CORRECT ANSWERS-(Chapter 2) What is the value in x after the following statement executes: x = 1 + 2 * 3 - 8 / 4 98 - CORRECT ANSWERS-(Chapter 2) What value be in the variable x when the following statement is executed? x = int(98.6) Pause the program and read data from the user - CORRECT ANSWERS-(Chapter 2) What does the Python raw_input() function do? Indent the line below the if statement - CORRECT ANSWERS-(Chapter 3) What do we do to a Python statement that is immediately after an if statement to indicate that the statement is to be executed only when the if statement is true? = - CORRECT ANSWERS-(Chapter 3) Which of these operators is not a comparison / logical operator? Depending on the value of x, either all three of the print statements will execute or none of the statements will execute - CORRECT ANSWERS-(Chapter 3)What is true about the following code segment: if x == 5 : print 'Is 5' print 'Is Still 5' print 'Third 5' You de-indent the next line past the if block to the same level of indent as the original if statement - CORRECT ANSWERS-(Chapter 3) When you have multiple lines in an if block, how do you indicate the end of the if block? You have most likely mixed tabs and spaces in the file - CORRECT ANSWERS- (Chapter 3) 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? except - CORRECT ANSWERS-(Chapter 3) 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? Small All done - CORRECT ANSWERS-(Chapter 3) What will the following code print out? x = 0 if x 2 : print 'Small' elif x 10 : print 'Medium' else : print 'LARGE' print 'All done' This code will never print 'Something else' regardless of the value for 'x' - CORRECT ANSWERS-(Chapter 3) For the following code, if x 2 : print 'Below 2' elif x = 2 : print 'Two or more' else : print 'Something else' What value of 'x' will cause 'Something else' to print out? 1 - CORRECT ANSWERS-(Chapter 3) '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' (5) istr = int(astr) (6) print 'Second', istr -1 - CORRECT ANSWERS-(Chapter 3) For the following code: astr = 'Hello Bob' istr = 0 try: istr = int(astr) except: istr = -1 What will the value for istr after this code executes? A built-in function - CORRECT ANSWERS-(Chapter 4) In Python what is the raw_input() feature best described as? def - CORRECT ANSWERS-(Chapter 4) Which Python keyword indicates the start of a function definition? 10 20 - CORRECT ANSWERS-(Chapter 4) What will the following Python code print out? def func(x) : print x func(10) func(20) Bonjour Michael - CORRECT ANSWERS-(Chapter 4) What will the following Python program print out? def greet(lang): if lang == 'es': return 'Hola' elif lang == 'fr': return 'Bonjour' else: return 'Hello' print greet('fr'),'Michael' Avoiding writing the same


Document information

Uploaded on
November 20, 2023
Number of pages
16
Written in
2023/2024
Type
Exam (elaborations)
Contains
Questions & answers
$9.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Bestcontents
4.5
(8)
Sold
34
Followers
13
Items
2030
Last sold
10 months ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions

Whoops! We can’t load your doc right now. Try again or contact support.