Week 3

Some Python things I’ve learnt:

‘!=’ means unequal

elif means else if

range makes a list from 1 to 10

xrange is used as a generator for large lists or things etc.

list.append is a method that appends an object to the end of the list

= is used to change the number to itself plus something else

while is for pre-test

do while is post-test

raw_number asks for an input

Some definitions:

  • variable: stores a piece of data and gives it a specific name
  • boolean: has two values, can only be True or False
  • Storing variables examples:

my_int = 3

my_variable = 4

  • Whitespace: used to structure a code; means right space
  • Interpreter: window running the code line by line and checking for errors
  • Single line comments: mode by using #

*comments are not run as codes, they are there for humans to read

  • Multi-line comments: use triple quotation marks
  • Exponentation — mathematical operation, written as b^n, represented as, for e.g. 2 ** 3
  • Modulo — returns the remainder from a division e. g. if I type 3 % 2 it will return 1 since 2 goes into 3 once
  • Data types: numbers and booleans
  • Arithmetic operations:

+

/

*

%

  • Strings: data types containing letters, numbers, and symbols, represented with single quotation marks
  • Escaping characters: use backlash before an apostrophe, for e.g. There\’s a snake in my boat!
  • Index: the assigned number for each character in a string. In Python the index is counted from 0, NOT 1
Show your support

Clapping shows how much you appreciated Simona’s story.