Question

In: Computer Science

Question 17 Demonstrate your knowledge of if, elif and else: Create a variable gpa. Set it...

Question 17

Demonstrate your knowledge of if, elif and else:

Create a variable gpa. Set it to a number between 0 and 4.0

Write python statements which produce one line of output -just one of the below

You are a great student!

You are a good student!

You really need to study more!

You choose the thresholds between 0 and 4.0 which determine the outputs.

Question 18 (Multiple Choice)

pizza_toppings = []

if pizza_toppings:

(a)This evaluates to true because there is a variable pizza_toppings

(b)This evaluates to false because there is not a variable pizza_toppings

(c)This evaluates to true because the list contains the null element.

(d)This evaluates to false because the list is empty.

  Question 20

Write a list comprehension which will do the same work as the below 3 statements:

squares = []

for i in range(10):

     squares.append(i * i)

Solutions

Expert Solution

Question 18:

Source Code:

Output:

Code in text format (See above image of code for indentation):

#set variable gpa to 2.0
gpa=2.0
#choose the thresholds between 0 and 4.0
if(gpa<=2.0):
print("You really need to study more!")
#print statement based on condition
elif(gpa>3.0):
print("You are a great student!")
else:
print("You are a good student!")

Question 19:

(b)This evaluates to false because there is not a variable pizza_toppings

The given if condition raises an EOF parsing error because if condition checks for a variable pizza_toppings but it is a list so the above is the correct one.

Question20 :

Source Code:

Output:

Code in text format (See above image of code for indentation):

#using list comprehension
squares=[x*x for x in range(10)]
#print list
print (squares)


Related Solutions

This discussion question will have you demonstrate your knowledge of the medical terms, understanding of the...
This discussion question will have you demonstrate your knowledge of the medical terms, understanding of the use of nouns, pronouns, and verbs, by creating a scenario of a patient. Research a medical disease and write 2-3 paragraphs to your classmates describing your patient’s condition using 20 of the words in Section 1, 2, and 3 of the textbook under “Medical Spelling.” You must highlight these words in yellow. You will also need to highlight at least ten nouns, ten pronouns,...
Create a mock merchandising company and demonstrate your knowledge of accrual basis accounting and the double-entry...
Create a mock merchandising company and demonstrate your knowledge of accrual basis accounting and the double-entry accounting system by creating a minimum of 10 original transactions spanning a period of 3 months (Jan. 1 – Mar. 31) and completing the requirements below. Assume your mock company is a new company that begins operations on Jan. 1st . The transactions should include examples of accruals and deferrals and at least one of each of the following: financing a new business (e.g....
QUESTION Demonstrate your knowledge of the difference between Economic and Business (Accounting) profit by showing relevant...
QUESTION Demonstrate your knowledge of the difference between Economic and Business (Accounting) profit by showing relevant examples. You may use your own examples or cite examples from other sources. What are the advantages of computing economic profit? Select your own firm or any firm that you are familiar with. Discuss the factors which have an influence on shareholders’ wealth. Identify managerial actions taken by the firm which are design to influence shareholder wealth.
Use this assessment as an opportunity to demonstrate the breadth of your knowledge and understanding of...
Use this assessment as an opportunity to demonstrate the breadth of your knowledge and understanding of experimental design.Respond to the following question in essay format. Approximately, three to four paragraphs or 500-550 words. G. has just completed a study that shows a correlation between the amount of time children watch television and their attention spans. Assume the correlation was r = -.34. State an experimental hypothesis based on this finding and devise a simple procedure for testing it.
This programming assignment is intended to demonstrate your knowledge of the following:  Writing a while...
This programming assignment is intended to demonstrate your knowledge of the following:  Writing a while loop  Write methods and calling methods Text Processing There are times when a program has to search for and replace certain characters in a string with other characters. This program will look for an individual character, called the key character, inside a target string. It will then perform various functions such as replacing the key character with a dollar-sign ($) wherever it occurs...
Create a hypothetical set of data for a single variable that is on an interval or...
Create a hypothetical set of data for a single variable that is on an interval or ratio scale measurement. There should be 50 scores. And name the variable And create a z score distribution.
Purpose: To strengthen and demonstrate your knowledge of the Immune and Lymphatic System and its systemic...
Purpose: To strengthen and demonstrate your knowledge of the Immune and Lymphatic System and its systemic relationship in the body. The ability to apply this content and think systemically with physiology processes will benefit you as a healthcare student and practitioner. Criteria for Success: To be successful you will make sure you complete diagrams as instructed in the tasks, including proper values (if required) on the x & y-axis as well as labeling those. You also need to make sure...
Purpose: To strengthen and demonstrate your knowledge of the Immune and Lymphatic System and its systemic...
Purpose: To strengthen and demonstrate your knowledge of the Immune and Lymphatic System and its systemic relationship in the body. The ability to apply this content and think systemically with physiology processes will benefit you as a healthcare student and practitioner. Criteria for Success: To be successful you will make sure you complete diagrams as instructed in the tasks, including proper values (if required) on the x & y-axis as well as labeling those. You also need to make sure...
Demonstrate your knowledge of medical terms understanding, research medical problems that would be treated in the...
Demonstrate your knowledge of medical terms understanding, research medical problems that would be treated in the hospital, and write 2-3 paragraphs describing the events that occurred during the patient's day?
The concept of death has numerous sociocultural definitions. Demonstrate your knowledge of these distinctions by describing...
The concept of death has numerous sociocultural definitions. Demonstrate your knowledge of these distinctions by describing some ways that different cultures view death. Then describe any five ways that Kalish (1987) believed that death could be viewed (e.g., death as a fear). Be sure to provide at least one example of each way.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT