Advertisement
hnitidat

analyzer

Feb 24th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.15 KB | None | 0 0
  1.  
  2.  
  3. TEXTS = {
  4.     '1': '''Situated about 10 miles west of Kemmerer,
  5. Fossil Butte is a ruggedly impressive
  6. topographic feature that rises sharply
  7. some 1000 feet above Twin Creek Valley
  8. to an elevation of more than 7500 feet
  9. above sea level. The butte is located just
  10. north of US 30N and the Union Pacific Railroad,
  11. which traverse the valley. ''',
  12.     '2': '''At the base of Fossil Butte are the bright
  13. red, purple, yellow and gray beds of the Wasatch
  14. Formation. Eroded portions of these horizontal
  15. beds slope gradually upward from the valley floor
  16. and steepen abruptly. Overlying them and extending
  17. to the top of the butte are the much steeper
  18. buff-to-white beds of the Green River Formation,
  19. which are about 300 feet thick.''',
  20.     '3': '''The monument contains 8198 acres and protects
  21. a portion of the largest deposit of freshwater fish
  22. fossils in the world. The richest fossil fish deposits
  23. are found in multiple limestone layers, which lie some
  24. 100 feet below the top of the butte. The fossils
  25. represent several varieties of perch, as well as
  26. other freshwater genera and herring similar to those
  27. in modern oceans. Other fish such as paddlefish,
  28. garpike and stingray are also present.'''
  29. }
  30.  
  31. # registered users
  32. users = {
  33.     "bob": "123",
  34.     "ann": "pass123",
  35.     "mike": "password123",
  36.     "liz": "pass123"}
  37.  
  38. # login
  39. print("-" * 40)
  40. print("Welcome to the app. Please log in: ")
  41.  
  42. user_name = input("USERNAME: ")
  43. user_password = input("PASSWORD: ")
  44.  
  45. istit = 0
  46. isnum = 0
  47. isupp = 0
  48. islow = 0
  49. numval = []  #číselné hodnoty v textu, slouží pro součet čísel v textu
  50. list_of_word_len = []  #list délky slov, slouží pro sestavení grafu
  51.  
  52.  
  53. # ověření uživatele
  54. if users.get(user_name) != user_password:
  55.     print("Wrong user name or password.")
  56. elif users.get(user_name) == user_password:
  57.     #výběr textu
  58.     print("-" * 40)
  59.     print("We have 3 texts to be analyzed.")
  60.     user_select = input("Enter a number btw. 1 and 3 to select: ")
  61.     print("-" * 40)
  62.     #převedení textu
  63.     short_us = TEXTS.get(user_select)
  64.     no_dot = short_us.replace("." , "")
  65.     no_comma = no_dot.replace("," , "")
  66.     sele = no_comma.split()
  67.     words_in_text = len(sele)
  68.     x = 0
  69.     while x < words_in_text:
  70.         if sele[x].istitle():
  71.             istit += 1
  72.         if sele[x].isnumeric():
  73.             numval.append(int(sele[x]))
  74.             isnum += 1
  75.         if sele[x].isupper():
  76.             isupp += 1
  77.         if sele[x].islower():
  78.             islow += 1
  79.         list_of_word_len.append(len(sele[x]))
  80.         x += 1
  81.     print("There are " + str(words_in_text) + " words in total.")
  82.     print("There are " + str(istit) + " titlecase words.")
  83.     print("There are " + str(isupp) + " uppercase words.")
  84.     print("There are " + str(islow) + " lowercase words.")
  85.     print("There are " + str(isnum) + " numeric strings.")
  86.     print("-" * 40)
  87.     val_in_set = set(list_of_word_len)
  88.     while len(val_in_set) > 0:
  89.         size = val_in_set.pop()
  90.         print(size , "*" * list_of_word_len.count(size) , list_of_word_len.count(size))
  91.     print("-" * 40)
  92.     print("If we summed all the numbers in this text we would get: " + str(sum(numval)))
  93.     print("-" * 40)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement