Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I would really appreciate it if you could answer the following questions using the Python language 3.1 Problem 1 (1 mark) Problem: Write a program

I would really appreciate it if you could answer the following questions using the Python language

image text in transcribedimage text in transcribed
3.1 Problem 1 (1 mark) Problem: Write a program that reads strings (without digits or symbols in the string) typed by the user until an empty string is entered. For each string, convert all words to lowercase, then sort and print the words into descending order lexicographically. Enter a string: Three Rings for the eleven kings under the sky Output: under three the the sky rings kings for eleven Enter a string: Seven for the Dwarf lords in their halls of stone Output: their the stone seven of lords in halls for dwarf Enter a string: Nine for Mortal Men doomed to die Output: to nine mortal men for doomed die Enter a string: One for the Dark Lord on his dark throne Output: throne the one on lord his for dark dark Enter a string: In the land of Mordor where the Shadows lie Output: where the the shadows of mordor lie land in Enter a string: Hint: use split function to split a string into a list, then sort it with a method. 3.2 Problem 2 (1 mark) Problem: Write a program that allows the user to enter two lists of integers, calculate the sum of the first and the last integers in each list, and print the larger sum. In the event of a tie, print Same. When there is only one integer in the list, the sum is the integer itself. For example: List 1: 1 2 3 4 5 List 2: 5 6 7 Output : 12 List 1: 4 3 10 1 List 2: 9 Output : 9 List 1: 4 3 2 1 List 2: 1 2 3 4 Output : Same3.3 Problem 3 (1 mark) Problem: We'll say that a lowercase 's' in a string is "happy" if there is another 's' immediately to its left or right. Write a function to print True if all the g's in the given string are happy, otherwise, print False. String: xggt Happy?: True String: abgsx Happy?: False String: g Happy"? False String: brggsomr Happy?: True 3.4 Problem 4 (1 mark) Problem: Write a program that allows the user to enter the marks of 5 students in 4 courses, Output the highest average marks for students and courses. For example: Student 1 (courses 1-4): 50 60 70 60 Student 2 (courses 1-4): 100 90 87 90 Student 3 (courses 1-4): 70 100 90 90 Student 4 (courses 1-4): 30 65 50 50 Student 5 (courses 1-4): 58 50 74 43 The highest average mark of students: 91.75 The highest average mark of courses: 74.2 Consider 2 dimensional lists, i.e. the element of a list is a list

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions