Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pickle#This is me importing my Pickle.def enter_list():
- def enter_list():
- mylist = []
- while True:
- #user_input = raw_input("Enter something:")
- #if user_input == "quit":
- #break
- input1=input("you entered:")
- if input1=="exit":
- #This if statement will exit the entering mode if the user types in e.
- break
- mylist.append(float(input1))
- print("your numbers are")
- print(mylist)
- return mylist
- def sortingasd(num_list):
- swapped = True
- while swapped:
- swapped = False
- p = (0)
- for i in range(len(num_list)-1):# This working until the length.
- q = p+(1)
- if num_list[p] > num_list[q]:
- num=num_list[p]
- num_list[p]=num_list[q]
- num_list[q]=num
- num_list[q]=num
- swapped = True
- p=p+(1)
- return num_list
- def sortingdsc(num_list):
- swapped = True
- while swapped:
- swapped = False
- p = (0)
- for i in range(len(num_list)-1):# This is printing the lenth of number list.
- q = p+(1)
- if num_list[p] < num_list[q]:#this code is telling the program if P is greater than q then process the code below.
- num=num_list[p]#This code is telling the program num is = to num_list.
- num_list[p]=num_list[q]
- num_list[q]=num
- num_list[q]=num
- swapped = True
- p=p+(1)
- return num_list
- num_list = []
- num_list = enter_list()
- #This input statement is asking the user if they want it in dsc or asd order.
- enterasdordsc= input("please enter either asd or dsc:")
- with open('linearprogrammingfile.pkl', 'wb') as picklefile:#This code open's the Pickle file.
- pickle.dump(num_list, picklefile)#This code is dump my code into linearprogrammingfile.pkl
- picklefile.close()#This is closing the Pickle file.
- with open ('linearprogrammingfile.pkl', 'rb') as picklefile:
- num_list = pickle.load(picklefile)
- picklefile.close()
- if enterasdordsc== "asd":
- print (sortingasd(num_list))
- with open('linearprogrammingfile.pkl', 'wb') as picklefile:
- pickle.dump(num_list, picklefile)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement