Creating an interactive menu (Python)

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

I’m currently making an automatic watering system using relays, servos, and a raspberry pi, and this video proved very helpful, thank you!

I’m going to create a menu in which you can view the last time watered, and specific zone watering

kurrocap
Автор

If it wasn't for the flickering blocks of black from time to time, this would have been a good video. How ever, I would encourage the maker of this video to make a new video and take this down.

AnaloguePhoto
Автор

Blinking bars on top portion of the screen render this video practically unwatchable.

manutoftime
Автор

You need a new Graphics Card Pal, that Blinking on your screen is very annoying.

arctictimberwolf
Автор

For me the error is like 11:35 it says "NameError: name 'Mikkel' is not defined". If I enter Mikkel in betwee quotes, it works. So, somehow, it is not interpreting the input value as a "string", it is interpreting it as a "script variable". Why is this happening if I wrote everything just like it is shown in this video? (different versions of Python maybe?)

aceofspades
Автор

import numpy as np

def inputNumber(prompt):
#INPUTNUMBER Prompts user to input a number
#
#Usage: num = inputNumber(prompt) Displays prompt and asks user
#number. Repeats until user inputs a valid number.
#

while True:
try:
num = float(input(prompt))
break
except ValueError:
pass

return num

def displayMenu(options):
"""
DISPLAYMENU Displays a menu of options, ask the user to choose
and returns the number of the menu item chosen.

Usage: choice = displayMenu(options)

Input options Menu options (cell array of strings)
Output choice Chosen option (integer)

Display menu options
"""
for i in range(len(options)):
print("{:d}.{:s}".format(i+1, options[i]))

# Get a valid menu choice
choice = 0
while not(np.any(choice == np.arange(len(options))+1)):
choice = inputNumber("Please choose a menu item: ")

return choice

#Define menu items
menuItems = np.array(["Enter name", "Display name", "Quit"])

while True:
#Display menu
choice = displayMenu(menuItems)

#Enter name
if choice ==1:
name = input("Please enter your name: ")

#Display greeting
elif choice == 2:
print(name)

#Quit
elif choice == 3:
break

JohnsonEbenezerRajendran
visit shbcf.ru