Question

Write the Script in Python.

courseCategories = ["Mathematics","Computer Science","Business","Economics","Literature","Art","Music"]

SR - Sort a. b. 1. This operation will display the list before being sorted Display the list to the user after being sorted

Sample of the output. It should look same as the output.

SR - Sort MENU *SR Sort * CC Character Count* *AS Add String EX EXIT Enter your choice: Sr BEFORE SORT [Mathematics, Com

CC-Character Count Valid Index Value MENU *SR- Sort *CC- Character Count * * AS - Add String *EX - EXIT Enter your choice: c

0 0
Add a comment Improve this question Transcribed image text
Answer #1
# Declare list
courseCategories = ["Mathematics", "Computer Science", "Business", "Economics", "Literature", "Art", "Music"]

# Print menu
print('*' * 24)
print('*' + "MENU".center(22, " ") + '*')
print('*' * 24)
print('*' + "SR - Sort".ljust(22, " ") + '*')
print('*' + "CC - Character Count".ljust(22, " ") + '*')
print('*' + "AS - Add String".ljust(22, " ") + '*')
print('*' * 24)
print('*' + "EX - Exit".ljust(22, " ") + '*')
print('*' * 24)

# Ask user to enter choice
choice = input('Enter your choice: ')

# Convert choice to upper() to make comparison case-insensitive
# If sr, apply sort function on list, and print it
# If cc, ask user to enter index, if index valid
# get the value from list using indexing and print result
if choice.upper() == "SR":
    print('BEFORE SORT:', courseCategories)
    courseCategories.sort()
    print('AFTER SORT:', courseCategories)
elif choice.upper() == "CC":
    index = int(input('Enter an index for the list: '))
    if index < 0 or index > len(courseCategories) - 1:
        print('You entered en invalid index!')
    else:
        value = courseCategories[index]
        print('The value at index', index, 'is', value, 'and is', len(value), 'characters long.')
else:
    print('Wrong choice entered!')
print('End of project #4')

SCREENSHOT

Course.py X : # Declare list 2 courseCategories - [Mathematics Computer Science, Business, 3 Economics, Literature,

27 28 29 30 31 32 elif choice.upperCC index -int (input (Enter an index for the list: if İndex < 0 or index > len (coursec

OUTPUT

urse E: \Practice Python\venv\Scripts python.exe E:/Practice/Python/Course.py ру MENU *SR Sort *CC-Character Count ASAdd Stri

E: \Practice\ Python\venv\Scripts \python.exe E:/Practice/Python/ MOPANIT *SR Sort *CCCharacter Count * ASAdd String *EXExit

ourse E:\Practice\Python\ venv\Scriptslpython.ex MOPN *SRSort *CCCharacter Count * ASAdd String EX-Exit Enter your choice: co

Add a comment
Know the answer?
Add Answer to:
Write the Script in Python. courseCategories = ["Mathematics","Computer Science","Business","Economics","Literature","Art","Music"] Sample of the output. It should look...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This Python module will be menu driven and use conditions to check user input in order...

    This Python module will be menu driven and use conditions to check user input in order to determine which operation to perform based on the user’s menu selection. The output should look like the attached example output. The menu will have the following selections (NOTE: all menu selections by the user should not be case sensitive) : 1. ‘CC’ – Character Count a. This operation will prompt the user for a string b. The number if characters will be counted...

  • PYTHON PROGRAMMING NEED HELP ASAP You will write an application to manage music collections -- a music collection is a l...

    PYTHON PROGRAMMING NEED HELP ASAP You will write an application to manage music collections -- a music collection is a list of albums. The named tuples used for Albums and Songs are defined below, and an example of a music collection is given. (DO NOT HARDCODE THE VALUES FOR MUSIC!) Album = namedtuple('Album', 'id artist title year songs') Song = namedtuple('Song', 'track title length play_count') MUSIC = [ Album("1", "Peter Gabriel", "Up", 2002, [Song(1, "Darkness", 411, 5), Song(2, "Growing Up",...

  • Using c++ Write a program that reads in a list of up to 25 first names...

    Using c++ Write a program that reads in a list of up to 25 first names from an input file nameData.txt and allows the user to display the name data, sort it in ascending or descending order, count the number of occurrences of a given name, or exit the program. The input file consists of a single names per line with each line terminated with an end of line (i.e. using Enter key to end the line). Your program should...

  • Stuck on this computer science assignment Write a program that demonstrates binary searching through an array...

    Stuck on this computer science assignment Write a program that demonstrates binary searching through an array of strings and finding specific values in an corresponding parallel double array. In all cases your output should exactly match the provided solution.o. Provided files: Assignment.cpp - starter assignment with function prototypes companies.txt - file for program to read. earnings.txt - file for program to read. Input1.txt Input2.txt - Test these inputs out manually, or use stream redirection Input3.txt - These inputs are based...

  • NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions...

    NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...

  • NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions...

    NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...

  • Professor Dolittle has asked some computer science students to write a program that will help him...

    Professor Dolittle has asked some computer science students to write a program that will help him calculate his final grades. Professor Dolittle gives two midterms and a final exam. Each of these is worth 100 points. In addition, he gives a number of homework assignments during the semester. Each homework assignment is worth 100 points. At the end of the semester, Professor Dolittle wants to calculate the median score on the homework assignments for the semester. He believes that the...

  • Overview: You will be writing classes that implement a playlist simulation for a music streaming app.The...

    Overview: You will be writing classes that implement a playlist simulation for a music streaming app.The Playlist class will contain a dynamic array of Song objects, and the Song class contains several pieces of information about a song. You will need to: 1) Finish the writing of two classes: Song and Playlist. The full header file for the Song class has been provided in a file called Song.h. 2) Write a main program (filename menu.cpp) that creates a single Playlist...

  • Below is the code for the class shoppingList, I need to enhance it to accomplish the...

    Below is the code for the class shoppingList, I need to enhance it to accomplish the challenge level as stated in the description above. public class ShoppingList {   private java.util.Scanner scan; private String[] list; private int counter; public ShoppingList() { scan = new java.util.Scanner(System.in); list = new String[10]; counter = 0; } public boolean checkDuplicate(String item) { for(int i = 0; i < counter; i++) { if (list[i].equals(item)) return true; } return false; } public void printList() { System.out.println("Your shopping...

  • please write C++ code to finish R0,R1,R2 Introduction In this assignment, you are going to develop...

    please write C++ code to finish R0,R1,R2 Introduction In this assignment, you are going to develop a "Schedule Book System that runs in the command line environment. The system stores the schedule of events input by user and allows users to add view or delete events. You can assume that the system can at most store 100 events Each group is required to write a Win32 Console Application program called ScheduleBook.cpp The requirements are listed below. RO When the program...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT