Mar-27-2018, 09:14 AM
Hello!!
I have some tasks I need to do (not real HW, it's more like tasks to help me understand python from a classmate)
1. Code a program that writes multiples of 3 which is smaller than 100 in a file named multi.txt.
2. Code a program that adds multiples of 7 which is smaller than 100 in the file you created above.
Since I'm quite new to python I'm not really sure how to start with this? I know I probably need the range function and a loop... but how exactly do I write it?
I found this code, but it prints the sum which I don't need..
I've been googling all day but apparently it's too easy to find a solution for it lol
Can someone please help me out..
I have some tasks I need to do (not real HW, it's more like tasks to help me understand python from a classmate)
1. Code a program that writes multiples of 3 which is smaller than 100 in a file named multi.txt.
2. Code a program that adds multiples of 7 which is smaller than 100 in the file you created above.
Since I'm quite new to python I'm not really sure how to start with this? I know I probably need the range function and a loop... but how exactly do I write it?
I found this code, but it prints the sum which I don't need..
I've been googling all day but apparently it's too easy to find a solution for it lol
1 2 3 4 5 |
n = 101 sum = 0 for i in range ( 1 ,n, 3 ): sum = sum + i print ( sum ) |