Instructions: In one file, write programs for the tasks below and upload the fil

Instructions: In one file, write programs for the tasks below and upload the fil

Instructions: In one file, write programs for the tasks below and upload the file (.py) to Blackboard. In the top comments section of the file, please include your name, the date, and the assignment number. While you don’t have to add comments for every line of code, please include comments to tell a reader what you are doing. Commenting your code also suggests to me that you know what you are doing.
While there is no one way to do things, your code should only use commands and methods from class. I do not want you using other commands that you got from the internet,
Also use the #%% command to divide each answer into its own cell. Note also include #%% after the last line of code in the program. the assignment questions in the word file ” assignment 2″, please the codes in the power point attached and not from any other source.

I am working on this assignment :Set Operations in Python. I have written the co

I am working on this assignment :Set Operations in Python. I have written the co

I am working on this assignment :Set Operations in Python. I have written the code but don’t know why I am not getting full marks.I have attached the my code and the instruction.

Please refer to Class Material to complete this assignment! As a new learner, pl

Please refer to Class Material to complete this assignment! As a new learner, pl

Please refer to Class Material to complete this assignment! As a new learner, please help to keep it simple and put well comments for understanding each step! Thank you
This task should be completed with well-commented code. Please comment all methods and functions.

Instructions: In one file, write programs for the tasks below and upload the fil

Instructions: In one file, write programs for the tasks below and upload the fil

Instructions: In one file, write programs for the tasks below and upload the file (.py) to Canvas In the top comments section of the file, please include your name, the date, and the assignment number. While you don’t have to add comments for every line of code, please include comments to tell a reader what you are doing. Commenting your code also suggests to me that you know what you are doing.
Remember there is no one way to do things. What matters is that it runs and gives the correct output.
Using python: Write a program that loops through the string ’abcdefghijklmnopqrstuvwxyz’ and creates a list of individual letter strings, i.e., [“a”, “b”…., “z”]. Next, using the index command, write a loop that finds the element locations of all the letters in your first name “mina” and adds them together. That is, you want to find the number values of each letter and get the sum. Note that when getting the values, you want to assign a=1, b=2…, and z=26. For example, if your name is “abe” the output would be 8 (1+2+5).
First, create a list with five street names in your neighborhood (leaving off the street type). For example, for “Main Street” just type “Main” in the list. Second, create a list with the names of three pets (either your pets or pets you know). Then using the print command, print out the second name of the pets list and the fifth street name in the same print command. By the way, this is your new Hollywood actor name!
Write a program where you have a user input a temperature (from 0 to 100). Then have the program tell the user if that temperature is “cold,” “mild” or “hot.” Say, below 50 is cold, from 50 to 70 is mild, and above 70 is hot.
Have a user input a list of five integers between 1 and 26. Find the letters that corresponds to these numbers (a=1, b=2…) and print out the word that the numbers create. For example, if the user inputs [3,1,2] the output is “cab.”
Required for MA Students (but extra credit for undergrads).
1.Have a user input a list of five integers between 1 and 26. Find the letters that corresponds to these numbers (a=1, b=2…) and print out the word that the numbers create. For example, if the user inputs [3,1,2] the output is “cab.” Big warning: Don’t use CHATGPT and the codes for abeginner.

Assignment InstructionsIn this unit, we explored the fundamental concepts in com

Assignment InstructionsIn this unit, we explored the fundamental concepts in com

