Python Scripting

User Generated

abgncvengr

Programming

Description

There are two parts to this assignment.

Part 1: Homework

hwk5_AdvPythonScripting.docx

Part 2: Lab

IFT383 Lab5(5).docx

Unformatted Attachment Preview

[IFT 383] Shell & Script Programming with Unix Homework Assigment –Python Control Structure, Function, and File I/O Include your script and a sample run of the output for each of the questions. 1. We want to compute your average test score and print along a congratulatory message if the average is greater than 95%. The pseudocode algorithm is as follow: • • • • • • Get the first test score and its max from the user in the form score/max (eg 35/50) Get the second test score and its max from the user in the form score/max Get the third test score and its max from the user in the form score/max Calculate the average if all test scores are numbers, with 1 decimal digit Display the average If the average is greater than 95%, congratulate the user Turn the above algorithm into a Python program. 2. Suppose you deposit money into a savings account and let it accumulate at 4% interest compounded annually. Write a program, using while loop, to determine when you will be a millionaire. Take the initial balance from the user. Sample Run Enter initial deposit: 123456 In 54 years you will have a million dollars. 3. Write a Python program that requests a word as input from the user and then displays it backward. Hint: Create a string consisting of the first letter of the word, and then successively append each subsequent letter to the front of the string. Sample Run Enter a word: zeus The reversed word for zeus is suez 4. Write a function called firstName that extracts and returns the first name from a full name. Assume the full name is in the form first middle (or middle initial) last Write a Python program called function_activity.py that uses the function above. Your program must take the full name from the user and print the first name. Sample Run Enter a person’s full name: Franklin Delano Roosevelt First name: Franklin [IFT 383] Shell & Script Programming with Unix 5. Consider the file score below, which provides the scores of each student in five different assessments. $ cat score pchen72 50 71 55 93 115 jmaszk 45 76 49 88 102 bvbui 59 78 53 96 145 mtcrowle 33 65 39 82 100 mrchave3 54 77 56 98 158 Write a Python script called file_activity.py that computes the final percentage score for each student, as well as the class average. The max score is 450 and must be set as constant. The output should be as below (rounded to the nearest integer): Total number of records: 5 Final score for pchen72 = 85% Final score for jmaszk = 80% … Class Average = 86% The header line should show: Final Score Computation [IFT 383] Shell & Script Programming with Unix LAB ACTIVITY: PYTHON CONTROL STRUCTURE Directions 1) Your programs must be save in a file with extension .py so they can be run from the command line as: python youfile.py 2) For every program, you must first develop an algorithm. 3) Your output should be formatted exactly as the sample runs provided, including the precisions for decimal numbers. Introduction The learning objectives are two-fold: 1) Develop proper algorithm for solving a given program. The instructions in the algorithm will serve as comments in your program 2) Turn the algorithm into code Activities Part 1: Checking Palindromes A string is a palindrome if it reads the same forward and backward. The words “mom,” “dad,” and “noon,” for instance, are all palindromes. The problem is to write a program that prompts the user to enter a string and reports whether the string is a palindrome. One solution is to have the program check whether the first character in the string is the same as the last character. If so, then the program can check whether the second character is the same as the second-to-last character. This process continues until a mismatch is found or all the characters in the string are checked, except for the middle character if the string has an odd number of characters. To implement this idea, you can use two variables, say low and high, to denote the position of two characters at the beginning and the end in a string s. Write a function isPalindrome() that takes a string and return True if it is a palindrome, and False if not. Write the main() function that takes the string from the user and passes it to the isPalindrome() function, then prints the appropriate message Sample Run Enter a string: noon noon is a palindrome Page | 1 [IFT 383] Shell & Script Programming with Unix Enter a string: moon moon is not a palindrome Part 2: Predicting the Future Tuition Suppose that the tuition for a university is $10,000 this year and increases 7% every year. In how many years will the tuition have doubled? Before you attempt to write a program, first consider how to solve this problem by hand. Sample Run: Tuition will be doubled in 11 years Tuition will be $21048.52 in 11 years Submissions Submit all the required files through Blackboard. You are to submit two (2) files: (1) A zip file of your 2 .py files (2) This document with your test run incorporated. Note that the comments (which result from writing an algorithm first) are a major part of the grading criteria. Page | 2
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

I finished all tasks and I am read...


Anonymous
I was having a hard time with this subject, and this was a great help.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags