It's a question about getting rid of the decimal places.

Asked 2 years ago, Updated 2 years ago, 22 views

I made a discount table according to the date of birth and the credit card company for the school assignment.
I want to throw away the decimal point here, but is there a way to throw it away without using an embedded function like append?
If it was a list, I think I could do something like delete a few columns, but it's a simple number string, so I don't know how to do it except for the built-in function. Can you teach me?
This is some of the functions that I made.
For example, those born in 2000 or older will get a 75% discount from 65,000 won.
There will be another discount depending on the name of the credit card company. In this case, the result was 14950.0 won.
Here, you must clear this 0 without using the built-in function. Help me.

adf=input ('Enter the date of birth of 8 digits')
if int(adf) <= 20001231 and adf[4:6]=='10' and adf[6:9]!='10':
    print ('65000 won, 50% discount')
    card=(input('Enter the name of the card company'))
    if card == 'kft' or card == 'smt':
        print(32500*0.92)
    elif card == ('rg'):
        print(32500*0.93)
    else:
        print(32500)
elif int(adf) <= 20001231 and adf[4:6]=='10' and adf[6:9]=='10':
    print ('65000 won, 75% discount')
    card=(input('Enter the name of the card company'))
    if card == 'kft' or card == 'smt':
        print(16250*0.92)
    elif card == ('rg'):
        print(16250*0.93)
    else:
        print(16250)

python

2022-09-22 17:54

1 Answers

Write the trunc() function in the math module...

// Enter your code here
import math

print(math.trunc(14950.0))

I don't know if I understand the problem. Why not use built-in functions...

data= int (1495.0)

print('data : ', data)


2022-09-22 17:54

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.