Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Questions about Python Q1. We can also say this about variables and memory usage: Group of answer choices a) All variables are each given their

Questions about Python

Q1.

We can also say this about variables and memory usage:

Group of answer choices

a) All variables are each given their own memory (and identity), so the memory usage of the Python program does not change during assignment

b) The memory usage in a program may increase after an assignment operation

Q2

Speaking of memory usage, let's take a peek (just for this recitation) at that:

import sys help(sys.getsizeof) sys.getsizeof(12) sys.getsizeof(123) sys.getsizeof(12345) 

Group of answer choices

a) These all have the same size, greater than 10 bytes

b) These have different sizes -- bigger numbers with different sizes

c) These all have the same size, fewer than 10 bytes

Q3

Those of course are numbers; and we could imagine strings that look like numbers:

sys.getsizeof('12') sys.getsizeof('123') sys.getsizeof('12345')

Group of answer choices

a) These are identical to the previous question

b) These are all the same as each other, but different from the previous question

c) These are all different, and much larger than the previous question's numbers

Q4

All of this extra memory here is a price we pay for using an interpreted language. Since we do not have a compiler involved in translating everything into the most concise machine code, some information must be kept around with each value to make proper use of it.

For example, for that string representing '123', in addition to remembering the '1', '2,, and '3', we would have to remember all of the following:

  • this is a character string, and not an integer
  • this character string is 3 characters long
  • applying + to this value concatenates strings instead of adding
  • what place in memory holds all the other info in the preceding bullet points!

Try to identify how many of bytes of memory hold all of this extra information for each string value. The three answers to the previous question should help you.

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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions

Question

Develop successful mentoring programs. page 400

Answered: 1 week ago