diff --git a/A_BrainTeaser_byScott.py b/Scott_Submissions/A_BrainTeaser_byScott.py similarity index 100% rename from A_BrainTeaser_byScott.py rename to Scott_Submissions/A_BrainTeaser_byScott.py diff --git a/Scott_Submissions/Floating_Point_Formats.py b/Scott_Submissions/Floating_Point_Formats.py new file mode 100644 index 0000000..5497505 --- /dev/null +++ b/Scott_Submissions/Floating_Point_Formats.py @@ -0,0 +1,2 @@ +import sys +print(sys.float_info) \ No newline at end of file diff --git a/Scott_Submissions/HW1_Scott.rtf b/Scott_Submissions/HW1_Scott.rtf new file mode 100644 index 0000000..e765ed0 --- /dev/null +++ b/Scott_Submissions/HW1_Scott.rtf @@ -0,0 +1,37 @@ +{\rtf1\ansi\ansicpg1252\cocoartf2580 +\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;\f1\fnil\fcharset0 Menlo-Regular;} +{\colortbl;\red255\green255\blue255;\red0\green0\blue0;\red0\green0\blue0;} +{\*\expandedcolortbl;;\cssrgb\c0\c0\c0\c87059;\cssrgb\c0\c0\c0\c3922;} +\margl1440\margr1440\vieww11520\viewh8400\viewkind0 +\deftab720 +\pard\pardeftab720\partightenfactor0 + +\f0\fs32 \cf2 \expnd0\expndtw0\kerning0 +1. What is the name of the international standard for floating-point representation?\ + \ + The IEEE-754 standard describes floating-point formats, a way to represent real numbers in hardware.\ +\ +\ +2. How many bits are the floating point numbers defined by that standard allowed to be?\ +\ + The floating-point numbers defined by the international standard can be allowed to be of different lengths depending on the specific interchange format. For binary interchange, the formats can be 16 bits, 32 bits, 64 bits, and any multiple of 32 bits \uc0\u8805 128. For decimal interchange, the formats can be any multiple of 32 bits.\ +\ +\ +3. Does your computer support all those formats? Can you think of an easy way to check with only one line of Python?\ +\ +import sys\ +print(sys.float_info)\ +\ +scott@MacBook-Pro-6 python-bootcamp % python3 Floating_Point_Formats.py \ +sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1)\ +\ +\ +\pard\pardeftab720\sa320\partightenfactor0 +\cf2 4. Why doesn't this code give the same answers to the two multiplications?\ + Because they are different operations. The normal Python multiplication operator will multiply two numbers together and return the product. The Pandas multiplication operator, on the other hand, performs element-wise multiplication on the corresponding columns in a DataFrame. In other words, it multiplies the first element in the first column with the first element in the second column, the second element in the first column with the second element in the second column, and so on. \ + Floating-point arithmetic has a limited precision due to the finite number of bits used to represent floating-point numbers in binary format. This can lead to rounding errors and loss of precision in arithmetic operations, particularly with very large or very small numbers.\ +\ +5. You can use +\f1\fs27\fsmilli13600 \cf2 \cb3 sys.getsizeof +\f0\fs32 \cf2 \cb1 to see how large a Python object is. Does the size of a Python floating-point number change as it gets larger? Why or why not?\ + The size of a Python floating-point number does not change as it gets larger. This is because Python uses a fixed number of bytes to represent floating-point numbers, regardless of their value.} \ No newline at end of file diff --git a/Scott_Submissions/Q4.py b/Scott_Submissions/Q4.py new file mode 100644 index 0000000..7ef6497 --- /dev/null +++ b/Scott_Submissions/Q4.py @@ -0,0 +1,18 @@ +import pandas as pd +import numpy as np + +# Generate two random 64-bit integers +num1 = np.random.randint(0, 10 - 1) +num2 = np.random.randint(0, 10 - 1) + +# Multiply them together using the normal Python multiplication operator +print(f"num1 * num2 = {num1 * num2}") + +# Create a Pandas DataFrame with the generated numbers +data = {'Number1': [num1], 'Number2': [num2]} +df = pd.DataFrame(data) + +# Multiply the numbers together using the Pandas multiplication operator +df['Product'] = df['Number1'] * df['Number2'] + +print(df) \ No newline at end of file diff --git a/Scott_Submissions/Q5.py b/Scott_Submissions/Q5.py new file mode 100644 index 0000000..636bcfa --- /dev/null +++ b/Scott_Submissions/Q5.py @@ -0,0 +1,4 @@ +import sys +num = 99999999999 +size = sys.getsizeof(num) +print(f"The size of the float is {size} bytes.") \ No newline at end of file diff --git a/cr-example.py b/Scott_Submissions/cr-example.py similarity index 100% rename from cr-example.py rename to Scott_Submissions/cr-example.py diff --git a/test.py b/Scott_Submissions/test.py similarity index 100% rename from test.py rename to Scott_Submissions/test.py