You are on page 1of 2

Python Code Symbols and Functions

/ simple division
* simple multiplication
// division and then round down the result
% takes the remainder of the division
** power symbol, etc 5**4 = 5^4
\n goes to a new line
r putting the letter r in front of the print(r.) will return the raw string of the whole
sentence and ignore the \n
function inside the whole string
you can add sting to another string, etc x = Becky
x + rocks! will give Becky rocks!
you can even multiply a string, etc x = Becky
x * 5 will give Becky Becky Becky Becky Becky
Although you and add and multiply a string by many times, you cant subtract a string from
another one,
etc, x = Becky , y = ky
x-y will give TypeError !!!
Extracting a letter from a string, computer counts from 0 as the first position
etc, user = Pikachu
so user[0] gives P , user[6] gives u , user[-1] gives u since it is
last letter so the sign lets u count from the back, reason why it counts from -1 and not -0 is
because -0 is still 0 so will return P again.
An empty space and any symbol is also counted
User[1:3] will return ik it will start with the letter on 1 and stop
before the letter at 3
User[2: ] will return ikachu
[ ,,].append [,] returns the added list to the original one
Or foodlist= foodlist + [,,]
For x in foodlist
print(x) will return all the elements inside the list on separate lines, of course you
must .., each string, or else it will just return just a whole lumb.

x=10
while x< 20:
print(x) so if we end the command here, then the program will run forever and keep
printing 10 since x will
always be <20
x+=1 now, if we end one more statement which make

You might also like