(40%) 1. Write a loop that calculates the total of the following series of numbers (the number n is from user): 1/n+ 2/(n-1)+ 3/(n-2)... (n-1)/2 +n/1 Enter the number n: 4 The total is 8.7 (30%) 2. Write and submit your code in a file called pattern2.py. Write a program that output the following diagonal pattern using loop (n number of "*", n is from user): Enter the number n: 8 * * * * * * * *
Added by Daniel M.
Close
Step 1
.. + (n-1)/2 + n/1. We can use a loop to iterate through the numbers from 1 to n and calculate the corresponding term in the series. We can then add up all the terms to get the total. Here's the code: ```python n = int(input("Enter the number n: ")) total = Show more…
Show all steps
Your feedback will help us improve your experience
Akash M and 51 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
i. Write a Python program to calculate the factorial value of a given number. The number must be entered by the user. ii. Write a Python program to print the following pattern: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
Liam H.
write a program in Python to print the series 1 2 4 7 11 16 72 ..... upto n terms
Varun I.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD