Recap

Complete each question below. Use the lectures and feel free to ask for help.

  • What is a literal?
  • What type is this: False?
  • What is the difference between 1233 and 12.33 (aside from their values)?
  • Create an empty list and then populate it with information about the werewolf, Jacob
    • Iterate through the list and print out the details
    • Now add if statements to each detail and make a comment on their age and/or name

REMEMBER: You will need to handle the different types

  • Find your favourite line from any of the Twilight movies, assign it to a variable.

Loop through the list and print out every word that is > 4 characters. DO NOT print the word if the word is Jacob or love.

  • What is the difference between instantiation and declaration? Explain them in Python. Provide examples.
  • Create a while loop that loops through a user input and exits when the user types 'save'. If they do not, add what they typed to a variable. Print the length of the variable when the while loop exits, as well as the mean length of all words entered.
  • What is the difference between a REPL and a script?
  • If we call the execution of code line by line in Python 'the flow', what would if statements be an example of?
  • Modify the while loop you wrote above to read input from the user, save numbers to one list and strings to another.

If, when the while loop exits, both lists have the same length then use a for loop to iterate through and multiple the element of the string list by the corresponding element of the numerical list.

  • Is the below code (results of print statements in comments) correct? Explain why it is/is not.
str_ex = "Hello"
str_two = str_ex
str_two += " Bella"
print(str_ex) #Hello Bella
print(str_two) #Hello Bella
  • What is the difference between interpreted and compiled as a language?
  • Write a while loop that takes a numeric input from the user (warning them if it is not a number) and then takes a second number to act as the power. I.e. input_one ^ input_two. The next input number they should use should be the answer to the previous sum.

For example:

Input 1: 12 Input 2: 2 Answer: 144 Input 1: 144 Input 2: 3 Answer: 2,985,984 etc etc

The loop should break if the user does not input the right answer and it cannot give the answer to the user

  • Create a list of the characters in the word 'Edward' and then create a string variable of the same word.

Without the changing the type of these variables, check through to ensure they are the same. Use iteration as one approach and then try using the String join method.

  • Perform equality and identity checks, explain the result.

EXTRA

All done? Happy with it all? WELL DONE

Create a game that uses any form of iteration you choose. Allow the user to move using keywords (up, down, left etc) and then provide them with options of things to do in each room. If they press q at any time then exit the game.

For extra, extra credit: Allow the input to be case insensitive.

Still done? GREAT! Allow the user to create custom shortcuts for