I have a little python project. Just for fun. There you can add when you want to shutdown your pc. At the beginning you can choose seconds/minutes/hours, and if you choose minutes than the input number* 60 will be in the “shutdown.exe /s /t …). (It’s only working with round numbers, even than 1.5*60 will be round at the end.) I want to check if the …*60 will be a round number or not. And if it isn’t than round it and run with the round number.
There is the code part what i am talking about:
JavaScript
x
7
1
minutes = input(":")
2
if minutes >= "1":
3
minutes = int(minutes)
4
minsec = (minutes*60)
5
minsec = str(minsec)
6
os.system("shutdown.exe /s /t " + minsec)
7
You can see the full code here.
(I just started learning python and that’s my first question, sorry if something isn’t understandable.)
Advertisement
Answer
I used eval(), this worked:
JavaScript
1
7
1
minutes = input(":")
2
if minutes >= "1":
3
#Minutes Calculation
4
minsec = str(int(eval(minutes) * 60))
5
#Shutdown with time
6
os.system("shutdown.exe /s /t " + minsec)
7