-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimple_python_code.py
71 lines (66 loc) · 1.7 KB
/
Simple_python_code.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
def check():
global listuna
isValid=False
while not isValid:
try:
listuna = int(input("Input Length of List: "))
isValid=True
break
except:
print "Input Integer Only"
def checking(lst) :
for i in range(len(lst)) :
if lst[i].isdigit() != True :
return False
return True
check()
list1 = []
for i in range (0, listuna):
lista = raw_input("Input value for list1: ")
list1.append(lista)
print "List 1: ",list1
for i in range(len(list1)) :
if checking(list1[i]) :
withstr = False
else:
withstr = True
break
if withstr == False:
Largest = max(list1)
Smallest = min(list1)
SumL = sum(map(int, list1))
print "The Sum of the List is: ", SumL
print "The Largest value in the list is: ", Largest
print "The Smallest value in the list is: ", Smallest
else:
Largest = max(list1)
Smallest = min(list1)
print "The Sum of the List is: Cannot be sum because of string"
print "The Largest value in the list is: ", Largest
print "The Smallest value in the list is: ", Smallest
print("\n")
check()
list2 = []
for i in range (0, listuna):
listb = raw_input("Input value for list: ")
list2.append(listb)
print "List 1: ",list1
print "List 2: ",list2
for g, c in map(None, list1, list2):
print "List 1:",g," ","List 2:",c
print ("\n")
print ("Convert list into list of dictionaries")
a = 0
dictio1={}
dictio2={}
for i in range(len(list1)):
a=i+1
dictio1[a]=list1[i]
for i in range(len(list2)):
a=i+1
dictio2[a]=list2[i]
print "List 1 into Dictionaries: ", dictio1
print "List 2 into Dictionaries: ", dictio2
for g, c in map(None, dictio1, dictio2):
print "Dictionaries 1 Value: ",g," ", "Dictionaries 2 Value: ",c
print("\n")