Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 100+ Python challenging programming exercises.txt #146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions 100+ Python challenging programming exercises.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2371,5 +2371,25 @@ solutions=solve(numheads,numlegs)
print solutions

#----------------------------------------#
Level 1:
Relatively easy problem that can be solved
by someone who is a beginner to Python

Question:
Write a program that goes through the integers from 1-100. For every integer divisible by 3 the program should print "Fizz". For every integer divisible by 5 the program should print "Buzz". For every integer divisible by both 3 and 5 the program should print "FizzBuzz". For every integer that are not divisible by either 3 or 5 and both, print the integer itself.

Hints:
Use a for loop and range(). Read the question carefully before writing any lines of code.

Solution:
def fizzbuzz() -> None:
for integer in range(1,101):
if integer % 3 == 0 and integer % 5 == 0:
print 'FizzBuzz'
elif integer % 3 == 0:
print 'Fizz'
elif integer % 5 == 0:
print 'Buzz'
else:
print integer
#----------------------------------------#