Compare commits
5 Commits
6690d9cdf4
...
6bef49c6b2
Author | SHA1 | Date |
---|---|---|
|
6bef49c6b2 | |
|
ba5ac1f29a | |
|
8391478991 | |
|
291fc92aa6 | |
|
f609162053 |
|
@ -0,0 +1,9 @@
|
|||
|
||||
def swap(list):
|
||||
m_list = list[0], list[-1] = list[-1], list[0]
|
||||
return m_list
|
||||
|
||||
values_list = input().split(',') # Program receives comma-separated values like 5,4,12,19
|
||||
swap(values_list)
|
||||
|
||||
print(values_list)
|
|
@ -0,0 +1,12 @@
|
|||
gas_const = 8.3144621
|
||||
|
||||
def compute_gas_volume(pressure, temperature, moles):
|
||||
return (moles * gas_const * temperature) / pressure
|
||||
|
||||
gas_pressure = float(input())
|
||||
gas_moles = float(input())
|
||||
gas_temperature = float(input())
|
||||
gas_volume = 0.0
|
||||
|
||||
gas_volume = compute_gas_volume(gas_pressure, gas_temperature, gas_moles)
|
||||
print('Gas volume:', gas_volume, 'm^3')
|
|
@ -0,0 +1,6 @@
|
|||
def swap_values(user_val1, user_val2):
|
||||
return user_val2, user_val1
|
||||
|
||||
if __name__ == '__main__':
|
||||
val1, val2 = swap_values(input(), input())
|
||||
print('{0} {1}'.format(val1, val2))
|
|
@ -0,0 +1,46 @@
|
|||
coins = [
|
||||
['Dollars', 'Dollar'],
|
||||
['Quarters', 'Quarter'],
|
||||
['Dimes', 'Dime'],
|
||||
['Nickels', 'Nickel'],
|
||||
['Pennies', 'Penny']]
|
||||
|
||||
def coin_enumeration(change):
|
||||
if len(change) != 0:
|
||||
for coin in coins:
|
||||
num_coins = change.count(coin)
|
||||
if num_coins != 0:
|
||||
if num_coins > 1:
|
||||
print('{0} {1}'.format(num_coins, coin[0].lower()))
|
||||
else:
|
||||
print('{0} {1}'.format(num_coins, coin[1].lower()))
|
||||
else:
|
||||
print('no change')
|
||||
|
||||
def fit_coin(to_make, coin_val):
|
||||
num_coin = to_make // coin_val
|
||||
remainder = to_make - (num_coin * coin_val)
|
||||
|
||||
return num_coin, remainder
|
||||
|
||||
def exact_change(input_val):
|
||||
nd, input_val = fit_coin(input_val, 100)
|
||||
nq, input_val = fit_coin(input_val, 25)
|
||||
ndime, input_val = fit_coin(input_val, 10)
|
||||
nn, input_val = fit_coin(input_val, 5)
|
||||
np, input_val = fit_coin(input_val, 1)
|
||||
|
||||
return nd, nq, ndime, nn, np
|
||||
|
||||
if __name__ == '__main__':
|
||||
change = []
|
||||
input_val = int(input())
|
||||
num_dollars, num_quarters, num_dimes, num_nickels, num_pennies = exact_change(input_val)
|
||||
|
||||
change.extend([coins[0] for i in range(num_dollars)])
|
||||
change.extend([coins[1] for i in range(num_quarters)])
|
||||
change.extend([coins[2] for i in range(num_dimes)])
|
||||
change.extend([coins[3] for i in range(num_nickels)])
|
||||
change.extend([coins[4] for i in range(num_pennies)])
|
||||
|
||||
coin_enumeration(change)
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
def shampoo_instructions(num_cycles):
|
||||
if num_cycles < 1:
|
||||
print('Too few.')
|
||||
elif num_cycles > 4:
|
||||
print('Too many.')
|
||||
else:
|
||||
for i in range(num_cycles):
|
||||
print('{0} : Lather and rinse.'.format(i + 1))
|
||||
print('Done.')
|
||||
|
||||
user_cycles = int(input())
|
||||
shampoo_instructions(user_cycles)
|
Loading…
Reference in New Issue