diff --git a/Leon_Submissions/Homework1.py b/Leon_Submissions/Homework1.py new file mode 100644 index 0000000..9384b12 --- /dev/null +++ b/Leon_Submissions/Homework1.py @@ -0,0 +1,28 @@ +# Question 1: +# The international standard for floating-point representation is +# called the "IEEE 754 Standard for Floating-Point Arithmetic." + +# Question 2: +# 32-bit and 64-bit formats are the most widely used ones in practice. + +# Question 3: +# My computer supports all these formats +import numpy as np + +supported_formats = np.finfo(np.float32).bits, np.finfo(np.float64).bits +print(f"Your computer supports the following floating-point formats: {supported_formats}") + + +# Question 4: +# Using the Pandas multiplication operator (df['Number1'] * df['Number2']) +# , the result is automatically converted to a floating-point data type. +# On the other hand, when I multiply the numbers using the normal Python +# multiplication operator (num1 * num2), the result remains an integer +# data type. + +# Question 5: +# The size of a floating-point number in memory is primarily determined +# by the data type and not the actual value it represents. So the size +# of a Python floating-point number does not change as it gets larger. +import sys +print(sys.getsizeof(70)) \ No newline at end of file diff --git a/leon.py b/Leon_Submissions/leon.py similarity index 100% rename from leon.py rename to Leon_Submissions/leon.py diff --git a/Scott_Submissions/HW2.py b/Scott_Submissions/HW2.py new file mode 100644 index 0000000..76eafb4 --- /dev/null +++ b/Scott_Submissions/HW2.py @@ -0,0 +1,54 @@ +# Name three practical differences between Python strings and bytes. +# Using sys.getsizeof, see how the sizes may be different. +# Do emoji change this answer? + +# Encoding +# Strings are created using Unicode character points. +# While bytes are used to represent actual bytes in memory, which can be encoded using ASCII or UTF-8. + +# Usage +# Strings are usually used to represent text. +# While bytes are used to represent binary data. + +# Memory Size +# Strings take up more memory than bytes, because they are Unicode-based and can contain any character. +# While bytes are limited to binary data. + + +print("---------------------------------------------") +print("This is the Memory Size test print out:") + + +import sys + +my_string = "Hello, world!" +my_bytes = b'\x48\x65\x6c\x6c' + +print(sys.getsizeof(my_string)) # Prints 62 +print(sys.getsizeof(my_bytes)) # Prints 37 + +print() +print('Test the emoji:') + +x = 'pizza' # Prints 54 +y = b'pizza' # Prints 38 +z = '🍕' #Prints 80 + +print(sys.getsizeof(x)) +print(sys.getsizeof(y)) +print(sys.getsizeof(z)) + + +print("---------------------------------------------") + +print("This is the String to Sequence of Numbers print out:") + +def String_to_SequenceofNumbers(): + my_string = input("Enter a string: ") + num_sequence = [ord(c) for c in my_string] + print(num_sequence) + +if __name__ == "__main__": + String_to_SequenceofNumbers() + +print("---------------------------------------------") \ No newline at end of file