Question
4.1. [Python] Write a Python function is prime() to check whether an input value is a prime. That is, if the input p is
4.1. [Python] Write a Python function is prime() to check whether an input value is a prime. That is, if the input p is a prime number, then the function outputs 1. Otherwise, outputs 0. (@4%) 4.2. [Python] Please complete the following function, it factorizes the input n: (@6%) def factorization (n): if return n else: for j in range (2, int (math.sqrt(n)) +1, 1): if n % j 0: return Example 1: print (factorization (10)) The output is: 2 5 Example 2: print (factorization (66)) The output is: 2 3 11 Example 3: print (factorization (103)) The output is: 103
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get StartedRecommended Textbook for
Income Tax Fundamentals 2013
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
31st Edition
1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516
Students also viewed these Programming questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App