Which programming structure is the most appropriate

Assignment Help Python Programming
Reference no: EM132357199

Multiple Choice Practice Questions

Select the best answer.

1. In a Python program, values are stored in:

a. statements
b. expressions
c. variables
d. operators

2. A value that is passed to a function is called:

a. identifier
b. argument
c. statement
d. parameter

3. Pseudocode is:

a. Python code, modified to be suitable for documentation
b. a few general statements about what a program will do
c. a detailed account of an algorithm in English rather than code
d. all comments from a program extracted into documentation

4. A function can send a value back to the method that called it using a(n):

a. operator
b. return statement
c. print statement
d. loop

5. What is the output of the following code?

def main():
x=10
x=calTest(x)
print (x)

def calTest(y):
y = int (y)
y= y*2+2*3/2
return y

main()

a. 5
b. 23
c. 10
d. 26

6. Which of the following would be a legal variable name?

a. class
b. 8th
c. MY_GUI
d. Second-name

7. To use the functions in an external module, a program should use:

a. comment
b. open statement
c. operator
d. import statement

8. In object-oriented programming, a class contains:

a. pseudocode
b. variables and methods
c. methods
d. variables

9. Which programming structure is the most appropriate to describe the statement "When it's cold close the window and the curtains otherwise leave the window and curtains open":

a. if...elif...else
b. while
c. if...else
d. for

10. If you need to re-use a section of code and use it in a number of different places, which is the most appropriate approach to use:

a. while loop
b. for loop
c. if statement
d. a function

11. What is the appropriate statement to call the doCalc() method of an object called thisObj, and capturing the return value into a variable result?

a. doCalc(thisObj, x, result)
b. result = doCalc()
c. result = thisObj.doCalc(x)
d. result = thisObj.doCalc()

12. What is the output of the following code?

def main():
x=5
y=4
x=calTest(x,y)
print (y)

def calTest(y,z):
z = 4
y = int (y)
y= y*z+2*3/2
return y

main()

a. 3
b. 23
c. 13
d. 4

13. What is the output from the following code?

for i in range (-1,9,3):
print (i)

a. 1 4 7
b. 8 7 6 5 4
c. -1 2 5 8
d. -1 2 5

14. What is the output of the following code?

myDict = {2:'cat',4:'chicken',3:'dog',1: 'rabbit'}
print (myDict[3])

a. cat
b. chicken
c. dog
d. rabbit

15. What is the output of the following code?

def main():
x=5
y=3

if x > 5:
x=calTest(x,y)

elif x <= 5:
x =calTest2(x,y)
print (x)

def calTest(y,z):
z = 4
y = int (y)
y= y*z+2*3/2
return y

def calTest2 (a,b):
a = int(a)
b = int(b)
c = a+b-55+102
d = c
c = 5
return c

main()

a. 55
b. 15
c. 5
d. 7

For questions 16 and 17, use the following variable assignment:

myList = [7 , 3 , 2 , 8]

16. What is the output of:

print (myList[2])

a. 2
b. 7
c. 9
d. 3

17. What is the output of:

print (7.0 / 2.0 + 2.0 * myList[2])

a. 11
b. 9.5
c. 7
d. 7.5

18. What is the output of:

x = 10
y = 5
if x > 2 and y < 6:
print (1)

elif x < 3 and y >= 5:
print (2)

elif x >= 3 and y < 5:
print (3)

else:
print (4)

a. 1
b. 2
c. 3
d. 4

19. What is the output from the following code:

def main():
x=5
x = calTest(x)
print (x)

def calTest(y):
y = int (y)
y= y*2+2*3/2

main()

a. 6
b. 13
c. 10
d. 5

20. What is the output from the following:

myString = 'letsDoIt'
print (myString[1:-3])

a. etsD
b. tsDo
c. etsDoI
d. none of the above

Reference no: EM132357199

Questions Cloud

Explain the compression techniques of zero length : Briefly explain the compression techniques of zero length suppression and runlength encoding.
Why the maintenance phase of sdlc : In your own opinion, speculate why the maintenance phase of SDLC is often so much larger than the other phases.
Why do you think the challenge might occur : Emergency Operations Centers (EOCs) are the critical structure for emergency response. EOCs perform six functions in response to an emergency.
Describe an obstacle you could potentially encounter : First, describe an obstacle you could potentially encounter when presenting quantitative information to a wider audience that includes participants.
Which programming structure is the most appropriate : Which programming structure is the most appropriate to describe the statement "When it's cold close the window and the curtains otherwise leave.
Write the code necessary to count number of perfect squares : Write the code necessary to count the number of perfect squares whose value is less than h, starting with 1. Assign the sum you compute to a variable q.
Sustainability - the triple bottom line and business : Sustainability, the Triple bottom line and business - understandings of the themes but also their consideration of the implications for the business sector
Describe the values they store and adhere to python : How to write in an include pseudocode that describes all steps required to solve the problem, and employ variable names.
Amendment always seems to generate a spirited discussion : The 4th Amendment always seems to generate a spirited discussion. It's not surprising given the fact that our 4th Amendment jurisprudence

Reviews

Write a Review

Python Programming Questions & Answers

  Write an expression whose value is the concatenation

Write an expression whose value is the concatenation of the three str values associated with name1, name2, and name3, separated by commas. So if name1, name2, and name3, were (respectively) "Neville", "Dean", and "Seamus", your expression's value wou..

  Write a python run test page

Write a python run test page. The run-test page will receive a data.csv from a configure page. The video is only to show you the whole project

  Eliminate duplicate by throwing an error

need to merge a series of such files into 1 file, eliminate duplicate by throwing an error and not merge files if duplicates exist

  Demonstrate data scraping of a social network of choice

COMP2782 - Social and Information Networks - FLINDERS UNIVERSITY - Demonstrate data scraping of a social network of choice

  Write a program that generates two integers

Write a program that generates two integers under 100, show them on screen, and prompts the user to enter the sum of these two integers. The program then reports true if the answer is correct, false otherwise.

  Without using the system function to call any bash commands

without using the system function to call any bash commands write a python program that will implement a simple version

  Display the stripped phone number

Ask the user to enter the 4-digit code of an orange. Strip all the leading and trailing whitespace characters from the code. Display the stripped phone number.

  Write a program to process an input j?le where data in j?le

Write a program to process an input J?le where data in the J?le is individual lines of credit card numbers.Your program must indicate.

  Create a program in python that analyzes twitter information

CS1026: Write a complete program in Python that analyzes twitter information. With the emergence of Internet companies such as Google, Facebook and Twitter.

  Create an application that displays he number of millimeters

Create an application that displays he number of millimeters that the ocean will have risen each year for the next 25 years.

  Write complete program which allows user to enter a integer

Write complete program named happyNumbers which allows user to enter a positive integer number, n, and display all the happy numbers from 1 up to n.

  Write python scripting application to perform several tasks

Write Python scripting application to perform (automate) several geoprocessing tasks. Purpose. Include what you hope to accomplish with this project.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd