-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFirstTest.py
More file actions
55 lines (45 loc) · 1.57 KB
/
FirstTest.py
File metadata and controls
55 lines (45 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import sys
import getpass
import platform
strHostName = platform.node()
def getInput(strPrompt):
if sys.version_info[0] > 2 :
return input(strPrompt)
else:
return raw_input(strPrompt)
# end getInput
print ("Welcome to my Python Test script. Your username is {3} and this is running on {4}. This is running under Python Version {0}.{1}.{2}".format(
sys.version_info[0],sys.version_info[1],sys.version_info[2],getpass.getuser(),strHostName))
sa = sys.argv
lsa = len(sys.argv)
if lsa != 2:
print("Usage: python {} duration_in_minutes.".format(sys.argv[0]))
print("Example: python {} 10".format(sys.argv[0]))
sys.exit(1)
try:
minutes = int(sa[1])
except ValueError:
print("Invalid value {} for minutes.".format(sa[1]))
print("Should be an integer >= 0.")
sys.exit(1)
if minutes < 0:
print("Invalid value {} for minutes.".format(minutes))
print("Should be an integer >= 0.")
sys.exit(1)
print ("Hello {}".format(getInput("What is your name? ")))
p = getpass.getpass(prompt="Tell me a secret ")
print ("I won't tell anyone about {}".format(p))
#print ("Your username is {}".format(getpass.getuser()))
seconds = minutes * 60
if minutes == 1:
unit_word = " minute"
else:
unit_word = " minutes"
strmin = str(minutes)
strsec = str(seconds)
# strout1 = "you entered " + strmin + unit_word
# strout2 = "which is " + strsec + " seconds"
# strout1 = "you entered {}".format(minutes) + unit_word
# strout2 = "which is {}".format(seconds) + " seconds"
print ("you entered " + strmin + unit_word)
print ("which is " + strsec + " seconds")