Run update21, if you haven't already, to create the cs21/labs/03. Then cd into your cs21/labs/03 directory and create the python programs for lab 3 in this directory (handin21 looks for your lab 3 assignments in your cs21/labs/03 directory):
$ cd cs21/labs/03 $ pwd /home/your_user_name/cs21/labs/03
Your programs are graded on both correctness and style. Please review
the comments regarding programming style on the main page.
A: 92-100 B: 82-91 C: 72-81 D: 60-71 F: below 60Write a program that takes as input a numeric score and prints out its letter grade equivalent. Here are some sample runs of a working program:
$ python grades.py This program computes a letter grade given a numeric score Enter the numeric score: 91 The letter grade equivalent is: B This program computes a letter grade given a numeric score Enter the numeric score: 63 The letter grade equivalent is: D This program computes a letter grade given a numeric score Enter the numeric score: 92 The letter grade equivalent is: A
Write a program, in a file named encode.py, that asks the user to enter a phrase and a cyclic shift value, and produces an encoded string by applying the cyclic cipher method to just the alphabetic characters in the phrase. Your solution should encode ONLY upper and lower case characters in the phrase.
A cyclic cipher, with a shift value of 3 will encode the character 'a' as the character 'd', the character 'b' as 'e', and so on (each character's encoding is shifted 3 characters to the right). A cyclic cipher wraps the encoding around the alphabetic characters, so that in this example, 'w' is encoded as 'z', 'x' is encoded as 'a', 'y' is encoded as 'b', and 'z' is encoded as 'c'. You can think of this as encoding where the alphabet is arranged in a circle, and the shift amount tells you how many places in one direction to move to find the encoding of any letter of the alphabet.
Here is what a few runs of your program might look like:
$ python encode.py This program encodes a phrase using a cyclic cipher Enter a phrase: Hello there, Zoe! What is happening??? Enter a shift value: 4 The encoded phrase is: Lipps xlivi, Dsi! Alex mw lettirmrk??? $ python encode.py This program encodes a phrase using a cyclic cipher Enter a phrase: yee ha!!! Enter a shift value: 1000 The encoded phrase is: kqq tm!!!Hints for solving: I'd suggest approaching this problem in the following way:
$ python stars.py This program prints out two different patterns of stars. Enter a value for the size of the pyramid of stars: 10 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Enter a value for the size of the diamond: 4 * * * * * * * * * * * * * * * * $ python stars.py This program prints out two different patterns of stars. Enter a value for the size of the pyramid of stars: 6 * * * * * * * * * * * * * * * * * * * * * Enter a value for the size of the diamond: 9 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Write a program that takes as input the size of the pattern to print, and prints the following box of stars:
$ python starbox.py This program prints out a box of stars Enter a value for the size of the box: 8 * * * * * * * * | * * * * * * * * * * * * * * * ## | ## * * * * * * * * * * * * * #### | #### * * * * * * * * * * * ###### | ###### * * * * * * * * * ######## | ######## * * * * * * * ########## | ########## * * * * * ############ | ############ * * * ############## | ############## * * ############## | ############## * * * ############ | ############ * * * * * ########## | ########## * * * * * * * ######## | ######## * * * * * * * * * ###### | ###### * * * * * * * * * * * #### | #### * * * * * * * * * * * * * ## | ## * * * * * * * * * * * * * * * | * * * * * * * * $ python starbox.py This program prints out a box of stars Enter a value for the size of the box: 5 * * * * * | * * * * * * * * * ## | ## * * * * * * * #### | #### * * * * * ###### | ###### * * * ######## | ######## * * ######## | ######## * * * ###### | ###### * * * * * #### | #### * * * * * * * ## | ## * * * * * * * * * | * * * * *