Maximum Element
Find and print the maximum element in an array.
BeginnerPhase 4 - Level 1: Basic ArraysExample 3 of 10
maximum-element.py
1# Array2arr = [10, 25, 5, 30, 15]34# Find maximum5max_element = arr[0]6for element in arr:7 if element > max_element:8 max_element = element910print(f"Maximum element: {max_element}")
Output
Maximum element: 30
What's going on
Compare each element with current maximum.
Key Concepts:
Initialize max to first element
Compare each element with max
Update max if element is greater
Print final max
🔗Related Content
- 📖
Phase 4 - Learn Concepts
Review Phase 4 concepts and explanations
- 📝
Phase 4 - Quiz
Test your Phase 4 understanding with quiz questions
- 💻
Phase 4 - All Practice Problems
Explore all practice problems for Phase 4
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum