gcagle1 / assignment-8

BIOL7800 Assignment 8

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Assignment 8

We talked about iteration and using while and for to accomplish iteration. Here, I want you to build off the new knowledge you have of while and for while revisiting a couple of tasks that you've already seen. As with the previous assignment, fork and clone this repository. Then create a directory equivalent to your username in the answers directory. Within your answers/username directory, write a program to complete each task, below. Name each of the programs you are writing, according to the "task" (e.g. task1.py). Commit those programs, push them up to your cloned repository, and make a pull request.

Task 1

Previously, you wrote a program that used a recursive function to compute the sum of the integers from 0 to 1000 (inclusive). This time, I want you to accomplish the same thing, but using a while loop. Compute the sum of 0 to 1000 (inclusive) in a function using while. Return the sum of these numbers to the main loop and print the result. Write the program to include a main() function and the ifmain statement.

Task 2

Above, you wrote a program that used a while loop to compute the sum of the integers from 0 to 1000 (inclusive). This time, I want you to accomplish the same thing, but using a for loop. Compute the sum of 0 to 1000 (inclusive) in a function using for. Return the sum of these numbers to the main loop and print the result. Write the program to include a main() function and the ifmain statement.

Task 3

In Python, we tend to use for loops over different types of iterators much more than while loops - they're more flexible and iterators are everywhere in Python. Write a program that includes 5 different functions, each of which should demonstrate the use of for over different types of iterators. Your program should include these five functions, a main() function that calls all the other functions, and the ifmain statement.

About

BIOL7800 Assignment 8


Languages

Language:Python 100.0%