Advertisement
Guest User

Untitled

a guest
Sep 1st, 2018
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.13 KB | None | 0 0
  1. import sys
  2. script, filename = sys.argv
  3.  
  4. print("How old are you?", end=' ')
  5. age = input('>  ')
  6. print("How tall are you?", end=' ')
  7. height = input('>  ')
  8. print("How much do you weigh?", end=' ')
  9. weight = input('>  ')
  10.  
  11. print(f"So, you're {age} old, {height} tall and {weight} heavy.")
  12.  
  13. txt = open(filename)
  14.  
  15. print(f"Here's your file {filename}:")
  16. print(txt.read())
  17.  
  18. print("Type the filename again:")
  19. file_again = input("> ")
  20.  
  21. txt_again = open(file_again)
  22.  
  23. print(txt_again.read())
  24.  
  25.  
  26. print('Let\'s practice everything.')
  27.  
  28. print("You\'d need to know \'bout escapes with \\ that do \n newlines and \t tabs.")
  29.  
  30. poem = """
  31. \tThe lovely world
  32. with logic so firmly planted
  33. cannot discern \n the needs of love
  34. nor comprehend passion from intuition
  35. and requires an explanation
  36. \n\t\twhere there is none.
  37. """
  38.  
  39. print("--------------")
  40. print(poem)
  41. print("--------------")
  42.  
  43.  
  44. five = 10 - 2 + 3 - 6
  45. print(f"This should be five: {five}")
  46.  
  47. def secret_formula(started):
  48.     jelly_beans = started * 500
  49.     jars = jelly_beans / 1000
  50.     crates = jars * 100
  51.     return jelly_beans, jars, crates
  52.  
  53. start_point = 10000
  54. beans, jars, crates = secret_formula(start_point)
  55.  
  56. # remember that this is another way to format a string
  57. print("With a starting point of: {}".format(start_point))
  58. # it's just like with an f"" string
  59. print(f"We'd have {beans} beans, {jars} jars, and {crates} crates.")
  60.  
  61. start_point = start_point / 10
  62.  
  63. print("We can also do that this way:")
  64. formula = secret_formula(start_point)
  65. # this is an easy way to apply a list to a format string
  66. print("We'd have {} beans, {} jars, and {} crates.".format(*formula))
  67.  
  68. people = 20
  69. cats = 30
  70. dogs = 15
  71.  
  72. if people < cats:
  73.     print("Too many cats! The world is doomed!")
  74.  
  75. if people > cats:
  76.     print("Not many cats! The world is saved!")
  77.  
  78. if people < dogs:
  79.     print("The world is drooled on!")
  80.  
  81. if people > dogs:
  82.     print("The world is dry!")
  83.  
  84. dogs += 5
  85.  
  86. if people >= dogs:
  87.     print("People are greater than or equal to dogs.")
  88.  
  89. if people <= dogs:
  90.     print("People are less than or equal to dogs.")
  91.  
  92. if people == dogs:
  93.     print("People are dogs.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement