<jupyter_start><jupyter_text>Data types and Variables---A variable is a placeholder for data.  It will have:*  a meaningful name that indicates what data is stored in it (you will often need to decide on the name*  a type of data it will hold (this will dictate what can be done with that data)   Creating a new variableWe do this using the assignment operator:` name = "Susan"`The variable **name** is a string variable because the data assigned to it when it was created was a string.`age = 21`The variable **age** is an integer variable (a whole number) because the data assigned to it when it was created was a whole number.` height = 1.67`The variable **height** is a float variable (a decimal number) because the data assigned to it when it was created was a decimal number.`clicked_on = True`The variable **clicked_on** is a boolean variable (True or False - the capitals are significant) because the data assigned to it when it was create was True, one of the two options.**Recap**: Variables can store data of different types.  *   **int** (whole numbers, e.g. 4, 523, 1984)  *   **float** (decimal numbers e.g. 4.3, )  *   **str** (strings of characters)  *   **bool** (True or False)  Variables can also store structured data (**lists, tuples, dictionaries,** etc)`scores = [34,56,27,84,65]`  The variable scores is holding a list of integers`column_headings = ("Age", "Income", "Population") The variable **column_headings** is holding a tuple of strings, a tuple can't be changed after it has been assigned, whereas a list can`person = {"Name":"Susan", "Age":21, "Height":1.67}`  The variable **person** is holding a dictionary, a set of data each with a label or key and a value.You can '**assign**' a value to a variable using the **=** sign. Changing a variable's typeOccasionally we need to change the type of a variable after it has been assigned.  This might be because when the variable was first assigned a value, it came from a process which produced it as a different type.For example, the input command to get input from a keyboard can only produce data as a string.  If the data needed was a number, then it can be cast as an integer like this:`age = int(input("Enter your age: "))`  Using variables of different types and functions---- Exercise 1The cell below contains a function. Functions are named sets of instructions that do one particular thing, often creating a new set of data but sometimes just setting something up.  A function starts with the keyword def (short for define or definition). All instructions below the definition are indented and this indicates that they are part of that function. A function runs when its name is used outside the function (here it is not indented). The indentation is important, note where the code is and isn't indented.  *  create a variable called **name** and assign it a value (any name)  *  print the message “Hello” name  *  change the value of `name` and run the code again to get a new message<jupyter_code>def print_welcome():
   # create the variable called name below here (indented like this line) and add the instruction print("Hello",name)
  
  
  
print_welcome()<jupyter_output><empty_output><jupyter_text>---- Exercise 2*  create two variables **num1** and **num2** and assign them each a whole number  *  create a third variable **total** which will store the sum of num1 + num2  *  run the code.  Change the value of one of the numbers and run the code again to get new messages and a new total.<jupyter_code>def print_total():
  # add your code below here
  
  
  print(num1, "+", num2, "=", total)

print_total()<jupyter_output><empty_output><jupyter_text>--- Exercise 3 - converting float to intWrite a function called **count_poundCoins()** which will:  *  ask the user to enter an amount in pounds and pence and assign this value to a float variable called **pounds_pence**  *  convert the float variable to int and assign this value to a variable called **pound_coins**  *  print the message Number of pound coins `pound_coins`  Test input:  3.48  Expected output:  Number of pound coins 3<jupyter_code><jupyter_output><empty_output><jupyter_text>--- Exercise 4 - converting int to stringWrite a function called **format_currency()** which will:*  ask the user to enter a number of pounds and assign this to an integer variable called **num_pounds**  *  convert numPounds to a string and assign it to a variable called **pounds**  *  create a String variable called **currency** which has a "£", pounds, ".00" joined together*  print the resulting currency, including the £ sign  Test input:  4Expected output:  £4.00<jupyter_code><jupyter_output><empty_output><jupyter_text>--- Exercise 5 - area of a circleWrite a function called **calculate_area()** which will:*  ask the user to enter the **radius** of a circle (which could be a float or an int)  *  create a variable called **pi** and assign it the value 3.14159*  calculate the **area** of the circle (pi * radius * radius)  *  print the area of the circle to 2 decimal places.  Test input:  5Expected output:  78.54<jupyter_code><jupyter_output><empty_output><jupyter_text>--- Exercise 6 - variables of different types*  create a variable called **name** and assign it the value "Billy"  *  create a variable called **age** and assign it the value 18  *  print a message "Hello `name` you are `age` years old" Test input:  Billy  18  Expected output:  Hello Billy you are 18 years old<jupyter_code>def print_info():
   # add your code below here
  
  

print_info()<jupyter_output><empty_output><jupyter_text>--- Exercise 7 - float variables (and writing your own function)Write a function called **print_price()** which will:  *  create a variable called **product** and assign the value "Chocolate Bar"  *  create a variable called **cost** and assign the value 1.39  *  print the message `product`, "costs", "£", `cost`  Expected output:  Chocolate Bar costs £ 1.39<jupyter_code><jupyter_output><empty_output><jupyter_text>--- Exercise 8 - concatenating stringsWrite a function called **print_full_name()** which will:  *  create variable called **name** and assign it the value "Monty"  *  create a variable called **surname** and assign it the value "Python"  *  create a variable called **full_name** and assign it the value `name` + " " + `surname`  *  print the `full_name`  Expected output:  Monty Python<jupyter_code><jupyter_output><empty_output><jupyter_text>Operators In Python, we can use the following arithmetic operators:  ![Python operators](https://drive.google.com/uc?id=1EARs0OefvMwAULyNGGs01xYLW3lIAO9B) --- Exercise 9 - BIDMASWrite a function called **calculate_average()** which will:  *  ask the user for 3 seperate numbers, **num1**, **num2**, **num3**  *  calculate the **average** of the three numbers*  print the `average`, rounded to 2 decimal places  *Hint 1:  to round a number, use round(), e.g. round(`average`)  **Hint 2: remember the BIDMAS order of operators and use brackets to change the order if necessary.*  Test Input:  3  5  9  Expected output:  5.67<jupyter_code><jupyter_output><empty_output><jupyter_text>--- Exercise 10 - BIDMASWrite a function called **calculate_avg_height()** which will:  *  ask the user to input their **height**  *  convert `height` to **height_centimeters** (multiply by 100)  *  print `height_centimeters`  *Remember, height in metres is usually a decimal, so data type matters*  Test Input:  1.67  Expected output:  167<jupyter_code><jupyter_output><empty_output><jupyter_text>--- Exercise 11 - calculating volumeBill is moving house. He needs to know how much space his cardboard packing boxes have.   Write a function called **calculate_volume()** which will:   *  assign the value 3.2, 5.6 and 7.8 to the variables **base**, **width** and **height** respectively  *  calculate the **box_volume** rounded to 1 decimal place  *  print the `box_volume`*Hint: volume = base x width x height*Expected output:  139.8<jupyter_code><jupyter_output><empty_output><jupyter_text>---***Floor Division***  *So far, we have been using standard arithmetic operators. If we would like to divide without remainders (eg. no decimals) we can use floor division using the // operator.  This will always round down*.  *For example*:  *42/8 = 5.75*  *BUT*  4*2//8 = 5* --- Exercise 12 - calculating with volumesBill needs to work out how many boxes he will need.  Building on what you did in the last exercise, write a function called **calculate_boxes(base, width, height)** which will:  *  calculate the volume of a box, using the **base**, **width** and **height** supplied in the brackets  *  ask Bill for the **total_volume** of his stuff  *  calculate the total **number_of_boxes** he will need, and print the `number_of_boxes`  *Hint: the `total` will not be a decimal number - you should use floor division and add one to the answer (for the box that will have the leftovers).*Test Input:  1500  Expected output:  11<jupyter_code>def calculate_boxes(base, width, height):
  # add your code below here to calculate the boxVolume, ask for totalVolume and calculate number of boxes


calculate_boxes(3.2, 5.6, 7.8)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.092279130719668, 'fraction_numerical': 0.01594408649120891, 'mean_word_length': 4.5841463414634145, 'pattern_counts': {'":': 3, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 1, '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': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '651275', 'license': 'CC0-1.0', 'n_tokens_mistral': 2692, 'n_tokens_neox': 2538, 'n_words': 1260, 'path': 'Consolidated/Data_Types,_variables_and_operators.ipynb', 'repo_name': 'futureCodersSE/data-analysis-with-python', 'size': '9157'}