Python Forum
Pairs of multiplied prime number--->N
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pairs of multiplied prime number--->N
#14
(Jan-16-2022, 11:33 AM)ibreeden Wrote: Hi @Frankduc ,
I am glad you got your program running. But if you don't mind I have two warnings.
First: you named a variable list. But this name is a built-in! Do not use build-ins as a name of a variable because it will hide this built-in! This practice can cause errors that are difficult to understand!
Second: for making the program clear and understandable: choose the names of your variables carefully. See how Deanhystad chose the names "primes" and "not_primes". It makes very clear what they are used for and will help you when you have to maintain the program. In your version you will later have a hard time to understand what the function does when the function returns "list" instead of "prime_list".

I did not know about list obviously, i will keep that in mine. I think also it is clear i have started this code by copying others not working code and try fitting parts of it to make something new. I did not bother using new names. I should be more carefull about that. I am wasting to much time searching answers in others code on the net when i should just trusting myself and be more consistant.

I thought in the first def function by returning prime_eratosthenes(lim) at the end of function it was automatically sending the prime numbers to the other def printPairs(lim): by doing primes = prime_eratosthenes(lim). Strange!

Thank you to both of you.
Now i will try to list all combinations possible as an exercise.
Reply


Messages In This Thread
Pairs of multiplied prime number--->N - by Frankduc - Jan-14-2022, 07:22 PM
RE: Pairs of multiplied prime number--->N - by Frankduc - Jan-16-2022, 01:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Improve Prime Pairs Code jzakiya 7 1,566 Mar-09-2025, 08:19 PM
Last Post: jzakiya
Star Pairs Trading Simulation Kiitoos 2 1,930 Aug-21-2024, 09:43 AM
Last Post: Larz60+
  Prime number detector Mark17 5 2,269 Nov-27-2023, 12:53 PM
Last Post: deanhystad
  Sample random, unique string pairs from a list without repetitions walterwhite 1 1,909 Nov-19-2023, 10:07 PM
Last Post: deanhystad
  Extracting unique pairs from a data set based on another value rybina 2 3,052 Feb-12-2021, 08:36 AM
Last Post: rybina
  Is 2 a prime number? for loop & range fuction in python docs says yes, mine says no. allusernametaken 4 3,978 Nov-17-2019, 02:56 AM
Last Post: allusernametaken
  check if the number is a prime integer atlass218 5 4,077 Sep-26-2019, 07:58 AM
Last Post: atlass218
  Key value pairs assistance UtiliseIT 2 3,595 May-09-2019, 09:26 AM
Last Post: UtiliseIT
  Creating a program to look for the largest prime number of a number Wikki14 4 4,905 Sep-08-2018, 12:30 AM
Last Post: Skaperen
  Create random pairs Dennisp44 3 10,371 Jun-02-2018, 05:51 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020