def infinite_loop(): while True: n = input("Enter a value: ") int_n = int(n) print(utils.process_item(int_n))
def main(): while (1): x = input("Enter number: ") if x == "q": return try: x = int(x) except: print("Wrong Input") else: print(utils.process_item(x))
def function(): x = 0 y = 0 while 1: inputs = input() if (inputs == "q"): return "Program ended." else: x = int(inputs) y = utils.process_item(x) print(y)
def process_loc(text, db, date, name): messages = ['%s: ' % name] for part in text.split(','): try: name, points, msg = utils.process_item(part, db['prehab']) except ValueError as err: messages[-1] += err.message else: if not date in db['days']: db['days'][date] = [] db['days'][date].append((name, points)) messages.append(msg) return messages
def process_meal(text, db, date, name): messages = ['%s: ' % name] for part in text.split(','): try: name, points, msg = utils.process_item(part, db['foods']) except ValueError as err: messages[-1] += err.message else: if not date in db['days']: db['days'][date] = [] db['days'][date].append((name, points)) messages.append(msg) return messages
from utils import process_item while 1: x = input("Number: ") if x == 'q': break x = int(x) print('Least prime number greater than %d is %d.' % (x, process_item(x)))
import utils if __name__ == "__main__": while True: x = input("Number: ") if x == 'q': break print(utils.process_item(int(x))) else: print("Exit")
import utils while True: choice = input("Enter your number: ") if choice == 'q': break else: print(utils.process_item(int(choice)))
# b) Write a module named app.py. When this module is run, it will run in an infinite loop, waiting for inputs from # the user. The program will convert the input to a number and process it using the function process_item implemented # in utils.py. You will have to import this function in your module. The program stops when the user enters the # message "q" import utils as ut while True: x = input("Input variable:") if x == 'q': print("Exiting ... ") break print(ut.process_item(int(x)))
import utils number = input() print(utils.process_item(number))
#1) #app.py from utils import process_item runnning = True while runnning: nr = input("Number:") if nr == "q": runnning = False else: print(process_item(int(nr))) ###utils.py def process_item(x): found = 0 while found == 0: x += 1 prim = True for div in range(2, int(x / 2)): if x % div == 0: prim = False if prim == True: found = 1 return x
import utils import app # Ex1.1 n = input("Enter a value: " ) print("Next prime number is: ", utils.process_item(n)) # Ex1.2 # app.infinite_loop() # Ex2 def sum(*x): sum = 0 for i in x: sum += i return sum def functionArgs(* args): sum = 0 for i in args: sum += i return sum print("Sum is:", functionArgs(1, 2, 3)) def anonymousArgs(): return lambda *args: sum(*args) print("Sum is:", anonymousArgs()(1, 2, 3))
import utils if __name__ == '__main__': while True: inp = input('Input a number, or q to quit: ') if inp == 'q': break elif inp.isnumeric(): num = int(inp) print('Next prime is', utils.process_item(num)) else: print("I don't understand.") r
__doc__ = """ 1) b) Write a module named app.py. When this module is run, it will run in an infinite loop, waiting for inputs from the user. The program will convert the input to a number and process it using the function process_item implented in utils.py. You will have to import this function in your module. The program stops when the user enters the message "q". """ from utils import process_item if __name__ == "__main__": print("Enter some integers. Press q to stop!") x = input() while x != "q": try: x = int(x) print(process_item(x)) except Exception as e: print(e) x = input()
# it will run in an infinite loop, waiting for inputs # from the user. The program will convert the input to a # number and process it using the function process_item # implented in utils.py. You will have to import this # function in your module. The program stops when the # user enters the message "q". import utils condition = True inputs = [] primes = [] ints = [] while condition is True: inp = input() if inp == "q": break inputs.append(inp) for element in inputs: try: ints.append(int(element)) except ValueError: pass for element in ints: primes.append(utils.process_item(element)) print(primes)
import utils if __name__ == '__main__': while True: input_received = input() if input_received == 'q': break else: print(utils.process_item(int(input_received)))