PYTHON Study Guide - Divisor

11 views2 pages
26 May 2023
Department
Course
Professor

Document Summary

#24 python tutorial for beginners | for else in. Section overview: in this document, he explains how to use for loops and else statements together in python. He provides an example of printing numbers between 1 to 20 that are not divisible by 5 using a for loop. Then he demonstrates how to print the first number that is divisible by 5 from a list of numbers using a for loop and an if statement. Finally, he shows how to add an else statement to handle cases where there are no numbers in the list that are divisible by 5. Use a for loop to print all the numbers between 1 and 20 that are not divisible by 5. Use the modulus operator (%) to check if a number is divisible by another number. Use continue statement to skip over certain iterations of the loop.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers

Related Documents

Related Questions