Question 9
(CO 6) The best way to call the main() function of a program is to code
main()
a while statement that calls the main() function in each loop
an if statement that calls the main() function in each method
an if statement that calls the main() function only if the current module is the main module
Question 10
(CO 6) A variable that can only be used within the function that defines it is known as a ______
local variable
global variable
shadow variable
unknown variable
Question 11
(CO 6) Which of the following statements imports a module?
export temperature
import temperature
from temperature import
global temperature import
Question 12
(CO 5) To insert the item “chewie” after “solo” in the following
list, which of the following methods would you use?
falcon = [“han”, “leia”, “solo”, “yoda”, “luke”]
falcon.pop(3,”chewie”)
falcon.remove(3,”chewie”)
falcon.insert(3,”chewie”)
falcon.insert(“chewie”, 3)
Question 13
(CO 5) The ______________ method adds an item to the end of a list.
index()
insert()
pop()
append()
Question 14
(CO 5) Given the following list, what is the value of
names[5]?
names = [“Harry”, “Ron”, “Ginny”, “Draco”, “Rowena” ]
“Harry”
“Rowena”
“Ron”
None – index error
Question 15
(CO 5) What is the value of the total variable after the
following code executes?
prices=[66, 22, 47, 30]
total = 0
i=1
while i<len(prices):
total+=prices[i]
i+=1
print(total)
35
66
0
99
9.The best way to call the main() function of a program is to code
main()
Answer:
an if statement that calls the main() function
10.variable that can only be used within the function that defines it is known as a
Answer:
local variable
11.Which of the following statements imports a module?
Answer:
Import temperature
Syntax:import module-name
12.To insert the item “chewie” after “solo” in the following list, which of the following methods would you use?
Answer:
falcon.insert(3,"chwie")
Syntax: listname.insert(index, object)
13.The ______________ method adds an item to the end of a list.
Answer:
append()
14.Given the following list, what is the value of
names[5]?
names = [“Harry”, “Ron”, “Ginny”, “Draco”, “Rowena” ]
Answer:
None-index error
15.What is the value of the
total variable after the following code executes?
prices=[66, 22, 47, 30]
total = 0
i=1
while i<len(prices):
total+=prices[i]
i+=1
print(total)
Answer:99
Thank you...
Question 9 (CO 6) The best way to call the main() function of a program is...
Questin 1 (CO 2) Which of the following is not a valid name in python? last_name lastName last name lname Question 2 (CO 3) How many times will “Hello World” be displayed after the following code executes? num=2 while num<12: print("Hello world") num+=2 2 12 5 4 Question 3 (CO 1) The following code contains an error, what type of error is it and what line number is it? 1 count=1 2 while count<4 3 print("count = ",...
Module 6 - Cash Register (10 Points) We are going to write a program that simulates a customer's transaction at a cash register. You will organize your code using functions. Each of the functions below counts for 2 points. You must create functions allowing the user to: 1. Add an item to the order. No name or list of items is needed simply prompt the user for a dollar amount to add. 2. Clear all transactions. Set the amount of...
Programming Assignment 1 Structures, arrays of structures, functions, header files, multiple code files Program description: Read and process a file containing customer purchase data for books. The books available for purchase will be read from a separate data file. Process the customer sales and produce a report of the sales and the remaining book inventory. You are to read a data file (customerList.txt, provided) containing customer book purchasing data. Create a structure to contain the information. The structure will contain...
PHP Programming Question. Use the techniques you learned so far to create an Address Book application that stores names, e-mail addresses, and phone numbers in a text file. Validate all input fields and include functionality that allows the user to view the address book. Also, include code that sorts the address book by name and deletes duplicate entries. Each page in the application should have a link back to the main page. Be creative and add extra features if you...
Pull out question 8 on Exercises. See also: Program 4.16 invert (), Program 4.4 printList () Configuring -main () 1. Create a linked list 2. Function call of 8 (a) and (b) 3. Check the accuracy of the output of r list and l list 4. Repeat steps 1-3 above Please use c language void printlist(listPointer first) printf ("The list contains: ) for (; first; first = first→link) printf ("%4d", first-"data); printf("In") Program 4.4: Printing a list the nodes are...
You can vary it as long as the fahr and cels temperatures line up vertically and everything is clearly labeled. This program involves inputting a set of Fahrenheit temperatures and performing a set of operations on them: The number of temperatures to input is determined by the user at the beginning of the program. You must ask them to enter the number of temperatures that they will be typing in. This number must be between 1 and 30 (inclusive.) If...
Lab 6 Instructions Objectives: • Executing and experimenting with programs that handle array related topics such as declaration, initialization, storing, retrieving, and processing elements. • Effectively manipulating and using ArrayList objects. • Becoming familiar with the use of arrays as method arguments and how array elements are passed to and returned from the called method. • Mastering the use of various debugging tools available on the Eclipse IDU. Important: EVERY one of the following Activities MUST be in a separate...
I need help solving this in c++ using visual Studio. For this assignment, you will be filling in missing pieces of code within a program, follow the comments in the code. These comments will describe the missing portion. As you write in your code, be sure to use appropriate comments to describe your work. After you have finished, test the code by compiling it and running the program, then turn in your finished source code. // TicTacToe.cpp: Follow along with...
Using C programming language Question 1 a) through m) Exercise #1: Write a C program that contains the following steps (make sure all variables are int). Read carefully each step as they are not only programming steps but also learning topics that explain how functions in C really work. a. Ask the user for a number between 10 and 99. Write an input validation loop to make sure it is within the prescribed range and ask again if not. b....
Program Overview This brief exercise is designed for you to consider how reference variables behave when you are passing them as arguments by-value. Instructions Name your class References.java. 1. Implement the following methods. 1.1 Method name: readStudentNames Purpose: This method accepts an array of strings as a parameter. It loops through the array and asks the user to input names. It populates the array of strings with the names. Parameters: an array of Strings, stringArray Return type: void In the...