Determine the admission fee of the agegroup that user inputs

Assignment Help Python Programming
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"

Reference no: EM132330220

Questions Cloud

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.

Reviews

Write a Review

Python Programming Questions & Answers

  Write a program that contains an introductory docstring

Implement the algorithm using Python programming language for given specifications/requirements - Create programs based on incremental development processes

  Determines number of occurrences of a given letter in string

In this last checkpoint, you will write a new program that determines the number of occurrences of a given letter in a string. To do so, you are only allowed to use the replace() and len() functions.

  What is the average size of each color diamond

Using pandas and the diamonds data set from class - What is the average size of each color diamond. Plot the density of the prices

  Write a python program that prints out a table

Write a Python program that prints out a table of values of all even powers of 2 from 2**0 through 2**32. For each value, print the value in decimal, hexadecimal, and binary.

  Write python code to analyze your dataset

FIT5196 - Data wrangling Assignment, Monash University, Australia. Write Python (Python 2/3) code to analyze your dataset

  Design and implement an english test

CSP1150 - Programming Principles - You are required to design and implement an "English Test" program in which the user is presented with a word and then asked to answer a simple question about the word. After 5 words, the program shows the user's..

  Program that allows the user to enter the type of coin

Create a program that allows the user to enter the type of coin to be evaluated and the number of coins. The program should calculate the total weight of the coins and the height of the coins when stacked. Name the program coins.py. Use the table bel..

  Write a function replist that receives two input arguments

In python, write a function repList that receives two input arguments: a list and the number of times each element is to be duplicated.

  Write a function digitize that takes two parameters

Write a function digitize (using loops) that takes two parameters: one integer parameter and one bool parameter.

  You are tasked with improving the code for the haunted

you are tasked with improving the code for the haunted house game. please read the associated hand-out and the code

  Design and implementation of your demonstration system

ICT705 - Data and System Integration - University of the Sunshine Coast - write a report explaining the theory underlining the key concepts around the design

  Design a prgram using python

Design a prgram USING PYTHON that students can use to calculate what score they need on final exam to get a certan final grade for a course.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd