1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Hoochie [10]
3 years ago
13

Secret_num = 10 temp = secret_num + 8 #evaluate secret + 8, and put the result #in temp temp = temp * 2 #evaluate temp * 2, and

put the results #in temp temp = temp / 4 answer = temp - secret_num / 2 print(answer)
why is the result always 4 ?why doesn't it change?​
Computers and Technology
1 answer:
Lunna [17]3 years ago
7 0

The result will always be 4 because the first four lines of code gets a number k+4, where k=\frac{\text{secret num}}{2}, and the last line subtracts 4 from k+4.. therefore leaving us with the value 4.

The effect of each line is explained below:

<em>secret_num </em>= 10

Assigns the value 10 to <em>secret_num</em>

<em>temp</em> = <em>secret_num</em> + 8

Stores the value 18 in <em>temp</em>

<em>temp</em> = <em>temp</em> * 2

Stores the value 36 in <em>temp</em>

<em>temp</em> = <em>temp</em> / 4

Stores the value 9 in <em>temp</em>

<em>answer</em> = <em>temp</em> - <em>secret_num</em> / 2

Stores the value 4 in <em>answer</em>

If the reasoning were done algebraically, we would have

(((\text{secret  num} + 8)\times 2)/4)-\text{secret  num}/2\\

Where the bracket nesting reflects the sequence of operations that led to the final answer in the code

Writing it mathematically, and simplifying

\frac{2(\text{secret  num} + 8)}{4}-\frac{\text{secret  num}}{2}\\\\=\frac{2\times\text{secret  num} + 16}{4}-\frac{\text{secret  num}}{2}\\\\=\frac{\text{secret  num}}{2}+4-\frac{\text{secret  num}}{2}\\\\=\frac{\text{secret  num}}{2}-\frac{\text{secret  num}}{2}+4\\\\=4

We see that at the end, no matter what the value of <em>secret_num</em> was, the <em>secret_num</em> term still cancels out, leaving us with 4.

Learn more about Arithmetic operations here: brainly.com/question/5973382

You might be interested in
What are the 2 levels of formatting in a word document
goldfiish [28.3K]

Answer:

Paragraph Styles and character formatting (font, color, etc.)

7 0
3 years ago
What type of code do computers typically use to operate? A. CSS B. HTML 5 C. HTML D. Binary
Ugo [173]

Answer:

D. Binary

Explanation:

Computer hardware parts are built on transistors, small electrical devices that switch electrical signals and amplify power. The CPU (Central Processing Unit), the "brain" of the computer, has billions of tiny transistors <em>alone</em>.

These transistors read binary, a code made up of 1's and 0's. This code tells what the computer to do.

CSS, HTML, and HTML 5 apply to web pages and web page designs, not code for the computer.

The OS (operating system) that your computer runs is coded in C++ (Windows) or C (Linux)

4 0
3 years ago
What questions do they ask for the 08.03 Discussion- Based Assesment in Drivers Ed?? Thanks.
mel-nik [20]

When should my headlights be turned on?

Why shouldn't one take medication before driving?

Why must you use a turn signal?

I'm not sure about that last one because I forgot but I think its right.

6 0
4 years ago
Why is the cpu the most important component in a computer?
german
CPU (Central Processing Unit) is also known as the brain of the computer because this is the place which actually runs the programs. The programs are the set of instructions needed to perform a task.
4 0
3 years ago
if the Titanic sank today , in what format would people receive or read the news? Indicate your favorable from of media format y
Diano4ka-milaya [45]

Answer:

It would hit MSM the soonest such as CNN, Fox , and all other news sources. The second that tge news got out, these news sources would dig in and find all information available and do a report on it

3 0
3 years ago
Other questions:
  • This career involves answering questions about computer parts and trouble shooting broken computers? Video game designer, comput
    10·1 answer
  • Write a program that calculates the occupancy rate for each floor of a hotel. The program should start by asking for the number
    10·1 answer
  • Generally, the more secure the system, the less usable it becomes. <br> O True O False
    9·2 answers
  • What is a phonograph?
    15·2 answers
  • Construct pseudocode for a program that prints ‘Hello World’ on the screen.
    7·2 answers
  • What is the purpose of reading in typography
    10·1 answer
  • What is the build in libary function to compare two strings?​
    15·1 answer
  • Explain how will you know the number of slides used in the presentation.​
    15·1 answer
  • Intro Programming - Problem(s)
    14·1 answer
  • What is the following file format called? inv_nbr, inv_name, inv_cost 876521,battery,45.00
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!