"Zhuan" Python Intermediate Tutorial 2 — Input Box
Intermediate Python Tutorial 2 — It's time for input boxes, let's continue learning Python together. In this section, we will learn about input boxes. This really shouldn't need an explanation! It's just entering some text. Let's first take a look at the function it uses: dialogGetInput(). This is actually very simple, similar to the prompt box. Now let's look at the code: droid.dialogGetInput('Title', 'Please enter:') Now, let's combine it with the prompt box from the previous section! First, look at the code in Figure 1: data = droid.dialogGetInput('input', 'Please enter').result droid.dialogCreateAlert('You entered', str(data)) droid.dialogShow() The result is shown in Figures 2 and 3. Code explanation: The first line means the content you enter is assigned to data. The second line displays the content of data using a prompt box. If anything is still unclear, you can ask, and I will do my best to help you. Everyone hasn't done homework for a long time, now let's do an assignment. This assignment might be a bit challenging for you now, but it's okay. If you don't know, you can refer to the assignment given by Paomo. Topic: Compare the size of two numbers. Requirements: Use if statements, prompt boxes, and input boxes. Hint: The method is somewhat similar to the tutorial example above. Use two input boxes to enter two numbers, assign them to variables, then compare the two values, and finally output them using a prompt box. Resource four provides the code for this tutorial, converted to py. Replying is a virtue!
×
❮
❯
Replies (1)
Sofa...
— All replies loaded —