18-SEP-18:Created for Evening north class after mess with West. Scanned images and code snippets are critical.
11-SEP-2023:Began conversion process for migrating this project to python 1 at Carlow
Might we be friends? Decision logic exercise
- Flow diagram: Author’s paper folder and/or git respository contains a logic flow chart whose components accurately reflect how the program actually functions, including all branching logic. User info: Program asks the user for their name. Program then greets the user by name and displays the purpose of the program. Friend compatibility questions: Program asks the user at least 6 questions that require an integer or float response.
- At least half of those questions result in a conditional “reply” statement based on the user’s input. e.g. “oh, great, you like airports, too”
- Friend index: Program generates an overall numeric score based on the user responses which matches the flow chart logic for point adjustment.
- Friend potential determination: Program implements logic to determine the user’s potential friend compatibility based on the embedded weightings of each question. Program displays this information in some quantitative form such as conveying the percentage of possible points the user accrued.
Start Here: Jump to a section
Project steps and code samples
- Flow chart on paper: Create a friend compatibility flow chart on paper like the ones shown below. Use our module guide on flow charting and if/else blocks as your reference. Remember, for our first draft, we'll only be gathering integer responses from the user. Once this works, you can work on String comparisons.
- Review sample code: Study the sample code with decision logic only that shows how to code up a single question with a hard-coded response
- Code it up: Write a draft version of your program like the previous sample in PyCharm:
- Test: Test your code ruthlessly! Make sure the logic works as the flow chart shows. Adjust your flow chart if you made mistakes.
- Comment your code sufficiently that another programmer of your level could read your code and understand its inner workings
- Sync: Make sure your hand-written flow chart matches how your program actually executes. Adjust one or the other to make them match.
- Share: Upload your code: Create a gitlab account if you don't already have one using this step-by-step guide.
- After all the questions have been inputted, create code that prints a neat summary of each question's answer and how that answer factored into the overall compatibility score.
- Add one or more questions that ask the user for text input in response to a question. Check their response against possible responses and adjust the compatibility score accordingly. Check out these cool string operations in PythonLand for comparing on case, such as converting all to lowercase and then comparing.
- Make your code more robust by surrounding each input() call with try: and except: to provide the user feedback that the answer they submitted is invalid. For starters, you can just skip the question, or you can get fancier and use a while() structure to ask the question again if an exception occurs. Check out the w3 schools on try except in python. PythonLand also has a decent tutorial on exceptions.
- Enclose your entire program in a looping mechanism so multiple user's compatibility scores can be assembled and compared at the end of all the candidates. Write code that allows for the user to signal the end of new candidates and display summary and comparison data related to friend compatibility.
Sample program output and source code
When fully-baked, a sample program output can look like figure 4
wb_incandescentSample flow charts
Legacy students have authorized the sharing of their work for the benefit of future javas at CCAC. Use their work as launchpads for yours.
Zoom in on images
On Win/Linux, Hold down control and engage your mouse's scroll ball to zoom.
(c)2023 technologyrediscogvery.net | content can freely reproduced according to the site's content use agreement.