John L.

asked • 11/06/23

Python problem Help ASAP Due today 11:00pm

Please avoid using any adcance coding like return, string(), and the f at the bottom to


PLease help me modify this problem of mine to match the output:

Been stuck on this for the past three days already.


print('This program creates a new integer from the entered integer.')

integer = int(input('Enter the number of integers you want to enter: '))


print('')

rule_a_count = 0

rule_b_count = 0

rule_c_count = 0


for i in range(1, integer + 1):

print(f'input #{i}')

positive = input('Enter a positive integer: ')

if not positive.isdigit():

print('The integer cannot be generated!')

continue

positive_int = int(positive)

if positive_int <= 0:

print('The integer cannot be generated!')

elif positive_int < 10:

new_int = positive_int ** 2

rule_a_count += 1

print(f'The created integer is {new_int} (Rule A)')

elif len(positive) % 2 == 0:

first_half = int(positive[:len(positive) // 2])

second_half = int(positive[len(positive) // 2:])

new_int = first_half + second_half

rule_b_count += 1

print(f'The created integer is {new_int} ({first_half} + {second_half}) (Rule B)')

else:

first_half = int(positive[:len(positive) // 2])

middle_digit = int(positive[len(positive) // 2])

second_half = int(positive[len(positive) // 2 + 1:])

new_int = first_half + middle_digit + second_half

rule_c_count += 1

print(f'The created integer is {new_int} ({first_half} + {middle_digit} + {second_half}) (Rule C)')


print(

print(f'\nThe rule use:\nRule A - {rule_a_count} times\nRule B - {rule_b_count} times\nRule C - {rule_c_count} times.')




Here is the output of what it is supposed to look like:

This program creates a new integer from the entered integer.

Enter the number of integers you want to enter: 5


input # 1

Enter a positive integer: 152

The created integer is 8 1 + 5 + 2 = 8


input # 2

Emter a positive integer: 4

The created integer is 16 because 4^2= 16


input # 3

Emter a positive integer: yes

The integer cannot be generated!


input # 4

Enter a positive integer: 1555555

The created integer is 715 because 155 + 5 + 555 =715


input # 5

Enter a positive integer: 2589

The created integer is 114 because 25 +89 = 114


The rule use:

Rule A- 1 times: rule B- 1 times, rule C- 2 times.


1 Expert Answer

By:

WILLIAMS W. answered • 11/06/23

Tutor
0 (0)

Experienced tutor passionate about fostering success.

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.