Professional Documents
Culture Documents
Homework 3
Problem 1:
Rewrite the programs in Homework 2 using functions and demonstrate the function usage
Problem 2:
Write a function to sort the names in a given list in ascending order and demonstrate the usage
Problem 3:
Write a function to obtain a string entered via keyboard in the reverse order as per word, e.g.
“How Are You” change to “You Are How”. Write a program to demonstrate the usage.
Problem 4:
Write a program to enter a sentence (or paragraph) and a word (or a string), then replace the word
(string) within the sentence (paragraph) with the equal number of "*" at all occurring. Design and use
appropriate functions to perform the task.
Problem 5:
Write a function that converts a string like “124” to an integer 124. Write a program to
demonstrate the usage.
Problem 6:
Write a function to check whether string inputted by user is palindrome or not. Demonstrate the
usage
Problem 7:
Write a function to remove all the extra blanks in a string. Demonstrate the usage
Problem 8
Write a program to enter any string and print the frequency of each character within the string. The
character with multiple frequencies should be displayed only once in the output, with the frequency value.
Design and use appropriate functions to perform the task.
Problem 9
Write a program to take a list of students in a programming class. The list should contain the
student id, student name and the final exam score. Write the student list to a csv file call “ee3491.csv” such
that each line consists of student id, student name and the score. Each field of information should be
separated by a comma “,”; e.g.: 20200001,Adam Smith,8.2. Design and use appropriate functions and data
types to perform the task.
Problem 10
Write a program to read a file which has the same format as described in problem 9. Calculate the
number of students who get A, B, C, D, and F. Design and use appropriate functions and data types to
perform the task.