From 5af112ebaedac86a90cb26cefb706c79b9f36429 Mon Sep 17 00:00:00 2001 From: leonhuang Date: Thu, 25 May 2023 14:02:12 -0500 Subject: [PATCH 1/3] Leon's Submussions --- Leon_Submissions/Homework1.py | 0 leon.py => Leon_Submissions/leon.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 Leon_Submissions/Homework1.py rename leon.py => Leon_Submissions/leon.py (100%) diff --git a/Leon_Submissions/Homework1.py b/Leon_Submissions/Homework1.py new file mode 100644 index 0000000..e69de29 diff --git a/leon.py b/Leon_Submissions/leon.py similarity index 100% rename from leon.py rename to Leon_Submissions/leon.py From 161a4e28db1b396fab63a8138126a883fd73474a Mon Sep 17 00:00:00 2001 From: leonhuang Date: Thu, 25 May 2023 14:28:54 -0500 Subject: [PATCH 2/3] Homework1 --- Leon_Submissions/Homework1.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Leon_Submissions/Homework1.py b/Leon_Submissions/Homework1.py index e69de29..9384b12 100644 --- a/Leon_Submissions/Homework1.py +++ 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 From 716e254905ca20257a1aa16ce269419337a5743e Mon Sep 17 00:00:00 2001 From: "scott.liu" Date: Fri, 26 May 2023 03:28:19 -0700 Subject: [PATCH 3/3] This is my hw2 --- Scott_Submissions/HW2.py | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Scott_Submissions/HW2.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