Skip to content
Parallax Learn

Parallax Learn

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence
          • Cybersecurity: Radio Data tutorialCybersecurity
          • cyber:bot + Python
          • cyber:bot + MakeCode
          • Boe-Bot Tutorial SeriesBoe-Bot
          • Arduino Shield-Bot
          • ActivityBot with C TutorialsActivityBot + C
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot + BlocklyProp
          • Scribbler 3 Tutorial SeriesScribbler 3
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education
          • Propeller C-Language BasicsPropeller C Basics
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit + C
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit + BlocklyProp
          • Badge WX Tutorial SeriesBadge WX
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • MakeCode
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Electrical Measurements

Electrical Measurements

How it Works

How the Calculator Script Works

The script starts inside the while True loop, prompting you with “Enter volts: “.  The characters you type are stored in the text variable.  Then V = float(text) converts the characters you have typed from text into a floating point value and stores the result in a variable named V.  It repeats those steps for loading the ohms value you enter into the variable R.

while True:
    text = input("Enter volts: ")
    V = float(text)
    text = input("Enter ohms: ")
    R = float(text)   
 

 

Since V and R are known, the I = V / R form of the Ohm’s Law equation calculates the current value I.

   I = V / R    

 

After printing “I = “, the value of I, and the “A” unit, the script prints an empty line.  After that, the while True loop repeats so that you can calculate another current value.

   print("I = ", I, "A")
   print()    

 

Try This: Calculate V from A and Ω

Try modifying your script to calculate volts from amps and ohms.

  • Modify your script as shown below.
  • Update the name in the project name field to calculate_v_from_i_and_r.  Then , click Load/Save → Download Project Hex to save a copy of your work.
  • Click Send to micro:bit. 
  • Try entering some of the measurements you have taken previously into the serial monitor.
  • Verify that they match the calculated values.


Printer-friendly version
Script and Tests
Prev
Using Ohm’s Law
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn • Built with GeneratePress