Chat with us, powered by LiveChat Touchstone 4: Python Journal Project ASSIGNMENT: For this project, you will learn how to effectively plan, design, develop, and test an original program of your choosing. This program i - Writingforyou

Touchstone 4: Python Journal Project ASSIGNMENT: For this project, you will learn how to effectively plan, design, develop, and test an original program of your choosing. This program i

 

Touchstone 4: Python Journal Project
ASSIGNMENT: For this project, you will learn how to effectively plan, design, develop, and test an original program of your choosing. This program is your choice and it can be as complex as you wish. The goal is to start with an idea for your program and then step through the process of most phases of the development lifecycle to turn your idea into an actual program. This includes planning out the algorithm using pseudocode, coding your program using everything you learned from Units 1-3, and finally testing and debugging your program to make sure it fulfills your intended purpose. Being able to create your own program can be beneficial in any career field. Anything that can be programmed or automated in any industry could make your work a lot easier. Even as a hobby, it can give you a reference point to have a better understanding of how to deal with common issues. Using basic Python to automate menial tasks can save you time and money! Whether you were in this class to learn programming at a professional level or if it’s just for fun, you will benefit from learning coding as a foundation of your technical skills.

For this Touchstone, you will fill out a journal (template link below) which has five sections that correspond to the five steps you will complete for your final project. Use this template to write your journal responses for each section of the project. When you have finished, you will submit this journal as a Word .doc/docx.

Python Journal Template

The following Example Python Journal Submission will be helpful to you as you work on this assignment and shows acceptable submissions for each entry.

Example Python Journal Submission

In order to foster learning and growth, all work you submit must be newly written specifically for this course. Any recycled work will be sent back with a 0, and you will be given one attempt to redo the Touchstone.

A. Directions

Step 1: Download and review the Python Journal Template.

Step 2: Review section C (Requirements) to get acquainted with the requirements for this Touchstone before you begin writing your journal entries.

Step 3: Follow the directions for each part of the journal template. Make sure to include in your response all the elements listed under the Requirements section. Prompts in the Inspiration section are not required; however, they may help you to fully think through your response.

  • Follow the journal creation process that is presented in your Unit 4 lessons to ensure you write a thorough journal entry. There is also an example of a successful journal entry for each submission in Example Python Journal Submission.
  • Review section B (Rubric) to make sure you have an understanding of how each journal entry will be graded.

Step 4: Once your journal is complete, including the code link, submit your journal for grading.

  • There is a help video on “How to submit your Touchstone” in the first lesson of Unit 4 (Python Touchstone Overview)

B. Rubric

Advanced (100%)Proficient (85%)Acceptable (75%)Needs Improvement (50%)Non-Performance (0%)

PART 1: Defining Your Problem (16 points)

State the problem you are planning to solve.The student clearly stated the problem they are trying to solve, including what the program is expected to do to solve the problem and any necessary inputs and outputs required for the program.The student clearly stated the problem they are trying to solve, including answers to most of the required questions.The student clearly stated the problem they are trying to solve, including answers to some of the required questions.Either the student did not clearly state the problem they are trying to solve and/or did not include answers to most of the required questions.No problem was identified and/or no details were given for the expected solution.

PART 2: Working Through Specific Examples (16 points)

Write down clear and specific steps to solve a simple version of the problem you identified in Part 1.The steps to solve the problem are in English and easily understood and appear in logical order. The journal entry fully satisfies the requirements.The steps to solve the problem are in English and easily understood, appear in logical order, however some minor steps may be missing. The journal entry mostly satisfies the requirements.The steps to solve the problem are in English but may not be in logical order or may be missing some steps. The journal entry barely satisfies the requirements.The steps to solve the problem are in English but highly illogical, confusing, or missing critical step(s) and /or the journal entry does not satisfy the requirements.No steps were provided in English and/or no answers to the required questions were submitted.

PART 3: Generalizing Into Pseudocode (16 points)

Write out the general sequence your program will use in pseudocode, including all specific examples you provided in Part 2.The pseudocode submitted encapsulates the full functionality of the program and includes common program elements. The pseudocode is clearly laid out and readable to a person that does not know Python.The pseudocode submitted encapsulates most of the functionality of the program including common program elements. The pseudocode is clearly laid out and readable to a person that does not know Python.The pseudocode submitted encapsulates most of the functionality of the program including common program elements. However, the pseudocode is not clearly laid out and readable to a person that does not know Python.The pseudocode submitted does not encapsulate the functionality of the program to include common program elements. The pseudocode is also not clearly laid out and readable to a person that does not know Python.No pseudocode was submitted and/or the pseudocode submitted was not understandable.

PART 4: Testing Your Program (16 points)

While writing and testing your program code, describe your tests, record any errors, and state your approach to fixing the errors.Entry consists of a thorough explanation of the testing utilized and why, recording the error(s) found, and the approach to fixing the error(s) for each of the test cases.Entry consists of a thorough explanation of the testing utilized; including answering most of the required questions.Entry consists of a thorough explanation of the testing utilized; including answering some of the required questions.Entry does not give a thorough explanation of the testing utilized and/or does not include answers to the required questions.No testing explanation was provided and/or no answers to the required questions were submitted.

PART 5: Commenting Your Program (16 points)

Submit your full program code, including thorough comments describing what each portion of the program should do when working correctly.The provided code in the journal entry includes comments that thoroughly describe the program flow to a degree that a non-programming individual can easily follow the steps and conclude the outcome of the program.The provided code in the journal entry includes comments that describe the program flow to a degree that a non-programming individual should be able to follow the steps and conclude the outcome of the program. There could be some additional comments needed or added clarity.The provided code in the journal entry includes some comments on the program flow that may not be clear to a non-programming individual and/or may be missing some comments that would make the flow easier to understand.The provided code in the journal entry includes minimal comments to explain the program flow and/or is missing comments that would make the program easy for a non-programming individual able to follow the steps and conclude the outcome of the program.The provided code in the journal entry did not include comments and/or comments provided do not provide any description or clarity on program flow.

PART 6: Your Completed Program (20 points)

Provide the Replit link to your full program code.The program works as expected. No errors present. Any required user input executed correctly. Output was as expected.Performance level not used.Performance level not used.Program did not work as expected however, detailed comments were given to why the student felt it did not run including testing efforts.No link to a program was submitted for testing.

C. Requirements

The following requirements must be met for your submission:

  • Use a readable 11- or 12-point font.
  • All writing must be appropriate for an academic context. Follow academic writing conventions (correct grammar, spelling, punctuation, and formatting).
  • Journal entries must be original and written for this assignment; plagiarism of any kind is strictly prohibited.
  • Submission must include your name and the date (included in the template).
  • Include all of the journal parts in a single file. Acceptable file formats include .doc and .docx.
  • Include your Replit Share link at the appropriate location in the journal template.

Python Journal Template

Directions: Follow the directions for each part of the journal template. Include in your response all the elements listed under the Requirements section. Prompts in the Inspiration section are not required; however, they may help you to fully think through your response.

Remember to review the Touchstone page for entry requirements, examples, and grading specifics.

Name:

Date:

Final Replit Program Share Link:

Complete the following template. Fill out all entries using complete sentences.

PART 1: Defining Your Problem

Task

State the problem you are planning to solve.

Requirements

· Describe the problem you are trying to solve for.

· Describe any input data you expect to use.

· Describe what the program will do to solve the problem.

· Describe any outputs or results the program will provide.

Inspiration

When writing your entry below ask yourself the following questions:

· Why do you want to solve this particular problem?

· What source(s) of data do you believe you will need? Will the user need to supply that data, or will you get it from an external file or another source?

· Will you need to interact with the user throughout the program? Will users continually need to enter data in and see something to continue?

· What are your expected results or what will be the end product? What will you need to tell a user of your program when it is complete?

<Write your journal entry response here>

PART 2: Working Through Specific Examples

Task

Write down clear and specific steps to solve a simple version of your problem you identified in Part 1.

Requirements

Complete the three steps below for at least two distinct examples/scenarios.

· State any necessary input data for your simplified problem.

· Write clear and specific steps in English (not Python) detailing what the program will do to solve the problem.

· Describe the specific result of your example/scenario.

Inspiration

When writing your entry below ask yourself the following questions:

· Are there any steps that you don’t fully understand? These are places to spend more time working out the details. Consider adding additional smaller steps in these spots.

· Remember that a computer program is very literal. Are there any steps that are unclear? Try giving the steps of your example/scenario to a friend or family member to read through and ask you questions about parts they don’t understand. Rewrite these parts as clearly as you can.

· Are there interesting edge cases for your program? Try to start one of your examples/scenarios with input that matches this edge case. How does it change how your program might work?

<Write your journal entry response here>

PART 3: Generalizing Into Pseudocode

Task

Write out the general sequence your program will use, including all specific examples/scenarios you provided in Part 2.

Requirements