Assignment InstructionsIn this unit, we explored the fundamental concepts in computer programming, basic debugging techniques, and reproducing simple calculations in Python.
Before completing this assignment, review the reading materials listed below:
a. Think Python: How to think like a computer scientist
Review Chapter 1 – The Way of the Program (pp. 1 – 8) and the examples presented in it.
b. For installing the IDLE development environment on UNIX:
Using Python on Unix platforms. (n.d.). Python Documentation. https://docs.python.org/3/using/unix.html
For Windows, refer to:
Using Python on Windows. (n.d.). Python Documentation. https://docs.python.org/3/using/windows.html
For Mac, refer to:
Savage, B. (n.d.). 5. Using Python on a Mac. Python Documentation https://docs.python.org/3/using/mac.html
There are two parts to this assignment.
Part 1:LEARN FROM YOUR MISTAKES!
In Chapter 1, section 1.9 Exercises (pg. 7) of your textbook, Exercise 1.1 suggests making mistakes when experimenting with a new programming feature. This kind of experiment helps you remember what you read, and also get information on the error messages.
Answer the following questions (a) to (d).by explaining some frequently occurring errors. To help you answer the questions, write the code in Python and run it to produce output for each of the questions.
a. If you are trying to print your name, what happens if you leave out one of the quotation marks or both, and why?
b. What is the difference between * and ** operators in Python? Explain with the help of an example.
c. In Python, is it possible to display an integer like 09? Justify your answer.
d. Run the commands type(’67’) and type(67). What is the difference in the output and why?
Copy and paste both the code and the screenshot of the output for each of the questions in a Word document.
Part 2:Write a Python program for each of the following questions (a) to (d).a. To multiply your age by 2 and display it. For example, if your age is 16, so 16 * 2 = 32 b
b. Display the name of the city, country, and continent you are living in.
c. To display the examination schedule (i.e., the starting and the ending day) of this term.
d. Display the temperature of your country on the day the assignment is attempted by you
Add the Python codes and screenshots of the related outputs in the same Word document created for Part 1 submissions. Also, explain what you learned from the results of each experiment in part 2 questions.
The code and its output must be explained technically. The explanation can be provided before or after the code. The descriptive part of your response must be at least 200 words.

Submission Instructions: Submit the solutions to both part 1 and part 2 on the same document.
Make sure your submission is double-spaced, using Times New Roman, 12-point font, with 1” margins.
Use sources to support your arguments. Use high-quality, credible, relevant sources to develop ideas that are appropriate for the discipline and genre of the writing.
Use APA citations and references to support your work. Add a reference list at the end of the submission. For assistance with APA formatting, view the Learning Resource Center: Academic Writing.
Your submission should be clearly written, concise, well organized, and free of spelling and grammar errors. The grading will be based on the quality of your analysis, accurate solution to the problem, and the quality of your writing.

Perform k-means color clustering in two photos you will take, and detect skin re

Perform k-means color clustering in two photos you will take, and detect skin re

