Skip to content

Instantly share code, notes, and snippets.

View samerlol's full-sized avatar

Samer Yousef samerlol

  • Amman, jordan
View GitHub Profile
Serial Keys:
FU512-2DG1H-M85QZ-U7Z5T-PY8ZD
CU3MA-2LG1N-48EGQ-9GNGZ-QG0UD
GV7N2-DQZ00-4897Y-27ZNX-NV0TD
YZ718-4REEQ-08DHQ-JNYQC-ZQRD0
GZ3N0-6CX0L-H80UP-FPM59-NKAD4
YY31H-6EYEJ-480VZ-VXXZC-QF2E0
ZG51K-25FE1-H81ZP-95XGT-WV2C0
VG30H-2AX11-H88FQ-CQXGZ-M6AY4
for i in range(0,10):
for x in range(i,i+5):
print("*", end=' ')
print(" ")
@samerlol
samerlol / Program2PrintSumOfElementsInTheArray.py
Created November 13, 2019 15:11
Python program to print the sum of all elements in an array
class Program2PrintSumOfElementsInTheArray :
# Python program to print the sum of elements in an array#
arr1=[1, 2, 3, 4, 2, 7, 8, 8, 3]
sum=0
for i in range(0,len(arr1)):
sum+=arr1[i]
print(sum)
@samerlol
samerlol / Program2PrintTheLargestElementInTheArray.py
Created November 13, 2019 15:09
Python program to print the largest element in an array
class Program2PrintTheLargestElementInTheArray :
# Python program to print the largest element in an array#
arr1=[1, 2, 3, 4, 2, 7, 8, 8, 3]
x= arr1[0]
for i in range(0,len(arr1)):
if arr1[i]>x:
x=arr1[i]
print(x)
@samerlol
samerlol / Program2PrintDuplicateValues.py
Created November 13, 2019 14:47
ALGORITHM: STEP 1: Declare and initialize an array. STEP 2: Duplicate elements can be found using two loops. The outer loop will iterate through the array from 0 to length of the array. The outer loop will select an element. The inner loop will be used to compare the selected element with the rest of the elements of the array. STEP 3: If a match…
class Program2PrintDuplicateValues :
# Python program to left rotate the elements of an array #
arr1=[1, 2, 3, 4, 2, 7, 8, 8, 3]
for i in range(0,len(arr1)):
for c in range(i+1,len(arr1)):
if arr1[i]==arr1[c]:
print(arr1[i])
continue
@samerlol
samerlol / program2shit2left.py
Created November 13, 2019 14:38
Python program to left rotate the elements of an array this program, we need to rotate the elements of an array towards the left by the specified number of times. In the left rotation, each element of the array will be shifted to its left by one position and the first element of the array will be added to end of the list. This process will be fo…
class program2shit2left :
# Python program to left rotate the elements of an array #
arr1=[1,2,3,4,5,6,7]
n = int(input("Enter how many times to shift to the left :"))
for c in range(0,n):
temp= arr1[0]
for i in range(0,len(arr1)-1):
arr1[i]=arr1[i+1]
arr1[len(arr1)-1]=temp
@samerlol
samerlol / FrequencyOfEachElementInTheArray.py
Created November 13, 2019 14:21
1 2 8 3 2 2 2 5 1 In the given array, 1 has appeared two times, so its frequency is 2, and 2 has appeared four times so have frequency 4 and so on.
class FrequencyOfEachElementInTheArray :
# Python program to find the frequency of each element in the array #
arr1=[1 , 2 ,8 ,3 , 2 , 2, 2 , 5 ,1 ]
arr2={}
for i in range(0,len(arr1)):
count=0
for sub in arr1:
if arr1[i]==sub:
count+=1
@samerlol
samerlol / CopyAnArray2Another.py
Created November 13, 2019 13:42
ALGORITHM: STEP 1: Declare and initialize an array. STEP 2: Declare another array of the same size as of the first one STEP 3: Loop through the first array from 0 to length of the array and copy an element from the first array to the second array that is arr1[i] = arr2[i].
class CopyAnArray2Another :
arr1=[1,2,3,4,5]
print(arr1)
e=0
arr2=[None]*len(arr1)
for i in range(0,len(arr1)):
arr2[i]=arr1[i]
print(arr2)
@samerlol
samerlol / Convert2BiOcHex.py
Created November 13, 2019 13:27
Decimal System: The most widely used number system is decimal system. This system is base 10 number system. In this system, ten numbers (0-9) are used to represent a number. Binary System: Binary system is base 2 number system. Binary system is used because computers only understand binary numbers (0 and 1). Octal System: Octal system is base 8 …
class Convert2BiOcHex :
number = int(input("Please, enter a number to convert it :"))
print(bin(number))
print(oct(number))
print(hex(number))
@samerlol
samerlol / SumNaturalNumbers.py
Created November 12, 2019 13:16
Sum of Natural Numbers This is a simple program to print the sum of natural numbers.
class SumNaturalNumbers :
natNum= int(input("Enter a Number to sum it's natural number :"))
while natNum<0:
print("Please, Enter a positive Number...")
natNum = int(input())
sum=0
while natNum>0:
sum+=natNum
natNum-=1
print(sum)