These are some practice exercises for you to prepare for Tuesday’s quiz! As mentioned in the FAQ, the quiz will essentially make you write programs to test your understanding of the content so far, similar to the exercises! We won’t be as decriptive with these in this practice because we want you to be able to recognize when to use certain concepts based off what we are asking you to do - that’s the main challenge! Also solutions along with videos explainations will be released at some point, so we want you to do as much as you can on your own :)
Open the course workspace in VS Code (File > Open Recent > comp110-workspace-…) and open the File Explorer pane. Expand exercises.
Right click on the word exercises and select “New Folder”.
Name the folder exactly: practice and create a new file called quiz00.py.
Write a function called ayeee that takes in a string, and returns the count of how many ‘a’s’ are in that string
ayeeeayeeestrintstr will be of variable length meaning your function should be able to handle strs of any length.Write a function called ayooo that takes three strings, returns whether or not any of the strings has greater than 10 a’s.
ayoooayooostrsboolayeee function that you previously!str that’s greater than 10.or, and. This can be done with one line of code! Do not stress if you cannot get it to be one line, it is just something interesting and challenging to think about!Write a function called yay_pass_fail takes in a course grade (before the exam) and a major, and returns the final exam grade needed in order to pass the class (at least a 60).
yay_pass_failyay_pass_failfloat, a strfloatWrite a function called time_loop that takes in a string that will ask the user repeatedly “You are in a time loop, enter the password to get out!” until the user will type in that string as the password, to which the time loop will end, and the number of tries it took gets returned.
time_looptime_loopstrintUse the print feature outside of your declared functions to test each one of your functions out! Best way to do this is think of some arguments that you can pass in (that matches the types declared for the function parameters) and have an expected return value in mind. The actual return value should be printed and then compare it with what you expected it to be, and try this for different combinations of them for each function!
While you are not submitting anything for this, it is always good practice to write your meaningful doc strings and have proper style in all your variable names, keeping in mind things such as types, magic numbers, etc.