Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You want to compare a variable var to the number 0. In the code snippet below, fill the blank such that the program sets output

You want to compare a variable var to the number 0. In the code snippet below, fill the blank such that the program sets output to 1 if var is less than 0 and 0 otherwise.if :

output = 1

else:

output = 0

Implement the following code:profit = 70 good_quarter = 0 while profit > 0:

profit = profit - 10 good_quarter = good_quarter + 1

What is the final value of the variable good_quarter?

Sum up all the integers from 2 to 81 with a for loop by filling in the black in the code snippet below: sum = 0 for i in range( ):

sum = sum + i

Modify your code from the above problem. Instead of using a for loop, use a list comprehension. Use the variable i as the indexer in the list comprehension and apply the function sum() to the list.

Modify your code from the above problem. Sum up the squares of the integers instead of just the integers. What is the result?

You are given the lambda function of the following form: func = lambda x: 8*x*(x**2 - 7). What is the result of func(3)?

Modify the lambda function above such that it multiplies not by 8, but by 3. Put into the answer box the Python code to assign to the function the name func2.

You are given two lists: [35, 24, 27, 39] and [28, 38, 38, 36]. Using the zip() function, write a list comprehension that computes the ratio of the elements of list1 and list2. Use the variable names l1 and l2 for the elements in the list comprehension.

Consider the list [10, 9, 4, 10, 8, 7, 5] Using a list comprehension, add one to each element and then multiply each element by 2. Finally, square the elements. Put in the answer box how you would write the list comprehension. Use the underscore (_) as the placeholder for the iterator. Using a list comprehension, add one to each element and then multiply each element by 2. Finally, square the elements. Put in the answer box how you would write the list comprehension. Use the underscore (_) as the placeholder for the iterator.

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

Financial Accounting A Critical Approach

Authors: John Friedlan

1st Edition

0130193720, 978-0130193728

More Books

Students also viewed these Accounting questions

Question

What are the factors affecting organisation structure?

Answered: 1 week ago

Question

What are the features of Management?

Answered: 1 week ago

Question

Briefly explain the advantages of 'Management by Objectives'

Answered: 1 week ago

Question

Describe the major barriers to the use of positive reinforcement.

Answered: 1 week ago