Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

data programming/python Problem 3: Triangular numbers Use a for loop to compute the 10th triangular number. The nth triangular number is defined as 1+2+3+...+n. (You

data programming/python
image text in transcribed
Problem 3: Triangular numbers Use a for loop to compute the 10th triangular number. The nth triangular number is defined as 1+2+3+...+n. (You can also compute the nth triangular number as n(n+1)/2. Use this formula to double-check that your loop is correct.) Hint: This outline is an almost-complete solution. You only have to replace each ellipsis by an expression. n = 10 triangular - 0 for i in... triangular - print("Triangular number", n, "via loop:", triangular) print("Triangular number", n, "via formular", n. (n + 1) / 2) Your code should be able to correctly calculate the 11th, 12th, or any other triangular number just by changing the first line to set n to 11, 12, or any other number. Be sure the code you submit calculates the triangle number for n - 10. Using the range function should help you accomplish this

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Which curl option is used to set request headers?

Answered: 1 week ago

Question

How many multiples of 4 are there between 10 and 250?

Answered: 1 week ago