Git Product home page Git Product logo

pypart4's Introduction

Part 4

Accompanying resources

Exercise 1

Create a program called fizz_buzz.py

The program should meet the following criteria.

  • The program prints each number from 1 to 100 to a new line.
  • If the number is a multiple of 3, print "Fizz" instead of the number.
  • If the number is a multiple of 5, print "Buzz" instead of the number.
  • If the number is a multiple of both 3 and 5, print "FizzBuzz" instead of the number.

Exercise 2

The Fibonacci Sequence is the series of numbers:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

Given the term n, determine the value of x(n).

n = 0 1 2 3 4 5 6 7 8 9 10 11 ..
x(n) = 0 1 1 2 3 5 8 13 21 34 55 89 ..

When n = 0, x(n) = 0
When n = 4, x(n) = 3
When n = 5, x(n) = 5

x(n) can be determined with the following rule:
x(n) = x(n - 1) + x(n - 2)

Create a program called fibonacci_recursive.py

Requirements

  • Given a term (n), determine the value of x(n).
  • In the fibonacci_recursive.py program, create a function called fibonnaci. The function should take in an integer and return the value of x(n).
  • This problem must be solved using recursion.

Constraints
n >= 0 and n <= 30

Exercise 3

Create a program called fibonacci_linear.py

Requirements

  • Given a term (n), determine the value of x(n).
  • In the fibonacci_linear.py program, create a function called fibonnaci. The function should take in an integer and return the value of x(n).
  • This problem must be solved WITHOUT the use of recursion.

Constraints
n >= 0

Exercise 4

Create a copy of the program called higher_or_lower.py from exercise 2 in Part 3.

Extend the functionality to meet the following requirements:

  • If a user's guess is incorrect, they get to keep guessing until they get it right.

higher_or_lower_demo

Exercise 5

Factorials are used to count permutations.

Create a program called factorial.py.

Requirements

  • Given a number (x), determine the value of x!
  • Use recursion
x result
0! 1
1! 1 * 1 1
2! 2 * 1 2
3! 3 * 2 * 1 6
4! 4 * 3 * 2 * 1 24
5! 5 * 3 * 2 * 1 120
... ... ...

Constraints

n >= 0 n < 995

pypart4's People

Contributors

xt0fer avatar git-leon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.