Cheat cheet INFO1110 Viva

docx

School

The University of Sydney *

*We aren’t endorsed by this school

Course

1110

Subject

Computer Science

Date

Jan 9, 2024

Type

docx

Pages

3

Uploaded by ColonelIce13179

Report
Examiner: We will start with 1. Game Title. Please open the program q1. - Can you explain what are variables? Variables are like containers for storing a data value. You create one by giving it a name and assigning a value to it. You can then recall on this value using the assigned name. - What data types did you use in this program? In q1 I have just used string variables. Examiner: Let's move to 2. What's ye called. Please open the program q2. - Explain the input(s), processes and output(s) of this program. Input is only taken once in this program and it is when the program asks for the users name. The processes involve ensuring that the input given is equal to or less than 9 characters, starting with an alphabetical letter, checking if it is one word and making sure it is not just a blank input. The outputs are determined on whether these processes return false or true and will let the user know whether they are or not and whether this name can be pronounced. - How did you format the output according to the given requirements? There are 4 strings outputted in this program. Depending on whether the name meets each requirement – the first 3 strings will either be true or false and if all are true the last string will return true. Examiner: Let's move to 3. Functions. Please open the program name. - What is the difference between this program and q2. In your answer, can you explain one benefit of writing functions? In q3, I have created functions for each condition that can be called upon at any time. This allows me to reuse the code at any time or any number of times in the program. This is very beneficial as it saves time as I will not have to rewrite the code each time to check the if the conditions return true. - What is the scope of variable name in function is_valid_length? How do you determine the value of variable name in this function? The len function is used on variable name to get a integer that can be checked whether it is equal to 9 or less. If it is 9 or less it will return is valid length as true. Examiner: Let's move to 4. The Training. Please open the flowchart you have designed for program q4. - How many conditions did you have in your flowchart? There are 10 conditions in the flowchart and they are represented by the diamonds. - What type of conditionals statements did you use in your program? Why?
I used while loops and if, elif and else statements. I would use a while loop where I would want a certain part of my code to be repeated and I would use if, elif and else statements on sections of the program where depending on a condition or requirement they would be executed. Examiner: Let's move to 5. The Training Again. Please open the flowchart you have designed for program train. Explain, using your flowchart, your loop design. - The flowcharts starts with intro messages and an input that requires the user to press to enter to proceed. They then reach the main loop of this program that contains all of the trapping that is involved in the program. The string “Let’s get your first trap” is always executed at the beginning of the loop and is followed by an input statement that prompts the user to press enter to continue. They are then required to answer another input statement that selects either the Left, Right or no trap. This followed by conditional statements depending on which trap they have chosen. If they have not selected a trap, the variable cheddar is assigned to 0 as Larry will no longer place cheese on a trap. If they have selected a trap the varable cheddar will be assigned to 1. They are then prompted to give their answer to an input statement that asks whether they want to sound the horn. They will only catch a mouse if they have selected the left or right trap and have sounded the horn. They will then be prompted on whether they wish to continue training or not. If they answer no, there is a break statement that exits the loop and if they select yes, the loop statement restarts from the initial “Let’s get your first trap” statement. What type of loop did you use in your program? - I used an event-controlled loop where the condition to terminate the loop is entering no to the input statement that asks whether they want to continue training or not. Examiner: Let's move to a Put-It-All-Together question. Please open the flowchart you have designed for program shop. How did you implement the cheese menu? The cheese menu is implemented entirely within a loop. The loop contains 3 options: option 1 is to buy Cheese, option 2 is to view inventory and option 3 is leave shop. If the user enters 1 or 2 they will repeat the loop and be shown the menu again. The only way to terminate the loop is by entering option 3 to exit the shop. If the game creators requires the Cheese Shop to have a new option 4. Freebies. How would you modify your flowchart and program account for this? You can use the Annotate feature on Zoom to help illustrate your answer on your current flowchart. - If the cheese shop required a 4 th option, I would add an additional conditional statement for option 4. This would be followed by some print statement that show what freebies up for offer. After this I would have an input statement that determines whether the user wants any these freebies or not. This would be followed by conditional statements depending on the users
previous input that will potentially change the inventory and this would be done by changing or creating variables accordingly. They would then reach the end of the option 4 conditional statement and restart the loop. Debugging python3 -m pdb <file name> h(elp) <command> list of available commands n(ext) Continue execution until the next line in the current function is reached or it returns. s(tep) Execute the current line, stop at the first possible occasion (either in a function that is called or on the next line in the current function). p <expression> Evaluate the expression and display its value. c(ontinue) Continue execution, only stop when a breakpoint is encountered. ll List all source code for the current function or frame. l List 11 lines around the current line. q Quit debugging mode.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help