![]() |
multiples of 3, smaller than 100 - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: multiples of 3, smaller than 100 (/thread-9213.html) |
multiples of 3, smaller than 100 - sonxy - Mar-27-2018 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 n = 101 sum = 0 for i in range(1,n,3): sum = sum + i print (sum)Can someone please help me out.. RE: multiples of 3, smaller than 100 - Larz60+ - Mar-27-2018 your print statement needs to be indented to same level as sum = ... |