Reference no: EM132330220
Question
Consider the program below. The program determines the admission fee of the ageGroup that user inputs. You can use the if-else statements to match the ageGroup and the fee. But you can also use a dictionary instead of the if-else to accomplish the same task with only one line of code.
def main():
## Determine an admission fee based on age group.
print("Enter the person's age group ", end="")
ageGroup = input("(child, minor, adult, or senior): ")
print("The admission fee is", determineAdmissionFee(ageGroup), "dollars." )
##def determineAdmissionFee(ageGroup):
## if ageGroup == "child": # age < 6
## return 0 # free
## elif ageGroup == "minor": # age 6 to 17
## return 5 # $5
## elif ageGroup == "adult": # age 18 to 64
## return 10
## elif ageGroup == "senior": # age >= 65
## return 8
def determineAdmissionFee(ageGroup):
dict = {"child":0, "minor":5, "adult":10, "senior":8}
return dict[ageGroup]
main()
a. Rewrite the code using a dict instead of if-else, write the main to ask user to input what year and then print the corresponding rank name eg 1 = Freshman.
def determineRank(years):
if years == 1:
return "Freshman"
elif years == 2:
return "Sophomore"
elif years== 3:
return "Junior"
else:
return "Senior"
Explain why arson evidence is packaged in metal cans
: Explain why arson evidence is packaged in metal cans. Explain the difference between the headspace and vapor concentration techniques in determining if a sample
|
Explain the technology used to detect illegal drugs
: List and explain the technology used to detect illegal drugs at entry points and within the prison. Examine the different techno-crimes and the importance.
|
Define crime data and trends in familiar violence
: Programs in which law enforcement can provide training to employers on preventative measures to protect employees from sexual violence; security precautions.
|
Is social control on your campus stricter or more lenient
: Write a 700-word response to the following question: What happens to students who do not conform to accepted social norms? Is social control on your campus.
|
Determine the admission fee of the agegroup that user inputs
: The program determines the admission fee of the ageGroup that user inputs. You can use the if-else statements to match the ageGroup and the fee.
|
Calculate the sum of the first n odd numbers
: A program that ask the user for a username and password and read the names and password from a text file, if the username and password match.
|
Define aspect of criminal justice reform
: Select one aspect of criminal justice reform (police operations, police conduct, sentencing, incarceration, criminal law, etc.) and describe and support.
|
Give examples that show different features of string slices
: Give at least three examples that show different features of string slices. Describe the feature illustrated by each example. Invent your own examples.
|
What are the issues or policies that need to be addressed
: What are the issues, problems, or policies that need to be addressed? Is it a combination of an issue, problem, or policy? Why or why not? Explain.
|