猴子學Python - Business Computing in Python (week 2)
This series are notes taken for the coursera course: Programming for Business Computing in Python(1)(用Python做商管程式設計)
Week 1 is just an introduction about how computing can work for business management.
print and arithmetic
some terms
statement, one statement must be put in a single line in python!
operation
function
operand(argument)“” or ‘’
change line with “newline character”: \n
And some other special characters: \t, \, ', "
string operation
arithmetic: +, -, *, **(square), /(floating-point division), //(floor division), %(remainder)
input and variables
variables:
- takes a memory space
- data type: int(integer), float(fractional numbers), string(string)
- type, name, value
- declare the value
- use type() to see the type
string, integer and floating point
- adding
- type conversion int(), str()
EX1:
w = int(input())
x = int(input())
y = int(input())
z = int(input())
print(w*50 + x*10 + y*5 + z*1)
EX2:(My solution looks stupid…… )
a = int(input("Total:"))
change = 1000-a
FHbill = change//500
leftFH = change-FHbill*500
OHbill = leftFH//100
leftOH = leftFH-OHbill*100
FTbill = leftOH//50
leftFT = leftOH-FTbill*50
TENcoin = leftFT//10
leftTEN = leftFT-TENcoin*10
FIVEcoin = leftTEN//5
leftFIVE = leftTEN-FIVEcoin*5
ONEcoin = leftFIVE
print(FHbill, OHbill, FTbill, TENcoin, FIVEcoin, ONEcoin)