<jupyter_start><jupyter_text>Lesson 4: Types of ThingsThis lesson we're taking a step back, and a wider look at the different things that the Python language makes available to us.The official name for these things is `built-in types`. This means that we don't have to import or use any outside package to access them, we can just type and execute.____**We'll cover 4 basic types this lesson:**_* Numbers (integers and floats)* Strings* Booleans  NumbersThe two most common types of numbers in programming are:* `int`, which represents whole numbers (integer)* `float`, which represents numbers with decimal places (floating-point)  IntegersLet's check out some basic operations that we can perform:<jupyter_code>a = 2

# what "class" (i.e. "type") is this variable that we've created?
a.__class__<jupyter_output><empty_output><jupyter_text>_Try changing the `2` above and rerunning to see if the class changes_<jupyter_code># we can use addition
a + 3<jupyter_output><empty_output><jupyter_text>_Try changing the number above and see if the sum changes_ There are a truckload of number operations for integers. This is just for reference, we'll only be covering a few of these (taken from [https://docs.python.org/3/library/stdtypes.htmlnumeric-types-int-float-complex](https://docs.python.org/3/library/stdtypes.htmlnumeric-types-int-float-complex)) Operation	        | Result------------------|----------x + y	            | sum of x and yx - y	            | difference of x and yx * y	            | product of x and yx / y	            | quotient of x and yx // y            |	floored quotient of x and yx % y	            | remainder of x / y-x	x             | negated	 	 +x	x             | unchanged	 	 abs(x)	          | absolute value or magnitude of xint(x)	          | x converted to integerfloat(x)	        | x converted to floating point pow(x, y)	        | x to the power yx ** y	          | x to the power y  Handy tricks<jupyter_code># Find out if a number is divisible by another, e.g. is 6 divisible by 3?
6 % 3
# Increment a number by 1
a = 1
a += 1
print(a)<jupyter_output>2<jupyter_text>_Try changing the values in the two examples above and rerun them_  FloatsFloats handle things like percentages, or anything where we need the numbers to be accurate to decimal places. Floats can handle any of the operations that were listed above for integers<jupyter_code>b = 3.1415
b.__class__
b / 2<jupyter_output><empty_output><jupyter_text>StringsStrings are awesome! They are the lifeblood of every program that does anything with text, they're used very frequently<jupyter_code>s = "yolo b**ches"
s.__class__<jupyter_output><empty_output><jupyter_text>> There are a bunch of super-useful methods on strings. We won't cover them all here, but if you ever need to look them up or check them, google "Python string methods", or go to [https://docs.python.org/3/library/stdtypes.htmlstring-methods](https://docs.python.org/3/library/stdtypes.htmlstring-methods)Let's look at a few of the cooler 😎 ones<jupyter_code># translate every letter to ALLCAPS
s.upper()
# translate every letter to lowercase
'ALL CAPS WOOO'.lower()
# How many times does the letter 'y' appear in this string?
s.count('y')
# How long is the string?
len(s)
# Check if the string ends with 'yolo'
s.endswith('yolo')
# Check if a string is actually a number
'123'.isdigit()<jupyter_output><empty_output><jupyter_text>_Try changing the definition at [44] and rerun the next steps and see what changes_  BooleanBooleans are things that have two possible values (i.e. `true/false`). Traditional male/female gender would be another example of a boolean, but generally it's used to describe `true/false`.We usually use `true/false` in `if` statements in order to make a decision about what to do<jupyter_code>bool = True
bool.__class__<jupyter_output><empty_output><jupyter_text>Equality"Equality" in computer science means "checking if things are the same". There are only a couple of operators to remember, and they're usually the same in most programming languages1. `a == b` Is `a` the same as `b`?2. `a != b` Is `a` different to `b`?3. `a < b` Is `a` less than `b`?4. `a <= b` Is `a` less than or equal to `b`?5. `a > b` Is `a` more than `b`?5. `a >= b` Is `a` more than or equal to `b`?If you use these operators, the return will be a `boolean`<jupyter_code># Check if two strings are the same
'123' == '123'
# Check if two strings are different
'a' != 'b'
# Check if one number is less than another
1 < 2<jupyter_output><empty_output><jupyter_text>_Python can only do comparisons that it already knows how to handle. Try changing the statement above to `'a' < 2`, rerun and see what happens_  Substituting You can also substitute in Python! For example:<jupyter_code># If we have an addition
4 + 4

# Then we could check the sum by doing
4 + 4 == 8<jupyter_output><empty_output><jupyter_text>If this, then thatNow on to the (_slightly_) fun(ner) stuff! Now that we know all of our basic types, lets use them in a basic `if` statement.> We'll cover if statements in more detail next lesson<jupyter_code># if two things are the same, print 'yay'
if 'a' == 'a':
    print('yay')<jupyter_output>yay<jupyter_text>Homework* Write an if statement that does the following:    `if 3 is an even number, then print something` * Bonus:    `if a string starts with 'yolo', the print it uppercased`<jupyter_code># this will start you off
s = 'yolo b**tches'<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09297634329726756, 'fraction_numerical': 0.008985879332477536, 'mean_word_length': 4.03601108033241, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '265284', 'license': 'MIT', 'n_tokens_mistral': 1719, 'n_tokens_neox': 1646, 'n_words': 736, 'path': 'beginner/lesson004/lesson004_types_of_things.ipynb', 'repo_name': 'tmck-code/Syllabus', 'size': '5453'}