subject
Computers and Technology, 07.06.2021 01:00 pmdm95

Import Math Def Isprime X N 2 N 3 Return True N 2 N 2 0 Return False N 9 Return True N 3 0 Q36682051 . . . import mathdef is_prime(x):if n == 2 or n == 3:return Trueif n < 2 or n % 2 == 0:return Falseif n < 9:return Trueif n % 3 == 0:return Falser = int(n**0.5)f = 5while f <= r:print ('t',f)if n % f == 0:return Falseif n % (f + 2) == 0:return Falsef +=6return True n = int(input('Enter an integer:n'))print (is_prime(n))
I got a few questions about this code. What's the use for theline of code that says if n < 9 return True?
Lastly, I'm not sure what's going on in this part of the code. The part where n has a power of 0.5 and f = 5 are more confusing. If anyone could help, I'd appreciate it. Thank you!
r = int(n**0.5)f = 5while f <= r:print ('t',f)if n % f == 0:return Falseif n % (f + 2) == 0:return Falsef +=6return True

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 07:20, Hcalhoun21
Write a pseudocode solution for each of these problems. 1. design a while loop that lets that user enter a number. the number should be multiplied by 10, and the result stored in a variable named product. the loop should iterate as long as product contains a value less than 100. 2. design a do-while loop that asks the user to enter two numbers. the numbers should be added and the sum displayed. the loop should ask the user whether he or she wishes to perform the operation again. if so, the loop should repeat; otherwise it should terminate. 3. design a for loop that displays the following set of numbers: 0, 10, 20, 30, 40, 50 100. 4. design a nested loop that displays 10 rows of # characters. there should be 15 # characters in each row. 5. convert this for loop to a while loop. declare integer count for count = 1 to 50 display count end for 6. find the error in the following pseudocode. declare boolean finished = false declare integer value, cube while not finished display “enter a value to be cubed.” input value; set cube = value ^ 3 display value, “ cubed is “, cube end while
Answers: 2
image
Computers and Technology, 23.06.2019 01:40, littlebirdd987
You have a linux system that has a 1000gb hard disk drive, which has a 90gb partition containing an ext4 filesystem mounted to the / directory and a 4gb swap partition. currently, this linux system is only used by a few users for storing small files; however, the department manager wants to upgrade this system and use it to run a database application that will be used by 100 users. the database application and the associated data will take up over 200gb of hard disk space. in addition, these 100 users will store their personal files on the hard disk of the system. each user must have a maximum of 5gb of storage space. the department manager has made it very clear that this system must not exhibit any downtime as a result of hard disk errors. how much hard disk space will you require, and what partitions would you need to ensure that the system will perform as needed? where would these partitions be mounted? what quotas would you implement? what commands would you need to run and what entries to /etc/fstab would you need to create? justify your answers.
Answers: 3
image
Computers and Technology, 23.06.2019 09:30, gabby640
Name the range function that would generate the following list of integers values: 0,1,2,3,4,5.
Answers: 1
image
Computers and Technology, 24.06.2019 01:30, tanya44737
Hazel has just finished adding pictures to her holiday newsletter. she decides to crop an image. what is cropping an image?
Answers: 1
You know the right answer?
Import Math Def Isprime X N 2 N 3 Return True N 2 N 2 0 Return False N 9 Return True N 3 0 Q36682051...

Questions in other subjects:

Konu
Arts, 20.09.2020 01:01
Konu
Mathematics, 20.09.2020 01:01
Konu
History, 20.09.2020 01:01
Konu
Mathematics, 20.09.2020 01:01