đĄ You are welcome to jump into rooms in pairs and one of you shares their screen or work on your own. The choice is yours.
â Do I have Python installed?
Every mac comes with Python pre-installed. The version might be different for different macOS systems but for the purpose of this challenge itâs ok.
âś How to open it?
⨠Keyboard Shortcuts Cheat Sheet
Assignment
You have here some challenges to solve, and the purpose is to solve them inside the interactive shell only.
Why canât I run the code normally via a file?
The interactive shell has its benefits - interactivity!
While you can technically run the exercise through a normal file, we want you to practice using the interactive shell.
đ§Ą Mini Challenge #1
You are working in a school, and youâre given a list of all grades in an exam.
grades = [10, 50, 60, 10, 50, 60, 30, 50]
- Copy this list and paste it into the interactive shell.
- Type
print(grades)
and see that you see the list of grades. - Type only
grades
and verify that you got the same result. - In the interactive shell, you donât need to
print
, as opposed to a regular file where you always have to print.
Assignment
- Print only the grades that passed the exam, i.e., got a grade above 60.
- Print âPASSEDâ for grades that have passed and âFAILEDâ for the rest, along with the grade itself.
- Print the grades with added 10% to every grade.
đ Mini Challenge #2
You got a list of websites:
websites = ["google.com", "youtube.com", "facebook.com", "twitter.com", "instagram.com", "baidu.com", "wikipedia.org","yandex.ru", "yahoo.com"]
- Print only the websites that end with .com.
- Print all the websites with .net instead of .com.
- Print only the website name capitalized without the extension (Output: Wikipedia, TwitterâŚ).
đ Mini Challenge #3
You are given a dictionary of restaurants and their ratings:
rest_rating = {
"McDonald's": 6,
"Foo": 10,
"Ramen": 8,
"Starbucks": 5
}
- Print all the names of the restaurants, along with their rating, in the format âFoo was rated 10â.
- Print only the restaurant names that got above 7.
- Delete the rating of âStarbucksâ.
đ Mini Challenge #4
Explore libraries with the Python interactive shell.
- Import the
random
module to the interactive shell by typingimport random
. - View the functions inside the module by typing
dir(random)
. - Choose a function that seems interesting to you. For example,
random.foo
(this function doesnât really exist). - Use the
help
command to read the documentation (in the interpreter) about the function:help(random.foo)
. - After you finish reading the documentation, you may need to press
q
to exit it. - Use the information that you read and use the function, to explore it.
- Feel free to explore more functions!