-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path11_homework_exercises.py
61 lines (51 loc) · 1.53 KB
/
11_homework_exercises.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Exercise 1 - Sum of 3s and 5s
# Write a program which given the number N will sum all numbers
# dividable by 3 and 5 which are less or equal to N.
# N=10
# 1 2 3 4 5 6 7 8 9 10
# 3 + 5 + 6 + 9 + 10 = 33
# Exercise 2 - Factorial
# Write a program which will compute n factorial.
# n factorial denoted as n! is the product of all numbers less than
# or equal to n.
# 3! = 3 * 2 * 1 = 6
# 7! = 7 * 6 * 5 * 4 * 3 * 2 * 1 = 5040
# Exercise 3 - Reversed
# Write a program which will reverse text inputted by the user.
# input: "coding in python is fun"
# output: "nuf si nohtyp ni gnidoc"
# tip: strings are just lists of characters
# Complete the exercise:
# a) using slicing
# b) without slicing
# Exercise 4 - Square
# Write a program which will print a square from asterisks.
# ***
# * *
# ***
# Ad 1.
# Modify the program so that the user can specify the side length.
# Exercise 5 - Fibonacci
# Write a program which will print out n elements of the fibonacci
# sequence.
# input: 6
# output:
# 1
# 1
# 2
# 3
# 5
# 8
# Ad 1.
# For each printed fibonacci number also print out the ratio of the
# current to the previous number.
# Exercise 6: Intersection
# Create two lists of numbers. Write a programs which will print
# numbers:
# a) present in both lists
# a) present only in first list
# Exercise 7: Fizz Buzz
# Write a program that prints the numbers from 1 to 100. For
# multiples of three print "Fizz" instead of the number and for
# multiples of five print "Buzz". For numbers which are multiples of
# both three and five print "FizzBuzz".