Skip to content

upperlinecode/loopy-math-python-iteration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Loopy Math

Run on Repl.it

TL;DR

This lab will give you practice with for __ in range(__): and style loops. Open up loops.py, where the challenges are written as python comments. Run the code after each new loop you write to see if your code works as intended.

Contents

  1. Intro
  2. The Lab
  3. Extra Help
  4. Stretch

Intro

Pandas Looping Through a Slide

Python can be used to make mathematical tasks much less... well... mathy. Use for loops to compute some of these math challenges without having to add hundreds of numbers by hand.

The Lab

Loops in python allow us to automate processes that would be tedious and exhausting otherwise.

Without loops, printing 100 different numbers would take 100 lines of code. With loops, we can do it in 2 lines of code. More impressively, we can bump that number up to 10,000, or even into the millions and billions without having to add extra lines of code.

Open up the main.py file, and try to complete each of the for ___ in range(___): loops described there.

Extra Help

Here's the easiest answer for problem 1:

for i in range(101):
  print(i)

This method will also print the zero, which is fine, but not technically what the challenge asked for. So remember that range can also take TWO arguments - a start and an end. You could refine your answer this way:

for i in range(0, 101):
  print(i)

Each of the challenges can be done in at least two ways, and some can be done in as many as 10 ways, so as long as your output meets the criteria for each problem, you're doing great!

Stretch

There are stretch activities built right into this lab.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages