Python Programming: An Introduction to Computer Science, 3rd Ed.
Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 3, Problem 12PE
Program Plan Intro

Sum of cubes of first n natural numbers

Program Plan:

  • Define the main function.
    • Get the value of “n” from the user.
    • Declare a variable “sum” and assign 0 to it.
    • Loop from 0 through n.
      • Find the cube of a number and store it in a variable “cube”.
      • Calculate the value of sum by adding “sum” and “cube” and store it in a variable “sum”.
    • Print the value of “sum”.

Blurred answer
Students have asked these similar questions
An integer n is divisible by 9 if the sum of its digits is divisible by 9. Develop a program to display each digit, starting with the rightmost digit. Your program should also determine whether or not the number is divisible by 9.
Write a program that calculates the sum of all positive integers less than or equal to a given number N.
You are given an integer, N. Your task is to print an alphabet rangoli of size N. (Rangoli is a form of Indian folk art based on creation of patterns.) Different sizes of alphabet rangoli are shown below: #size 3 ----C---- --c-b-c-- c-b-a-b-c --c-b-c-- ----C---- #size 5 ------e-d-e-- ----e-d-c-d-e---- --e-d-c-b-c-d-e-- e-d-c-b-a-b-c-d-e --e-d-c-b-c-d-e-- ----e-d-c-d-e---- e-d-e---- ---- #size 10 --j- -j-i-j- --j-i-h-i-j-- ---j-i-h-g-h-i-j- --j-i-h-g-f-g-h-i-j- -j-i-h-g-f-e-f-g-h-i-j-- ------j-i-h-g-f-e-d-e-f-g-h-i-j-- ----j-i-h-g-f-e-d-c-d-e-f-g-h-i-j--- --j-i-h-g-f-e-d-c-b-c-d-e-f-g-h-i-j-- j-i-h-g-f-e-d-c-b-a-b-c-d-e-f-g-h-i-j --j-i-h-g-f-e-d-c-b-c-d-e-f-g-h-i-j-- ----j-i-h-g-f-e-d-c-d-e-f-g-h-i-j-- -j-i-h-g-f-e-d-e-f-g-h-i-j- -j-i-h-g-f-e-f-g-h-i-j- ---j-i-h-g-f-g-h-i-j- --j-i-h-g-h-i-j- -j-i-h-i-j- j-i-j- The center of the rangoli has the first alphabet letter a, and the boundary has the Nth alphabet letter (in alphabetical order). Eunction Descrintion
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY