Skip to content

eirkostop/Python

Repository files navigation

Python Simple Exercises

Ladder

Create a program which asks the user for the number of floors and prints a ladder of * of equal floors. For example for floors = 5 it prints:

*
**
***
****
*****

Pyramid

Create a program which asks the user for the number of floors and prints a symmetrical pyramid f * of equal floors. For example for floors = 4 it prints:

   *
  ***
 *****
*******

Factorial

Create the function factorial(n) which calculates the factorial of the number n.

Fibonacci

Create the function fibonacci(n) which returns the n'th fibonacci number.

FizzBuzz

Create the procedure FizzBuzz(n) which prints the numbers 1 to n or Fizz if the number is a multiple of 3, Buzz if the number is a multiple of 5, or FizzBuzz if the number is a multiple of both 3 and 5.

Custom Range

Create the function custom_range(start, end, step) which returns a list containing numbers in the range [start, end) and increase by step in each iteration.

Larger than Sum

Create the function larger_than_sum(L) which returns True if for every item of list L it holds that L[i] > sum(L[i+1] + L[i+2] + ... + L[len(L)-1]]) or False otherwise.

Palindrome

Create the function isPalindrome(L) which returns True if the list L is symmetrical or False otherwise. That is, L[0] == L[len(L)-1], L[1] == L[len(L)-2] etc.

Rock - Scissors - Paper Person vs Computer

Create a game for one player. Player chooses between rock / scissors / paper and the same isdone by the computer in a random way. If someone wins the round he gets 1 point. The game is finished when someone gets 3 points.

Hangman Player vs Computer

Create a game for one player against the computer. The computer has a 'word bank', a list ofwords, from where it chooses one for the game. The player tries to guess it, character by character with a maximum of 7 wrong guesses. If he manages to guess it he wins otherwise he loses. The game continually provides visual aid about the state of the game.

About

Python simple exercises

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages