简体   繁体   English

如何将 output 打印为两位数?

[英]How can I print the output as a two digit-number?

So, I am solving a question (attached below) where I have to print the remaining account balance as a two digit number.所以,我正在解决一个问题(附在下面),我必须将剩余的帐户余额打印为两位数。 Can someone tell what should I add in my program to achieve so?有人可以告诉我应该在我的程序中添加什么来实现这一目标吗?

try:
        x,y = map(float, input().split())
        if (x <= y-5 and x % 5==0):
            print(y-x-5)
        else:
            print(y)
        
    except:
        pass    

Q: Neha wants to use an ATM to get X rupees.问: Neha 想用 ATM 取 X 卢比。 If X is a multiple of 5, and there is enough money in Neha's account balance to complete the withdrawal transaction, the cash machine will accept the transaction (including bank charges).如果 X 是 5 的倍数,并且 Neha 的账户余额中有足够的钱来完成提款交易,则提款机将接受交易(包括银行手续费)。 The bank charges 5 rupees for each withdrawal that is successful.银行对每次提款成功收取 5 卢比的费用。 Calculate Neha's account balance following a transaction attempt.尝试交易后计算 Neha 的帐户余额。

Input Format输入格式

The amount of money Neha wants to withdraw is a positive integer. Neha 想要提取的金额是正数 integer。

Neha's starting account balance is a nonnegative value with two digits of accuracy. Neha 的起始账户余额是具有两位数精度的非负值。

Constraints约束

0 ˂ X ≤ 5000 0˂ X ≤ 5000

0 ≤ Y ≤ 5000 0≤Y≤5000

Output Format Output 格式

Publish the account balance following the attempted transaction as a two-digit number.将尝试交易后的帐户余额发布为两位数。 Output the existing account balances if there is not sufficient cash in the account to execute the transaction. Output 如果账户中没有足够的现金来执行交易,则现有账户余额。

Hello this is LPU Hacker rank question please don't answer this fellow question otherwise teacher will curse you as well I will also....你好这是LPU黑客等级问题请不要回答这个问题否则老师会诅咒你我也会......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM