Question: 1. Circle T for True or F for False for the following statements. (10 pts) a) TF Indentation does not matter in Python. b) TF

 1. Circle T for True or F for False for the
following statements. (10 pts) a) TF Indentation does not matter in Python.
b) TF A variable name can start with a \% (percent sign).
c) TF The join function will turn a string into a list.
d) T F Floats are sequences. e) T F To concatenate two
string together, use \&. f) T F An if statement must have
a corresponding else statement. g) T F A for loop repeats based

1. Circle T for True or F for False for the following statements. (10 pts) a) TF Indentation does not matter in Python. b) TF A variable name can start with a \% (percent sign). c) TF The join function will turn a string into a list. d) T F Floats are sequences. e) T F To concatenate two string together, use \&. f) T F An if statement must have a corresponding else statement. g) T F A for loop repeats based on a condition. h) T F Lists are immutable. i) T F Slicing a list always gives you back a list. j) T F In sorting a list like mylist. sort(), you need a new variable to store the result 2. Circle T for True or F for False for how the following boolean expressions will be evaluated (such as in an if statement). Assume the following lines of code with the variable declarations have just been executed. (5 pts) triforce =3 pie =3.14 convenience =711 answer =42 dip1 = "hummus" dip2 = "guacamole" a) T F pie T triforce I=12 c) T F not (answer =3 and answer I= convenience Circle the letter of each answer to the following multiple-choice questions. (5 pts) 3. What kind of language is Python? a) Compiled c) Machine b) Interpreted d) Logical 4. In, It, and \" are examples of what? a) Escape characters c) Format specifiers b) White space d) All the above 5. What is the index of the last letter in the string "success"? a) 5 c) 6 b) 7 d) 8 6. random. choice ([1,6,2]) will select a number from which of the following groups? a) 1,2,3,4,5,6 b) 1,2,3,4,5,6,7 c) 1,3,5 d) 1,2,6 7. Which of the following is a valid value for a Boolean variable? a) true b) True c) "True" d) "true" Write the answers to the following questions on the lines provided. 8. Answer the following three questions about comments. What cho you use for a one-line comment in Python? Where in code do you put comments? Why do we use comments? (3 pts) Write the value of each expression on the corresponding line. Make sure to write the correct number type. Assume the following lines of code with the variable declarations have just been executed. (4 pts) i=10j=5k=4 a) i+jk b) i//k c) i/k d) ij Full Name 10. Write the output that will be displayed or the word "error" for the given code and user input. Assume that this is one continuous program. (2 pts) a) num =f float(input("Enter a score: ")) Enter a score: 2.1 print(num*2) b) result =int( num )+ num print(result) 11. Write the output that will be displayed or the word "error" for the given code. ( 3 pts) message = "Lamb Karahi" print( message[ 3:6]) print(message[8:]) i=message.find("a") print(message[:i]) 12. Write the answer to each question or the requested code on the corresponding line. Assume the following lines of code with the variable declarations have just been executed. ( 8 pts) cetaceans = ["blue whale", "dolphin"] marsupials = ["koala", "wombat", "kangaroo"] mammals = marsupials + cetaceans numspecies =[8,20] length = len (mammals) bigone = cetaceans [] critters = mammals [2:3] a) What type of variable is marsupials? b) What type of variable is bigone? c) What type of variable is critters? d) What is the value of length? e) What is the value of bigone? f) Write the code to create a new empty list called primates. g) Write the code to store the number 334 in the second item of numspecies. h) Write the code to remove "dolphin" from cetaceans. 13. What is the sequence generated by the following code? (2 pts) a) range( 3 ) b) range (5,6) 14. What is the output (or error) of the following code? (2 pts) word = "naan" for num in range(1en(word), 1,1 ): print(num, end="^^") 15. The following is a complete program. The program will not run because of syntax errors (over 5 ). Identify 5 errors and how to correct them. Circle your corrections and write on the lines the code you type to fix each one. You will earn 1 point for each error that you correctly identify and 1 point for each correction of the error. (10 pts) print("Multiplication Table" (n) num = input("Please enter a whole number") symbol = " x " for index = range(13): product = index " num msg =" " if index =" " msg = msg + index output(msg, symbol, num, "=", product) print(Math is funl) Corrections 6. Write a program that creates four variables: section, time, prof, and days. Get the values for prof and days from the user by asking for the last name of the professor and the days of the week (MW or TH). Your program should then use branching to set the values of section and time according to the following table. After branching, then print all the information bout the class (see sample run below) using the four variables. No error checking needed. (10 pts) Sample run 17. Write a program that asks the user for words until the user enters a blank line, which is a return with no input (i.e., the empty string). Then the program should print out the longest and the shortest words entered. Use the appropriate loop. Create any variables that you need. No error checking is required (for the user putting two or more words on a line or other weirdness). (10 pts)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!