The program to print the sum of all cubes


Asked by admin @ in Computer Science viewed by 1967 People


Choose the correct option.

The program to print the sum of all cubes that lie between 0 and 100 isgiven below. Does this program have an error? If yes, which statementshould be modified to correct the program?integer i = 0.a // Statementinteger sum = 0;a = (ii)while (<100) // Statement 2sum = sum + a // Statement 3= -1Statement 45}print sum​

Answered by admin @



Answer:

The process of converting the value of one data type (integer, string, float, etc.) to another is called type conversion. Python has two types of type conversion.

Explanation:

This book has two goals: to teach you to think like a computer programmer, and to help you apply your new understanding in creating web applications.

Learning to think like a computer programmer is a good end in itself, since the processes used in computer programming combine some of the best features of mathematics, engineering, and natural science. Like mathematicians, computer programmers use formal languages to denote ideas (specifically computations). Like engineers, they design things, assembling components into systems and evaluating tradeoffs among alternatives. Like scientists, they observe the behavior of complex systems, form hypotheses, and test predictions.

The single most important skill for a computer programmer is problem solving. Problem solving means the ability to formulate problems, think creatively about solutions, and express a solution clearly and accurately. As it turns out, the process of learning to program is an excellent opportunity to practice problem-solving skills. That’s why this chapter is called “The way of the program.”

On one level, you will be learning to program, a useful skill in itself. On another level, you will use programming as a means to an end - creating web applications.

1.1. The Python programming language

The programming language you will be learning is Python. Python is an example of a high-level language; other high-level languages you might have heard of are C++, PHP, and Java.

As you might infer from the name high-level language, there are also low-level languages, sometimes referred to as machine languages or assembly languages. Loosely speaking, computers can only execute programs written in low-level languages. Thus, programs written in a high-level language have to be processed before they can run. This extra processing takes some time, which is a small disadvantage of high-level languages.

But the advantages are enormous. First, it is much easier to program in a high-level language. Programs written in a high-level language take less time to write, they are shorter and easier to read, and they are more likely to be correct. Second, high-level languages are portable, meaning that they can run on different kinds of computers with few or no modifications. Low-level programs can run on only one kind of computer and have to be rewritten to run on another.

Due to these advantages, almost all programs today are written in high-level languages. Low-level languages are used only for a few specialized applications requiring exact control of the computer.

Two kinds of programs process high-level languages into low-level languages: interpreters and compilers. An interpreter reads a high-level program and executes it, meaning that it does what the program says. It processes the program a little at a time, alternately reading lines and performing computations.

Interpret illustration

A compiler reads the program and translates it completely before the program starts running. In this case, the high-level program is called the source code, and the translated program is called the object code or the executable. Once a program is compiled, you can execute it repeatedly without further translation.

Compile illustration

Many modern languages use both processes. They are first compiled into a lower level language, called byte code, and then interpreted by a program called a virtual machine. Python uses both processes, but because of the way programmers interact with it, it is usually considered an interpreted language.

There are two ways to use the Python interpreter: shell mode and script mode. In shell mode, you type Python expressions into the Python shell, and the interpreter immediately shows the result:

$ python3

Python 3.5.2 (default, Nov 17 2016, 17:05:23)

[GCC 5.4.0 20160609] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> 2 + 2

4

>>>

The >>> is called the Python prompt. The interpreter uses the prompt to indicate that it is ready for instructions. We typed 2 + 2, and the interpreter evaluated our expression, and replied 4, and on the next line it gave a new prompt, indicating that it is ready for more input.

Alternatively, you can write a program in a file and use the interpreter to execute the contents of the file. Such a file is called a script.

Traditionally, the first program written in a new language is called Hello, World! because all it does is display the words, Hello, World! In Python, the script looks like this:

print("Hello, World!")

This is an example of using the print function, which doesn’t actually print anything on paper. It displays a value on the screen. The quotation marks in the program mark the beginning and end of the value; they don’t appear in the result.


Similar Questions

Program to find sum of two numbers in c++

Asked by admin @ in Computer Science viewed by 354 persons

Write a program in C++ to display the sum of two numbers 20 and 30.

Write a program to print a simple message in java

Asked by admin @ in Computer Science viewed by 352 persons

Write a program to print a simple message in java​

Python program to print first n numbers divisible by 5

Asked by admin @ in Computer Science viewed by 359 persons

Write a Python program using while loop first N numbers divisible by 5.

C program to print number in words using switch case

Asked by admin @ in Computer Science viewed by 367 persons

C program to display the number in words using switch case where a sample input and output is given

Write a c++ program to accept and print your name

Asked by admin @ in Computer Science viewed by 333 persons

Write a C++ program to accept and print your name?​

Which expression is a sum of cubes

Asked by maham237 @ in Mathematics viewed by 274 persons

Which expression is a sum of cubes?

Which expression is a sum of cubes?

Asked by maham237 @ in Mathematics viewed by 261 persons

Sum of the cubes of first 20 natural numbers is

Asked by admin @ in Math viewed by 342 persons

The sum of cubes of first 20 natural numbers is

Overcoming fixed mindset: a step-by-step guide to cultivating a growth mindset

Asked by wiki @ in Health viewed by 1305 persons

Which of the following would best complete this list?

Asked by wiki @ in Social Studies viewed by 758 persons

What had the king decided to do before he saw the spider

Asked by vanshika149 @ in English viewed by 1162 persons

Describe the karez in your own words

Asked by rajesh064 @ in English viewed by 1334 persons

What is 8 + (x + 5)?

Asked by jaylord7 @ in Mathematics viewed by 1115 persons

What is the topic of the info grapher

Asked by jesus643 @ in History viewed by 1414 persons

Most viewed questions in Computer Science


A programmer mistakenly writes gor instead of for

Asked by admin @ in Computer Science viewed by 19030 persons


Domestic data entry operator ncert book class 9 solutions

Asked by admin @ in Computer Science viewed by 15816 persons


Information technology code 402 class 9 solutions chapter 1

Asked by admin @ in Computer Science viewed by 10977 persons



Ncert solutions for class 8 computer chapter 1 computer system

Asked by admin @ in Computer Science viewed by 10407 persons


A scrum team works on a 4 weeks sprint

Asked by admin @ in Computer Science viewed by 8723 persons


Which of the following occupies more memory in c

Asked by admin @ in Computer Science viewed by 8145 persons



A database of motor vehicles has the base entity

Asked by admin @ in Computer Science viewed by 7845 persons


The network architecture can be termed as a mcq

Asked by admin @ in Computer Science viewed by 6492 persons


Cat5 and cat6 cabling refer to which reference model layer

Asked by admin @ in Computer Science viewed by 5796 persons



Class 7 computer chapter 3 questions and answers

Asked by admin @ in Computer Science viewed by 5696 persons


Choose the correct options about usability and user experience

Asked by admin @ in Computer Science viewed by 5479 persons


Which advocates daily team meetings for coordination and integration

Asked by admin @ in Computer Science viewed by 4986 persons



Which three security features match the database security level

Asked by admin @ in Computer Science viewed by 4976 persons


Which of the dbms package is not available

Asked by admin @ in Computer Science viewed by 4690 persons


________ aid a business grow and attain its objectives

Asked by admin @ in Computer Science viewed by 4492 persons