Description
Objective:
To work with string slicing, lists, and creating basic function in python.
Assignment:
Create menu function and print out the following options using while loop. Exit from the program when user enters option 5. The functions performed by each option is given below:
Option 1: Ask the user to input a string “CSCI161L” and assign it to a variable. Use string operations to print the following: “CSCI”, ”161”, and reverse version of the string (“L161ICSC”) using string slicing.
Option 2: Ask the user to input a string and assign it to a variable and check whether it is palindrome using string slicing.
Option 3: Create a list which consists of 5 integers or input 5 integers from users and assign to a list separated by comma and print out their squares using any loop.
Option 4: Exit from the program.
Sample output:
Menu:
Option 1: String Operation 1
Option 2: String Operation 2 Option 3: List Operation 1 Option 4: Exit
Please enter an option: 1
Please enter a string: CSCI161L Output >> String 1: CSCI
String 2: 161
Reversed string: L161ICSC
Menu:
Option 1: String Operation 1
Option 2: String Operation 2 Option 3: List Operation 1 Option 4: Exit
Please enter an option: 2
Please enter a string: abba
Output
>> String is palindrome.
Menu:
Option 1: String Operation 1 Option 2: String Operation 2 Option 3: List Operation 1 Option 4: Exit
Please enter an option: 3
Enter a list of 5 integers. 6,3,4,12,10
Output >> Square of numbers in the list are: [36, 9, 16, 144, 100]
Menu:
Option 1: String Operation 1
Option 2: String Operation 2 Option 3: List Operation 1 Option 4: Exit
Please enter an option: 4 Exit from the program!
Instructions:
• Preferred programming environment:
- OS
- Interpreter
- Editor
: Linux (Mint)
: Python 3 (not Python 2)
: gedit or editor of your choice
- The program is saved as a file with .py extension.
- The program should include a comment block at the top with your name, course number and course section, assignment number