This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Write a program that uses raw_input to prompt a user for their name and then welcomes them. Note that raw_input will pop up a dialog box. Enter Sarah in the pop-up box when you are prompted so your output will match the desired output. | |
name = raw_input("Enter your name:") | |
print "Hello",name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hours = float(raw_input("Enter Hours:")) | |
rate = float(raw_input("Enter rate:")) | |
print hours*rate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hours = float(raw_input("Enter Hours:")) | |
rate = float(raw_input("Enter Pay rate per hour:")) | |
if hours>40.0 : | |
pay = rate*40 | |
pay = pay+(1.5*rate*(hours-40)) | |
else : | |
pay = rate*hours | |
print pay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
score = float(raw_input("Enter score between 0.0 and 1.0: ")) | |
if score>1.0 or score<0.0 : | |
print "error" | |
elif score>=0.9 : | |
print 'A' | |
elif score>=0.8 : | |
print 'B' | |
elif score>=0.7 : | |
print 'C' | |
elif score>=0.6 : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def computepay(hours,rate): | |
if hours>40.0: | |
p = rate * 40.0 | |
p = p+(1.5*rate*(hours-40)) | |
else: | |
p = rate*hours | |
return p | |
hours = float(raw_input("Enter worked hours: ")) | |
rate = float(raw_input("Enter Pay rate per hour: ")) | |
print computepay(hours,rate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
largest = None | |
smallest = None | |
while True: | |
num = raw_input("Enter a number:") | |
try: | |
if num == 'done': | |
print "Maximum is",largest | |
print "Minimum is",smallest | |
break | |
num = int(num) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text = "X-DSPAM-Confidence:0.8475" | |
epos = text.find(':') | |
print float(text[epos+1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for data in open(raw_input("Enter file name: ")): | |
print data.rstrip().upper() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sum = 0.0 | |
count = 0 | |
fname = open(raw_input("Enter file name: ")) | |
for line in fname: | |
if not line.startswith("X-DSPAM-Confidence:") : continue | |
sum = sum + float(line[line.find(" ")+1:]) | |
count = count + 1 | |
print "Average spam confidence:",sum/float(count) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
finlist = list() | |
for line in open(raw_input("Enter the file Name:")): | |
words = line.rstrip().split() | |
for arr in words: | |
if arr in finlist: | |
continue | |
else: | |
finlist.append(arr) | |
finlist.sort() | |
print finlist |
OlderNewer