Advertisement
Chl_Snt

№11. Модули

Feb 24th, 2023
626
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. import название_модуля
  2. # или
  3. import main
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10. import random
  11.  
  12. a = random.randint(0, 10)
  13. print(a)
  14.  
  15.  
  16.  
  17.  
  18.  
  19. import random
  20.  
  21. shop = ["молоко", "колбаса", "сыр"]
  22. ch = random.choice(shop)
  23. print(ch)
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31. import time
  32.  
  33. print(1)
  34. time.sleep(2)
  35. print(3)
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42. import datetime
  43.  
  44. print(datetime.datetime.now().hour)
  45. print(datetime.datetime.now().minute)
  46. print(datetime.datetime.now().second)
  47. print(datetime.datetime.now().year)
  48. print(datetime.datetime.now().month)
  49. print(datetime.datetime.now().day)
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56. import random
  57.  
  58. dictionary = {
  59.     "Слива": "12 ккал",
  60.     "Банан": "120 ккал",
  61.     "Яблоко": "54 ккал",
  62.     "Snickers": "132 ккал"
  63. }
  64.  
  65. keys = list(dictionary.keys())
  66. rnd = random.choice(keys)
  67. print("%s: %s" % (rnd, dictionary[rnd]))
  68.  
  69.  
  70.  
  71. import time
  72.  
  73. max = int(input("Введи количество секунд: "))
  74. timer = 0
  75. while timer != max:
  76.     print("Прошла 1 секунда. Осталось", max - timer, "секунд.")
  77.     time.sleep(1)
  78.     timer += 1
  79. print("Дзынь-Дзынь")
  80.  
  81.  
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement