Read each script and predict what happens before you try it in Scratch.
Answer these questions about sequence, waiting and starting positions.
Read each situation carefully and predict what happens on the stage.
Check that you know your way around Scratch before you build your first real script.
Create a class BankAccount. BankAccount(owner, balance=0) stores owner and balance as attributes. deposit(amount) adds amount to the balance. If amount is 0 or less, raise ValueError. withdraw(amount) subtracts amount. If amount is more than the balance, raise ValueError and leave …
A palindrome reads the same forwards and backwards, like “level”. Write a function is_palindrome(text) that returns True or False. Ignore upper and lower case: “Anna” is a palindrome. Ignore spaces: “never odd or even” is a palindrome.
Write a function count_words(text) that returns a dictionary. Each key is a word and each value is how many times the word appears. Ignore upper and lower case: “Tea” and “tea” are the same word. Keys are lowercase. Remove these …
The list scores holds test results for a class in Keren. Create a list passed with every score that is 50 or more, in the same order. Create average: the average of all scores, rounded to 1 decimal place with …
Write a function grade(score) that returns a letter grade as a string: Score Grade 90 to 100 “A” 80 to 89 “B” 70 to 79 “C” 60 to 69 “D” 0 to 59 “F” If the score is below 0 …
Abel buys some items at a market in Asmara. Write a program that works out his bill. Create total: the sum of bread, milk and coffee. If total is more than 100, Abel gets 10% off: create discount equal to …
