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

  Why modules would benefit an application you are designing

What is operator precedence? How can a debugger help you an Find operator precendance error? Define in order the steps/phases of SDLC.

  Create a ride share simulator assignment

Create a ride share simulator assignment. In this particular function, I am trying to create a list of the drivers in a Driver Class that are currently listed as idle. Since they are idle, I can then match them up with an awaiting rider. The assignme..

  Write a program to conversate with the user

Write a program to conversate with the user. The program must ask for both strings and numbers as input.

  Create a class variable and assign an initial value of zero

Python Programming Assignment - You need to create a class variable and assign an initial value of zero to it and update it throughout your program

  Evaluate quality of the random number generator in python

This program is going to evaluate the quality of the random number generator in Python by simulating dice rolls and looking at the distributions of the values.

  Create an employee class that keeps data attributes

Create an Employee class that keeps data attributes for the following pieces of information: Employee Name and Employee Number

  Compare the scores of two volleyball teams

Compare the scores of two volleyball teams that play each other. To win a match in volleyball, a team must get 25 points.

  Investigate mortality levels of infants and babies

ICT702 - Which countries have a high rate of child deaths and which countries have low rates? Are there connections between child mortality rates

  Write the new methods you would have to implement in class

Write the class Box3D that inherits from Rectangle2D and uses the additional public attribute d. Every methods should use the super operator.

  Create an inheritance relationship between two classes

For this assignment you will create a simple class hierarchy. You will create an inheritance relationship between two classes -- a Friend class and a Person class - Friend will inherit Person

  Write a pep program that inputs the scores

Write a Pep/9 program that inputs the scores and outputs a message indicating whether the students passed. Note that it is not necessary to use arrays.

  Takes as input a list of integers and outputs the integers

Write function doubles that takes as input a list of integers and outputs the integers in the list that are exactly twice the previous integer in the list.

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