· Write pseudocode for the program in English but refer to Python program elements where they are appropriate. The pseudocode should represent the full functionality of the program, not just a simplified version. Pseudocode is broken down enough that the details of the program are no longer in any paragraph form. One statement per line is ideal.

Help with writing pseudocode

· Here are a few links that can help you write pseudocode with examples. Remember to check out part 3 of the Example Journal Template Submission if you have not already. Note: everyone will write pseudocode differently. There is no right or wrong way to write it other than to make sure you write it clearly and in as much detail as you can so that it should be easy to convert it to code later.

· https://www.geeksforgeeks.org/how-to-write-a-pseudo-code/

· https://www.wikihow.com/Write-Pseudocode

Inspiration

When writing your entry below ask yourself the following questions:

· Do you see common program elements and patterns in your specific examples/scenarios in Part 2, like variables, conditionals, functions, loops, and classes? These should be part of your pseudocode for the general sequence as well.

· Are there places where the steps for your examples/scenarios in Part 2 diverged? These may be places where errors may occur later in the project. Make note of them.

· When you are finished with your pseudocode, does it make sense, even to a person that does not know Python? Aim for the clearest description of the steps, as this will make it easier to convert into program code later.

<Write your pseudocode here>

PART 4: Testing Your Program

Task

While writing and testing your program code, describe your tests, record any errors, and state your approach to fixing the errors.

Requirements

· For at least one of your test cases, describe how your choices for the test helped you understand whether the program was running correctly or not.

For each error that occurs while writing and testing your code:

· Record the details of the error from Replit. A screenshot or copy-and-paste of the text into the journal entry is acceptable.

· Describe what you attempted in order to fix the error. Clearly identify what approach was the one that worked.

Inspiration

When writing your entry below ask yourself the following questions:

· Have you tested edge cases and special cases for the inputs of your program code? Often these unexpected values can cause errors in the operation of your program.

· Have you tested opportunities for user error? If a user is asked to provide an input, what happens when they give the wrong type of input, like a letter instead of a number, or vice versa?

· Did the outcome look the way you expected? Was it formatted correctly?

· Does your output align with the solution to the problem you coded for?

<Record your errors and fixes here>

PART 5: Commenting Your Program

Task

Submit your full program code, including thorough comments describing what each portion of the program should do when working correctly.

Requirements

· The purpose of the program and each of its parts should be clear to a reader that does not know the Python programming language.

Inspiration

When writing your entry, you are encouraged to consider the following:

· Is each section or sub-section of your code commented to describe what the code is doing?

· Give your code with comments to a friend or family member to review. Add additional comments to spots that confuse them to make it clearer.

<Copy your full program code here, including comments>

PART 6: Your Completed Program

Task

Provide the Replit link to your full program code.

Requirements

· The program must work correctly with all the comments included in the program.

Inspiration

· Check before submitting your touchstone that your final version of the program is running successfully.

<Provide the link to your program here>

Python Journal Template 1

,

Python Journal Template Directions: Follow the directions for each part of the journal template. Include in your response all the elements listed under the Requirements section. Prompts in the Inspiration section are not required; however, they may help you to fully think through your response.

Remember to review the Touchstone page for entry requirements, examples, and grading specifics.

Name: Learner

Date: 03/15/2022

Final Replit Program Share Link: https://replit.com/@Sophia-IPP-Replit/Unit4-Final-Demo#main.py

Complete the following template. Fill out all entries using complete sentences.

Example Python Journal Submission 1

PART 1: Defining Your Problem

Task State the problem you are planning to solve.

Requirements ● Describe the problem you are trying to solve for. ● Describe any input data you expect to use. ● Describe what the program will do to solve the problem. ● Describe any outputs or results the program will provide.

Inspiration When writing your entry below ask yourself the following questions:

● Why do you want to solve this particular problem? ● What source(s) of data do you believe you will need? Will the user need to supply that data, or

will you get it from an external file or another source? ● Will you need to interact with the user throughout the program? Will users continually need to

enter data in and see something to continue? ● What are your expected results or what will be the end product? What will you need to tell a

user of your program when it is complete?

<Write your journal entry response here>

Casino craps is a dice game in which players bet on the outcome of the roll of a pair of dice. The problem to solve is to help a user better understand the odds of winning and losing at casino craps at an actual casino. I will create a simulation of the craps game to solve this problem. When executed, the program will first provide a sample game as an example for the user. Second, the program will ask the user to input the number of games to play. The program will play the requested number of games. After the last game is played, the program will output (display) the results of the games. The program will store a record of the simulations in an external log file. By playing the game multiple times and reviewing the statistics, users will get a better understanding of their chances of winning.

