Untitled Document
Untitled Document
Compound Interest
# 1.b. is_sorted
is_sorted_flag = True
is_sorted_flag = False
break
print(is_sorted_flag)
# 1.c. has_duplicates
has_duplicates_flag = False
seen_elements = set()
if item in seen_elements:
has_duplicates_flag = True
break
seen_elements.add(item)
print(has_duplicates_flag)
# 1.d. Character Type Checker
print("Digit") [cite: 4]
else: [cite: 4]
import math
print("Distance:", distance)
# 1.f. GCD
print("GCD:", a_gcd)
# 1.h. remove_duplicates
unique_list = []
seen_h = set()
unique_list.append(item)
seen_h.add(item)
print(unique_list)
print(result_sentence_j)
arr1_input_k = input("Enter elements of the first array separated by commas: ") [cite: 11]
arr2_input_k = input("Enter elements of the second array separated by commas: ") [cite: 11]
# 1.l. Palindrome
file_name_c = input("Enter the filename for word count: ") [cite: 15]
try:
except FileNotFoundError:
user_input_d = input("Enter dictionary items as key:value pairs, separated by commas (e.g., 'a:1,b:2'): ")
[cite: 16]
matrix_e = []
matrix_e.append(row_e)
print("\nMatrix:")
print(row_print_e)
# 3.a. Merge two file contents into a third file
file1_content = ""
file2_content = ""
[cite: 18]
except FileNotFoundError:
# Half Adder
FA_Sum = FA_Sum1
content_c_check = file_c_check_object.read().lower() #
file_c_check_object.close() #
found_words_c = [] #
if word_c_check in content_c_check: #
found_words_c.append(word_c_check) #
if found_words_c: #
else: #
class A_mro:
def method(self):
class B_mro(A_mro):
def method(self):
class C_mro(A_mro):
def method(self):
pass
d_instance_mro = D_mro()
try:
# 4.a. Module concept (basic example, typically this would be separate files)
def circle_area(radius):
print("Unknown shape.")
content_b_analyze = file_b_analyze_object.read() #
file_b_analyze_object.close() #
# 4.c. Generate all binary strings of n-bit length (recursive helper function still used internally)
if n == 0: [cite: 25]
generate_binary_strings_recursive(n_bits_c)
sizes_str_plot = input("Enter sizes for pie chart (comma-separated): ") [cite: 28]
labels_str_plot = input("Enter labels for pie chart (comma-separated): ") [cite: 28]
sizes_plot = [float(val.strip()) for val in sizes_str_plot.split(',')] [cite: 28]