Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if __name__ == "__main__":
- # Problem I
- x = int(input("Enter a number from 1 to 20: "))
- x = ((x * 2 + 10) / 2) - x
- print(x)
- # Problem II
- a = int(input("Enter first number: "))
- b = int(input("Enter second number: "))
- c = a + b
- d = b + c
- e = c + d
- f = d + e
- g = e + f
- h = f + g
- i = g + h
- j = h + i
- print((a + b + c + d + e + f + g + h + i + j) / g)
- # Problem III
- num = int(input("Enter a 4-digit number: "))
- a = num // 1000
- a1 = a * 1000
- b = num % 10
- b2 = b * 1000
- num2 = (num - a1 + b2 - b + a)
- smaller = min(num, num2)
- larger = max(num, num2)
- subtract = larger - smaller
- digit_thousand = subtract // 1000
- digit_hundred = subtract % 1000 // 100
- digit_one = subtract % 10
- digit_ten = subtract % 100 // 10
- digit_added = digit_thousand + digit_hundred + digit_one + digit_ten
- two_digit_add = (digit_added % 10) + (digit_added // 10)
- print(two_digit_add)
- # Problem IV
- num = int(input("Enter a number not divisible by 7: "))
- divided = num / 7
- num1 = (divided * 1000000)
- digit1 = (num1 % 1000000 // 100000)
- digit2 = (num1 % 100000 // 10000)
- digit3 = (num1 % 10000 // 1000)
- digit4 = (num1 % 1000 // 100)
- digit5 = (num1 % 100 // 10)
- digit6 = (num1 % 10)
- print(int(digit1 + digit2 + digit3 + digit4 + digit5 + digit6))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement