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
Korolek [52]
3 years ago
8

TOPIC-PYTHON

Computers and Technology
2 answers:
Wewaii [24]3 years ago
6 0

Explanation:

r=r*10+d shifts the previous value to the left (by multiplying by 10) and adds a new digit.

So imagine r = 123 and you want to append 4 to it.

First r is multiplied by 10, so you have 1230. Then you add 4, and get 1234.

The r variable builds up the reverse of s, so it starts at 0.

mixer [17]3 years ago
4 0

This program prints a number with reversed digits. For example, if you input 3564, you'll get 4653.

Suppose you give s=45, and let's see what the code does line by line:

We give 45 as input, and define r=0.

Then, we enter the while loop. The instruction d = s%10 simply extracts the last digit from s. In this case, d=5.

The istruction r = r\ast 10+d adds a 0 at the end of the current value of r. Then we add d, so now the last digit of r is d: we're performing

0\cdot 10 + 5 = 5

Finally, the integer division s = s//10 cuts the last digit from s. So, after the first loop, we have

d=5,\quad r=5,\quad s=4

We enter the loop again. we have

d = s\%10 = 4\%10 = 4

The new value of r is

5\cdot 10 + 4 = 54

And the division s//10 returns 0, so we exit the loop.

And indeed we have r=54, which is 45 in reverse.

You might be interested in
Arrange the binary number in increasing order of their arithmetic output in the decimal number system ?
tiny-mole [99]
I think the order would be

10010001-1000001 (as the biggest amount)
100101100/101
10011x101
10010x11
10100+10101 (as the least amount)

hope this helps! :)
6 0
3 years ago
A) How could you modify Shelve with a technique discussed in class so that you can create Shelve instances that contain // Tools
Kay [80]

Answer:

See explanation

Explanation:

A “shelf” is a dictionary-like object. A shelf is an arbitrary Python objects, that is; anything that the pickle module can handle. This includes recursive data types and objects containing lots of shared sub-objects. It must be noted that the keys are ordinary strings.

(A). modification to Shelve can be done by following this instructions;

(1). Do not redefine built-in functions,(2). grab shelved item, mutate item, write mutated item back to shelf.

The number (2) instructions is during iteration over shelved items.

(B). CREATING FUNCTIONS THAT TAKES IN TWO SHELVES;

import shelve

d = shelve.open(filename) # open -- file may get suffix added by low-level

# library

d[key] = data # store data at key (overwrites old data if

# using an existing key)

data = d[key] # retrieve a COPY of data at key (raise KeyError if no

# such key)

del d[key] # delete data stored at key (raises KeyError

# if no such key)

flag = key in d # true if the key exists

klist = list(d.keys()) # a list of all existing keys (slow!)

# or, d=shelve.open(filename,writeback=True) would let you just code

# d['xx'].append(5) and have it work as expected, BUT it would also

# consume more memory and make the d.close() operation slower.

d.close() # close it

3 0
4 years ago
Complete the following sentences using the drop-down menus.
shepuryov [24]

Answer:

✔ E-mail

is considered by some to be the most important program because of its popularity and wide use.

✔ Presentation

applications are used to display slide show-style presentations.

✔ Spreadsheet

programs have revolutionized the accounting industry.

Explanation:

just did it on edg this is all correct trust

7 0
3 years ago
When was Imagine dragons created
Eva8 [605]
They started at 2008                                            
5 0
3 years ago
Which of the following is NOT an option in the comments group
IgorLugansk [536]
I need the options to help you out, thanks. :)
4 0
3 years ago
Other questions:
  • What are the links between the operating systems, the software, and hardware components in the network, firewall, and IDS that m
    7·1 answer
  • In which of the following scenarios would it be best to use a for loop?
    6·1 answer
  • Technology will not? A. change the way work is done B. process information faster C. slow the pace of work D. link companies and
    8·1 answer
  • Indicate the time efficiency classes of the three main operations (i.e., FindMax, DeleteMax, and Insert) of the priority queue i
    11·1 answer
  • Name the contributions of Steve Jobs and Bill Gates, with respect to technology.
    5·1 answer
  • Use C++:
    9·1 answer
  • Match the categories in the first column with examples in the second column.
    14·1 answer
  • What is output? Select all that apply. c = 3 while (c < 10): c = c + 2 print (c)
    6·1 answer
  • Which of the following BEST describes Computer Science (CS)?
    8·1 answer
  • True and false 1. Trace topology is also referred to as tree bus topology. ​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!