Python 39
[Python 100] Python 100
(Python 2.0+)
#!/usr/bin/python
# -*- coding: UTF-8 -*-
if __name__ == '__main__':
# 0
a = [1,4,6,9,13,16,19,28,40,100,0]
print (':')
for i in range(len(a)):
print (a[i])
number = int(input("\n:\n"))
end = a[9]
if number > end:
a[10] = number
else:
for i in range(10):
if a[i] > number:
temp1 = a[i]
a[i] = number
for j in range(i + 1,11):
temp2 = a[j]
a[j] = temp1
temp1 = temp2
break
print (':')
for i in range(11):
print (a[i])
: 1 4 6 9 13 16 19 28 40 100 0 : 7 : 1 4 6 7 9 13 16 19 28 40 100
[Python 100] Python 100
wei***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- a = [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29] b = 18 a.append(b) c = a[:] l = len(c) # for i in range(l,0,-1): if (b>c[i-2]): c[i-1] =b break else: c[i-1] = c[i-2] print cwei***[email protected]
824***[email protected]
#!/usr/bin/python #coding:utf-8 import sys reload(sys) sys.setdefaultencoding('utf-8') # list = [1,2,3,4,5,6,8,9,10,11,12,13] print list #7 n = int(raw_input("")) #for for i in range(0,13): if list[i] < n < list[i+1]: list.insert(i+1,n) print u"\n",list824***[email protected]
animo
z@g***cc
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Lei Zhong' x=[1,3,5,6,88,99] y=int(raw_input(": ")) x.append(y) x.sort() print(x)animo
z@g***cc
252***[email protected]
:
#!/usr/bin/env python3 # -*- coding: utf-8 -*- L = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19] print(': {}'.format(L)) num = int(input(':')) L.append(num) for i in range(1, len(L)+1): if L[-i] < L[-(i+1)]: L[-i], L[-(i+1)] = L[-(i+1)], L[-i] else: break print(': {}'.format(L))252***[email protected]
JohnLee
372***[email protected]
Python3
# !/usr/bin/env python3 a = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31] b = 18 #, f0, f1 = 0, len(a) - 1 while f1 - f0 > 1: mid = f0 + int((f1 - f0) / 2) if a[mid] > b: f1 = mid else: f0 = mid a.insert(f0 + 1, b) print(a)JohnLee
372***[email protected]
dayu
923***[email protected]
#!/usr/bin/env python # -*- coding: utf-8 -*- l = [2,5,9,12,89] num = input("enter the num:") if num > l[len(l)-1]: l.append(num) elif num < l[0]: l.insert(0,num) else: for i in range(len(l)-1): if l[i] < num and num < l[i+1]: l.insert(i+1,num) break print ldayu
923***[email protected]
253***[email protected]
Python3
# coding:utf-8 List1=[2,5,4,8,3,1,9] List1=sorted(List1) print(":",List1) print() num=int(input(":")) List1.append(num) print(":",sorted(List1))253***[email protected]
Think_dfrent
iwa***[email protected]
Python3
#!/usr/bin/python3 carray=[1,4,6,9,13,16,19,28,40,100,110] n=int(input("please enter a number:\n")) newarray=[] flag,a=0,0 #flagn while a<len(array): if array[a]<n or flag==1: newarray.append(array[a]) else: newarray.append(n) a=a-1 flag=1 a=a+1 if flag==0: newarray.append(n) print(newarray)Think_dfrent
iwa***[email protected]
colinshi
col***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- def px(n): l=[1,4,6,9,13,16,19,28,40,100] d=[] if n>l[-1]: # l.append(n) print (l) else: # while len(l) >0 : l1=l.pop(0) if l1 < n: d.append(l1) else: # d.append(n) d.append(l1) d=d+l break print(d) if __name__=='__main__': px(111) px(0) px (10)colinshi
col***[email protected]
382***[email protected]
a=[1,2,3,4,5,6,9] b=7 for i in range(len(a)-1): if b >=a[i] and b<=a[i+1]: a.insert(i+1, b) break elif i==(len(a)-2): a.append(b) break print(a)382***[email protected]
py
152***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- arr = list(map(int, raw_input("").split())) arr.sort() # print arr arr1 = [] n = int(raw_input('')) for i in range(len(arr)): #nn if arr[i] < n and (arr[i+1] == n or arr[i+1] > n): arr1.extend(arr[0:i+1]) arr1.append(n) arr1.extend(arr[i+1:len(arr)]) break print arr1py
152***[email protected]