Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Home Work 4 Include all your solutions in a single .py file. When the code is executed, the following message should appear before start of

Home Work 4

  • Include all your solutions in a single .py file. When the code is executed, the following message should appear before start of each task.

    Press any key to start Task n, where n is the task number (1, 2, or 3) There should be two blank lines before and after this message.

  • The file name should be YourFirstNameLastName.py.

  • Add a substantial amount of comments for each solution. Read the requirements in the syllabus.

  • All applications must be developed using Python 3.x.

  • At least 20% will be deducted for deviation from any instruction in this assignment or in the syllabus.

  • Submission: Submit in the Assignment2 Dropbox in D2L by 11.59 pm on Tuesday March 12, 2019. Email attachments will be not be accepted or graded and will be ignored.

    T ASKS:

  1. The password rules for a login are as follows.

    • have at least eight characters.

    • be mix of uppercase and lowercase alphabets. The first character must be an alphabet.

    • have at least two digits.

    • can have maximum one symbol only from $, #, @

      Write a function in python that checks whether a string is a valid password. Write a python program that prompts the user to enter a password and displays valid password if the rules are followed or invalid password otherwise. You need to handle all possible exceptions.

  2. Write python program to achieve the following functionalities.

    1. Prompt the user for a file name. If you get an answer that begins with q or Q go to step vii.

    2. Read the file that contains four lines with 4 integers on each line separated by a space. Each integer is a positive

      1- or 2-digit number.

    3. Using a function, print the 16 numbers in a square as shown below.

    4. Determine if the numbers form a magic square. In a magic square each row, column and the two diagonals each

      add up to the same sum (always 34) and each value from 1 to 16 is used exactly once in the square. Each of the tests as noted in the next step (step v) should be written as a function that prints necessary messages and returns a True if all of its tests pass and False otherwise. Your main function should print It is a magic square only if all the tests pass. Each function should be appropriately named and have the entire square as its only input parameter.

    5. Print whether or not it is a magic square. If it is not, print all of the reasons found:

      1. Bad row sum = ___

      2. Bad column sum = ___

      3. Bad diagonal sum = ___

      4. Not every integer used exactly once.

    6. Loop back to step i and do this for another square.

    7. Print Quitting.

Sample output: Which file? sq1.txt

16 3 2 13 51011 8 9 6 7 12 4 15 14 1

It is a magic square.

Which file? sq2.txt 16 3 2 13 9 6 7 12 41514 1 51011 8

Bad diagonal sum = 44 Bad diagonal sum = 40

Your program will be tested with different squares (some magic, some not) to verify that you have performed all the necessary tests to verify that the square is magic. You should make up your own files with numbers, some magic, some not.

You must protect against all possible errors exceptions. 3. A standard letter/number mapping for telephones is:

Write a function getNumber(alphabet), that returns a number, given an uppercase letter. Write a python program that prompts the user to enter a ten digit phone number as a string. The input number may contain mix of letters and digits. The program translates a letter (uppercase or lowercase) to a digit and leaves all digits in their places.

You must protect against errors in all possible user inputs and possible exceptions.

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_2

Step: 3

blur-text-image_3

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

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions