Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #py lab 1
- #1
- print("Сonditions: a, b = (1..100)")
- a = int(input("Enter a: "))
- b = int(input("Enter b: "))
- while (a < 1 or a > 100 or b < 1 or b > 100):
- print("ERROR: invalid values")
- print("Enter a, b again")
- a = int(input("Enter a: "))
- b = int(input("Enter b: "))
- if a > b:
- x = a / b + 1
- elif a == b:
- x = -2
- else:
- x = (a - b) / b
- print("Result: {0}".format(x))
- #2
- N = 30
- sum = 0
- for i in range(N):
- sum += 1 / (i+1)
- print("Result: {0}".format(sum))
- #3
- N = int(input("Enter N: "))
- for i in range(N):
- print(i * 2 * ' ', end='')
- for j in range(i, N):
- print(j + 1, end=' ')
- print()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement