Python Program Multiple Choice A variable that is created inside a…

Question Answered step-by-step Python Program Multiple Choice A variable that is created inside a… Python ProgramMultiple ChoiceA variable that is created inside a function is a ___ variable.global variablelocal variablesecret variablenone of the above; variables cannot be createdParameters are variables that receive a piece of data when a function is called.TrueFalseWhat will the following program display?def main():    x = 1    y = 2    print(x, y)    change_us(x, y)    print(x, y)def change_us(a, b):    a = 0    b = 0    print(a, b)main() 1 21 21 21 20 01 21 20 00 01 21 20 0Which statement do you use to respond to exceptions?run/handletry/excepttry/catchattempt/exceptA virtual space is a small “holding section” in memory that many systems write data to before writing the data to a file.TrueFalseWhat kind of exception occurs when you try to use an index that is out of range for a list?ValueErrorBoundaryErrorIndexErrorNothing – the invalid index will be ignoredGiven a list, mylist, which of the following adds ‘apple’ to the list at index 3? (This problem will be a freebee due to a typo)mylist[3] = ‘apple’mylist.insert(3, ‘apple’)mylist.insert(‘apple’, 3)mylist.append(‘apple)What will the following statements display?values = [1,3,5,7,9]print(values[2:4])[3, 5, 7][5, 7, 9][7, 9][5, 7]Which built-in string method returns true if a string contains only alphabetic characters and is at least one character in length?the isalpha methodthe alpha methodthe ischars methodthe isletters methodWhat will the following code display?stuff = {1:[0,1], 2:[2,3], 3:[4,5], 4:[6,7]}result = “”for key in stuff:    result += str(key)print(result)13570123456702451234CodingP1.Writ a program that writs a series of random numbers to a file called “random.txt”. Each random number should be in the range of 1 through 100 (inclusive or exclusive) and be written to its own new line. The application should let the user specify how many random numbers will be written to the file. After the numbers are written, have the program read the numbers and print the sum and average of the numbers in the file.P2.Writ a class called Piglatinizer. The class should have: A method that acceptas sentence as an argument, uses that parameter value, and replaces words in the sentence that consist of at least 4 letters into their Pig Latin counterpart, stores the sentence in a global class variable `translations` and then finally returns the converted sentence to the caller. In this version, to convert a word to Pig Latin, you remove the first letter and place that letter at the end of the word. Then, you append the string “ay” to the word. For example:piglatinize(‘I want a doggy’)// >>> I antway a oggydayA method that retrieves all previous translations generated so far.Associated tests that create an instance of Piglatnizer and makes sure both methods above work properly. P3.Writ a program that reads the contents of a text file. Create your own text file with at least three new lines of sentences at least 5 words long. The program should creat a dictionary in which the key-value pairs are described as follows:The keys are the individual words in the file.The values are the line numbers in the file where the word (the key) is found.For example, suppose the word “hello” is found in lines 1, 2, 3, and 4. The dictionary would contain an element in which the key was the string “hello” and the value was a list of the line numbers [1,2,3,4].Once the dictionary is built, the program, in an infinite while loop, should prompt the user for a word. When the user enters the word, the program should display what line numbers the word can be found on. If the word is not found in the dictionary, the program should display: “{replace with user-inputted word} does not exist in the file”.  Computer Science Engineering & Technology Python Programming CS 87A Share QuestionEmailCopy link Comments (0)