CoursesCSS StudioExamplesGATECompaniesPrepMentora
Programs/Logic building/Phase 4 - Level 1: Basic Arrays

2 / 10

Next
1. Input N Integers and Print Them2. Sum of Array3. Maximum Element4. Minimum Element5. Count Positive, Negative, Zero6. Count Even and Odd Elements7. Index of Maximum Element8. Index of Minimum Element9. Elements Greater Than K10. Average of Array

Phase 4 - Level 1: Basic Arrays

  1. 01Input N Integers and Print Them
  2. 02Sum of Array
  3. 03Maximum Element
  4. 04Minimum Element
  5. 05Count Positive, Negative, Zero
  6. 06Count Even and Odd Elements
  7. 07Index of Maximum Element
  8. 08Index of Minimum Element
  9. 09Elements Greater Than K
  10. 10Average of Array

Sum of Array

Calculate and print the sum of all array elements.

BeginnerPhase 4 - Level 1: Basic ArraysExample 2 of 10
sum-of-array.py
1# Array
2arr = [10, 20, 30, 40, 50]
3
4# Calculate sum
5sum = 0
6for element in arr:
7 sum += element
8
9print(f"Sum: {sum}")

Output

Sum: 150

What's going on

Iterate through array and accumulate sum.

Key Concepts:

Initialize sum to 0
Loop through each element
Add element to sum
Print final sum

🔗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

PreviousInput N Integers and Print ThemNextMaximum Element

On this page

CodeOutputExplanation
Up nextMaximum Element
Schoolabe

Learn, Practice, Ace Coding

ExamplesCompaniesTutorialsCSS StudioDSA VisualizersQuizInterview PrepMentoraCareer QuestGATE CS prepGATE CS 2027 study planJob ReadyInternships
AboutContactCareersAffiliate programBlog
DocumentationAPI ReferenceCommunitySupport
Privacy PolicyTermsRefund PolicyCookie Policy

© 2026 Schoolabe