Create a program named distribute_race_awards_with_dictionary. This program performs a simple lookup based upon integer input provided by the user at the console. This program is different from a similar program created in a previous assignment in that the lookup is performed using a Python dictionary. When coding and testing this program, follow the approach that I take in the Part 2 tutorial video. When this program is run, console sessions should look like this: Please enter the place in which the participant finished (1, 2, 3, ...): 1 Participant place: 1 Participant award: Blue Ribbon Please enter the place in which the participant finished (1, 2, 3, ...): 6 Participant place: 6 Participant award: Purple Ribbon Please enter the place in which the participant finished (1, 2, 3, ...): 7 Participant place: 7 Participant award: Participant Ribbon Please enter the place in which the participant finished (1, 2, 3, ...): 0 Participant place: 0 Participant award: Input Error - Place must be greater than 0
CODE:
# intially place is 1 beacause to iterate the loop
place = 1
# taking race awards with dictionary.
awards =
{1:"Blue",2:"Red",3:"Green",4:"Yellow",5:"Violet",6:"Purple"}
# loop for aksing user input repeatedly
while(place!=0):
#Asking the user for input
a = int(input("Please enter the place in which the participant
finished (1, 2, 3, ...): "))
# if input is less than 0
if(a<=0):
#printing output error
print("Input Error - Place must be greater than 0")
# if input between 1 and 6 inclusive
elif(1<=a<=6):
# then print output using dictionary values
print("Participant Place : ",a)
print("Participant award: ",awards[a],"Ribbon")
else:
# greater than 6 will given participant award
print("Participant Place : ",a)
print("Participant award: Participant Ribbon")
CODE ATTACHMENT:

OUTPUT:

Please UPVOTE my solution and Comment if you have any doubts. i will definitely answer.
Sure, here's a Python program named distribute_race_awards_with_dictionary that performs a simple lookup using a dictionary based on the integer input provided by the user:
pythonCopy codedef distribute_race_awards_with_dictionary():
awards = { 1: "Blue Ribbon", 2: "Red Ribbon", 3: "White Ribbon", 4: "Green Ribbon", 5: "Yellow Ribbon", 6: "Purple Ribbon", 7: "Participant Ribbon"
} while True: try:
place = int(input("Please enter the place in which the participant finished (1, 2, 3, ...): ")) if place <= 0: print("Participant place: ", place) print("Participant award: Input Error - Place must be greater than 0") else: print("Participant place: ", place) print("Participant award: ", awards.get(place, "Participant Ribbon")) break
except ValueError: print("Invalid input. Please enter a valid integer.")if __name__ == "__main__":
distribute_race_awards_with_dictionary()When you run this program, it will prompt you to enter the place in which the participant finished. Based on the input, the program will look up the corresponding award from the dictionary and display it on the console. If the input is not a positive integer, it will show an error message. The program will keep asking for input until a valid place is provided.
Create a program named distribute_race_awards_with_dictionary. This program performs a simple lookup based upon integer input provided...
Please use Python
Exercise 1 Create a program named sentinel_loop using break. This program should implement functionality that is the same as the Part 1 tutorial example, except for the following differences: • • This program should count even and odd integers. This program should report counts of even and odd integers. Remember that even integers can be identified using the test condition: value % 2 == 0 Remember to test your code for appropriate behavior when the user signals...
3 Dn Ent Write a python program to create a Dictionary named grade with the given items and do the below operations: i. 15 i. Create Dictionary with keys-{'Monday', 'Tuesday', 'Wednesday Thursday', 'Friday') ii. values-{1, 2, 3, 4, 5) ii. Now append another item with key-'Saturday') and value-(63 to the already created Dictionary and print it.
Complete the Python program below that performs the following operations. First prompt the user to input two integers, n and m. If n<m, then print the odd positive integers that are less than m (in order, on a single line, separated by spaces). If man, then print the even positive integers that are less than n (in order, on a single line, separated by spaces). If neem, then print nothing. For instance, if the user enters 5 followed by 10,...
In Python 3 - Write a program that reads a sequence of integer inputs from the user. When the user is finished entering the integers, they will enter a 'q'. There is no need to check if the entry is a valid integer. All integers in the test data (input) will be between -255 and 255. The program should then print: The smallest and largest of the inputs. The number of even and odd inputs (0 should be considered even)...
This program will require you to create a basic parser for an input string that is somewhat like Python. Python has an older parser module and a newer ast module to manage pure Python syntax, but they won't be useful here. The program will read a data string, identify the control characters, and print out the overall structure of the string. Here's an example Input String: [{1}] Output: Number inside a dictionary inside a list Here are some basic rules...
write in python Create a program that will ask the user for a list of integers, all on one line separated by a slash. construct a list named "adj_numbers" which contains the users input numbers after subtracting 2 from each number. then print the resulting list. the input statement and print statement are given to you in the starting code. a sample run of the program is as follows: Enter a list of integers, separated by slashes: 7/3/6/8 resulting list:...
I'm working in assembly using nasm, and need to create a program that performs simple calculations. The prompt is below: Write a program that contains 4 procedures: ADD SUBTRACT MULTIPLY DIVIDE Read expressions from the user, such as: 1 + 2 4 - 3 2 * 3 4 / 2 . Execute every expression by calling the proper procedure. The end of user input is a period: . The output for the above code should be: 1 + 2 =...
PYTHON PROGRAM
by using functions & dictionary or set.
- must create a variable to hold a dictionary or sets
- must define a function that accepts dictionaries or sets as an
argument
A dictionary maps a set of objects (keys) to another set of objects (values). A Python dictionary is a mapping of unique keys to values. For e.g.: a dictionary defined as: released = { "iphone" : 2007, "iphone 3G": 2008, "iphone 3GS": 2009, "iphone 4" : 2010,...
Create a C# console application that performs the following: 1) Build a method which reads 3 integers from the console and returns them as an int array (type a number, then hit enter, 3 times). This needs to be its own method. 2) Call this method twice to store 2 local int array variables. 3) Once both arrays are built, write another method which accepts the two arrays and compares the contents to see if they match. If the method...
Create a C# console application that performs the following: 1) Build a method which reads 3 integers from the console and returns them as an int array (type a number, then hit enter, 3 times). This needs to be its own method. 2) Call this method twice to store 2 local int array variables. 3) Once both arrays are built, write another method which accepts the two arrays and compares the contents to see if they match. If the method...