Documente Academic
Documente Profesional
Documente Cultură
Symbols:
+ add
- subtract
* multiply
// divide (whole number)
/ divide (can be a decimal number)
< less than
> more than
<= less-than-equal (the value on the left of the sign is smaller than, or equal to,
the value on the right).
>= more-than-equal
% modulus (not percentage)- the remainder after dividing. For example, 100/16=
6 remainder 4: 4 is the modulus.
!= Not equal to
== equal to
= used when defining a variable.
General Rules:
At the start of each string, after the >>>, you have to put print with a lowercase
p.
On the python shell mode, you cant leave lines out: everything has to be line after
line. To be able to skip lines and have paragraph written together, you will have to
open another window.
File, New File
Type in your code or message using variables or anything else you want.
Save the file.
Press f5, showing the message/code on the main shell mode.
Range (3, 31, 1)= the first number is where the loop will start.
= the second is where the loop will end (+1, so it would
end at 30)
This is the Boolean condition. If it is true
the code will run.
String methods:
Lower() - all the letter are outputted as lower case.
upper() - all of the letters are outputted as upper case.
title() - the first letter of each word turns capital (like in a title).
swapcase() - the letters that were inputted capital are lowercase, and those lowercase
are now capital.
Capitalize() - the first letter is capitalized.
Operands:
day += 1 - shortcut of (day = day+1)- you dont have to repeat day.
print ("Shaking \n" * 4) - since *4 is not in the speech marks, what is in the speech
marks will be outputted 4 times.
Import random allows the computer to generate random numbers where wanted
{random.randint(1, 100)}
Import time allows times breaks between code {time.sleep(1)}.
SOMETIMES REPEAT THE CODING AT BEGINNING AND END!!!
Lists
Lists square brasckets/start at 0.
List.append adds value to list.
List.insert(1, item) adds item to a specific place in the list.
List.count(Jan) how many times it appears in list
List.remove(Jan)- removes
Len(list)- length of the list.
List.reverse()- reversezs the oder of the list.
List.sort() sorts the list alphabetically
In searches for something in the list.