# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# **Lab 01**
#
# Labs in general are for you to solve short programming challenges in class. In contrast, homework assignments will involve more challenging and lengthy problems.
#
# Feel free to ask the TAs for help if there is anything you do not understand. The TAs will go through suggested solutions in the last 15 minutes of the lab - typically by solving them in a live demo. **Your midterm exams will be like this, so it is highly beneficial for you to attend these labs**.
#
# The first lab is to gain basic familiarity with Python. 
#
# - Any library needed has been imported for you
# - You are not to use any 3rd party library such as `numpy` for the first lab
# - Do this lab without using the web to search for solutions

# +
import random
import math

random.seed(123)
# -

# **1**. Write Bayes theorem in $\LaTeX$ using a Markdown cell.



# **2**. Create two lists of 100 random integers in the range`[0, 1000)`.  Find all numbers that are shared by the two lists.
#
# Hint: Use the function `random.randint` to generate a random integer



# **3**. A Pythagorean triplet is a tuple of integers $(a, b, c)$ such that $a^2 + b^2 = c^2$. Find all unique Pythagorean triplets for which $a$ and $b$ are less than 25. For example, $(3,4,5)$ is a Pythagorean triplet.
#
# Hint: To check if a number $x$ is a whole number, you can use
#
# ```python
# math.isclose(x % 1, 0)
# ```
#
# or the built-in method
#
# ```python
# x.is_integer()
# ```



# **4**. Implement a bubble sort function in Python. Use it to sort the list `[9,1,9,6,6,8,2,4,5,9]`. Make sure your function has a `docstring`.
#
# Hint:
#
# Recall that in Python, a swap is as simple as
#
# ```python
# x, y = y, x
# ```



# **5**. The "Fizz-Buzz test" is an interview question designed to help filter out the 99.5% of programming job candidates who can't seem to program their way out of a wet paper bag. The text of the programming assignment is as follows:
#
# ```Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.```
#
# Source: "Using FizzBuzz to Find Developers who Grok Coding" http://tickletux.wordpress.com/2007/01/24/using-fizzbuzz-to-find-developers-who-grok-coding/
#
# Write the Fizz-Buzz program in Python. Print the 100 encoded numbers in a single line.
#
# Hint: See what the `end` argument to the `print` function does. Alternatively, see how to use the `join` method of any string.



# **6**. Bonus for those who found the above exercises too easy.
#
# Write a function that returns the specified output for the given input.
#
# ```
# Input: ['Tokyo', 'London', 'Rome', 'Donlon', 'Kyoto', 'Paris']
# // YOUR ALGORITHM
# Output: [['Tokyo', 'Kyoto'], ['London', 'Donlon'], ['Rome'], ['Paris']]
# ```



StarcoderdataJupyterScriptsDedupFiltered