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
  • 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...

  • 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...

  • 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...

  • 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...

  • 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...

  • For this c++ assignment, Overview write a program that will process two sets of numeric information....

    For this c++ assignment, Overview write a program that will process two sets of numeric information. The information will be needed for later processing, so it will be stored in two arrays that will be displayed, sorted, and displayed (again). One set of numeric information will be read from a file while the other will be randomly generated. The arrays that will be used in the assignment should be declared to hold a maximum of 50 double or float elements....

  • C++ Design a class bankAccount that defines a bank account as an ADT and implements the...

    C++ Design a class bankAccount that defines a bank account as an ADT and implements the basic properties of a bank account. The program will be an interactive, menu-driven program. a. Each object of the class bankAccount will hold the following information about an account: account holder’s name account number balance interest rate The data members MUST be private. Create an array of the bankAccount class that can hold up to 20 class objects. b. Include the member functions to...

  • write a code on .C file Problem Write a C program to implement a banking application...

    write a code on .C file Problem Write a C program to implement a banking application system. The program design must use a main and the below functions only. The program should use the below three text files that contain a set of lines. Sample data of these files are provided with the assessment. Note that you cannot use the library string.h to manipulate string variables. For the file operations and manipulations, you can use only the following functions: fopen(),...

  • Need help for C program. Thx #include <stdio.h> #include <string.h> #include <ctype.h> // READ BEFORE YOU...

    Need help for C program. Thx #include <stdio.h> #include <string.h> #include <ctype.h> // READ BEFORE YOU START: // This homework is built on homework 06. The given program is an updated version of hw06 solution. It begins by displaying a menu to the user // with the add() function from the last homework, as well as some new options: add an actor/actress to a movie, display a list of movies for // an actor/actress, delete all movies, display all movies,...

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
Active Questions
ADVERTISEMENT