Write function d2x() that takes as input a nonnegative integer n (in the standard decimal representation) and an integer x between 2 and 9 and returns a string of digits that represents the base-x representation of n.

Answers

Answer 1

Answer:

The function in Python is as follows:

def d2x(d, x):

   if d > 1 and x>1 and x<=9:

       output = ""

       while (d > 0):

           output+= str(d % x)

           d = int(d / x)

       output = output[::-1]

       return output

   else:

       return "Number/Base is out of range"

Explanation:

This defines the function

def d2x(d, x):

This checks if base and range are within range i.e. d must be positive and x between 2 and 9 (inclusive)

   if d >= 1 and x>1 and x<=9:

This initializes the output string

       output = ""

This loop is repeated until d is 0

       while (d > 0):

This gets the remainder of d/x and saves the result in output

           output+= str(d % x)

This gets the quotient of d/x

           d = int(d / x) ----- The loop ends here

This reverses the output string

       output = output[::-1]

This returns the output string

       return output

The else statement if d or x is out of range

   else:

       return "Number/Base is out of range"


Related Questions

Which of the following is true? a. There are RFCs that describe challenge-response authentication techniques to use with email. b. Filtering for spam sometimes produces a false positive, in which legitimate email is identified as spam. c. Spam relies heavily on the absence of email authentication. d. All of the above.

Answers

The option that is true is option b. Filtering for spam sometimes produces a false positive, in which legitimate email is identified as spam.

How is spam filtration carried out?

The processing of email to organize it in accordance with predetermined criteria is known as email filtering. The word can allude to the use of human intelligence, although it most frequently describes how messages are processed automatically at SMTP servers, sometimes using anti-spam tactics.

Therefore, Email filtering operates as previously stated by scanning incoming messages for red flags that indicate spam or phishing content and then automatically transferring such messages to a different folder. Spam filters evaluate an incoming email using a variety of criteria.

Learn more about Filtering for spam from

https://brainly.com/question/13058726
#SPJ1

list and describe each of the activities of technology

Answers

Answer:

network has led to exposure of dirty things to young ones.

air transport has led to losing of lives

Write a program to implement problem statement below; provide the menu for input N and number of experiment M to calculate average time on M runs. randomly generated list. State your estimate on the BigO number of your algorithm/program logic. (we discussed in the class) Measure the performance of your program by given different N with randomly generated list with multiple experiment of Ns against time to draw the BigO graph (using excel) we discussed during the lecture.

Answers

Answer:

Explanation:

#include<iostream>

#include<ctime>

#include<bits/stdc++.h>

using namespace std;

double calculate(double arr[], int l)

{

double avg=0.0;

int x;

for(x=0;x<l;x++)

{

avg+=arr[x];

}

avg/=l;

return avg;

}

int biggest(int arr[], int n)

{

int x,idx,big=-1;

for(x=0;x<n;x++)

{

if(arr[x]>big)

{

big=arr[x];

idx=x;

}

}

return idx;

}

int main()

{

vector<pair<int,double> >result;

cout<<"Enter 1 for iteration\nEnter 2 for exit\n";

int choice;

cin>>choice;

while(choice!=2)

{

int n,m;

cout<<"Enter N"<<endl;

cin>>n;

cout<<"Enter M"<<endl;

cin>>m;

int c=m;

double running_time[c];

while(c>0)

{

int arr[n];

int x;

for(x=0;x<n;x++)

{

arr[x] = rand();

}

clock_t start = clock();

int pos = biggest(arr,n);

clock_t t_end = clock();

c--;

running_time[c] = 1000.0*(t_end-start)/CLOCKS_PER_SEC;

}

double avg_running_time = calculate(running_time,m);

result.push_back(make_pair(n,avg_running_time));

cout<<"Enter 1 for iteration\nEnter 2 for exit\n";

cin>>choice;

}

for(int x=0;x<result.size();x++)

{

cout<<result[x].first<<" "<<result[x].second<<endl;

}

}

hello! can someone write a c++ program for this problem

Problema 2018.3.2 - Cheated dice
Costica is on vacation and his parents sent him to the country. There he gets terribly bored and looking through his grandfather's closet, he came across a bag full of dice. Having no one to play dice with, but it seemed to him that some of the dice were heavier than the others, Costica chose a dice and started to test it by throwing it with him and noting how many times each face fell. He then tries to figure out whether the dice are rolled or not, considering that the difference between the maximum number of appearances of one face and the minimum number of occurrences (of any other face) should not exceed 10% of the total number of throws.
Requirement
Given a number N of dice rolls and then N natural numbers in the range [1: 6] representing the numbers obtained on the rolls, determine whether the dice is tricked according to the above condition.
Input data
From the input (stdin stream) on the first line reads the natural number N, representing the number of rolls. On the following N lines there is a natural number in the range [1: 6] representing the numbers obtained on throws.
Output data
At the output (stdout stream) a single number will be displayed, 0 or 1, 0 if the dice are normal, and 1 if it is cheated.
ATTENTION to the requirement of the problem: the results must be displayed EXACTLY in the way indicated! In other words, nothing will be displayed on the standard output stream in addition to the problem requirement; as a result of the automatic evaluation, any additional character displayed, or a display different from the one indicated, will lead to an erroneous result and therefore to the qualification "Rejected".
Restrictions and clarifications
1. 10 ≤ N ≤ 100
2. Caution: Depending on the programming language chosen, the file containing the code must have one of the extensions .c, .cpp, .java, or .m. The web editor will not automatically add these extensions and their absence makes it impossible to compile the program!
3. Attention: The source file must be named by the candidate as: . where name is the last name of the candidate and the extension (ext) is the one chosen according to the previous point. Beware of Java language restrictions on class name and file name!
Input data

10
6
6
6
6
6
6
6
6
6
6
Output data
1

Roll the dice 10 times, all 10 rolls produce the number 6. Because the difference between the maximum number of rolls (10) and the minimum number of rolls (0) is strictly greater than 10% of the total number of rolls (10% of 10 is 1), we conclude that the dice are oiled.

Input data
10
1
4
2
5
4
6
2
1
3
3
Output data
0

Throw the dice 10 times and get: 1 twice, 2 twice, 3 twice, 4 twice, 5 and 6 at a time. Because the difference between the maximum number of appearances (two) and the minimum number of occurrences (one) is less than or equal to 10% of the total number of throws (10% of 10 is 1), we conclude that the dice are not deceived.

Answers

Answer:

f0ll0w me on insta gram Id:Anshi threddy_06 (no gap between I and t)

Linda wants to change the color of the SmartArt that she has used in her spreadsheet. To do so, she clicks on the shape in the SmartArt graphic. She then clicks on the arrow next to Shape Fill under Drawing Tools, on the Format tab, in the Shape Styles group. Linda then selects an option from the menu that appears, and under the Colors Dialog box and Standard, she chooses the color she wants the SmartArt to be and clicks OK. What can the option that she selected from the menu under Shape Fill be

Answers

Answer: Theme colors

Explanation:

Based on the directions, Linda most probably went to the "Theme colors" option as shown in the attachment below. Theme colors enables one to change the color of their smart shape.

It is located in the "Format tab" which is under "Drawing tools" in the more recent Excel versions. Under the format tab it is located in the Shape Styles group as shown below.

What is the function of the NOS? Select all that apply.

•network management
•connects network nodes
•network security
•provides MACs
•gives access to privileges
•data protection

Answers

Answer:

.network management

Explanation:

pls need brainliest

Answer:

gives access privileges

network management

network security

data protection

Explanation:

4. Write a program to calculate square root and
cube root of an entered number .​

Answers

Answer:

DECLARE SUB SQUARE (N)

CLS

INPUT “ENTER ANY NUMBER”; N

CALL SQUARE(N)

END

SUB SQUARE (N)

S = N ^ 2

PRINT “SQUARE OF NUMBER “; S

END SUB

Select the correct term to complete the sentence.
The
file format is used for video files.

A. .pptx

B. .mp3

C. .jpeg

D. .mp4

Answers

Answer: D. mp4

its mp4 because its always on video files

Other Questions
Can anyone recommend some good books for someone who likes Harry Potter? Which of the following statements regarding Germany under Hitler is true? * The Nazis controlled the government but had little influence on other German institutions. The Nazis kept firm control over Germany but followed moderate and tolerant policies.The Nazis sent Jewish people to internment camps.Most Germans were barely affected by Nazism. The Nazis controlled all aspects of German life. The diagram shows variations of Galpagos Island finches that formed over many generations.What most likely caused the variations in these finches?A the temperatures on the islandsB the available food on the islandsC the available water on the islandsD the number of mates on the islands When do populations increase and when do they decrease? The world continues to increase till this day. Cite trs exemplos de fronteiras artificiais. A cylinder is filled with 10.0 L of gas and a piston is put into it. The initial pressure of the gas is measured to be 273. kPa.The piston is now pulled up, expanding the gas, until the gas has a final volume of 50.0 L. Calculate the final pressure of the gas. Be sure your answer has thecorrect number of significant digits. Answer pleasseee, and explain how you got it. please help me pleaseeee The Persistent GardenerIt was Jilly's last day in the green house. Summer was coming to an end and so was the growing season. School would be starting next week and the fall plants were well enough along to allow Mrs. T. to manage the greenhouses herself. As Jilly worked the plants for the last time, she tried to focus on the new school year instead of the details of the greenhouse. It had been a hard, hot summer, but Jilly was not ready for it to be over.Jilly moved down the tables, tucking a stray hair behind her ear with a gloved and already dirty hand. She'd repotted the last of the rosemary plants and mixed a new batch of potting soil already. Mrs. T. now had enough potting soil to last her through September. Jilly looked at a couple of maiden-hair ferns that were beginning to yellow in their small pots. She loved their lacey fronds and had grown concerned over the last few days that they needed repotting or a boost of fertilizer. She had also worried that she would continue to find chores that needed doing, plants that needed help, right up until the minute she left today. She hated unfinished things. She hated details not being tended to.The sun had been above the trees and blasting the greenhouse for a good hour now. Jilly listened for the familiar whirr of the automatic vents opening. When the greenhouse reached a certain temperature, the vents would open automatically. The vents would have a cooling effect for an hour or so, and then no amount of breeze would put a dent in the heat. Mrs. T. often claimed Jilly must be part reptile as she was able to work longer in the greenhouse than anyone else. The heat just didn't bother her. In fact, Jilly often looked forward to the warmth of the greenhouse and feeling the heat seep into her bones. It felt good to her, but she understood others who found it hard to breathe in 100 degree temperatures.Jilly heard the greenhouse door bang, and looked up from her ferns to see Mrs. T. walking down the aisle with a tray of young plants. Mums, Jilly supposed, the flowers everyone wants for fall. She had helped Mrs. T. take cuttings and plant the small stems in new pots. They were doing nicely from the look of things."We will keep these in here for now," said Mrs. T. "They are getting too much rain outside."It had been a rainy couple of days. Jilly knew, as well as anyone, that overwatering could kill potted plants quickly."Do you remember when I overwatered those mint plants?" Jilly asked Mrs. T."I used to think no one could kill a mint plant," Mrs. T. said, laughing."Well I am full of surprises, apparently," Jilly replied. Jilly remembered the sad green plants that just kept looking more and more wilted no matter how much water she gave them. It was a beginner's mistake, and Jilly had been so embarrassed for making it."That you are," replied Mrs. T. "But I know you learned a lesson you won't ever forget.""Of course. Herbs like their roots damp, not flooded," Jilly answered."Well that is not the lesson I was thinking of," Mrs. T. said.Jilly wondered for a minute what the lesson could be. She straightened the rows of geraniums in front of her, picking up one or two to check for aphids under the leaves. It had been a summer full of lessons, some especially hard for a girl who thought she knew a lot about plants. She breathed deeply the warm, humid air. She hated the cooped up feeling of air conditioned air, the feeling of being cut off from the sun. She knew school and the library would offer only these uncomfortable feelings and little time to spend in the sun or with plants. She had come to understand this over the summerher need to be around growing things was huge."I'm not sure, Mrs. T." she said, "I've learned so much this summer. I couldn't possibly say what you are thinking.""You did learn many lessons, Jilly. You knew so much when you started. You've gone farther than any other assistants I've had. I will miss you.""And I will miss you," Jilly replied. "Thank you for the opportunity and the job." Jilly watched Mrs. T. put the tray of mums down on the center row of tables. Wearing her familiar brown apron, Mrs. T. looked just as she had on Jilly's first day."My pleasure, of course, dear," Mrs. T. replied. "My hope for you, as for all my assistants over the years, is that you will learn as much about yourself as you do about growing plants."Recalling her thoughts all morning, about what she enjoyed about her summer job, Jilly realized she knew much more than just how to not drown the mint.Which line from the text best explains the lesson Jilly has learned over the summer? Jilly had been so embarrassed for making it. She straightened the rows of geraniums in front of her. Her need to be around growing things was huge. She loved their lacey fronds. Last one, omg so ready to be done with school. how does Zora Neale Hurston's attempt to reflect and attempt to move away from the ideas of the Harlem Renaissance? One advantage of using dialogue in a narrative essay is tohighlight the essay's topic.define the essay's purpose.show who the essay's characters are.determine the essay's point of view.Mark this and retumSave and ExitNex Please help I'm failing PLEASE HELP ILL DO ANYTHINGDescribe a time when you made a meaningful contribution to others in whichthe greater good was your focus. Discuss the challenges and rewards ofmaking your contribution. 3-5 paragraphs Brief Exercise 24-01 Wildhorse Company uses both standards and budgets. For the year, estimated production of Product X is 565,000 units. Total estimated cost for materials and labor are $1,243,000 and $1,638,500. Compute the estimates for (a) a standard cost and (b) a budgeted cost. The diagram above represents the rock cycle. According to this diagram, metamorphic rock is formed by Which of the following requirements had to be met before a state could be formed in the Northwest Territory? A. The government decided to declare a specific part of the territory a state. B. A religious group claimed land for its own in order to start a religious community. C. One of the original 13 states claimed a section of the territory for its own. D. Sixty thousand people or more lived in the area.The correct answer pls Which equation represents the word sentence shown below?The quotient of a number band 0.3 equals negative 10. I didnt mean to pick b lol (also pls dont give me a link, they dont work) A class has 12 boys and 16 girls. The teacher needs to pick two volunteers. What is the probability that she chooses a girl given that she chose a boy first? All answers should be given as a fraction in simplest form!Any help is appreciated!