This file contains hidden or 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
| # Numpy is imported, seed is set | |
| # Starting step | |
| step = 50 | |
| # Roll the dice | |
| dice = np.random.randint(1,7) | |
| # Finish the control construct | |
| if dice <= 2 : | |
| step = step - 1 | |
| elif dice > 2 and dice < 6 : | |
| step= step + 1 |
This file contains hidden or 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
| fname = input("Enter file name: ") | |
| fh = open(fname) | |
| lst = list() | |
| for line in fh: | |
| word = line.rstrip().split() | |
| for element in word: | |
| if element in lst: | |
| continue | |
| else : | |
| lst.append(element) |
This file contains hidden or 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
| fname = input("Enter file name: ") | |
| fh = open(fname) | |
| count = 0 | |
| plus = 0 | |
| for line in fh: | |
| if not line.startswith("X-DSPAM-Confidence:") : continue | |
| startPos = line.find(':') | |
| piece = line[startPos+1:] | |
| end = float(piece) | |
| plus = plus+end |
This file contains hidden or 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
| fname = input("Enter file name: ") | |
| try : | |
| fh = open(fname) | |
| except: | |
| print('Cannot open the file ',fname ,'please try again') | |
| quit() | |
| for line in fh : | |
| line = line.upper() |
This file contains hidden or 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"; | |
| startPos = text.find(':') | |
| piece = text[startPos+1:] | |
| end = float(piece) | |
| print(end) |
This file contains hidden or 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 = input("Enter a number: ") | |
| if num == "done" : break | |
| try : n = int(num) | |
| except : | |
| print('Invalid input') | |
| continue | |
| if largest is None: |
This file contains hidden or 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
| num = 0 | |
| tot = 0.0 | |
| while True: | |
| number = input("Enter a number") | |
| if number == 'done': | |
| break | |
| try : | |
| num1 = float(number) | |
| except: | |
| print('Invailed Input') |
This file contains hidden or 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(h,r): | |
| x=0 | |
| if h > 40.0: | |
| x = r * 40.0 +(1.5*r*(h-40.0)) | |
| elif h <= 40 : | |
| x= h*r | |
| return x | |
| hrs = float(input("Enter Hours:")) |
This file contains hidden or 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 = input("Enter Score: ") | |
| s = float(score) | |
| x = 'Error' | |
| if s >= 0.9: | |
| x = 'A' | |
| elif s >=0.8: | |
| x='B' | |
| elif s >=0.7: | |
| x='C' | |
| elif s >= 0.6: |
This file contains hidden or 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
| hrs = input("Enter Hours:") | |
| h = float(hrs) | |
| xx = input("Enter the Rate:") | |
| x = float(xx) | |
| if h <= 40: | |
| print( h * x) | |
| elif h > 40: | |
| print(40* x + (h-40)*1.5*x) |
NewerOlder