Question
Programming Exercises As mentioned before, you will be answering all the following questions in one single python file and the person running your file will
Programming Exercises As mentioned before, you will be answering all the following questions in one single python file and the person running your file will be prompted to choose which one of these programming exercises they wish to run. A good approach to design this file is to have a main function for each of the questions (maini, main2, etc.). These functions will be called when the user chooses each of the questions (if the user chooses 1, main1 will be executed and so on). You can call different functions in each of your mains if you wish. Below are the programming exercises. The questions are in all levels, some of them are very easy, and some are more challenging. Start with the questions that are easier for you and then try to answer as many questions as possible. For grading, we will be looking at the codes, so even if you have not completely answered a question, make sure you still include your code in the submitted file as you may receive a partial grade for it. Note: all user inputs should be entered in a new line after the prompted message. Question one Write a program that receives a sequence of numbers from user and prints the number of appearances for each digit in the sequence. Below is an example of what the program should look like. Please note that the numbers that have not appeared in the sequence (such as 9) are not printed. For this question, you may not use Python's dictionary (data type) or the counter function. Please enter your sequence: 318047170471 I In this sequence we saw: "O": 2 time(s) "1": 3 time(s) "3": 1 time(s) "4": 2 time(s) "7": 3 time(s) "g": 1 time(s
Another example: Enter the string: When did you have your dinner? Result: dinner 6 fote: If there is a punctuation mark at the end of the string it should be ignored. There will not Se any punctuation marks in the beginning or middle of the string. Question four Write a function that receives a list as its only parameter. Inside the body of the function remove all the duplicate items from the list and returns the new list. For this question, you may not use Python's dictionary (data type). Call the function with a simple input- we will change this input while grading Example: If we call the function with ("hey", "swim","day", "night", "swim") as its input, the returned value should be ["hey", "swim","day", "night"). The order of the items inside the returned list does not matter. Question five Write a function that receives a list of strings as its only parameter. Inside the body of the function find the first palindromic word and return it. If there is no such word, return an empty string. Note: A string is palindromic if it reads the same forward and backward mom", "noon", and "civic" are palindromic). Call the function with a simple input- we will change this input while grading. Example: If we call the function with ["abc", "hello", "car", "level", "mom"), the returned value should be "level". Note that "mom" is also a palindrome, but it is not the first one.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started