🔒 Closed Para sa pyhton programmer help naman

Status
Not open for further replies.

Migzjr025

Leecher
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.webp
 
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
 
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
 
Status
Not open for further replies.

About this Thread

  • 7
    Replies
  • 1K
    Views
  • 5
    Participants
Last reply from:
arj21

Trending Topics

Online now

Members online
1,166
Guests online
2,645
Total visitors
3,811

Forum statistics

Threads
2,293,150
Posts
29,081,945
Members
1,208,682
Latest member
CB_PredDy
Back
Top