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
quester [9]
3 years ago
13

Write a program that will take a user-input number and then display all of the whole # factors for that number. For example, if

I typed in 4, your program should display all # of the factors for 4 (1, 2, and 4). Your program should work for any number. # # Hint: What approach would you take if faced with this scenario? What Python operator can # be used to determine whether a number is divisible by another number?
Computers and Technology
1 answer:
klemol [59]3 years ago
4 0

Answer:

The program to this question can be given as:

Program:

Number=int(input("Insert a number :"))   # input a number from

fact=[]               # crate list

for k in range(1,Number+1):              #loop

   if Number%k==0:                      # check number is divisible by k

      fact.append(k)    

print ("Factors of {} = {}".format(Number,fact))   #print value

Output:

Enter a number: 4

Factors of 4= [1,2,4]

Explanation:

In the above python program firstly we declare a variable that is Number in this variable we take user input. To user input, we first convert the value into the integer and the input function is used for input. Then we declare a list that fact =[]. In the python, the list is used for placing all the elements inside a square bracket [ ] all the elements will be separated by commas. Then we use for loop it is used for iterate over a sequence. Then we use the if statement. It is used for check condition. In this statement, the number is divided by k. if the remainder is equal to 0. It will print the value.

You might be interested in
Which of the following is NOT true about variables?
VikaD [51]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The value stored by a variable can be changed after it is assigned(true).

The value of a variable can be changed after it is assigned, for example:

int a=10;

and we can change the value of variable a in letter program such as:

a=15;

Variables are a name for a spot in the computer's memory (true).

it is true, because the variables value stored in the computer's memory and we can access theses values by their name (variable name). so Variables are a name for a spot in the computer's memory.

Variable names can be words: such as temperature or height (true).

Yes, the variable name can be words such as height, width, temperature etc.

The value stored by a variable cannot be changed after it is assigned (false).

It is noted that the value stored by a variable can be changed after it is assigned. However, it is noted that is some programming language, you can't change the value of static variable.

3 0
4 years ago
Write the code to create a variable score and assign it the value 0?​
Galina-37 [17]

Answer:

You can assign a value to a routine variable in any of the following ways:

Use a LET statement.

Use a SELECT INTO statement.

Use a CALL statement with a procedure that has a RETURNING clause.

Use an EXECUTE PROCEDURE INTO or EXECUTE FUNCTION INTO statement.

Explanation:

4 0
3 years ago
Write a program that records high-score data for a fictitious game. the program will ask the user to enter five names, and five
Harman [31]

Scores.cpp

#include <iostream>

#include <string>

using namespace std;

void initializeArrays(string names[], int scores[], int size);

void sortData(string names[], int scores[], int size);

void displayData(const string names[], const int scores[], int size);

int main()

{

   string names[5];

   int scores[5];

   //reading names and scores

   initializeArrays(names, scores, 5);

   //sorting the lists based on score.

   sortData(names, scores, 5);

   //displaying the contents of both arrays

   displayData(names, scores, 5);

 

  return 0;

}

void initializeArrays(string names[], int scores[], int size){

   for(int i=0; i<size; i++){

       cout<<"Enter the name for score #"<<(i+1)<<": ";

       cin >> names[i];

       cout<<"Enter the score for score #"<<(i+1)<<": ";

       cin >> scores[i];

       }

}

void sortData(string names[], int scores[], int size){

   

       int temp = 0;

       string tempStr = "";

       

       for(int i=0; i < size; i++){

               for(int j=1; j < (size-i); j++){

                      //checking max score and sorting based on it.

                       if(scores[j-1]< scores[j]){

                               //swap the elements!

                           //swapping scores

                               temp = scores[j-1];

                               scores[j-1] = scores[j];

                               scores[j]=temp;

                               

                               //swapping names

                               tempStr = names[j-1];

                               names[j-1] = names[j];

                               names[j]=tempStr;

                       }

                       

               }

       }

}

void displayData(const string names[], const int scores[], int size){

   cout<<"Top Scorers:"<<endl;

       //printing the elements up to the size of both arrays.

       for(int i=0; i<size; i++){

           cout<<names[i]<<": "<<scores[i]<<endl;

       }

}

3 0
4 years ago
True False The explicit location always tells you where users are located when they type the query.
gregori [183]
It's true for only some users
7 0
3 years ago
Read 2 more answers
Assume that the variable myString refers to a string. Write a code segment that uses a loop to print the characters of the strin
Svetach [21]

Answer:

hi my name is antonette Jane S pascua please help me my question thank you for your answer

5 0
3 years ago
Other questions:
  • Fundamental types of data, such as strings, integers, and real numbers, are known as
    5·1 answer
  • 4.2 lesson practice helps plzs
    9·1 answer
  • 6) Read the article posted on The Verge entitled How to fight lies, tricks, and chaos online and summarize the four steps. Then
    15·1 answer
  • Technology, by itself is neither good nor bad.<br> A) true<br> B) false
    11·2 answers
  • Which pair of devices have the same input motion and different outputs?
    15·1 answer
  • Free points <br><br><br><br><br> also if u wanna check out my spotlfy u can (xkuromist)
    6·2 answers
  • n (m,n) correlating branch predictor uses the behavior of the most recent m executed branches to choose from 2m predictors, each
    11·1 answer
  • What is shotgun microphone?
    7·1 answer
  • what statement about constructors is false? group of answer choices all constructors are passed a pointer argument constructors
    14·1 answer
  • Passing an argument by ___ means that only a copy of the arguments value is passed into the parameter variable and not the addrt
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!