Mapa mental
python; strings and variables
Contenido del mapa
python; strings and variables
variable is a letter- stores temporary values, may be a place or location
- variable may only contain letters, numbers or underscores (such as _ ) but cannot start with a number
python is a programming language
- code tries to solve a problem, by breaking things into smaller, simpler steps / tasks
- known as decomposition
- in general coding language, not just python
- ordered, small steps are known as an algorithm (like instructions)
- a sequence is an order in which a computer solves a problem, using an algorithm
- the algorithm's instructions must be clearly defined and in the correct order (it must not miss any steps, such as going from step 1 to 3)
- known as decomposition
- code tries to solve a problem, by breaking things into smaller, simpler steps / tasks
syntax errors are errors that occur due to typing incorrectly
- for example, print "hello world" is wrong because there are no brackets
- the correct way to type this is print ("hello world")
- you may use single or double quotations
- for example, print "hello world" is wrong because there are no brackets
IDLE- integrated development environment
- there are two modes:
- interactive, allows you to see your results as you type
- script mode; you must save and run the code to see your results
- there are two modes:
comments are in Python
- to make a comment, you must put * around the comment
- comments help the programmer or anyone reading the code. It allows someone, at a later date than the code was created, to understand what the programmer was trying to do
- the comment does not affect the actual code or the results
all functions in Python are in purple
- functions include input () and print
- functions are special built-in routines that do a specific job
strings represent uncoded characters; they must be two or more characters
a = 'hello' ; print () (an example of variable usage, ; represents next line)
an integer is a variable, letters are strings
- a decimal is called a float
an array can be seen as a list
- strings in Python are arrays of bytes representing characters
- len () refers to the length of the string
- for example, a = hello world
- print (len(a))
- the number 11 will come up, because there are 11 characters in 'hello world'
- print (len(a))
- for example, a = hello world
to write three quotes in one go, you must use three sets of quotation marks
square brackets are used to access certain parts of the string
- for example; a = abcdefghijklmnopqrstuvwxyz
- print (a [2])
- this would print b, the second element of the string, represented by the number 2 in the square brackets
- print (a [2:5] would mean print letters 2 to 5, not including 2
- so this command would print 'cde'
- print (a [-5:-2]) would be the same, but starting from the end of the string
- print (a [2:5] would mean print letters 2 to 5, not including 2
- this would print b, the second element of the string, represented by the number 2 in the square brackets
- print (a [2])
- for example; a = abcdefghijklmnopqrstuvwxyz
Información
- Descripción
- Year 8 Computing Mapa Mental sobre python; strings and variables, creado por emily ! el 04/12/2019.
- Creado por
- emily !
- Visitas
- 0
- Valoración