Example Python Journal Submission 2

PART 2: Working Through Specific Examples

Task Write down clear and specific steps to solve a simple version of your problem you identified in Part 1.

Requirements Complete the three steps below for at least two distinct examples/scenarios.

● State any necessary input data for your simplified problem. ● Write clear and specific steps in English (not Python) detailing what the program will do to

solve the problem. ● Describe the specific result of your example/scenario.

Inspiration When writing your entry below ask yourself the following questions:

● Are there any steps that you don’t fully understand? These are places to spend more time working out the details. Consider adding additional smaller steps in these spots.

● Remember that a computer program is very literal. Are there any steps that are unclear? Try giving the steps of your example/scenario to a friend or family member to read through and ask you questions about parts they don’t understand. Rewrite these parts as clearly as you can.

● Are there interesting edge cases for your program? Try to start one of your examples/scenarios with input that matches this edge case. How does it change how your program might work?

<Write your journal entry response here>

Scenario 1: Player loses on first roll:

1. Roll two six-sided random dice for the first time, getting a 1 and a 2. 2. Add the values on the top of the two dice, getting 3. 3. The player loses the game.

Scenario 2: Player wins on first roll:

1. Roll two six-sided random dice for the first time, getting a 3 and a 4. 2. Add the values on the top of the two dice, getting 7. 3. The player wins the game.

Scenario 3: Player loses on a few rolls of the dice:

1. Roll two six-sided random dice for the first time, getting a 1 and a 4. 2. Add the values on the top of the two dice, getting 5. 3. The value is not 2, 3, 7, 11, or 12, so the game continues. 4. Roll the two dice again, getting a 3 and a 6.

Example Python Journal Submission 3

5. Add the values on the top of the two dice to get 9. 6. That value is not equal to either 7 or 5, so the game continues. 7. Roll the two dice again, getting a 4 and a 3. 8. Add the values on the top of the two dice to get 7. 9. The player loses the game.

Example Python Journal Submission 4

PART 3: Generalizing Into Pseudocode

Task Write out the general sequence your program will use, including all specific examples/scenarios you provided in Part 2.

Requirements ● Write pseudocode for the program in English but refer to Python program elements where

they are appropriate. The pseudocode should represent the full functionality of the program, not just a simplified version. Pseudocode is broken down enough that the details of the program are no longer in any paragraph form. One statement per line is ideal.

Help with writing pseudocode ● Here are a few links that can help you write pseudocode with examples. Remember to check

out part 3 of the Example Journal Template Submission if you have not already. Note: everyone will write pseudocode differently. There is no right or wrong way to write it other than to make sure you write it clearly and in as much detail as you can so that it should be easy to convert it to code later.

○ https://www.geeksforgeeks.org/how-to-write-a-pseudo-code/ ○ https://www.wikihow.com/Write-Pseudocode

Inspiration When writing your entry below ask yourself the following questions:

● Do you see common program elements and patterns in your specific examples/scenarios in Part 2, like variables, conditionals, functions, loops, and classes? These should be part of your pseudocode for the general sequence as well.

● Are there places where the steps for your examples/scenarios in Part 2 diverged? These may be places where errors may occur later in the project. Make note of them.

● When you are finished with your pseudocode, does it make sense, even to a person that does not know Python? Aim for the clearest description of the steps, as this will make it easier to convert into program code later.

<Write your pseudocode here>

Function play() Set the rolled value to roll first dice + roll second dice If the rolled value is equal to 2, 3 or 12

Set player status to lose Else If the rolled value is equal to 7 or 11

Set player status to win Else

Set point value to rolled value Set the rolled value to roll first dice + roll second dice If the rolled value is equal to 7

Set player status to lose Else If rolled value is equal to point value

Set player status to win

Example Python Journal Submission 5

Else Set the rolled value to roll first dice + roll second dice If the rolled value is equal to 7

Set player status to lose Else If rolled value is equal to point value

Set player status to win Else

Reroll again and continue over and over.

Main Program Set Wins = 0 Set Losses = 0 Set Total of Win Rolls = 0 Set Total of Loss Rolls = 0 Set Games Played to 0

Input Times to Play from user Loop until Games Played = Times to Play

Add 1 to Games Played Call function play() Get if the player won or lost Get the number of rolls If the player won

Add 1 to Wins Add the rolls values to the Total of Win Rolls

Else if player lost Add 1 to Losses Add the rolls values to the Total of Loss Rolls

