Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Webinar Input Patterns Jan 14 2023
- # input() ALWAYS returns a string
- # myInput = input()
- #
- # but we might want to change it to something else...
- # myVar = input()
- # print(type(myVar))
- # 1 Recast a numeric string into an int or float
- # 2 Breaking up a long string into a list of smaller strings
- # 3 Break up a string containing numeric chars into a list of
- # recast ints or floats
- # 4 One value tells you how many times to call input()
- # 5 We DON'T KNOW how many times to call input(), but we know
- # a sentinel value to stop
- # 1 Recast a numeric string into an int or float
- # myInput = input()
- # myInput = "5" # input()
- # #yInput = int(myInput)
- # print(myInput, type(myInput).__name__)
- # myInput = int(input()) # float(input())
- # 2 Breaking up a long string into a list of smaller strings
- # "Pat Silly Doe"
- # # myInput = input()
- # myInput = "Pat Silly Doe"
- # strList = myInput.split()
- # print(strList)
- # 3 Break up a string containing numeric chars into a list of
- # recast ints or floats
- # 10 5 3 21 2
- # myInput = "31 333 2 78 92"
- # strList = myInput.split()
- # print(strList)
- # numList = []
- # for num in strList:
- # numList.append(int(num))
- #
- #
- # # You could do this as a LIST COMPREHENSION
- # # [expression for item in other container]
- # numList = [int(num) for num in strList]
- # print(numList)
- #4 One value tells you HOW MANY TIMES to call input()
- # ... inputs:
- # 5
- # 30.0
- # 50.0
- # 10.0
- # 100.0
- # 65.0
- # numValues = int(input())
- numValues = 5
- floatValues = []
- # for n in range(numValues): # [0, 1, 2, 3, 4]
- # nextInput = float(input())
- # floatValues.append(nextInput)
- # print(floatValues)
- # 5 We DON'T KNOW how many times to call input(), but we know to stop on some SENTINEL VALUE
- # March 1, 1990
- # April 2 1995
- # 7/15/20
- # December 13, 2003
- # -1
- myInput = input()
- # THEN we can loop...
- while myInput != "-1": # myInput < 0:
- # do the stuff for this problem
- myInput = input()
- # Student questions
- # multiple quit commands
- # Done, done, d, quit
- myInput = input()
- # while myInput != "Done" and myInput != "done" and myInput != "d":
- quitCommands = ["Done", "done", "d", "quit"]
- while not myInput in quitCommands:
- # do your stuff
- myInput = input()
- # 11.18
- # 25 51 0 200 33 # from nums like this
- # 0 50 # get those in this range, inclusive
- numsList = input().split()
- numsList = [int(num) for num in numsList]
- startStopList = input().split()
- start = int(startStopList[0])
- stop = int(startStopList[1])
- for num in numsList:
- if start <= num <= stop:
- print(num, end=" ") # normally we wouldn't stop without a \n, but note in questions says to do this
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement