Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Deliverables: There are three deliverables for this team assignment. Please submit the files to the Submission Box labeled Lab Assignment 6 Individual Activities. The three

image text in transcribed
image text in transcribed
Deliverables: There are three deliverables for this team assignment. Please submit the files to the Submission Box labeled "Lab Assignment 6 Individual Activities". The three files should be named as listed below: Lab6_Acti.py Lab6_Act2.py Lab6_Act3.py Activity #1: Team Activity The following activities are based on selected exercises from Chapter 7 in the zyBook. You do not need access to the zyBook to complete these activities. Instead, research the following topics as preparation for this assignment. Topics related to this week's activites (including the supplemental activities): Sorting a list using a built-in member function Addressing a specific item in a list based on its index in the list Searching for a specific item in an existing list using the in operator Making certain that a specific item is not in an existing list using the not in operator Splitting a string into a list of items using the myString.split() member function Retrieving user values from the keyboard one at a time and appending each value to a list Using list slicing to retrieve a sub-list from an existing list Please put the code for the following Activity #1 exercises in the same file (Lab6_Acti.py). Please separate code for each part with appropriate comments. Part 1: CHALLENGE ACTIVITY 7.6.1: For loop. Printing a list. (zyBook) Write code to accomplish the following tasks: Input a string from the keyboard that represents three or more stock prices separated by spaces. Example: '34.62 76.30 85.05' Convert the string into a Python list of floats Print each price in the list on a separate line with a dollar sign ($) as the first character on each line Print the output such that the decimal points are aligned vertically even if the user enters values such as '1.23 23.45 345.56' Example output: $ 1.23 $ 23.45 $ 345.56 Part 2: EXAMPLE (See Figure 7.7.2 zyBook) Iterating through a list. Study the code sample given below. This code allows the user to enter numbers from the keyboard as a string, converts that string to a list, then finds/prints the maximum even number in the list. Modify the given code to find/print the minimum odd number in the list. Thoroughly test your code with different sets of numbers. Vary the length of the list of numbers and make sure the result is not dependent on the length as a parameter. + User inputs string w/ numbers: "203 12 5 800 -10" user input input (Enter numbers:') tokens - user_input.split() Split into separate strings + Convert strings to integers nums1 for token in tokens: nums.append(int (token)) Print each position and number print() + Print a single newline for index in range (len (nums) value- numa index print("d: 8d' index, val Determine maximum even number max num - None for num in nums: if (max_num - None) and (num 2 - 0 # First even number found max_num- num elit (max_num - None) and (num > max_num ) and (num # Larger even number found max numnum 2 - 0): print('Max even :', max_num) Part 3: CHALLENGE ACTIVITY 7.7.3: Hourly temperature reporting. (zyBook) Write code to perform the following tasks: Hard-code a list of at least five temperature values between 75. and 105. Example: myTemps = [ 75, 87, 95, 102, 76) . Retrieve a two-character string from the keyboard to use as a separator during printing O Example: user should enter something like ->', >'," then separate each printed value by ' -> which includes an extra space before and after the two characters. After the last element is printed, a newline should be printed o Example output: 90 -> 92 -> 94 -> 95

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

Students also viewed these Databases questions