Tags:
view all tags
---+ Exercise 1: REPL and standard Python programming ---++ Introduction The goal of these exercises is to bring your Python programming skills to a level needed for the rest of the course. <p align="center"><font face="Liberation Sans, sans-serif"><font size="6"> *Course on Internet of Things* </font></font></p> ---+ Exercises Session 1: ---++ Exercise 1: Connect to your ESP32 with minicom or thonny. Using REPL: * <p>print “Hello World!”</p> * <p>read in a text using <i>input() </i>and print it</p> * <p>Calculate</p> <p><img align="middle" alt="calculations.png" height="52" src="%ATTACHURL%/calculations.png" title="calculations.png" width="142" /></p> * <p>Calculate sin(30°) <br /> If you see errors, how do you correct them? Are the results correct?</p> ---++ Exercise 2: Write a script that assigns the values 5 and 3 to the variables a and b respectively Print the results of 4 basic arithmetic operations: * <p>a+b</p> * <p>a-b</p> * <p>a*b</p> * <p>a/b</p> Which result do you observe for division? Can you correct? Improve this program asking the user to enter 2 integers separated by a space. If this happens when the user mistypes and enters something that is not an integer can you capture the error and simply ask him to repeat his input until you get 2 correct integer numbers? ---++ Exercise 1: Connect to your ESP32 with minicom or thonny. Using REPL: * <p>print “Hello World!”</p> * <p>read in a text using <i>input() </i>and print it</p> * <p>Calculate</p> * <p>Calculate sin(30°) <br /> If you see errors, how do you correct them? Are the results correct?</p> ---++ Exercise 2: Write a script that assigns the values 5 and 3 to the variables a and b respectively Print the results of 4 basic arithmetic operations: * <p>a+b</p> * <p>a-b</p> * <p>a*b</p> * <p>a/b</p> Which result do you observe for division? Can you correct? Improve this program asking the user to enter 2 integers separated by a space. What happens when the user mistypes and enters something that is not an integer? Can you capture the error and simply ask him to repeat his input until you get 2 correct integer numbers? ---++ Exercise 3: Ask the user for 2 integer numbers. Check with one is bigger and print the result: Running the program should result in output as shown below: <img align="left" alt="" height="145" name="Image1" src="file:///tmp/lu55472qt7090.tmp/lu55472qt709d_tmp_9eb3e6ce3d8cb9c1.png" width="622" /> ---++ Exercise 3: Ask the user for 2 integer numbers. Check with one is bigger and print the result: Running the program should result in output as shown below: <img align="left" alt="" height="145" name="Image1" src="file:///tmp/lu55472qt7090.tmp/lu55472qt7098_tmp_9eb3e6ce3d8cb9c1.png" width="622" /> -- %USERSIG{UliRaich - 2020-05-03}% ---++ Comments %COMMENT%
Attachments
Attachments
Topic attachments
I
Attachment
History
Action
Size
Date
Who
Comment
png
calculations.png
r1
manage
2.3 K
2020-05-03 - 09:22
UliRaich
png
conversionError.png
r1
manage
19.3 K
2020-05-03 - 09:22
UliRaich
Edit
|
Attach
|
Watch
|
P
rint version
|
H
istory
:
r14
|
r4
<
r3
<
r2
<
r1
|
B
acklinks
|
V
iew topic
|
Raw edit
|
More topic actions...
Topic revision: r1 - 2020-05-03
-
UliRaich
Home
Site map
AFNOG web
Embedded_Systems web
IoT_Course_English web
IoT_Course_French web
Main web
Sandbox web
TWiki web
IoT_Course_English Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Register User
Edit
Attach
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback