Posts

Showing posts from March, 2022

#4aa: Coding in Python {LCM Calculator}

Image
x=1 while x!=0:     howMany = int(input('Enter number of numbers: '))     print()     if howMany>1:         x=0         allNumbers = []         for i in range(howMany):             EN=('Enter number #{}: '.format(i+1))             y=1             while y!=0:                                 number = int(input(EN))                 if number>1:                     y=0                     allNumbers.append(number)                 else:                     print('Retry, make sure that desired number is a natural number, i.e., more than 0.')                     print()         #product         product = 1         for i in (allNumbers):                 product=product*i         #collection            bigList=[]         for i in (allNumbers):             for j in range (1,(int(product/i))+1):                 bigList.append(i*j)               #filter         for i in (bigList):             if bigList.count(i)==howMany:                  print()                 print

#4z: Coding in Python {Sorter}

Image
 116 times better than this garbage  . n = int(input('No of terms: ')) itema = [] for i in range(n):     t = int(input("Enter numbers: "))     itema.append(t)     def ran(di):     global want     low = di[0]         for i in (di):         if i<low:low=i       return low test1 = [] for i in range (n):     test1.append(ran(itema))     itema.remove(ran(itema)) print(test1) test1.reverse() print(test1) I would like to thank Mr. Abdul Rahmani for suggesting major changes. Download the above code from here .