Question

1) Which of the following is NOT true about a Python variable?

a) A Python variable must have a value

b) A Python variable can be deleted

c) The lifetime of a Python variable is the whole duration of a program execution.  

d) A Python variable can have the value None.       

2) Given the code segment:

      def f1(a, b = 2): if a: print(1) f1(1)

What is the result of executing the code segment?

a) Syntax error

b) Runtime error

c) No error     

d) Logic error

3) What is the output of executing the code segment?

a, b, c = False, True, False if a or b: print(A, end = ) else: print(B, end = ) if not b: print(C, end = ) elif c

a) A E    

b) B E

c) A

d) None of the above

4) Suppose k = {“a”: “apple”, “b”: "banana", “c”: "cherry"}  

Which statement(s) when executed does not cause a run-time error?

a) del k[“apple”]

b) k.sort(reverse = True)

c) k.get(“apple”, ‘Not found’)

d) All three statements do not cause a run-time error.

5) Which collection(s) is (are) the best choice for displaying the student scores and corresponding student numbers, in descending order of score?

a) A list where each element is a list. The element contains the student number and the score in a single list.    

b) A list with 2 elements which are lists. The first element contains the student numbers and the second element contains the scores.

c) A dictionary with student number as key and student score as value.

d) Two paired lists with student numbers in one list and the scores in another list

6) Which collection(s) is (are) the best choice for updating student score by student number?

a) A list where each element is a list. The element contains the student number and the score in a single list.

b) A list with 2 elements which are lists. The first element contains the student numbers and the second element contains the scores.

c) A dictionary with student number as key and student score as value.  

d) Two paired lists with student numbers in one list and the scores in another list

7) What is the output of executing the code segment?

a, b, c = False, True, False if a: if b: print(A, end = ) else: print(B, end = ) elif b: print(c, end = ) if c: p

a) A C E

b) C E   

c) A

d) C

8) Which control structure must always accompany the processing of data lines in a file?

a) selection

b) definite loop    

c) indefinite loop

d) All of the above

9) Which scenario requires a while loop?

a) Removing the negative numbers from a list

b) Reading user input for the student numbers of students who did not take an exam     

c) Reading each character in a file

d) Checking the score of a student based on student number given that the scores and student numbers are stored separately in two lists

10) Give the order of the precedence (from highest to lowest) for the operators: <, +, and, not.

a) not, and, <, +

b) +, <, not, and    

c) <, +, not, and

d) <, +, and, not

                 

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

1) OPTION A IS CORRECT

2) OPTION C IS CORRECT

3) OPTION A IS CORRECT

4) OPTION C IS CORRECT

5) OPTION C IS CORRECT

Note: Brother According to HomeworkLib's policy we are only allowed to answer first 5 part if there are many. So, I request you to post other part as separate posts.

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
1) Which of the following is NOT true about a Python variable? a) A Python variable...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python: 1) What output is generated by the following code segment? table = [["T", "U", "V"],...

    Python: 1) What output is generated by the following code segment? table = [["T", "U", "V"], ["W", "X", "Y"]] print(table[0]) Group of answer choices a- T b- ["T", "W"] c- ["T", "U", "V"] d- [["T", "U", "V"], ["W", "X", "Y"]] 2) Consider the following code segment: values = [4, 12, 0, 1, 5] print(values[1]) What is displayed when it runs? Group of answer choices a- 0 b- 1 c- 4 d- 12 3) Consider the following code segment: x =...

  • Python Programming QUESTION 16 Which of the following is an example of a Keyword in Python?...

    Python Programming QUESTION 16 Which of the following is an example of a Keyword in Python? elif class for All of the above QUESTION 17 Which of the following is not an acceptable variable name in Python? 2ndVar $amount Rich& ard None of the above are acceptable variable names QUESTION 18 The number 1 rule in creating programs is ___________________- Write the code first Think before you program Let the compiler find you syntax errors There are no rules just...

  • Python: 1) Consider the following code segment: try : inputFile = open("lyrics.txt", "r") line = inputFile.readline()...

    Python: 1) Consider the following code segment: try : inputFile = open("lyrics.txt", "r") line = inputFile.readline() print(line) _____________________ print("Error") What should be placed in the blank so that the program will print Error instead of crashing if an exception occurs while opening or reading from the file? Group of answer choices a- except RuntimeError : b- except EnvironmentError : c- except IOError : d- except IndexError : 2) Consider the following code segment: line = "hello world!" parts = line.split()...

  • Question 1 True and False are Boolean keywords in Python True False Question 2 0.0/1.0 point...

    Question 1 True and False are Boolean keywords in Python True False Question 2 0.0/1.0 point (graded)       hot_plate = True if hot_plate:     print("Be careful, hot plate!") else:     print("The plate is ready.") The output of from running the above code is ___ "Be careful, hot plate!" "The plate is ready." "True" NameError Question 3 0.0/1.0 point (graded)       vehicle_type = "Truck" if vehicle_type.upper().startswith("P"):     print(vehicle_type, 'starts with "P"') else:     print(vehicle_type, 'does not start with "P"')     The...

  • In this assignment you are asked to write a python program to maintain the Student enrollment...

    In this assignment you are asked to write a python program to maintain the Student enrollment in to a class and points scored by him in a class. You need to do it by using a List of Tuples What you need to do? 1. You need to repeatedly display this menu to the user 1. Enroll into Class 2. Drop from Class 3. Calculate average of grades for a course 4. View all Students 5. Exit 2. Ask the...

  • this code is not working for me.. if enter 100 it is not showing the grades...

    this code is not working for me.. if enter 100 it is not showing the grades insted asking for score again.. #Python program that prompts user to enter the valuesof grddes . Then calculate the total scores , #then find average of total score. Then find the letter grade of the average score. Display the #results on python console. #grades.py def main(): #declare a list to store grade values grades=[] repeat=True #Set variables to zero total=0 counter=0 average=0 gradeLetter='' #Repeat...

  • Questin 1 (CO 2) Which of the following is not a valid name in python? last_name...

    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 = ",...

  • Question 17 (3 points) Predict the output of the following code segment: a = 99.98 if...

    Question 17 (3 points) Predict the output of the following code segment: a = 99.98 if a + 0.01 >= 100: print('A') elif a + 0.02 >= 100: print('B') print('c') else: print('D') print('E') Question 16 (3 points) Predict the output of the following code segment: X = 6 if x % 2 == 0: print ("x is even.") else: print ("x is odd.") Please use the decimal point to distinguish int and float. For example, number 3 + number 4...

  • Write a PYTHON program that allows the user to navigate the lines of text in a...

    Write a PYTHON program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line numbers range from 1 to the number of lines in the file. If the input is 0, the...

  • I am completing a rental car project in python. I am having syntax errors returned. currently...

    I am completing a rental car project in python. I am having syntax errors returned. currently on line 47 of my code "averageDayMiles = totalMiles/daysRented" my entire code is as follows: #input variable rentalCode = input("(B)udget , (D)aily , (W)eekly rental? \n") if(rentalCode == "B"): rentalPeriod = int(input("Number of hours rented?\n")) if(rentalCode == "D"): rentalPeriod = int(input("Number of days rented?\n")) if(rentalCode == "W"): rentalPeriod = int(input("Number of weeks rented?\n")) rentalPeriod = daysRented return rentalCode , rentalPeriod budget_charge = 40.00 daily_charge...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT