## Python Cheatsheet

##### Python Comparison Operators
Operator Name Example
== Equal x==y
!= Not equal x!=y
> Greater than x>y
< Less than x<y
>= Greater than or equal to x>=y
<= Less than or equal to x<=y
##### Python Arithmetic Operators
Operator Name Example
- Subtraction x-y
* Multiplication x*y
/ Division x/y
% Modulus x%y
** Exponent x**y
// Floor Division x/ y
##### Python Logical Operators
Operator Name Result
and (x and y) is True if both x and y are true.
or (x or y) is True if either x or y is true.
not (x not y) If a condition is true then Logical not operator will make false.
in Evaluates to true if it finds a variable in the specified sequence and false otherwise. x in y, here in results in a 1 if x is a member of sequence y.
not in Evaluates to true if it does not finds a variable in the specified sequence and false otherwise. x not in y, here not in results in a 1 if x is not a member of sequence y.

##### Conditional statements if, elif, else perform different actions based on different conditions.

``````
weather = input("What does the weather look like?:")
if weather == "rainy":
elif weather == "sunny":
else:
print("Not a valid choice")
``````

Python built-in data types: int (integer), float (floating-point number), str (string), list (list), and dict (dictionary).

If you are ever unsure of the type of the particular object, use the type() function, to check data type.

##### Converting Between Types
Function Result
int(obj) Returns an integer object constructed from a number or string.
str(obj) Returns a str version of an object.
bool(obj) Return a Boolean value, True or False.
bin(obj) Converts an integer number to a binary string.
list() Converts string, tuple, dictionary to a list.
tuple() Converts string, list to a tuple.
chr(i) Returns the string representing a character whose Unicode code point is the integer i.
ord(str) Given a string representing one Unicode character, return an integer representing the Unicode code point of that character.