Skip to content
Snippets Groups Projects
Commit 61378c05 authored by Bianca Laker's avatar Bianca Laker
Browse files

Upload New File

parent c39cfe55
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
# Python course - Exercises Gap text
%% Cell type:markdown id: tags:
Correct the Code
%% Cell type:code id: tags:
```
# What is missing here? Expected output: Hi!
('Hi!')
```
%% Cell type:code id: tags:
```
# Here are two mistakes. Can you find them?
Hi! I am a comment. How are you?
print('Hello world!')
```
%% Cell type:code id: tags:
```
# Multi-line comments
I want to be a
mutli line comment.
"""
print('Hello world!')
```
%% Cell type:code id: tags:
```
# Expected output: 5
c = 5
print( )
```
%% Cell type:code id: tags:
```
# How to print two strings as one. Expected output: Hello world
a = 'Hello'
b = 'world'
print( a b )
```
%% Cell type:code id: tags:
```
# Variable types
# Does the error output help you?
a = 'Hello'
b = 0
print( a + b )
```
%% Cell type:code id: tags:
```
# What is missing?
a = 'Hello'
b = a
if a == b:
print('Same!')
```
%% Cell type:code id: tags:
```
# Print the variable type
# Expected output: a is of type <class 'str'>
a = 'How are you?
print('a is of type', (a))
```
%% Cell type:code id: tags:
```
# Variable names: What is allowed and what not?
_1th_string = "Hello"
second_string = 'world'
3rd_string = '!'
FOURTH_STRING = 'How'
FIFTH STRING = 'are'
_6th-string = 'you?'
print(_1th_string, second_string,
3rd_string, FOURTH_STRING,
FIFTH STRING, _6th-string
)
```
%% Cell type:code id: tags:
```
# convert b into float
a = 2
b = (a)
print(b)
```
%% Cell type:code id: tags:
```
# How to access Lists?
my_list = ["!", "Hello", 'you', "How", '?', 1, 'are', 2, 3, "world"]
print(my_list)
print(my_list[ ]) # print '!'
print(my_list[ ]) # print 'Hello'
print(my_list[ ]) # print the last element of a list without the real index; here 'world'
### print 'Hello world! How are you?':
print(my_list[ ], my_list[ ] ,my_list[0] ,my_list[ ] ,my_list[ ] ,my_list[ ], my_list[4])
```
%% Cell type:code id: tags:
```
# Indices of Strings
a = 'Hello world!'
print(a[ ]) # only print !
print(a[ ]) # only print H
print(a[ ]) # only print 'world', without '!'
```
%% Cell type:code id: tags:
```
# Dictionaries
my_dict = { 'chr1' : 'gene1', 'chr2' : 'gene3' }
print(my_dict[ ]) # print gene1 of the dictionary
```
%% Cell type:code id: tags:
```
# Dictionaries2; Find the mistake
my_dict = { 'chr1' : 'gene1', 'chr1' : 'gene3' }
print(my_dict[ ]) # print gene1 of the dictionary
```
%% Cell type:code id: tags:
```
# Dictionaries3
my_dict = { 'chr1' : ['gene1', 'gene2'], 'chr2' : 'gene3' }
print(my_dict[ ][ ]) # print gene2 of the dictionary
```
%% Cell type:code id: tags:
```
# Booleans
a = 0
b = 1
print(bool( )) # print True; insert the right variable
print(bool( )) # print False; insert the right variable
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment