It is important to remember that there are two ways to enter your code into Python: the shell and the text editor. Make sure to play around and start getting comfortable with them both.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Exercise 1 Solution | |
class Square: | |
square_list = [] | |
def __init__(self): | |
self.square_list.append(self) | |
# Exercise 2 Solution |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print("Hello, World!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print(8 * 9) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#exercise 1 | |
print("It was a bright cold day in April, and the clocks were striking thirteen."[:33]) | |
#exercise 2 | |
print(""" "Hi" """) | |
#exercise 3 | |
print('A screaming comes across the sky.'.replace('s', '$')) | |
#exercise 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# exercise 1 | |
for c in "Camus": | |
print(c) | |
# exercise 2 | |
print("aldous was born in 1894.".capitalize()) | |
# exercise 3 | |
print("Where now? Who now? When now?".split('?')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def convert(a_string): | |
return float(a_string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Functions Exercise 1 | |
def square(n): | |
return n ** 2 | |
# Functions Exercise 2 | |
def print_string(a_string): | |
print(a_string) | |
# Functions Exercise 3 | |
def opt(a, b, c, d=1, f=2): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Exercise Solution 1 | |
class Stack: | |
def __init__(self): | |
self.items = [] | |
def is_empty(self): | |
return self.items == [] | |
def push(self, item): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Arithmetic Operators Exercise 1 | |
x = 15 | |
y = 4 | |
print(x % y) | |
# Arithmetic Operators Exercise 2 | |
print(30//4) | |
# Arithmetic Operators Exercise 3 |
NewerOlder