POTD 7 - caesar.py

Due: Monday, September 26, 11:00 AM

Write a program called caesar.py to decode text that was encoding using the Caesar cipher.

Caesar's cihper works by shifting every letter in a piece of text three characters over, so "A" becomes "D", "B" becomes "E", etc.

An example run of the program might look like:

Enter your cipher text: zhofrph wr xyd!
The decoded phrase is: welcome to uva!

An example run of the program might look like:

Enter your cipher text: fv 1110 lv pb idyrulwh fodvv!!!
The decoded phrase is: cs 1110 is my favorite class!!!

Note: To make it easier, convert all text to lowercase before doing any conversion. We will be checking for lowercase letters only. However, you should allow all punctuation and spacing to go through unchanged.

Submission: Please submit one .py file named caesar.py to the POTD submission system at https://archimedes.cs.virginia.edu/cs1110/. (note the spelling: ae not e or ea; and ar not er)

more ...

POTD 6 - roman.py

Due: Friday, September 23, 11:00 AM

Write a program called roman.py to compute the roman numeral representation of integers.

Given an integer larger than 0 and less than 4000, convert it to roman numerals. You can find the rules for this at http://literacy.kent.edu/Minigrants/Cinci/romanchart.htm, or simply search for it online.

There are many ways to do this, some more efficient than others. If it works and you wrote it yourself that's good enough.

If the integer they provide is not in the right range, print "Input must be between 1 and 3999"

An example run of the program might look like:

Enter an integer: 1997
In roman numerals, 1997 is MCMXCVII

Another run might look like:

Enter an integer: 5820
Input must be between 1 and 3999

Submission: Please submit one .py file named roman.py to the POTD submission system at https://archimedes.cs.virginia.edu/cs1110/.

more ...

POTD 5 - higher_lower.py

Due: Wednesday, September 21, 11:00 AM

Write a program called higher_lower.py to play a simple guessing game with you.

The computer will pick a number between 1 and 100, then give you 5 guesses. If you guess right, it will say "You win!". If you guess higher or lower than correct, it will say "The number is higher than that." (or lower). If after five guesses they still don't know the number, print "You lose; the number was x." where x was the number you were to guess.

Before the game begins, ask what number to pick. If they say "−1", pick randomly; otherwise, use their number even if it is outside the 1–100 range. Check your notes for how to get a random integer by using the random.randint() method.

An example run of the program might look like:

What should the answer be? 19
Guess a number: 9
The number is higher than that.
Guess a number: 40
The number is lower than that.
Guess a number: 19
You win!

Another run might look like:

What should the answer be? -1
Guess a number: 5
The number is higher than that.
Guess a number: 100
The number is lower than that.
Guess a number: 50
The number is lower than that.
Guess a number: 25
The number is lower than that.
Guess a number: 12
You lose; the number was 7.

You do not have to use loops to make the program work. If, however, you know how to use loops or would like to try, you may do so.

Submission: Please submit one .py file named higher_lower.py to the POTD submission system at https://archimedes.cs.virginia.edu/cs1110/.

more ...

POTD 4 - phone_book.py

Due: Monday, September 19, 11:00 AM

Write a program called phone_book.py that will read in 5 entries into a phone book dictionary. Then, prompt the user to find a number by a given name, and a name by a given number.

An example run of the program might look like this:

Add an entry to the phone book: Mark 434-982-2688
Add an entry to the phone book: Sally 434-893-5665
Add an entry to the phone book: Carl 804-889-4554
Add an entry to the phone book: Carol 804-327-2414
Add an entry to the phone book: Jackie 545-677-0984

Who do you want to call?: Sally
Sally's number is: 434-893-5665

Which number do you want to lookup?: 545-677-0984
That number belongs to: Jackie

Another run might look like:

Add an entry to the phone book: Mark 434-982-2688
Add an entry to the phone book: Sally 434-893-5665
Add an entry to the phone book: Carl 804-889-4554
Add an entry to the phone book: Carol 804-327-2414
Add an entry to the phone book: Jackie 545-677-0984

Who do you want to call?: Bob
That name is not in the phone book.

Which number do you want to lookup?: 111-111-1111
That number is not in the phone book.

Please match our prompts, etc, exactly. Your program should work for any names and phone numbers.

Submission: Please submit one .py file named phone_book.py to the POTD submission system at https://archimedes.cs.virginia.edu/cs1110/.

more ...

POTD 3 - number_list.py

Due: Friday, September 16, 11:00 AM

Write a program called number_list.py that will read in 5 integer values from the user, store them in a list, and perform some basic mathematical operations. Then, prompt the user to remove one item and perform the same operations. You will need to calculate the range (the difference between the largest and smallest numbers) and the average.

An example run of the program might look like this:

Number 1: 1
Number 2: 2
Number 3: 3
Number 4: 4
Number 5: 5

You entered: [1, 2, 3, 4, 5]
The average is: 3.0
The range is: 4
Which item do you want to remove?: 5

The new list has the following values: [1, 2, 3, 4]
The average is: 2.5
The range is: 3

Another run might look like:

Number 1: 34
Number 2: -12
Number 3: 109
Number 4: -34
Number 5: 6

You entered: [34, -12, 109, -34, 6]
The average is: 20.6
The range is: 143
Which item do you want to remove?: -34

The new list has the following values: [34, -12, 109, 6]
The average is: 34.25
The range is: 121

Please match our prompts, etc, exactly. Your program should work for any 5 integers that we provide. You can leave the default precision (i.e. you do not have to format to a certain number of decimal places)

Submission: Please submit one .py file named number_list.py to the POTD submission system at https://archimedes.cs.virginia.edu/cs1110/.

more ...

POTD 2 - dating.py

Due: Wednesday, September 14, 11:00 AM

Write a program called dating.py that can tell you the age range of people you can date.

There is a folk rule that says you can date people as young as half your age plus seven years old. This suggests they can date you if they are as old as twice your age minus thirteen. [https://en.wikipedia.org/wiki/Age_disparity_in_sexual_relationships#The_.22half-your-age-plus-seven.22_rule]

An example run of the program might look like:

How old are you? 17
You can date people between 15 and 21 years old

Another run might look like:

How old are you? 70
You can date people between 42 and 127 years old

Please match our prompts, etc, exactly. Your program should work for any integer age ≥ 14 that we provide.

Submission: Please submit one .py file named dating.py to the POTD submission system at https://archimedes.cs.virginia.edu/cs1110/.

more ...

POTD 1 - c2f.py

Due: Monday, September 12, 11:00 AM

Write a program called c2f.py that can convert Celsius to Fahrenheit.

You should prompt the user for the current temperature in Celsius, then print out the corresponding temperature in Fahrenheit (recall that 5(F − 32) = 9 C). An example run of the program might look like:

What is the temperature in Celsius? 31
It is 87.8 degrees Fahrenheit

Another run might look like:

What is the temperature in Celsius? 100
It is 212.0 degrees Fahrenheit

One quick hint: Consider that you might need to use float to get decimal numbers. Also, if you are having issues with decimal places, check out the format() function found in Section 2.8 of the Gaddis book.

Please match our prompts, etc, exactly. Your program should work for any integer Celsius temperature we provide.

Submission: Please submit one .py file named c2f.py to the POTD submission system at https://archimedes.cs.virginia.edu/cs1110/.

more ...