A beginner has tried to write a Python function which takes as input an integer N and returns a list of all integers from 1 to N which are not divisible by 7 and are not perfect cubes. def Perfect Square (N) : for i in range (N): if not i % 7 = 0: print (i) if not i** (1/3) = int(i** (1/3)): print (i) How would you improve this code? (Comment on problems with this function, do not include your own function in your answer.)

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 8SA
icon
Related questions
Question
A beginner has tried to write a Python function which takes as input an integer N and returns a
list of all integers from 1 to N which are not divisible by 7 and are not perfect cubes.
def PerfectSquare (N):
for i in range (N):
if not i % 7 = 0:
print (i)
if not i** (1/3)
print (i)
=
int(i** (1/3)):
How would you improve this code? (Comment on problems with this function, do not include
your own function in your answer.)
Transcribed Image Text:A beginner has tried to write a Python function which takes as input an integer N and returns a list of all integers from 1 to N which are not divisible by 7 and are not perfect cubes. def PerfectSquare (N): for i in range (N): if not i % 7 = 0: print (i) if not i** (1/3) print (i) = int(i** (1/3)): How would you improve this code? (Comment on problems with this function, do not include your own function in your answer.)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning