Provide a brief overview of the issue to solve, or why this is a best practice. Explain the goal of this step and how it connected to the previous ones. Optionally, if you have assigned a task in the previous chapter, provide the solution at the beginning of this one.
Explain the solution step by step. If you can, record a video following our video guidelines for Tutorials. If there’s code involved, explain small snippets first and add more to build the final code, which you can display at the end of the chapter.
Use subheaders if needed.
# program to check if a number is prime or not num = 333 # prime numbers are greater than 1 if num > 1: # check for factors for i in range(2,num): if (num % i) == 0: print(num,"is not a prime number.") print(i,"times",num//i,"is",num) break else: print(num,"is a prime number.") # if num is less than or equal to 1, it is not prime else: print(num,"is not a prime number.")
333 is not a prime number 3 times 111 is 333
Explain briefly how to bring this to the next level, provide useful resources, and announce what will come in the following chapter.
# to take input from the user num = int(input("Enter a number: "))
(Optional) Knowledge check
Challenge your audience with a small test, quiz or task. You can provide the (written or video) answer in the next chapter.