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
vichka [17]
2 years ago
6

Write a program in python to test if given number is prime or not.

Computers and Technology
2 answers:
Lerok [7]2 years ago
7 0

num = int(input("Enter a number to test if it's prime or not: "))

if num%2 == 0:

   if num == 2:

       print(num,"is prime")

   else:

       print(num,"is not prime")

else:

   count = 0

   for x in range(2,num):

       if num % x == 0:

           count+=1

   if count==0:

       print(num,"is prime")

   else:

       print(num,"is not prime")

I wrote my code in python 3.8. I hope this helps!

Paraphin [41]2 years ago
4 0

Answer:

Answer:

def main():

num = int(input("Input a number to check for prime: "))

if num > 1:

 for i in range(2,num):

  if (num % i) == 0:

   print("%d is not a prime number" % num)

   break

  else:

   print("%d is a prime number" % num)

   break

else:

 print("%d is not a prime number" % num)

 

if __name__ == "__main__":

main()

Explanation:

Solution retrieved from programiz.com.

Note, this program uses the idea of the Sieve of Eratosthenes to validate the input number by using the modulo operator to determine primeness.

The program will output to the user if the number input is indeed prime or not.

Cheers.

Explanation:

You might be interested in
Please explain what Level 5 Automation is and give 2 examples of the technology.
arsen [322]

Level 5 ( Full Driving Automation ) Level 5 cars won't even have steering wheels or acceleration / braking pedals . They will be free from geofencing , able to go anywhere and do anything that an experienced human driver can do .

Pls follow me and Mark as brainlest!!! :-)

8 0
3 years ago
How does Mixed Reality expand on Augmented Reality?
taurus [48]

Mixed Reality expand on Augmented Reality option d: by enabling real-time interaction between real and virtual objects.

<h3>How does mixed reality expand on augmented reality?</h3>

Mixed reality is known to be one that is made up of both augmented reality and that of augmented virtuality.

Note that Mixed reality is one that acts so as to make an environment with interactive kinds of digital objects. Augmented reality needs a screen to be able to experience the augmented experience. Mixed reality is said to be experienced via the a headset.

Hence, Mixed Reality expand on Augmented Reality option d: by enabling real-time interaction between real and virtual objects.

Learn more about Augmented Reality from

brainly.com/question/9054673

#SPJ1

3 0
2 years ago
Save As .csv .html Worksheet tab Format Cells SUM Function Destination cell Home tab AutoFit A. Applies a border or shading to s
stiv31 [10]

Answer and Explanation:

A.) Format Cells

When the format cells in an Excel then, change an appearance of the number without the changing a number itself. Apply the number formats (0.7, $0.70, 70%, etc) or other formatting (alignments, fonts, borders, etc).

1. Enter a value 0.7 into the cell B2.

By default, the Excel use the General formats (no specific numbers format) for the numbers To apply the number format, use a 'Format Cell' dialog box.  

2. Then, Select the cell B2.

3. Then, Right click, then click the Format Cell (or press the shortcut key CTRL + 1).

The 'Format Cell' dialog box will appears.

4. Then, For example, if you want - select Currency.

Note: The Excel give you the life preview of how a number will formatted.

5. After that, Click OK.

The Cell B2 will still contain the number 0.7. Then you only changed an appearance of the number. Most frequently used a formatting command that are available on Home tab.

6. On Home tab, in a Number group, click percentage symbol to apply the Percentage formats.

7. On Home tab, in Alignment group, center a numbers.

8. On Home tab, in Font group, add the outside border and change the fonts color to the blue.

B). Destination cell

Destination area or Destination cell - A range of the cells that is select to hold a summarized data in the consolidations. The destination area or cell can be on same worksheets as source data or on the different worksheets. Worksheet can contains only the one consolidation.

C). Save As

If you want to save workbook with the different name use File then click on Save As dialog box or use a shortcut key (Alt + F2).

Then, Select a folder that you wants to store a workbook in using Save in the drop-down lists.

Then, Enters a new filename in the File name box at bottom.

D.) .html

Extension of the web page workbooks is .html.

E). SUM

The SUM function is the built in function in the excel which is used to add all the numbers in the range of the cells and returns its result.

F). Home Tab

A clipboard group is on far left side of a Home Tab. It is an often used in the conjunctions with Editing group, which is on far right side of the tab.

G.) .csv

CSV stands for Comma Separated Value.

CSV is the simple file format that is used to store a tabular datas, such as the spreadsheet or the database. A File in the CSV formats can be imported and exported from the programs that stores data in the tables, such as the Microsoft Excel or the OpenOffice Calc.

H). Worksheet tab

.

To Show the Sheet tabs settings is turned off.

Firstly, ensure that Show Sheet tab is enabled or not.

To do, all the other Excel version, click the File >then Options >then Advanced, in the under Display option for the workbook, then ensures that there is the check in a Show sheet tabs box.

I). AutoFit

J). Sum, Product, Power, Sqrt, Quotient, Mod and many others.

There are 300+ formulas in Excel.

5 0
3 years ago
Int [] val = { 3, 10, 44 };
irina1246 [14]

Answer:

5) 3 0 0

Explanation:

Given data

int [] val = { 3, 10, 44 };

The total number of parameters of given array are 3, so total length of array is also 3.

The indexing of array starts with '0', Therefore the indexes of array with length zero are: {0,1,2}

The value of array at index 0 is = 3

similarly

value at index 1 = 10

value at index 2 = 44

Here, Int i = 1 is storing the value '1' in integer variable i.

In addition to that, any value of index 'i' of an array is selected using array[i].

Therefore,

val[i] = i-1 is copying the value (i-1 = 1-1 = 0) to the index '1'  of the array because i = 1.

So value at index 1 would be = val[1] = 0

The term i++ is incrementing the value of i, it makes i =2

val[i] = i-1 is copying the value (i-1 = 1-1 = 0) to the index '2' of the array because i = 2 now.

So value at index 2 would be = val[2] = 0

Hence, the output would be {3 0 0}. So 5th option is correct.

4 0
3 years ago
Attacking systems by exploiting otherwise unknown and unpatched vulnerabilities is also known as:
Nostrana [21]

Answer:

Zero-day exploits

Explanation:

Zero-day exploits refers to recently found vulnerabilities in a computer software program that has been in existence but was hitherto not known and addressed by the software security experts, however, these vulnerabilities were known to hackers. While the existence of these "loop-holes" in the software can go on unnoticed for several years, hackers can take advantage of it to cause harm to the computers' programs and data.

When these attacks occur, it is called a zero-day because the attack took place on the very day that the loop-hole was discovered in the software. So exploitation has already taken place before a fix is carried out.

5 0
3 years ago
Other questions:
  • An ipv4 address in the range 169.254.0.1 through 169.254.255.254 indicates a problem with what type of service
    10·1 answer
  • ________ are used in input, processing, and output operations that can help create more efficient programs as the data can be pr
    11·1 answer
  • A column letter above the grid, also called the ____, identifies each column.
    9·1 answer
  • I am trying to write a c++ program like the game typeracer. When the player starts the program he will be asked to write a sente
    5·1 answer
  • Some numbers are formed with closed paths. the digits 0, 4, 6 and 9 each have 1 closed path and 8 has 2. None of the other numbe
    6·1 answer
  • Huffman trees use the _________ of each character to work out their encoding. A) Frequency B) Order in ASCll
    12·1 answer
  • WHY IS BRAINLY NOTIFICATIONS LIKE THIS?????
    15·2 answers
  • CMS is a content management system that collects, organization, publishes, and manages creative content. Right...?
    9·1 answer
  • (9.10 Code Practice: Question 1)
    12·1 answer
  • Does anybody have the answer for 2.19.6 checkerboard for codehs??
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!