Skip to main content
added 260 characters in body
Source Link
toolic
  • 16.4k
  • 6
  • 29
  • 221

any other feedback is welcome too

Here are some general coding style recommendations.

Documentation

The PEP 8 style guide recommends adding a docstring at the top of the code to describe its purpose.

"""
The purpose of this code is to find the smallest semiprime s=ab
satisfying a bunch of conditions. The conditions are:

list of conditions here

"""

Comments

There are a lot of helpful comments in the code.

It would also be helpful to add a comment explaining why you chose the number 17:

b = 17

If the code can be run with other values, it would be a good idead to take input from the user.

Simpler

Large integers are easier to read using underscores. Change:

140000000000

to:

140_000_000_000

Scientific notation works too.

This line:

print('found {} = {} * {}'.format(s, a, b))

is simpler using an f-string:

print(f'found {s} = {a} * {b}')

Since these values are large integers (like 137800963117), and they can be hard to read, you could format the output using commas:

print(f'found {s:,} = {a:,} * {b:,}')

This would print:

found 137,800,963,117 = 42,299 * 3,257,783

Layout

The indentation is great and consistent.

It would be nice to have a few blank lines added, especially after the while loop.

any other feedback is welcome too

Here are some general coding style recommendations.

Documentation

The PEP 8 style guide recommends adding a docstring at the top of the code to describe its purpose.

"""
The purpose of this code is to find the smallest semiprime s=ab
satisfying a bunch of conditions. The conditions are:

list of conditions here

"""

Comments

There are a lot of helpful comments in the code.

It would also be helpful to add a comment explaining why you chose the number 17:

b = 17

If the code can be run with other values, it would be a good idead to take input from the user.

Simpler

Large integers are easier to read using underscores. Change:

140000000000

to:

140_000_000_000

Scientific notation works too.

This line:

print('found {} = {} * {}'.format(s, a, b))

is simpler using an f-string:

print(f'found {s} = {a} * {b}')

Layout

The indentation is great and consistent.

It would be nice to have a few blank lines added, especially after the while loop.

any other feedback is welcome too

Here are some general coding style recommendations.

Documentation

The PEP 8 style guide recommends adding a docstring at the top of the code to describe its purpose.

"""
The purpose of this code is to find the smallest semiprime s=ab
satisfying a bunch of conditions. The conditions are:

list of conditions here

"""

Comments

There are a lot of helpful comments in the code.

It would also be helpful to add a comment explaining why you chose the number 17:

b = 17

If the code can be run with other values, it would be a good idead to take input from the user.

Simpler

Large integers are easier to read using underscores. Change:

140000000000

to:

140_000_000_000

Scientific notation works too.

This line:

print('found {} = {} * {}'.format(s, a, b))

is simpler using an f-string:

print(f'found {s} = {a} * {b}')

Since these values are large integers (like 137800963117), and they can be hard to read, you could format the output using commas:

print(f'found {s:,} = {a:,} * {b:,}')

This would print:

found 137,800,963,117 = 42,299 * 3,257,783

Layout

The indentation is great and consistent.

It would be nice to have a few blank lines added, especially after the while loop.

Source Link
toolic
  • 16.4k
  • 6
  • 29
  • 221

any other feedback is welcome too

Here are some general coding style recommendations.

Documentation

The PEP 8 style guide recommends adding a docstring at the top of the code to describe its purpose.

"""
The purpose of this code is to find the smallest semiprime s=ab
satisfying a bunch of conditions. The conditions are:

list of conditions here

"""

Comments

There are a lot of helpful comments in the code.

It would also be helpful to add a comment explaining why you chose the number 17:

b = 17

If the code can be run with other values, it would be a good idead to take input from the user.

Simpler

Large integers are easier to read using underscores. Change:

140000000000

to:

140_000_000_000

Scientific notation works too.

This line:

print('found {} = {} * {}'.format(s, a, b))

is simpler using an f-string:

print(f'found {s} = {a} * {b}')

Layout

The indentation is great and consistent.

It would be nice to have a few blank lines added, especially after the while loop.