Average Number of Rolls Per Win = Total of Win Rolls / Wins Average Number of Rolls Per Loss = Total of Loss Rolls / Loss Winning Percentage = Wins / Games Played Output results

Example Python Journal Submission 6

PART 4: Testing Your Program

Task While writing and testing your program code, describe your tests, record any errors, and state your approach to fixing the errors.

Requirements ● For each test case, describe how your choices for the test helped you understand whether the

program was running correctly or not. For each error that occurs while writing and testing your code:

● Record the details of the error from Replit. A screenshot or copy-and-paste of the text into the journal entry is acceptable.

● Describe what you attempted in order to fix the error. Clearly identify what approach was the one that worked.

Inspiration When writing your entry below ask yourself the following questions:

● Have you tested edge cases and special cases for the inputs of your program code? Often these unexpected values can cause errors in the operation of your program.

● Have you tested opportunities for user error? If a user is asked to provide an input, what happens when they give the wrong type of input, like a letter instead of a number, or vice versa?

<Record your errors and fixes here>

After changing my initial code in the main program to check for invalid user entries by adding the try and except statements, I noticed it handled the invaid input (no error) but would stop after that and not request another entry from the user. Here was my initial code:

def main(): #play one game print("Running one sample game in full:") playOneGame() number = 0 #play multiple games based on the entry by the user user_input = input("How many games would you want to have tested: ")

try: number = int(user_input) playMultipleGames(number)

except ValueError: print("Please enter in a number for the number of games.")

And the output did handle the exception of the letter “a” as input but the program stopped. The output looking like this.

Example Python Journal Submission 7

I want the program to prompt the user again to enter another input until a valid number has been entered. I then added a while loop. By using this loop this will repeat while the variable number is equal to zero. The loop will continue to ask the user for a value user until a valid number is set. I changed my code to look like this (while loop statement is bolded):

def main(): #play one game print("Running one sample game in full:") playOneGame() number = 0 #play multiple games based on the entry by the user while number == 0: user_input = input("How many games would you want to have tested: ") try: number = int(user_input) playMultipleGames(number)

except ValueError: print("Please enter in a number for the number of games.")

Now after adding in the <code>while</code> loop, I ran the code again and entered in the letter “a” as input. When doing so, the program then prompted me again to enter in the number of games rather than ending the program. This solves the issue of the program ending now.

Example Python Journal Submission 8

PART 5: Commenting Your Program

Task Submit your full program code, including thorough comments describing what each portion of the program should do when working correctly.

Requirements ● The purpose of the program and each of its parts should be clear to a reader that does not

know the Python programming language.

Inspiration When writing your entry, you are encouraged to consider the following:

● Is each section or sub-section of your code commented to describe what the code is doing? ● Give your code with comments to a friend or family member to review. Add additional

comments to spots that confuse them to make it clearer.

<Copy your full program code here, including comments>

Comments are colored in red. There are three modules/classes to this program.

—-The main.py file—-

#This game plays the game of dice called craps where #Players would bet on the outcomes of a pair of dice rolls. #If the sum of the dice is 2, 3 or 12, the player loses immediately. #If the sum of the dice is 7 or 11, they win immediately. #The purpose of the program is to simulate the results between two players

from player import Player

#Importing the datetime to get the current date and time from datetime import datetime

#This function is created to play a single game and print out the results after each roll. def playOneGame():

player = Player() while not player.isWinner() and not player.isLoser():

player.rollDice() print(player)

if player.isWinner(): print("You win!")

else: print("You lose!")

#This function is created to play multiple games and outputs the results based on the number of games selected.

Example Python Journal Submission 9

def playMultipleGames(number): #Initializing the variables wins = 0 losses = 0 winRolls = 0 lossRolls = 0

#Looping through the number of executions for count in range(number):

player = Player() hasWon = player.play() rolls = player.getNumberOfRolls() if hasWon:

wins += 1 winRolls += rolls

else: losses += 1 lossRolls += rolls

#Calculating the statistics print("The total number of wins is", wins) print("The total number of losses is", losses) if wins > 0: print("The average number of rolls per win is %0.2f" %

(winRolls / wins)) if losses > 0: print("The average number of rolls per loss is %0.2f" %

(lossRolls / losses))

print("The winning percentage is %0.3f" % (wins / number)) print("The multi-game has been saved into the log.")

logStats(wins, losses, winRolls, lossRolls, number)

#This function will log each multi game run to include the date/time and the details of the run def logStats(wins, losses, winRolls