Data structures
This has all the python course it needs.
It has 4 modules:
- Data structures: For Basic python
- OOPS: For Classes and Functions in python
- Algorithms: For Search, Sort and Other algorithms
- Bytes: Quick points to Excel
Data Structures:
-
Max Number: Finding the Max number in a list
# problem: Largest of N numbers # solution: we can use a for loop, iterate over & compare. numbers = [23,45,56,44,56,77,33,44,22,11,10] big = numbers[0] # it is advantage to take the ""First value"" in list, rather than taking big = np.inf # or big = 0 for number in numbers: if number>big: big = number print(big)
-
GCD or HCF: Finding the Max Common number that devides the numbers.
-
Proper use of
if
vselif
:button = int(input()) while button != 6: if button <= 5 and button>=1: # since it is b/n 2 bounds, "AND" is used. a = int(input()) b = int(input()) if button ==1: print(a+b) if button ==2: print(a-b) if button ==3: print(a*b) if button ==4: print(a//b) if button ==5: print(a%b) elif button <1 or button >5: # Since it is outside of 2 bounds, "OR" is used. print("Invalid Operation") button = int(input())
-
Fibanocci number: Fibanocci is a number pattern that use its precident 2 numbers and keeps their sum as 3 rd number. There are many different ways. this is one way.
-
Reverse Number
num = 1234 reversed_num = 0 while num != 0: digit = num % 10 # it gives the remainder. Always last value in a number from right side. reversed_num = reversed_num * 10 + digit # this increases number at 10X & adds Remainder. num //= 10 # this gives the quotient with roundedness. print("Reversed Number: " + str(reversed_num))
-
Palindrome Number: If Reverse of a number equal to the number, then it is palindrome. ex:
121