Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON 3 - please show format Question 11.) A list called theLst has six string values. Append hi to the first value in the list.

PYTHON 3 - please show format

Question 11.)

A list called theLst has six string values. Append "hi" to the first value in the list.

For example:

Test Result
theLst=['a','b','c','d','e','f'] ['ahi', 'b', 'c', 'd', 'e', 'f']

Question 12.)

Use the Design Recipe to write a function, print_histogram, that takes a list of numbers and prints a histogram graph using asterisks to represent each number in the list. Use one output line per number in the list.

For example:

Test Result
print_histogram([ 0, 2, 4, 1]) ** **** *
print_histogram([10, 5, 3, -1, 8]) ********** ***** *** ********

Question 13.)

Use the Design Recipe to write a function, sum_between, that takes a list and two numbers, a and b, and returns the sum of the numbers in the list that are between a and b (inclusive of both a and b).

For example:

Test Result
print(sum_between([0, 100, 50, 20], 10, 60)) 70
print(sum_between([0, 100, 50, 20], 50, 100)) 150
print(sum_between([-17, -20, -33, 40], -18, 60)) 23

Question 14.)

Use the Design Recipe to write a function total_numbers(number_list,weights) that takes a list of numbers and their weights and returns the weighted total of the numbers. Think about what needs to happen before using a loop, during the loop, and after the loop finishes. In this question you are required to use a for loop, and not allowed to use the sum function. If the numbers are [1,2,3] and the weights are [.1,.5,.4] then the weighted total should be 1 * .1 + 2 * .5 + 3 * .4 = 2.3

For example:

Test Result
print(round(total_numbers([1,2,3],[.1,.5,.4]),1)) 2.3

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

Database Design For Mere Mortals

Authors: Michael J Hernandez

4th Edition

978-0136788041

More Books

Students also viewed these Databases questions