This python program asks the user to input the number of characters they want to use in a list. The user then inputs multiple numbers to form their list. The program runs through these numbers and checks if their list forms a geometric progression. If this sequence creates a geometric progression, the ratio of that progression is shown as well.
firstlist =  # The list with the inputted numbers. secondlist =  # The list with the division between each number. length = int(input("How many numbers do you want in the list? ")) # Ask user how many numbers in sequence. # The user inputs a number and that number is added to the firstlist def inputlist (length): for x in range(0, length): number = float(input("Type your number: ")) firstlist.append(number) division = 0 # Every two numbers in firstlist are divided, and the divided number is added to secondlist. def divlist (length): for y in range(0, length): if y < (len(firstlist)-1): division = (firstlist[y + 1] / firstlist[y]) secondlist.append(division) inputlist(length) divlist(length) counter = 0 # Counter to count the number of times the ratio is equal to each other. firstnum = secondlist # The list of all numbers from secondlist are compared to each other to see if they are similar or not. def geometric (secondlist, firstnum, counter): for x in secondlist: if firstnum == x: # This if-statement is to start the counter with the base of 1. firstnum == x counter = counter + 1 if counter == len(secondlist): # If the progressed counter is equal to the number of numbers in the list, then geometric progression exists. print("This sequence is a geometric progression. The common ratio is", firstnum) if x == secondlist[len(secondlist)-1] and counter != len(secondlist): # If x is equal to the last number in the division list (to make sure the list is ran through) and the counter isn't equal to the number of characters in the list, a geometric progression does not exist. print("This is not a geometric progression.") geometric(secondlist, firstnum, counter)