Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Solutions for Notebook 1

# You can print special characters:
print("My first message #1")
print("Another special character: one \ two")

# However, there are some special combinations such as \n that have another meaning. 
# In this case, \n starts a new line.
print("Another special character: one \n two")

# If we wish to print the text \n, we should add another \ to indicate that we do not.
print("Another special character: one \\n two")

print('This is the first string' + 'and this is the second string.')
# The strings are joined.
# Only 0 is False, some examples:
if 0:
    print('0 is True')
else: 
    print('0 is False')
    
if 1:
    print('1 is True')
else: 
    print('1 is False')
    
if -57:
    print('-57 is True')
else: 
    print('-57 is False')
    
if 6/7:
    print('6/7 is True')
else: 
    print('6/7 is False')
a = [2,3,5]
b = (2,3,5)
print(a[0]*2)
print(b[0]*2)
b = list(b)
b[0] = 10
print(b)
4
4
[10, 3, 5]
a = [2,3,5]
b = np.array([2,3,5])

print(2*a) # Multiplying the list is like adding the two lists such that it is repeated. 
print(2*b) # Multiplying the numpy array multplies each value in the array.
even_nr = np.arange(0,10,2)
print(even_nr)
odd_nr = np.arange(1,11,2)
print(odd_nr)

total = np.append(even_nr, odd_nr)
print(total)
total = np.sort(total)
print(total)
total = np.delete(total, 2)
print(total)
print('7*3 =', 7*3)
print('7-3 =', 7-3)
print('7/3 =', 7/3)
print('7**3 =', 7**3)
print('7//3 =', 7//3)
print('7%3 =', 7%3)
# You can chech that the input is always a string.
a = input('type input: ')
print(type(a))
ZeroDivisionError: division by zero You cannot divide by zero, so this results in an error. NameError: name 'practicum' is not defined You cannot use an undefined variable, use a string to print text. TypeError: can only concatenate str (not "int") to str You cannot add a string and an integer. We can add two strings:
print('practicum is great' + str(2))