Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 12 pages
Summary

Summary Introduction to Programming for Biosciences Cheatsheet (5BBB0238)

Document preview thumbnail
Preview 2 out of 12 pages

A comprehensive, notes form summary/cheatsheet of the 5BBB0238 Introduction to Programming for Biosciences module at King's College London. It provides a completely beginner-friendly overview of everything you need to get started with Python programming, with particular relevance to use for biological applications such as genomic analysis. The key functions/commands/skills from all workshops and practice exercises are included in direct accordance with the module's learning objectives, with code examples highlighted in bold. I memorised this alone and came first in the year in the exams with 95%! Topics covered include variables, for loops, while loops, if/else statements, functions, dictionaries, tuples, images, files and equations so it will also be highly relevant for anyone wanting to learn to code with Python.

Content preview

Cheatsheet
Reviewed



General
just type to write in code or begin line with # for comments

print(””) to display a string/phrase, use commas between to print several
variables

= to assign variable, == to check if true/false, ! = not equals



Variable types
Boolean = true/false or 0/1

String = text (“…”)

Int = integer (number)

Float = decimal number, be aware of floating point error eg. 1.2-1 gives
0.19999

List = […, …]

Tuple = (…, …)

Dictionary = {…, …}

to update a variable: eg. a=a+3 or a+=3, computer looks at right hand side of
equation first then assigns to left hand side

identify variable type with type(variablename)

word.isnumber() = checks if string can be converted to number, true/false
output eg. word.isnumber(’three’) would give true



If statements

Cheatsheet 1

, If… = checks if statement is true/false ie boolean

Elif… = comes after if, this second statement is only checked if first if is false

else… = final statement, carries out only if all previous are false

conditional statements: and (executes if both statements are true), or (if one
or both are true) not (switches true/false so executes if statement is not…)

Nested if statements:

if…
if…

inner if loop only runs if outer if statement is true



For loops
When to use: when you want to run a programme for a specified number of
times/in a specific range eg. printing the numbers of all the adenine bases in a
DNA sequence of set known length

How to construct a for loop:

for i in range():

command…

Using all three range arguments: range(start, stop+1, step) eg. range(2,11,2)
will give 2,4,6,8,10 use range(length(variable)) as stop value for words as
indexing already starts from 0

to loop backwards through a string/list: list = reversed(list) to update variable
to reversed version or newlist = list[::-1] or for i in range((length-1), -1, -1)

to break out of a loop (end it): break

Nested for loops eg.




Cheatsheet 2

Document information

Study
Unknown
Uploaded on
August 12, 2025
Number of pages
12
Written in
2024/2025
Type
Summary
£15.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
rcnotes
4.3
(3)
Sold
14
Followers
2
Items
22
Last sold
2 months ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions