How to write virtual currency API interface in Python
This problem is very simple. You need to add some comments. I don't know how to add them. Let's look at the specific code
< pre t = "code" L = "Python" > # define payment computer classclasspaycalculator:
# initialization method, set hourly wage
def__ init__( self):
self.pay_ Rate = 100
? Calculation method, enter the working hours, and return the salary payable
defcompute_ pay(self,hours):
returnself.pay_ Rate * hours
# define a payment computer object
A = paycalculator()
# when calculating the default hourly wage, 10 hours of work should be paid
Print (a.compute_ Pay (10))
# set hourly wage
A.pay_ rate=20
print(a.compute_ pay(10))
return f' RMB: 20 US dollars: {money * 20} & # 39
I don't know what you mean, but it's very simple. I don't know what effect you want. You'd better give an example, such as what to input and what to output
count = 0 # 1 正面 0 反面 记录1的次数
for i in range(10000000):
n = random.randint(0,1)
if n == 1:
count += 1
print(u'正面{0}次,反面{1}次'.format(count,1000000-count))
From the requirements of the program, we can get five for 50 yuan, six for 5 yuan and three for 1 yuan. It can be directly calculated by operations such as surplus, or solved by greedy thinking, but it is simple to use surplus
correct code:
0 count=283
x = int(count/50)
y = int((count-x*50)/5)
z=count-(x*50)-(y*5)
print(' Change {} yuan, including 50 yuan: {} Zhang, 5 yuan: {} Zhang, 1 yuan: {} Zhang, 39 yuan Format (count, x, y, z))
{rrrrrrr}
extended data:
advantages and disadvantages of Python:
advantages:
1, simple, Python is a language representing the idea of simplicity. Reading a good Python program is like reading English. It allows you to focus on solving problems instead of understanding the language itself
Easy to learn, Python is extremely easy to use, because Python has extremely simple documentation The bottom layer of Python is written in C language, and many standard libraries and third-party libraries are also written in C, so the running speed is very fast Python is one of floss (free / open source software). Users are free to publish copies of the software, read its source code, make changes to it, and use part of it in new free software. Floss is based on the concept of a community sharing knowledge5. High level language. When writing programs in Python, you don't need to consider the bottom details such as how to manage the memory used by your program
Because of its open source nature, python has been transplanted to many platforms (changed to work on different platforms) Explanatory: a program written in a compiler language such as C or C + + can be converted from a source file (i.e. C or C + + language) to a language (binary code, i.e. 0 and 1) used by your computer. This process is accomplished through the compiler and different tags and options8, standard code, python uses the way of forced indentation to make the code have better readability. Programs written in Python do not need to be compiled into binary code
disadvantages:
slow running speed: here, compared with C and C + +
source: Internet Python