Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The followings are for Python and Python web 1. For Python, the join() method of a list can be used to combine a. the items

The followings are for Python and Python web 1. For Python, the join() method of a list can be used to combine a. the items in the list into a string b. the items in the list into a string thats separated by delimiters c. two or more lists d. two or more strings into a list 2. A Python dictionary stores a collection of a. ordered items c. mutable items b. unordered items d. immutable items 3. Which of the following Python code snippets will result in this display: Countdown... 5... 4... 3... 2... 1... Blastoff! a. counting = "5...4...3...2...1" print("Countdown...") for char in counting: print(char + "...") print("Blastoff!") c. counting = "54321" print("Countdown...") for char in counting: print(char + "...") print("Blastoff!") b. counting = "54321" for char in counting: print("Countdown...") print(char + "...") print("Blastoff!") d. counting = 54321 print("Countdown...") for char in counting: print(char + "...") print("Blastoff!") 4. How many items does the following dictionary contain? flowers = {"red": "rose", "white": "lily", "yellow": "buttercup", "purple": "tulip" } a. 1 b. 3 c. 4 d. 8 Consider the following program segment 1. flowers = {"red": "rose", "white":"lily","yellow":"buttercup","purple": "tulip" } 2. print(flowers) 3. flowers["blue"] = "carnation" 4. print(flowers) 5. print("This is a red flower:", flowers.get("red", "none")) 6. key = "white" 7. if key in flowers: 8. flower = flowers[key] 9. print("This is a", key, "flower:", flower) 10. key = "green" 11. if key in flowers: 12. flower = flowers[key] 13. del flowers[key] 14. print(flower + " was deleted") 15. else: 16. print("There is no " + key + " flower") 5. Refer to the code above: Which of the following represents a key/value pair for the dictionary named flowers defined on line 1? a. lily/white c. blue/carnation b. red/rose d. yellow/flower 6. Refer to code above: What would the print statement on line 9 display? a. This is a white flower: white b. This is a white flower: lily c. This is a lily flower: white d. This is a lily flower: lily 7. What is the value of s3 after the code that follows is executed? s1 = "abc def ghi"; s2 = s1[1:5] s3 = s2.replace('b', 'z') print(s3) a. bc d d. azc d b. zc d e. zc de c. abc d 8 Which of the following will display this result? B = 66 a. print("B = ", ord("B")) c. print("B = ", ascii("B")) b. print("B = ", char("B")) d. print(ord(66)) 9. To determine the length of a string thats in a variable named city, you can use this code: a. len(city) c. length(city) b. city.len() d. city.length() 10. You can use the split() method to split a string into a list of strings based on a specified a. word c. delimiter b. character d. punctuation mark 11. To retrieve the fifth character in a string thats stored in a variable named city, you can use this code: a. city(5) c. city(4) b. city[3] d. city[4] 12. To access the substring from character 2 to character 4 of a string thats stored in a variable named message, you can use this code: a. first_three = message[0:3] c. first_three = message.slice(2:4) b. first_three = message[2:5] d. first_three = message.split(0:3) 13. Given the following code, what will be displayed after the code executes? name = "Mervin the Magician" words = name.split() print(words[0] + ", you are quite a " + words[2].lower()) a. Mervin , you are quite a magician c. Mervin, you are quite a magician b. Mervin, you are quite a Magician d. Mervin , you are quite the magician 14. If word = "a horse", which of the following snippets of Python code will display this result? a horsea horse! My kingdom for a horse! a. print((word * 2) + "! My kingdom for " + word + "!") b. print((word + "! " + " My kingdom for " + word + "!") * 2) c. print(word * 2 + " My kingdom for " + word + "!") d. print((word + "! ") * 2 + " My kingdom for " + word + "!") 15. Which of the following is not a proper way to import module from Python? For example we want to use sin() of math module a. import math as m b. from math import * c. math import d. Import math 16. To throw an exception with Python code, you use the a. raise statement b. throw statement c. built-in throw() function d. build-in raise() function 17. The __________ method adds an item to the end of a list. a. pop() b. append() c. insert() d. index() 18. To insert the item melon after grapes in the following Python list, you would use which of these methods? fruit = ["apple", "banana", "grapes", "mangos", "oranges"] a. fruit.pop("melon", 3) c. fruit.insert(3, "melon") b. fruit.insert("melon", 3) d. fruit.append(3, "melon") 19. What will this Python loop display? sum = 0 for i in range(0, 15, 5): sum += i print(sum) a. 30 c. 0, 5, 10, 15 b. 50 d. None of the above 20. What line number of the following Python code contains an error and what type of error is it? 1. def sales_tax(amt): 2. sale = amt + (amt * .06) 3. return amt 4. 5. def main(): 6. print("Welcome to the 6% tax calculator! ") 7. total = int(input("Please enter the total amount: ")) 8. print("The total amount after tax is: ", sales_tax(total)) a. line 6, syntax error c. line 3, runtime error b. line 1, syntax error d. line 8, logic error 21. In order to connect to MySql database using Python MySql connector which of the following is not true a. One must specify which table one wants to connect to b. A legitimate user name and the corresponding password pair is required c. MySql server which one wants to connect to must running. d. A machine which hosts the MySql database must be specified. 22. For Python web using cgi module, which of the following is correct to retrieve a name entered by the user from an html form shown as the following

One will use a. formData = cgi.GetFieldStorage() hisname = $_Get[formData.hisname] b. formData = cgi.FieldStorage() hisname = $_POST[formData.name] c. formData = cgi.FieldStorage() hisname = formData.getvalue('name') d. formData = cgi.FieldStorage() hisname = formData.getvalue('hisname') The followings are for ASP.NET C# 23. The file that contains the C# code for a web form is the a. code-behind file c. assembly file b. aspx file d. DLL file 24. If you set the AutoPostBack property of a control to True, the page is posted back to the server a. only if the IsPostBack property of the page is set to True b. whenever the value of the control changes c. when the value of the control changes, but only if view state is enabled for the control d. when you change the value of the control and then click a button control 25. Which event occurs when you select an item from a drop-down list? a. Click c. CheckedChanged b. TextChanged d. SelectedIndexChanged 26. When would you typically use the RedirectPermanent method to display another page? a. When the page is located at another website b. When the page resides in the root directory of the web application c. When the page has been moved or renamed d. When you want to avoid an extra round trip to the server 27. If you dont need to retrieve data from the original web page, which is the best way to transfer control to a new page? a. the Server.Transfer method c. cross-page posting b. the Response.Redirect method d. no method is clearly the best 28. When a browser requests a web page, ASP.NET a. creates a session state object that keeps track of the user entries b. creates a session state object that contains an ID for the session c. creates a session state object that the application can store a session ID in d. does none of the above 29. By default, ASP.NET sends the session ID to the browser in a. a cookie c. the session state object b. the URL d. a text file 30. Which statement best describes the operation of the following code? if (!IsPostBack) ddlProducts.DataBind(); a. If the page is being requested for the first time, bind a drop-down list to a data source. b. If the page isnt being requested for the first time, bind a drop-down list to a data source. c. If the page is being requested for the first time, bind a data source to a drop-down list. d. If the page isnt being requested for the first time, bind a data source to a drop-down list 31. What happens when following button is clicked?

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

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions

Question

What Is acidity?

Answered: 1 week ago

Question

Explain the principles of delegation

Answered: 1 week ago

Question

State the importance of motivation

Answered: 1 week ago

Question

Discuss the various steps involved in the process of planning

Answered: 1 week ago

Question

What are the challenges associated with tunneling in urban areas?

Answered: 1 week ago