90.5k views
0 votes
• Assignment. Python Programming

Cornerstone Hospital has
strike due
a
to
the reant inflation. The
Hospital is looking for Volunteers to work. Create
able to
program that is
to enter their
their name, age
work in
group of nußes
* The
in
$ allow the user
would want to
Program should be able to display the
of categories (1. Sate
a
and category they
menn
3. Tollets 4 Maternit
2. Pharmacy 3. Toilets 4
I
name, aga ad categories should be saved
arrays for later
access of data. [25]

User Skamradt
by
8.1k points

1 Answer

0 votes

Sure, here's an example Python program that allows the user to enter their name, age, and the category they would like to work in as a volunteer at Cornerstone Hospital. The program also saves the data in arrays for later access:

# Initialize empty arrays for name, age, and category data

name_data = []

age_data = []

category_data = []

# Define function to get user input for name, age, and category

def get_user_input():

name = input("Enter your name: ")

age = input("Enter your age: ")

category = input("Enter the category you would like to work in (1. State, 2. Pharmacy, 3. Toilets, 4. Maternity): ")

return name, age, category

# Define function to display the categories

def display_categories():

print("Categories: ")

print("1. State")

print("2. Pharmacy")

print("3. Toilets")

print("4. Maternity")

# Get user input and append to data arrays

name, age, category = get_user_input()

name_data.append(name)

age_data.append(age)

category_data.append(category)

# Display categories and user input

display_categories()

print("Name: ", name_data[0])

print("Age: ", age_data[0])

print("Category: ", category_data[0])

This program initializes empty arrays for name, age, and category data. It then defines a function get_user_input() that prompts the user to enter their name, age, and the category they would like to work in. Another function display_categories() displays the categories for the user to choose from.

The program then gets user input using get_user_input() and appends the input to the data arrays. Finally, the program displays the categories and the user input using display_categories() and array indexing.

Note that this is just an example program and can be modified to suit your specific needs.

User Josue Morales
by
7.9k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.