Ch05 - Hw5-2

.docx

School

California State University, Long Beach *

*We aren’t endorsed by this school

Course

340

Subject

Business

Date

May 10, 2024

Type

docx

Pages

3

Uploaded by DrFire6669

California State University, Long Beach Information Systems College of Business Administration IS 340 – Business Application Programming Ch05 Functions Professor: Jorge Echavarria Week 05 Assignment Chapter 05 (Functions) Before you complete each of the following exercises, print this page out and use it to keep notes about your progress. When you are done with each exercise, "check it off" of the list so you can keep track of your progress. Student Learning Outcomes: 1. Students will implement different programs using each of the following: basic computation, simple I/O, conditional and iterative structures. 2. Students will write programs that make use of function definitions, decomposition, parameter passing, and arrays. 3. Students will write programs that implement programmer-defined types (classes or structures). Submit the Assignment into “Assignment 5” Dropbox Folder. Attach it with the name LastnameFirstname_Assign5.docx (or .doc for Office 2003) Don't forget to write your name and the chapter number and any relevant information on the top of the document as well The deadline for all the assignments will be posted in Canvas All Test Cases must be demonstrated in order to get full credit 1. Write pseudocode/algorithm for a function that translates a telephone number with letters in it (such as 1-800-FLOWERS) into the actual phone number. Use the standard letters on a phone pad. Make sure your function has an input and a return result. Also, be specific on how the numbers are translated in your algorithm (don’t use a “dictionary” or “map”. Use what we’ve learned: “if blocks”) 4 pts IS 340: Ch05 Assignment Page 1
California State University, Long Beach Information Systems College of Business Administration IS 340 – Business Application Programming Ch05 Functions Professor: Jorge Echavarria 2. Write the following function and provide a program to test it (main and function in one .py) 5 pts def repeat(string, n, delim) that returns the string string repeated n times, separated by the string delim . For example repeat(“ho”, 3, “,”) returns “ho, ho, ho”. a) Your code with comments b) A screenshot of the execution 3. Write the following functions and provide a program to test them (main and all functions in one .py). 6 pts A) def allTheSame(x, y, z) (returning True if the arguments are all the same, otherwise False) B) def allDifferent(x, y, z) (returning True if the arguments are all different, otherwise False) C) def sorted(x, y, z) (returning True if the arguments are sorted in ascending, otherwise False) Note : Make sure your output has meaning (Don’t just print “True” or “False”) a) Your code with comments b) A screenshot of the execution 4. Write the following function and provide a program to test it (main and function in one .py) 5 pts Def countVowels(string) that returns a count of all vowels in the string string . Vowels are letters a, e, i, o, and u and their uppercase variants. Your main program should ask the user to input a string and then print the results. Test Case: Please enter a string: sentencE The total number of vowels = 3 a) Your code with comments b) A screenshot of the execution 5. Write the following function and provide a program to test it (main and function in one .py) 5 pts def readFloat(prompt) that displays the prompt string, followed by a space, reads a floating-point number in, and returns it. Below is how you’re going to call the function: salary = readFloat(“Please enter your salary:”) percentageRaise = readFloat(“What percentage raise would you like?”) print("The salary is", salary) print("The raise percentage is", percentageRaise) a) Your code with comments b) A screenshot of the execution IS 340: Ch05 Assignment Page 2
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help