Guest User

Untitled

a guest
Feb 18th, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. import csv
  4. import math
  5.  
  6. list_tc = [None]*75
  7. list_adsoyad = [None]*75
  8.  
  9. def hash(tc):
  10. tc = int(tc)
  11. k = int(math.sqrt(tc)**3+math.sqrt(tc)*2)
  12. return k%75
  13.  
  14.  
  15. def hash_chain():
  16.  
  17. oku = open("ogrenci10.csv", "r")
  18. kisiler = oku.readlines()
  19.  
  20. for kisi in kisiler:
  21.  
  22. ad = kisi.split(';')[1]
  23. soyad = kisi.split(';')[2]
  24. tc = kisi.split(';')[3]
  25. tc = tc[:len(tc)-1]
  26.  
  27. adsoyad = ad[:len(ad)-1] + " " + soyad[1:]
  28.  
  29. indis = hash(tc)
  30.  
  31. if list_tc[indis] == None :
  32.  
  33. list_tc[indis] = tc
  34. list_adsoyad[indis] = adsoyad
  35. else :
  36.  
  37. if len(list_tc[indis]) == 11 :
  38. gecici = list_tc[indis]
  39. gecici2 = list_adsoyad[indis]
  40. list_tc[indis] = [gecici]
  41. list_adsoyad[indis] = [gecici2]
  42. list_tc[indis].append(tc)
  43. list_adsoyad[indis].append(adsoyad)
  44.  
  45. else :
  46. list_tc[indis].append(tc)
  47. list_adsoyad[indis].append(adsoyad)
  48.  
  49. print list_adsoyad
  50. print list_tc
  51.  
  52.  
  53. def hash_name(tc):
  54.  
  55. index = hash(tc)
  56.  
  57. if len(list_tc[index]) == 11:
  58. print list_adsoyad[index]
  59.  
  60. else:
  61. i = list_tc[index].index(tc)
  62. print list_adsoyad[index][i]
  63.  
  64. hash_chain()
  65. hash_name('66808095204')
Add Comment
Please, Sign In to add comment