def menu(): # the user is asked to enter each of the settings, # settings are stored in placeholder variables and sent to the database if choice == 1: user_too_low_temp = int( input("Enter in Fahrenheit the Temperature deemed too low: ")) user_just_right_temp = int( input("Enter in Fahrenheit the Temperature deemed just right: ")) user_too_high_temp = int( input("Enter in Fahrenheit the Temperature deemed too high: ")) user_humidity_limit = int( input("Enter the humidity limit without the % symbol: ")) user_light_threshold = int(input("Enter the light threshold value: ")) Database.send_settings_to_firebase(user_too_low_temp, user_just_right_temp, user_too_high_temp, user_humidity_limit, user_light_threshold) print("Your settings have been configured\n") print("The system will now run") elif choice == 2: # runs the function which displays the graph of temperature and humidity print("Here is your Graph!") graph.graph() else: # Any integer inputs other than values 1-2 print an error message raw_input("Wrong option selection. Enter any key to try again..")
def Trans_Main(): #The main program of Vigenere print("Do you want to use Transposition Cipher Mode ? (y):yes / (n):no") from click._compat import raw_input answer= raw_input().lower() answer.split() while answer[0] == 'y': choice_of_mode = ChooseMode() entered_message = collectMessage() entered_key = collectKey() if choice_of_mode[0] == 'e': final_form = Encryption(entered_message,entered_key) print("Your Cipher Text is: " + final_form) elif choice_of_mode[0] == 'd': final_form = Decryption(entered_message,entered_key) print("Your Plain Text is: " +final_form) print("Do you want to use Transposition Cipher Mode once again ? (y):yes / (n):no") from click._compat import raw_input answer = raw_input().lower() answer.split() if answer[0] == 'y': continue elif answer[0] == 'n': break print("Done!")
def main(): products = { "cocacola": 1000, "fanta": 120, "ice cream": 200, "chocolate": 150, "chrisps": 15, "queen cakes": 46, "cocktail": 24, "cocacola": 1000, "avocado": 120, "nuggets": 200, "sharwama": 150, "apple juice": 15 } vendingManenoz = VendingMachine("Janta Machine", "Blue", "120kg", "12", "0", False, products) print("Welcome to " + vendingManenoz.getVendingMachineName() + " vending machine") print( "You are welcomed to enjoy yourself with any product you seem to want, Just enter a coin" ) print("We offer the following products and their pricing: ") vendingManenoz.showProducts() product_name = raw_input("Select the product you want by its name: ") paid_amount = raw_input("Enter cash in the money pane to continue: ") product_pricing = vendingManenoz.processSelection(product_name, paid_amount) vendingManenoz.recieveCash(paid_amount, product_pricing, product_name) vendingManenoz.printRecievedCashLogs()
def modify_std_infor(): modify_name = raw_input("请输入要修改的学生名字:") modify_flag = 0 for temp in Students_List: if modify_name == temp['name']: print("1、修改学生姓名") print("2、修改学生学号") print("3、修改学生电话") print("4、修改学生地址") print("5、退出修改系统") while True: num2 = int(input("请输入要修改的信息编号:")) if num2 == 1: temp['name'] = raw_input("请输入要修改的正确姓名:") modify_flag = 1 elif num2 == 2: temp['number'] = int(input("请输入要修改的正确学号:")) modify_flag = 1 elif num2 == 3: temp['cellphone'] = int(input("请输入要修改的正确电话:")) modify_flag = 1 elif num2 == 4: temp['address'] = raw_input("请输入要修改的正确地址:") modify_flag = 1 elif num2 == 5: break else: print("输入有误,请重新输入") if modify_flag == 1: print("修改成功") break break
def main(): dr = du.Drone() print("start mission...") # sleep(20) dr.take_off(10) sleep(2) print("Starting to sample") dr.take_sample() for k in range(2): for i in range(6): dr.goto(-2.8, 2.8) dr.take_sample() dr.goto(2.8, 2.8) dr.take_sample() for i in range(6): dr.goto(2.8, -2.8) dr.take_sample() dr.goto(2.8, 2.8) dr.take_sample() for j in range(3): dr.goto(-2.8, 2.8) dr.take_sample() dr.land() raw_input("Press any key to turn off the drone") dr.close_connection()
def scan(self, height, width, length): pic_size = get_pic_size(height) adv_size = 0.6 * pic_size self.num_rows = int(length // (2 * adv_size)) self.row_size = int(width // adv_size) found = False while not found: print("Select the orientation of the scan area: \n" + "1. North \n" + "2. North - East \n" + "3. North - West") direction = int(input()) if direction == 1: found = True self._scan_straight(height, length, width, adv_size) elif direction == 2: found = True raw_input("Place the drone in the Southern corner of the scan " + "area, and press any key to start the scan") self._scan_diagonal(height, length, width, 1, 1, adv_size) elif direction == 3: found = True raw_input("Place the drone in the Eastern corner of the scan " + "area, and press any key to start the scan") self._scan_diagonal(height, length, width, -1, -1, adv_size) else: print("Bad direction")
def convert_module(module): attr_list = [] for k, v in module.__dict__.items(): if k.isupper(): convert = bool( int(raw_input('Convert {}? (1=True,0=False): '.format(k)))) attr_dict = {'name': k, 'convert': convert} default_val = None if convert: default_val = raw_input( 'Default Value? (default: {}): '.format(v)) if default_val: default_val = ast.literal_eval(default_val) if not default_val: default_val = v attr_dict['default_val'] = default_val var_type = raw_input( 'Variable Type Choices (ex. boolean,string,list,tuple,integer,float,dict): ' ) if not var_type in VAR_TYPES: raise ValueError('{} not in {}'.format( var_type, VAR_TYPES)) attr_dict['var_type'] = var_type if not default_val: default_val = v attr_list.append(attr_dict) return attr_list
def get_filters(): """ Asks user to specify a city, month, and day to analyze. Returns: (str) city - name of the city to analyze (str) month - name of the month to filter by, or "all" to apply no month filter (str) day - name of the day of week to filter by, or "all" to apply no day filter """ print('Hello! Let\'s explore some US bikeshare data!') # get user input for city (chicago, new york city, washington). HINT: Use a while loop to handle invalid inputs city = raw_input( "Please choose one of the following cities (Chicago, New York City, or Washington): " ).lower() # get user input for month (all, january, february, ... , june) month = raw_input( "Please enter the month of the bikeshare data to view (January, February, March, April, May, June or all): " ).lower() # get user input for day of week (all, monday, tuesday, ... sunday) day = raw_input( "Please enter the day of the week of the bikeshare data to view (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday or all): " ).lower() print('-' * 40) return city, month, day
def input_data(self): global email global password global question_url self.username = raw_input('请输入用户名:') self.password = raw_input('请输入密码:') self.show_or_save_captcha(self.get_captcha()) self.captcha = raw_input('请输入验证码:')
def inputUser(): global USERNAME global PASSWORD print("请输入大麦网账号:") USERNAMETEMP = raw_input() if '' != USERNAMETEMP: USERNAME = USERNAMETEMP print("请输入大麦网账号密码:") PASSWORDTEMP = raw_input() if '' != PASSWORDTEMP: PASSWORD = PASSWORDTEMP
def Main(): choice = raw_input("Would you like to (E)ncrypt or (D)ecrypt?: ") if choice == 'E': filename = raw_input("File to encrypt: ") password = raw_input("Password: "******"PASSWORD_ECD")), filename) print("Done.") elif choice == 'D': filename = raw_input("File to decrypt: ") password = raw_input("Password: "******"PASSWORD_ECD")), filename) print("Done.", getKey(os.getenv("PASSWORD_ECD"))) else: print("No Option selected, closing...")
def add_new_card_infor(): """完成添加一个新的名片""" new_name = raw_input("请输入新的名字:") #信息的录入 new_qq = int(input("请输入新的QQ:")) new_weixin = int(input("请输入新的微信:")) new_addr = raw_input("请输入新的住址:") new_infor = {} #定义一个新的字典,用来存储一个新的名片 new_infor['name'] = new_name #信息的录入 new_infor['qq'] = new_qq new_infor['weixin'] = new_weixin new_infor['addr'] = new_addr #将一个字典,添加到列表中 card_infors.append(new_infor) #用append()函数在列表中增加一个字典元素
def add_new_std_infor(): new_name = raw_input("请输入新的名字:") new_number = int(input("请输入新的学号:")) new_cellphone = int(input("请输入新的手机号码:")) new_address = raw_input("请输入新的地址:") new_infor = {} #定义一个新的字典,用来储存新的学生的信息 new_infor['name'] = new_name new_infor['number'] = new_number new_infor['cellphone'] = new_cellphone new_infor['address'] = new_address #将一个字典添加到列表中 Students_List.append(new_infor) #用append函数在列表中加一个字典元素
def GetJebLicenseKey(): licdata = raw_input("Input License Data:\n") if licdata: i, MachineID = DecodeRc4Str(licdata) SN = KeygenSN(i[3], i[4]) print("JEB License Key:", SN) return SN
def query_yes_no(question, default="yes"): """Ask a yes/no question via raw_input() and return their answer. "question" is a string that is presented to the user. "default" is the presumed answer if the user just hits <Enter>. It must be "yes" (the default), "no" or None (meaning an answer is required of the user). The "answer" return value is True for "yes" or False for "no". """ valid = {"yes": True, "y": True, "ye": True, "no": False, "n": False} if default is None: prompt = " [y/n] " elif default == "yes": prompt = " [Y/n] " elif default == "no": prompt = " [y/N] " else: raise ValueError("invalid default answer: '%s'" % default) while True: sys.stdout.write(question + prompt) choice = raw_input().lower() if default is not None and choice == '': return valid[default] elif choice in valid: return valid[choice] else: sys.stdout.write("Please respond with 'yes' or 'no' " "(or 'y' or 'n').\n")
def handle_delete_all(default="no"): question = 'Do you want to remove all frames?' valid = {"yes": True, "y": True, "ye": True, "no": False, "n": False} if default is None: prompt = " [y/n] " elif default == "yes": prompt = " [Y/n] " elif default == "no": prompt = " [y/N] " else: raise ValueError("invalid default answer: '%s'" % default) while True: sys.stdout.write(question + prompt) choice = raw_input().lower() if default is not None and choice == '': return valid[default] elif choice in valid: if valid[choice]: delete_all() return valid[choice] else: sys.stdout.write("Please respond with 'yes' or 'no' " "(or 'y' or 'n').\n")
def conv(conversation): message = raw_input() response = conversation.message( workspace_id='727a8a5e-1b66-4009-9a5e-b64bd1505f4c', message_input={'text': message}) if len(response["intents"]) > 0: if len(response["intents"] ) > 0 & response["intents"][0]["intent"].__eq__( "weather_conditions") & len(response["entities"]) > 0: weather = Weather() #print (response["entities"][0]["value"]) print(response["output"]["text"][0] + weather.lookup_by_location( response["entities"][0]["value"]).condition()['temp']) elif len(response["entities"]) > 0: weather = Weather() print("The weather at " + response["entities"][0]["value"] + " is " + weather.lookup_by_location( response["entities"][0]["value"]).condition()['temp']) else: print(response["output"]["text"][0]) elif len(response["entities"]) > 0: weather = Weather() print("The weather at " + response["entities"][0]["value"] + " is " + weather.lookup_by_location(response["entities"][0] ["value"]).condition()['temp']) else: print(response["output"]["text"][0]) conv(conversation)
def play_again(): should_you_play_again = raw_input( "Would you like to play again? (Y/N) > ").upper() if should_you_play_again == "Y": return True print("Thanks for playing!") return False
def input(): try: print('Now press any alphabet key in 2 seconds to break.') foo = raw_input() return foo except: # Timeout return
def getOneStory(self, pageStories, nowPage): for story in pageStories: input = raw_input() self.loadPage() if input == 'Q': self.enable == False return print("%d %s %s %s %s" % (nowPage, story[0], story[2], story[3], story[1]))
def delete(): try: criteria = raw_input('\nEnter employee id to delete\n') db.Plans.delete_many({"id": criteria}) print '\nDeletion successful\n' except Exception as e: print str(e)
def clipMerger(): name2 = raw_input("Enter second clip name(File has to be in same folder as other one): ") clip1 = VideoFileClip(user_input1) clip2 = VideoFileClip(name2) clip_name = os.path.splitext(user_input1)[0] clip_name1 = os.path.splitext(name2)[0] final = concatenate_videoclips([clip1, clip2]) final.write_videofile('merged.mp4', threads=4, fps=24, codec='libx264', preset='ultrafast') Current_Date = datetime.datetime.today().strftime("%H.%M.%S") os.rename('merged.mp4', 'merged_' + str(clip_name) + '_' + str(clip_name1) + '_' + str(Current_Date) + '.mp4') def cls(): print("\n" * 100) cls() print("Clip was created, you can find it at: " + path_name + " with file name: " + 'merged_' + str(clip_name) + '_' + str(clip_name1) + '_' + str(Current_Date)) user_input6 = raw_input("Do you want to open that file?: ") if user_input6 == 'yes': startfile('merged_' + str(clip_name) + '_' + str(clip_name1) + '_' + str(Current_Date) + '.mp4') else: exit()
def takeoffLand(): print("connect...") vehicle = connect('/dev/ttyUSB0', wait_ready=True) vehicle.mode = VehicleMode('GUIDED') vehicle.armed = True sleep(5) if not vehicle.armed: print("Vehicle not armed") return print("Taking off") vehicle.simple_takeoff(2) sleep(5) raw_input("Press any key to land") print("Landing") vehicle.mode = VehicleMode('LAND') sleep(10) vehicle.close()
def ChooseMode(): #Choose which mode of the program to launch while True: print('Do you wish to encrypt or decrypt a message?') from click._compat import raw_input mode = raw_input().lower() if mode in 'encrypt e decrypt d'.split(): return mode else: print('Enter either "encrypt" or "e" or "decrypt" or "d".')
def _scan_straight(self, height, length, width, adv_size): raw_input("Place the drone in the South-East corner of the scan " + "area, and press any key to start the scan") self.take_off(height) for i in range(int(length // (2 * adv_size))): self.take_sample() for j in range(int(width // adv_size)): self.goto(0, -adv_size) self.take_sample() self.goto(adv_size, 0) self.take_sample() for j in range(int(width // adv_size)): self.goto(0, adv_size) self.take_sample() self.goto(adv_size, 0) takeoff_return = int(length // adv_size) * adv_size + adv_size self.goto(int(-takeoff_return), 0) self.land() raw_input("Press any key to turn off the drone") self.close_connection()
def textadder(): name = os.path.splitext(user_input1)[0] clip = VideoFileClip(user_input1) desiredText = raw_input("What text you want to add?: ") txt = TextClip(desiredText, font='Courier', fontsize=30, color='white') txt = txt.set_pos('right', 'bottom').set_duration(5) Current_Date = datetime.datetime.today().strftime("%H.%M.%S") video = CompositeVideoClip([clip, txt]) video.write_videofile('converted.mp4', threads=4, fps=24, codec='libx264', preset='ultrafast') os.rename('converted.mp4', 'new_' + str(name) + '_' + str(Current_Date) + '.mp4') def cls(): print("\n" * 100) cls() print("Clip was created, you can find it at: " + path_name + " with file name: " + 'new_' + str(name)) user_input6 = raw_input("Do you want to open that file?: ") if user_input6 == 'yes': startfile('new_' + str(name) + '_' + str(Current_Date) + '.mp4') else: exit()
def list_commands(self): for num, cmd in enumerate(self.commands): print(str(num) + ') ' + cmd.__name__) try: choice = int(raw_input('\n' + self.prompt)) except ValueError: print('Please enter an integer number.') sys.exit(1) return choice
def four_points(connect_str): print("connect to: " + connect_str) vehicle = connect(connect_str, wait_ready=True) vehicle.mode = VehicleMode('GUIDED') vehicle.armed = True sleep(5) if not vehicle.armed: print("Vehicle not armed") return print("tern on devices...") camera = PiCamera() camera.resolution = (1024, 768) lidar = Lidar_Lite() connected = lidar.connect(1) if connected < -1: print("Lidar not Connected") return print("Taking off") vehicle.simple_takeoff(10) time.sleep(15) goto(10, 0, vehicle.simple_goto) point_handler(1, camera, lidar) goto(0, 10, vehicle.simple_goto) point_handler(2, camera, lidar) goto(-10, 0, vehicle.simple_goto) point_handler(3, camera, lidar) goto(0, -10, vehicle.simple_goto) point_handler(4, camera, lidar) print("Landing") vehicle.mode = VehicleMode('LAND') sleep(15) raw_input("Press any key to turn off the drone") vehicle.close() with open('4pts_dump/logs.json', 'w') as fp: json.dump(l_samples, fp)
def insert(): try: planId = raw_input('Enter Plan id :') planName = raw_input('Enter Plan Name :') planPrice = raw_input('Enter price :') planAmount = raw_input('Enter Amount :') currency = raw_input('Enter currency') db.plans.insert_one({ "id": planId, "name": planName, "price": planPrice, "amount": planAmount, "currency": currency }) print '\nInserted data successfully\n' except Exception as e: print str(e)
def getaddressbypostalcode(): number = raw_input('Enter porstal code:\n') mUrl = "http://zip.ricollab.jp/{0}.json".format(number) with urllib.request.urlopen(mUrl) as url: data = json.loads(url.read().decode("utf-8")) print(data['zipcode']) print('prefecture:'+data['address']['prefecture']) print('city: '+data['address']['city']) print('town: '+data['address']['town']) print('Address: '+data['address']['prefecture']+', '+data['address']['city']+', '+data['address']['town']) print('Address(yomi): '+data['yomi']['prefecture']+', '+data['yomi']['city']+', '+data['yomi']['town'])
def action(): action = raw_input("What do you want to do? \n" "1: Add text to a clip \n" "2: Edit clip Answer \n" "3: Merge two clips \n" "Answer: ") if action == "1": textadder() if action == "2": converter() else: clipMerger()
def convert_module(module): attr_list = [] for k, v in module.__dict__.items(): if k.isupper(): convert = bool(int(raw_input('Convert {}? (1=True,0=False): '.format(k)))) attr_dict = {'name': k, 'convert': convert} default_val = None if convert: default_val = raw_input('Default Value? (default: {}): '.format(v)) if default_val: default_val = ast.literal_eval(default_val) if not default_val: default_val = v attr_dict['default_val'] = default_val var_type = raw_input('Variable Type Choices (ex. boolean,string,list,tuple,integer,float,dict): ') if not var_type in VAR_TYPES: raise ValueError('{} not in {}'.format(var_type, VAR_TYPES)) attr_dict['var_type'] = var_type if not default_val: default_val = v attr_list.append(attr_dict) return attr_list
''' Created on Oct 22, 2018 @author: nwijesinha ''' from click._compat import raw_input if __name__ == '__main__': # Ask the user for age and save in age variable age = raw_input("How old are you? ") # Ask the user for the height and save in height variable height = raw_input("How tall are you? ") # Ask the user for weight and save in weight variable weight = raw_input("How much do you weigh? ") # Print the age, height and weight of the user print("So you're %r years old, %r cm tall and %r lbs heavy" % (age, height, weight))
''' # Import Sys.argument library from sys import argv from click._compat import raw_input # assign arguments when script is run to script, username script, user_name = argv # Create variable prompt prompt = '>' # Print the arguments collected and prompt the user for input print("Hi %s, I'm the %s script." % (user_name, script)) print("I'd like to ask you a few questions.") print("Do you like me %s" % user_name) likes = raw_input(prompt) # Accept second input from user print("Where do you live %s?" % user_name) lives = raw_input(prompt) # Accept third input from user print("What kind of computer do you have?") computer = raw_input(prompt) # Prin the user input on the screen print(""" Alright, so you have said %r about liking me You live in %r. Not sure where that is. And you have a %r computer. Nice
''' Created on Oct 23, 2018 @author: nwijesinha This example is using alternative input method to pass a variable ''' from sys import argv from click._compat import raw_input # Create variable for the example script, first, second, third = argv # using print method to assign information to variables print("This script is called: ", script) print("Your first variable is: ", first) print("Your first variable is: ", second) print("Your first variable is: ", third) answer = raw_input("Did you see the correct out put?") # Check fthe answer os Yes and print Yes or No if answer == "Yes": print(answer) else: print("No")
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/2/11 16:54 # @Author : Huyd # @Site : # @File : 5全排列.py # @Software: PyCharm ''' 题目描述 输入一个字符串,打印出该字符串中字符的所有排列。 例如输入字符串abc,则输出由字符a、b、c 所能排列出来的所有字符串 abc、acb、bac、bca、cab 和 cba。 ''' import itertools from click._compat import raw_input line = raw_input("please input some char:\n") for i in itertools.permutations(list(line)): print("".join(i))
''' # Import libraries from sys import argv from click._compat import raw_input # Caoture and assign file name to variable from user script, filename = argv # promt the user regarding action print("We are going to erase %r." % filename) print("If you dont want that, hit CRTL-C (^C).") print("If you do want that, enter RETURN.") raw_input("?") # Read fiel print("Opening the file....") txt = open(filename, 'w') # Erase the file print("Truncating the file. Goodbye!") txt.truncate() # Prompt user for three line to write to the file print(" Now I am going to ask you for three lines.") line1 = raw_input("Line 1: ") line2 = raw_input("Line 2: ") line3 = raw_input("Line 3: ")
''' Created on Oct 22, 2018 @author: nwijesinha This example is to understand how to receive input from user using Python code ''' from click._compat import raw_input if __name__ == '__main__': # Ask the user for age and save in age variable print("How old are you?") age = raw_input() # Ask the user for the height and save in height variable print("How tall are you?") height = raw_input() # Ask the user for weight and save in weight variable print("How much do you weigh?") weight = raw_input() # Print the age, height and weight of the user print("So you're %r years old, %r cm tall and %r lbs heavy" % (age, height, weight))
This exercise is to read a text file ''' # Import sys.argument and click._compat.raw_input library from sys import argv from click._compat import raw_input # Accept input from user for the filename script, filename = argv # Create File name object and hold the content in the file txt = open(filename) # print the file name print("Here is your file %s:" % filename) #Print the contents of the file print(txt.read()) #request user to type the file name again print("Type the filename again:") #Prompt for input and save the file content to file_again variable file_again = raw_input("> ") # Print the content txt_again = open(file_again) print(txt_again.read())