Just a couple minor bits of feedback if you don’t mind:
It’s standard practice per PEP-8 (the Python style guide) to use snake case for all variable names, this is all lowercase with words separated by underscores, so password_attempt or ship_name instead of PasswordAttempt/ShipName. There’s nothing wrong with doing it any other way per se (and consistency is the really key thing) but it’s generally better to follow the recommended practices
This is extremely picky, but I think this should be “n” instead of “No” to follow the (y/n) format given by the instructions:
@notlyall I totally didn’t realize that I had typed ‘No’ instead of ‘n’ thanks for pointing it out. And thanks for the information about the standard practice as I didn’t know about that. Thanks for taking your time to review it.
Good job! I really like that you focus on readability. Beside following PEP you could also focus on formatting. To further improve your formatting, I recommend using black. You can read about how to install and use it on their documentation (Black 22.1.0 documentation)
import statistics
import math
import sys
import time
def sort_list (list):
list.sort()
min = list[0]
max = list[-1]
def find_quartile1 (list):
len2 = len(list) / 2
if len2 % 2 != 0:
len2 = math.ceil(len2)
list2 = list[0: len2]
return list2
def find_quartile2 (list):
len2 = len(list) / 2
if len2 % 2 != 0:
len2 = math.ceil(len2)
len2 = len2
list3 = list[len2: -1]
list3.append(list[-1])
return list3
def find_IQR1 (quartile1):
print(statistics.median(quartile1))
def find_IQR2 (quartile2):
print(statistics.median(quartile2))
def find_ans (list):
print(‘median:’)
print(statistics.median(list))
print(‘quartile range 1:’)
print(find_quartile1(list))
print(“Quartile 1:”)
find_IQR1(find_quartile1(list))
print(‘quartile range 3:’)
print(find_quartile2(list))
print(“Quartile 3:”)
find_IQR2(find_quartile2(list))
print(“max:”)
print(str(max))
print(‘min:’)
print(str(min))
print(‘list:’)
print(str(list))
choice = input(“Would you like to use the console to input a list? (Y/N)”)
if choice == ‘Y’:
lst =
number of elements as input
n = int(input("Enter number of elements : "))
iterating till the range
for i in range(0, n):
ele = int(input())
lst.append(ele) # adding the element
print(lst) #Credit to Python | Get a list as input from user - GeeksforGeeks for user list input syntax
choice2 = input(“Is this correct? (Y/N)”)
if choice2 == “Y”:
sort_list(lst)
else:
print(“restart program”)
exit()
elif choice == ‘N’:
print(“Now use the code window. Pause the code. When you are finished, reload the program.”)
lst =
sort_list(lst)
else:
print(“Invalid Choice”)
exit() #end the program