Multiple of 7 or Ends with 7
Check if a number is a multiple of 7 or ends with 7.
IntermediatePhase 1 - Level 3: Math and Number LogicExample 5 of 10
multiple-of-7-or-ends-with-7.py
1# Take number2num = int(input("Enter a number: "))34# Check conditions5is_multiple = num % 7 == 06ends_with_7 = num % 10 == 778if is_multiple or ends_with_7:9 print("Number is multiple of 7 or ends with 7")10else:11 print("Number is neither multiple of 7 nor ends with 7")
Output
Enter a number: 14 Number is multiple of 7 or ends with 7 Enter a number: 17 Number is multiple of 7 or ends with 7 Enter a number: 15 Number is neither multiple of 7 nor ends with 7
What's going on
Use OR operator to check either condition.
Key Concepts:
Multiple of 7: num % 7 == 0
Ends with 7: num % 10 == 7
Use 'or' to check if either is true
🔗Related Content
- 📖
Phase 1 - Learn Concepts
Review Phase 1 concepts and explanations
- 📝
Phase 1 - Quiz
Test your Phase 1 understanding with quiz questions
- 💻
Phase 1 - All Practice Problems
Explore all practice problems for Phase 1
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum