SHARE
TWEET

Untitled

a guest Jan 16th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if __name__ == "__main__":
  2.    
  3.     # Problem I
  4.     x = int(input("Enter a number from 1 to 20: "))
  5.     x = ((x * 2 + 10) / 2) - x
  6.     print(x)
  7.  
  8.     # Problem II
  9.     a = int(input("Enter first number: "))
  10.     b = int(input("Enter second number: "))
  11.     c = a + b
  12.     d = b + c
  13.     e = c + d
  14.     f = d + e
  15.     g = e + f
  16.     h = f + g
  17.     i = g + h
  18.     j = h + i
  19.     print((a + b + c + d + e + f + g + h + i + j) / g)
  20.    
  21.     # Problem III
  22.     num = int(input("Enter a 4-digit number: "))
  23.     a = num // 1000
  24.     a1 = a * 1000
  25.     b = num % 10
  26.     b2 = b * 1000
  27.     num2 = (num - a1 + b2 - b + a)
  28.     smaller = min(num, num2)
  29.     larger = max(num, num2)
  30.     subtract = larger - smaller
  31.     digit_thousand = subtract // 1000
  32.     digit_hundred = subtract % 1000 // 100
  33.     digit_one = subtract % 10
  34.     digit_ten = subtract % 100 // 10
  35.     digit_added = digit_thousand + digit_hundred + digit_one + digit_ten
  36.     two_digit_add = (digit_added % 10) + (digit_added // 10)
  37.     print(two_digit_add)
  38.  
  39.     # Problem IV
  40.     num = int(input("Enter a number not divisible by 7: "))
  41.     divided = num / 7
  42.     num1 = (divided * 1000000)
  43.     digit1 = (num1 % 1000000 // 100000)
  44.     digit2 = (num1 % 100000 // 10000)
  45.     digit3 = (num1 % 10000 // 1000)
  46.     digit4 = (num1 % 1000 // 100)
  47.     digit5 = (num1 % 100 // 10)
  48.     digit6 = (num1 % 10)
  49.     print(int(digit1 + digit2 + digit3 + digit4 + digit5 + digit6))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top