What's new

Python Para sa pyhton programmer help naman

Migzjr025

Enthusiast
Joined
Dec 8, 2020
Posts
3
Reaction
0
Points
32
The first input is any series of random 9 arithmetic operators.

Then input 10 numbers separated by “;”

Then perform the computation.

Not allowed to use the loop and conditional statements, just simple function, string, and arithmetic operators.

Assuming that the first input is strictly 9 arithmetic operators;

The second input is strictly 10 values separated by “;” ; and

The result should be in the same format as in the sample output.

image.png
 

Attachments

Python:
# operators = '+/*%-++/-'
# numbers = '1;2;3;4;5;6;7;8;9;10'

operators = input('Enter 9 random arithmetic op: ')
numbers = input('Enter 10 values separated by semicolon (;): ')

zipped = zip(numbers.split(';'), list(operators + ' '))

result = ''.join([num for op in zipped for num in op])

print(f'\nThe result of {result} is: {eval(result)}')

OUTPUT:
The result of 1+2/3*4%5-6+7+8/9-10  is: -4.444444444444445

ps. sakto wala akong ginagawa kaya sinagot ko nalang haha pero next time lagay karin ng input mo kahit may error
 
Last edited:
Python:
# operators = '+/*%-++/-'
# numbers = '1;2;3;4;5;6;7;8;9;10'

operators = input('Enter 9 random arithmetic op: ')
numbers = input('Enter 10 values separated by semicolon (;): ')

zipped = zip(numbers.split(';'), list(operators + ' '))

result = ''.join([num for op in zipped for num in op])

print(f'\nThe result of {result} is: {eval(result)}')

OUTPUT:
The result of 1+2/3*4%5-6+7+8/9-10  is: -4.444444444444445

ps. sakto wala akong ginagawa kaya sinagot ko nalang haha pero next time lagay karin ng input mo kahit may error
grabe naman yung syntax mo subrang concise
i mean yung beauty ni python 😅 (yung one liner)


parang mahirap sa beginner😂
 
grabe naman yung syntax mo subrang concise
i mean yung beauty ni python 😅 (yung one liner)


parang mahirap sa beginner😂
Haha yan lang nasa isip kong magawa boss eh.
Bawal daw kasi for loop and conditional statement =D
Explain ko nalang sa kanya if maguguluhan siya
 

Similar threads

Back
Top