Last active
October 25, 2017 08:18
-
-
Save ysnerdem/fbf9e4c8a317961029101069ac08bf09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list = [-1, -2, 0, 1, 2, 3, 4, 5, 18, 6] | |
class count: | |
temp = 0 | |
templist = [] | |
def max(self): | |
max = 0 | |
for i in list: | |
if i > max: | |
max = i | |
self.temp = max | |
print(max) | |
def min(self): | |
min = list[0] | |
for i in list: | |
if i < min: | |
min = i | |
self.temp = min | |
print(min) | |
def sum(self): | |
sum = 0 | |
for i in list: | |
sum += i | |
self.temp = sum | |
print(sum) | |
def sort(self): | |
for j in range(len(list) - 1, 0, -1): | |
for i in range(j): | |
if list[i] > list[i + 1]: | |
list[i], list[i + 1] = list[i + 1], list[i] | |
self.templist = list | |
print(list) | |
def pnz(self): | |
neg_nums = 0 | |
pos_nums = 0 | |
zero = 0 | |
for i in list: | |
if i > 0: | |
pos_nums += 1 | |
self.temp = pos_nums | |
elif i < 0: | |
neg_nums += 1 | |
self.temp = neg_nums | |
else: | |
zero += 1 | |
self.temp = zero | |
print("negative numbers:", neg_nums) | |
print("positive numbers:", pos_nums) | |
print("zeros:", zero) | |
def div(self): | |
num = 3 | |
div = 0 | |
for i in list: | |
if i%num == 0 and i != 0: | |
div += i | |
self.temp = div | |
print(div) | |
while True: | |
print("**You can perform the desired operation by entering the number of operations**") | |
print("1.Max.Number") | |
print("2.Min Number") | |
print("3.Sum of Numbers at the List:") | |
print("4.Alignment") | |
print("5.Positives,Negatives and Zeros") | |
print("6.Division") | |
print("*Enter 0 or any Number for Termination*") | |
number = int(input("Process number:")) | |
if number == 1: | |
maximize = count | |
count.max(maximize) | |
elif number == 2: | |
min_ = count | |
count.min(min_) | |
elif number == 3: | |
sum_ = count | |
count.sum(sum_) | |
elif number == 4: | |
sorted = count | |
count.sort(sorted) | |
elif number == 5: | |
pnz_ = count | |
count.pnz(pnz_) | |
elif number == 6: | |
num = int(input("Enter the desired number of divisions:")) | |
division = count | |
count.div(division) | |
else: | |
break | |
canozel
commented
Oct 25, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment