Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Pick the right answer: a,b,c or d 1. What is the output of the following code snippet? my_var = This is a variable def my_func():

Pick the right answer: a,b,c or d

1. What is the output of the following code snippet? my_var = "This is a variable" def my_func(): pass print(globals())

a. something new b. a larch c. {'my_func': , 'my_var': 'This is a variable'} d. a program error

2. What is the output of the following code? def cat(): print('meow') def pig(): print('oink') cat = pig cat()

a. oink b. cat c. meow d. pig Consider the following code example.

3. What is the last line printed to the console? def count_down(count): if count == 0: print('Go!') else: print(count) count_down(count-1) count_down(2)

a. Go! b. 0 c. 1 d. 2

4. The output of the following print statement is ___________. url = 'http://en.wikipedia.org/wiki/Turing' domain = url[7:23] print(domain)

a. en.wikipedia.org b. larch.wikipedia.org c. wikipedia.org d. en.wikipedia

5. What is the output of the following print function? def compute_square(num_to_square): return num_to_square ** 3 num_squared = 0 num_squared = compute_square(6) print(num_squared)

a. 36 b. 216 c. 6 d. 18

6. What is the output of the following code snippet? import math real_pi = math.pi # math library provides close approximation of pi approximate_pi = 22.0 / 7.0 # Approximate pi to 2 decimal places print('22/7 is accurate for 2 decimal places: %.2f' % approximate_pi) a 22/7 is accurate for 2 decimal places: 3.141593 b 22/7 is accurate for 2 decimal places: 3 c 22/7 is accurate for 2 decimal places: d 22/7 is accurate for 2 decimal places: 3.14

7. What is the output of the following code? my_str = 'The cat in the hat' print(my_str[0:3])

a The b cat in the c cat d The cat in

8. What is the output of the following print statement? def modify(my_list): my_list[1] = 99 my_list = [10, 20, 30] modify(my_list) print(my_list)

a [] b [10, 20, 30] c [10,99,30] d [10,30]

9. What is the output of the following code? def sandwich(bread, meat, *args): print('%s on %s' % (meat, bread), end=' ') if len(args) > 0: print('with', end=' ') for extra in args: print(extra, end=' ') print("") sandwich('sourdough', 'spam', 'mayo')

a. spam on sourdough with mayo b. spam on sourdough with args c. spam on sourdough with larch d. a program error.

10. What is the output from the following print statement? Assume Joe was entered in response to the input prompt. employee_name = 'N/A' def get_name(): name = input('Enter employee name:') employee_name = name get_name() print('Employee name:', employee_name)

a. Joe b. N/A c. The program gives an error. d. spam

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic6 Database Programming

Authors: John W. Fronckowiak, David J. Helda

1st Edition

0764532545, 978-0764532542

More Books

Students also viewed these Databases questions

Question

What is the effect of word war second?

Answered: 1 week ago