2-1
num = int(input('plz input an num:'))
a = int(num / 100)
b = int(num / 10) - a * 10
c = num % 10
print('ones, tens, hundreds')
print(a, b, c)
-----------------------------------------------------------------------------------------------------------------------
RIVISED1
x = input('plz input an num:')
a, b, c = map(int, x)
print('ones, tens, hundreds')
print(a, b, c)
RIVISED2:
x = int(input('plz input an num:'))
a, b = divmod(x, 100)
b, c = divmod(b, 10)
print('ones, tens, hundreds')
print(a, b, c)
-----------------------------------------------------------------------------------------------------------------------
2-2
import math
x = float(input('plz input 1st side:'))
y = float(input('plz input 2nd side:'))
a = float(input('plz input angle(°):'))
z = math.sqrt(x**2 + y**2 - 2*x*y*math.cos(a*math.pi/180))
print(z)
-----------------------------------------------------------------------------------------------------------------------
RIVISED:
import math
num = input('plz input side1, side2, angle(°):\n(split by key space)')
x, y, a = map(float, num.split())
z = math.sqrt(x**2 + y**2 - 2*x*y*math.cos(a*math.pi/180))
print(z)
-----------------------------------------------------------------------------------------------------------------------
2-3
a = []
for i in range(3):
letter = input('plz input 1 of 3 letters:')
a.append(letter)
a.sort()
for i in a:
print(i)
-----------------------------------------------------------------------------------------------------------------------
RIVISED:
letters = input('x, y, z = ')
x, y, z = sorted(letters.split(','))
print(x, y, z)
-----------------------------------------------------------------------------------------------------------------------
|