Perform k-means color clustering in two photos you will take, and detect skin regions. These two images should depict your hand on different backgrounds.
The scopes of this assignment: (1) to identify qualitatively/visually, what data (images) can make processing easier, including resolution, distance from target, background complexity, lighting, etc.; (2) to evaluate the computational challenges; (3) to study a simple clustering method in image region segmentation and be able to identify alternative solutions.
Specifically:
0. take two photos of your hand in a setting you define (lighting, background, distance from camera), each with a different background.
1. implement “repetitive” k-means, as described below; use k = {2, 3, 5} (number of clusters).
2. cluster the image pixels with respect to color {R,G,B}, and display the corresponding k probability maps (for each of the three k-values).
3. threshold the probabilities to detect skin regions (binary outcome for each pixel): each pixel will have k (for a given k-value) probability values; for a pixel to be considered as skin region, the highest among its k probability values should correspond to the skin color cluster(s) and should be over a threshold.
Repetitive k-means:
Every execution of k-means is an iterative process, from start to convergence, using k randomly chosen cluster centroids during initialization: pick k random pixels, and use their {R,G,B}-values. Consider an execution (from initialization to convergence) as a single instance in a “bigger” repetitive process, where you will execute k-means several times, each with different randomly chosen centroids/pixel {R,G,B} values. The output should be probability maps.
For example, for k=3, and 100 repetitions, the output should be three maps:
P(x belongs to cluster i) | {Rx,Gx,Bx} ), for i={1,2,3} ({Rx,Gx,Bx} are the chromatic values of x). That is, calculate P(x belongs to cluster 1) | {Rx,Gx,Bx} ), P(x belongs to cluster 2) | {Rx,Gx,Bx} ), and P(x belongs to cluster 3) | {Rx,Gx,Bx} ). After the 100 executions of k-means, each with different initialization, you will observe each pixel (the corresponding {R,G,B}) how many times it is assigned to cluster 1, to cluster 2, and to cluster 3. For each pixel, convert the frequency of assignment (to cluster 1, 2, and 3) into percentage: e.g., a% found in cluster 1, b% found in cluster 2, c% found in cluster 3, with a+b+c = 100.
Example: routine M = my_rep_kmeans(X, k)
step 0: Define k value
step 1: load image into variable X (of size h x w x 3) since it is a color image (you may have to convert the {R,G,B} values into double precision if they are in a different format, e.g., “uint8” in Matlab)
step 1.5: numofexec = 1 (counts how many times you execute k-means (see below); initialize to 1)
step 2: randomly choose k pixels and use their color as initialization in the color space; i.e., {C1, …, Ck}, where C1, …, Ck are 3×1 (or 1×3) matrices {R,G,B}-values. The random choice of k pixels can be based on cartesian coordinates: for each initial centroid, use the {R,G,B}-value of a randomly chosen pixel X(i,j) with coordinates i in [1,h] and j in [1,w].
step 3: perform k-means: Xout = somekmeansfun(X, k, [C1, …, Ck]) ==> notice the input: variable k, and random centroids. The output Xout should be of size h x w x 1. For more compact representation (see below), M( : , : , numofexec) = Xout. See notes below.
step 3.5: align cluster numbers for consistency throughout all repetitions based on a fixed rule, e.g., sort clusters based on the {R,G,B}-values of their centroids (say, cluster 1 is the cluster with the lowest R-value, etc.)
step 4: numofexec = numofexec + 1; Repeat step 2 ; repeat step 3, repeat step 3.5.
step 5: At the end, you will have a 3-dimensional matrix M: size(M) = [h, w, numofexec]. You can visualize the cluster assignments of each pixel X(i, j) as: v = M(i, j, 🙂 ==> size(v) = [1, numofexec] (1 x numofexec) ==> plot it. For each pixel, you can calculate the frequency of its assignment to each cluster using v.
step 5: Calculate P1 = P( all hxw pixels belong to cluster 1), P2 = P( all hxw pixels belong to cluster 2), …, Pk = P( all hxw pixels belong to cluster k). Note that P1, P2, …, Pk are 2D matrices (hxw).
step 6: Display as color/heat maps the 2D matrices/probability maps P1, P2, …, Pk.
The whole procedure should be done three times, for the three different values of k =2, 3, 5.
Notes:
— steps 2-4 should be in a for loop.
— in each exec. of k-means, the cluster numbers may change (see step 3.5): you need to reassign numbers based on the centroid values (e.g., use as reference the value of a chromatic component). For example: the “deep red” (high R-values, very low G,B-values) cluster may be labeled as “1” in one k-means execution, and as “2” in another execution; you will have to align/readjust those cluster number after each k-means execution.
— to randomly choose centroid values, you can use a random integer generator that will be sampling the image pixels.
SUBMIT:
Code in Python or Matlab and a screen recording of your execution (demo video).
Point reduction:
-3pts for not submitting a demo screen recording;
-5 pts for not implementing the repetitive schema described above

PA 1. Tic-Tac-Toe Game Topics Covered Modules Classes, Inheritance, and Polymorp

PA 1. Tic-Tac-Toe Game
Topics Covered
Modules
Classes, Inheritance, and Polymorp

PA 1. Tic-Tac-Toe Game
Topics Covered
Modules
Classes, Inheritance, and Polymorphism
Recursions
Game AI and Minimax Algorithm
Instructions
Tic-Tac-Toe Game
Objective: practicing with classes, modules, and recursions
Description
In this assignment you will write a program for a popular game Tic-Tac-Toe. Your program will generate a board with nine cells using the traditional 3 x 3 layout and ask each of two users to choose one cell at a time. The users take turns, and each user marks the board cells with a naught O or a cross X. The game continues until either one of the users won or all cells on the board are marked with O or X. The user won when the three marks (O or X) are located on one line horizontally, vertically, or diagonally as shown on the picture below:
X
X
X
X X X
X
X
X
There are 8 winning cases in total: 3 horizontally arranged marks, 3 vertically arranged marks, and two diagonally arranged marks. The program writes who is the winner or it is a tie. After that it will ask the users if they want to play again. Here are the snippets of the program output, be aware that your program output should match this format exactly. Please read the instructions carefully and completely before starting to work on your program!
In the beginning the program should output the following messages and draws the board:
Welcome to TIC-TAC-TOE Game!
A B C
+—+—+—+
1| | | |
+—+—+—+
2| | | |
+—+—+—+
3| | | |
+—+—+—+
Bob, X: Enter a cell [A-C][1-3]:If the user (the default first user is Bob) chose cell a1, the program updates the board and produces the following output:
A B C
+—+—+—+
1| X | | |
+—+—+—+
2| | | |
+—+—+—+
3| | | |
+—+—+—+
Alice, O: Enter a cell [A-C][1-3]:If the user (the default second user is Alice) chose cell a1, the program does not update the board because this cell is already marked with an X. It asks the user to enter valid input in the following way:
You did not choose correctly.
Alice, O: Enter a cell [A-C][1-3]:Notice that the second sentence is the same prompt used before. If the user (Alice or Bob) does not choose valid input, the program outputs the same messages as before until the user enters valid input. Valid input is a two-character string, which has the first character a letter A, B, or C (uppercase or lowercase) and the second character is 1, 2, or 3. The program should analyze if input is valid or invalid.
If Alice enters b2, the program updates the board and produces the following output:
A B C
+—+—+—+
1| X | | |
+—+—+—+
2| | O | |
+—+—+—+
3| | | |
+—+—+—+
Bob, X: Enter a cell [A-C][1-3]:As you can see, the program makes turns for players: after Bob chose a cell, Alice chooses a cell, and after Alice chose a cell, Bob chooses a cell. When the game is over, the program prints one of the following messages:
Bob is a winner!
Would you like to play again? [Y/N]or
Alice is a winner!
Would you like to play again? [Y/N]or
It is a tie!
Would you like to play again? [Y/N]If the user types ‘Y’ or ‘y’ the program starts a new game, draws the empty board, and prints the following message again:
A B C
+—+—+—+
1| | | |
+—+—+—+
2| | | |
+—+—+—+
3| | | |
+—+—+—+
Bob, X: Enter a cell [A-C][1-3]:Otherwise it prints the following new message and terminates:
Goodbye!
Tic-Tac-Toe Game AI
To implement the full version of tic-tac-toe, you need to create an AI (Artificial Intelligence) Player that can play against the user. In this assignment, you have to create three different types of AI: a simple AI that chooses moves randomly, a sophisticated SmartAI that never looses a game because it is based on heuristic approaches, and a MiniMax that also never looses a game because it precalculates all possible moves. All three AI classes should be placed in the same module, the file player.py, where the class Player is written.
AI should be a subclass of the class Player and should inherit all properties from its superclass Player. The init and choose methods should be overridden (modified). The simplest implementation of an AI player is to use a random choice for generating a valid move. For this strategy, you need to create all possible moves: in the beginning of the game, all moves are empty cells on the board, so you can create a list of all cells and then remove the occupied cells from the board as the game progresses. You can import choice from the random module to randomly choose a cell (a move) from the list of all possible cells (moves).
The output of the program should be the same as before, the user plays as Alice and the AI plays as Bob. The only difference from the previous tic-tac-toe game is that the user does not have to play for Bob, the AI (your computer program) plays instead of the user. To do so, you need to modify tictac.py to create an AI object: you can achieve it by substituting player1 = Player(“Bob”, “X”) to player1 = AI(“Bob”, “X”, board) and the import statement from player import Player to from player import Player, AI.
Minimax Algorithm
To improve the performance of a random-choice AI, you can create another class, MiniMax that uses a minimax algorithm based on recursion. MiniMax should be a subclass of AI and inherit all methods from its superclass AI. The method choose should be overridden and should call the recursive minimax method. The pseudocode for minimax is shown below, “self” refers to the MiniMax player and “opponent” – to its opponent:
Minimax:
1. Check the base case: if the game is over, then return -1 if self lost, 0 if it is a tie, or 1 if self won.
2. Set the min score to infinity and max score to -infinity
3. Choose a cell (or make a move):
a. iterate through all available cells (9 cells)
b. check if the cell is empty
c. mark the cell with X or O (if self then mark it with its sign, otherwise mark it with another sign)
d. get score by calling the minimax recursively (you need to alternate between self and opponent)
e. update score: if self then use the max score (compare it to the max score), otherwise use the min score (compare it to the min score)
f. update move: update the cell index
g. unmark the cell (make it a space again ” “) and reset all other variables that were affected by the game play
4. If it is the start level (the last level to be executed completely and the last score to be returned) return the move. Let see how it works. At the start, the program chooses the first cell (e.g., ‘A1’) and marks it with X, then on the next level it chooses the next cell (e.g., ‘B1’) and marks it with O, on the third level it chooses the next cell (e.g., ‘C1’) and marks it with X, and so on until there will be a winning condition or a tie. i.e., the game is over. After that, the program returns to the previous upper level and updates the min and max scores depending on whose turn is. The process continues until it reaches the beginning level. At this point the program should return the optimal move as a cell. You can read more about a minimax algorithm here: Minimax – WikipediaLinks to an external site..
Smart AI Extra Credit (5 points)
You can improve the performance of a random-choice AI in a different way by creating another class, SmartAI. SmartAI should be placed in the same module, the file player.py, where the class Player and AI are written. SmartAI should be a subclass of the class AI and should inherit all properties from its superclass AI. Only the choose method should be overridden (modified). The output of the program should be the same as before, but this time the user plays as Bob and the SmartAI plays as Alice. The only difference from the previous tic-tac-toe game is that the user does not have to play for Alice, the SmartAI (your computer program) plays instead of the user.
You need to modify the tictac.py to create a SmartAI object: you can achieve it by substituting player2 = Player(“Alice”, “O”) to player2 = SmartAI(“Alice”, “O”, board) and the import statement from player import Player, AI to from player import Player, AI, SmartAI.
The simplest heuristic approach is to check all possible winning conditions. If we assume that the player is Alice and her sign is O, then the program should find two Os in a row, column, or a diagonal and add the missing O to complete them and win the game. The program should also check the winning conditions of the opponent and place O in patterns made of two Xs to prevent the opponent from winning the game. At the beginning of the game, you can start at positions that have high probability of winning (the center or corners). You can read about additional heuristic rules here: Tic-tac-toe – WikipediaLinks to an external site.. After you successfully implemented both SmartAI (Alice) and AI (Bob), you can even make them to play against each other.
Programming Approaches
In this assignment you need to create two base classes Board and Player, each class should be written in its own file named board.py and player.py. They should be located in the same directory as the main program tictac.py.
Class Board should have six methods init, get_winner, set, isempty, isdone, and show. Please read the following code and instructions carefully. You can type or copy and paste this code into your file board.py. The file board.py should be located in the same directory as tictac.py (the main program) and player.py.
class Board:
def __init__(self):
# board is a list of cells that are represented
# by strings (” “, “O”, and “X”)
# initially it is made of empty cells represented
# by ” ” strings
self.sign = ” ”
self.size = 3
self.board = list(self.sign * self.size**2)
# the winner’s sign O or X
self.winner = “”
def get_size(self):
# optional, return the board size (an instance size)
def get_winner(self):
# return the winner’s sign O or X (an instance winner)
def set(self, cell, sign):
# mark the cell on the board with the sign X or O
# you need to convert A1, B1, …, C3 cells into index values from 1 to 9
# you can use a tuple (“A1”, “B1″,…) to obtain indexes
# this implementation is up to you
def isempty(self, cell):
# you need to convert A1, B1, …, C3 cells into index values from 1 to 9
# return True if the cell is empty (not marked with X or O)
def isdone(self):
done = False
self.winner = ”
# check all game terminating conditions, if one of them is present, assign the var done to True
# depending on conditions assign the instance var winner to O or X
return done
def show(self):
# draw the boardA class Player should have four methods init, get_sign, get_name and choose. Please read the code and instructions carefully. You can type or copy and paste this code into your file player.py. The file player.py should be located in the same directory as tictac.py (the main program) and board.py.
class Player:
def __init__(self, name, sign):
self.name = name # player’s name
self.sign = sign # player’s sign O or X
def get_sign(self):
# return an instance sign
def get_name(self):
# return an instance name
def choose(self, board):
# prompt the user to choose a cell
# if the user enters a valid string and the cell on the board is empty, update the board
# otherwise print a message that the input is wrong and rewrite the prompt
# use the methods board.isempty(cell), and board.set(cell, sign)In the main program tictac.py, write the following code. Your code should match this code precisely!!!
# author: Larissa Munishkina
# date: May 21, 2020
# file: tictac.py a Python program that implements a tic-tac-toe game
# input: user responses (strings)
# output: interactive text messages and a tic-tac-toe board
from board import Board
from player import Player
# main program
print(“Welcome to TIC-TAC-TOE Game!”)
while True:
board = Board()
player1 = Player(“Bob”, “X”)
player2 = Player(“Alice”, “O”)
turn = True
while True:
board.show()
if turn:
player1.choose(board)
turn = False
else:
player2.choose(board)
turn = True
if board.isdone():
break
board.show()
if board.get_winner() == player1.get_sign():
print(f”{player1.get_name()} is a winner!”)
elif board.get_winner() == player2.get_sign():
print(f”{player2.get_name()} is a winner!”)
else:
print(“It is a tie!”)
ans = input(“Would you like to play again? [Y/N]n”).upper()
if (ans != “Y”):
break
print(“Goodbye!”)You can use the following code snippet to start working on MiniMax:
class MiniMax(?):
def choose(self, board):
print(f”n{self.?}, {self.?}: Enter a cell [A-C][1-3]: “)
cell = MiniMax.minimax(self, board, True, True)
print(cell)
board.set(cell, self.sign)
def minimax(self, board, self_player, start):
# check the base conditions
if board.isdone():
# self is a winner
if board.get_winner() == ?
return 1
# is a tie
elif board.get_winner() == ?:
return 0
# self is a looser (opponent is a winner)
else:
return -1

# make a move (choose a cell) recursively
# use the pseudocode given to you above to implement the missing code

Building our menu The next step in our project is to build a menu and the code t

Building our menu
The next step in our project is to build a menu and the code t

Building our menu
The next step in our project is to build a menu and the code to support it. The menu provides the interface that a user will use to interact with the program.
This assignment will give us practice using loops and conditionals.
We are building on the previous assignment. So start with a copy Lab Assignment 2 and add your new code.
In this Lab Assignment you are going to:
Create a new file named lab_assignment 3.py.
Copy your code from Lab Assignment 2 and paste it into you new file
Add information to update the module docstring to reflect Lab Assignment 3
Add the new code you are writing to support the requirements for Lab Assignment 3
Delete the main() the code used in lab_assignment 2 and write a new main() function to generate the required output (the Unit Test, for Lab Assignment 3)
Write a function named print_menu()
print_menu() that takes no arguments and returns nothing, don’t forgat to add the docstring for the new function. Its whole job is to print this menu:
Main Menu
———
1 – Process a new data file
2 – Choose units
3 – Edit room filter
4 – Show summary statistics
5 – Show temperature by date and time
6 – Show histogram of temperatures
7 – QuitIncidentally, during the rest of the course, we will work on implementing all of the items referenced by the menu.
We are first going to write stub functions which will later be completed. A stub is a function that has the expected signature (i.e. name of the function and parameters), but an incomplete implementation. A stub function is used as a placeholder and so that the code that calls the function can be tested before the called function is fully written.
Next, we need stub functions for the following
Each line below gives you the function signature (name of the function and it’s parameters) of each function that you will create in the assignment
new_file(dataset) will be called when the user chooses item one.
choose_units() will be called when the user chooses item two.
change_filter(sensor_list, active_sensors) will be called when the user chooses item three.
print_summary_statistics(dataset, active_sensors) will be called when the user chooses item four.
print_temp_by_day_time(dataset, active_sensors) will be called when the user chooses item five.
print_histogram(dataset, active_sensors) will be called when the user chooses item six. This is an optional no-credit project.
And what about item seven? The program should exit gracefully.
These functions do not have any functionality yet. They will initially be stub functions, later you will add the code required for the application. Instead of using the pass statement, we will use a print statement for each function so we know that it has been called. Our new_file() function, for example, will look like this:
def new_file(dataset):
“””
Open a new file
“””
print(“New File Function Called”)
Since you do not know the purpose of each of these functions yet, you can just a generic docstring for now.
main()
In addition, to implementing these new functions, you need to create logic in the main() to print the menu, ask for the user’s input, and process the response. Your code should call the appropriate function and then print the menu again. This is the Unit Test for this Lab Assignment.
Some of these functions require parameters, but we haven’t defined the variables (arguments) that we need to pass to the functions. The interpreter will complain if you call the functions without any arguments. For now, you can just call the functions that require an argument with None, e.g. new_file(None). The None object is used to define a null value (no value at all). None is not the same as 0, False, or an empty string. None is an object type (NoneType) and only None can be None.
How will you call a function that takes two arguments?
Whenever you prompt for input be sure to allow the response to the prompt to be on the same line and to put a space after the prompt to increase readability.
Be sure to skip a line between each prompt.
Error Handling
Your code should print an error message describing the error if the user enters a number outside the range 1-7, and a different error message if the user enters anything other than an integer. Use a try-except block.
Your code should keep looping until the user enters 7 to quit.
Remember to remove the unit tests from main() that you coded lab_assignment_2, but your convert_units() function should stay because it will be used later.
A note about elegance:
One indication that your code needs more elegance is when you have the same statements repeated. For example, do you have “What is your choice” more than once in your code? Is there more than one place that you call print_menu()? If either of these is true, your code should be improved to make it more elegant. Many times this happens because you can’t figure out how to make something happen at the right place in the loop. Take the time to figure this out.
Finally, a couple of reminders about style that we haven’t discussed yet, but need to keep in mind starting now:
The indent should consistently be multiples of four spaces (no tabs)
No line should be more than 79 characters longThe only exception to this is the final multiline string containing your program’s output, paste it in exactly as it appears.
Here’s a sample run (remember, it looks like nothing is happening, but the menu is calling each function), your output must match what you see below:
STEM Center Temperature Project
Mike Murphy
Main Menu
———
1 – Process a new data file
2 – Choose units
3 – Edit room filter
4 – Show summary statistics
5 – Show temperature by date and time
6 – Show histogram of temperatures
7 – Quit
What is your choice? 1
New File Function Called
Main Menu
———
1 – Process a new data file
2 – Choose units
3 – Edit room filter
4 – Show summary statistics
5 – Show temperature by date and time
6 – Show histogram of temperatures
7 – Quit
What is your choice? 2
Choose Units Function Called
Main Menu
———
1 – Process a new data file
2 – Choose units
3 – Edit room filter
4 – Show summary statistics
5 – Show temperature by date and time
6 – Show histogram of temperatures
7 – Quit
What is your choice? 3
Change Filter Function Called
Main Menu
———
1 – Process a new data file
2 – Choose units
3 – Edit room filter
4 – Show summary statistics
5 – Show temperature by date and time
6 – Show histogram of temperatures
7 – Quit
What is your choice? 4
Summary Statistics Function Called
Main Menu
———
1 – Process a new data file
2 – Choose units
3 – Edit room filter
4 – Show summary statistics
5 – Show temperature by date and time
6 – Show histogram of temperatures
7 – Quit
What is your choice? 5
Print Temp by Day/Time Function Called
Main Menu
———
1 – Process a new data file
2 – Choose units
3 – Edit room filter
4 – Show summary statistics
5 – Show temperature by date and time
6 – Show histogram of temperatures
7 – Quit
What is your choice? 6
Print Histogram Function Called
Main Menu
———
1 – Process a new data file
2 – Choose units
3 – Edit room filter
4 – Show summary statistics
5 – Show temperature by date and time
6 – Show histogram of temperatures
7 – Quit
What is your choice? 9
Invalid Choice, please enter an integer between 1 and 7.
Main Menu
———
1 – Process a new data file
2 – Choose units
3 – Edit room filter
4 – Show summary statistics
5 – Show temperature by date and time
6 – Show histogram of temperatures
7 – Quit
What is your choice? -1
Invalid Choice, please enter an integer between 1 and 7.
Main Menu
———
1 – Process a new data file
2 – Choose units
3 – Edit room filter
4 – Show summary statistics
5 – Show temperature by date and time
6 – Show histogram of temperatures
7 – Quit
What is your choice? a
*** Please enter a number only ***
Main Menu
———
1 – Process a new data file
2 – Choose units
3 – Edit room filter
4 – Show summary statistics
5 – Show temperature by date and time
6 – Show histogram of temperatures
7 – Quit
What is your choice? 7
Thank you for using the STEM Center Temperature Project
Process finished with exit code 0