Python commands are case-sensitive.
help()
is used to display the documentation of modules, functions, classes, keywords etc.
#
comment follows.
""" (triple quotes) starts a multi line comment and another """ (triple quotes) ends the comment.
=
is assignment operator, like a = 'Hello World'.
a.upper()
- an example for a Python method (result is 'HELLO WORLD
').
a.lower()
returns the lowercase version of a string.
print()
prints an object to the screen: print("Hello World").
abs()
returns the absolute value of a numeric value (e.g. integer or float).
round()
returns the rounded value of a numeric value.
A list, [2, 3, 5, 6]
, or ['a', 'c', 'd', 'a']
.
len()
returns the number of elements in a list or the number of characters in a string.
min()
returns the smallest item of a list or of the typed-in arguments.
max()
returns the largest item of a list or of the typed-in arguments.
sorted()
sorts a list into ascending order.
sum()
sums a list.
type()
returns the type of an object.
a.strip()
removes white space in a string
a.replace('old', 'new')
replaces a given string with another string.
a.split('delimiter')
splits a string into a list. a.split(' ')
returns ['Hello', 'World']
'delimiter'.join(a)
joins elements of a list into one string. ','.join(a)
returns 'Hello, World'
dir()
returns a list of valid attributes of an object.
This guide has a user friendly interface.