Language:EN
Pages: 2
Words: 181
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
example user input list size and list elements are

Example user input- list size and list elements are

Python Program Assignment Answers

Question:

Write a python program to find the sum of elements which are stored at odd indexed and divisible by 3 in a list of integers. Create the list by asking the user the size and elements of the list. Example: (i) (User Input-> List size =6 and List elements are= 10, 12, 5, 9, 19, 31, 42 Then the output is 21)

Python Program Answer and Explanation

        if lst[i] % 3 == 0:  # Check if the element at the odd index is divisible by 3

            result += lst[i]  # Add the element to the result

    # Input list elements from the user

    elements = []

    result = sum_odd_divisible_by_three(elements)

    print("Sum of elements at odd indices and divisible by 3:", result)

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : Zain Ganesh

PageId: DOC4069F20