Помогите решить,пайтон | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 2

Помогите решить,пайтон

Помогите решить:даны три целых положительных числа.Если все они четные,каждое число уменьшить в два раза,если хотя бы одно из них четное, увеличить каждое число на 20%,если чётных чисел нет,оставить без изменения

20th Oct 2018, 6:55 PM
Elaqwe
Elaqwe - avatar
30 ответов
+ 2
Nice job putting the code together!
20th Oct 2018, 10:10 PM
John Wells
John Wells - avatar
+ 2
You could do: a+=a*0.2 and a/=2 I happen to like this syntax. Initially, compilers generated better code this way. But, with today's optimizations there is no difference so it is more programmer preference.
20th Oct 2018, 10:17 PM
John Wells
John Wells - avatar
+ 2
sure, what did you submit as your input at the prompt?
20th Oct 2018, 11:14 PM
John Wells
John Wells - avatar
+ 1
Thank you, but you could not explain more in detail the last step
20th Oct 2018, 9:21 PM
Elaqwe
Elaqwe - avatar
+ 1
Thank you again, I will work on
20th Oct 2018, 9:34 PM
Elaqwe
Elaqwe - avatar
+ 1
a= int(input('a= ')) b= int(input('b= ')) c= int(input('c= ')) print('a =',a ,'b =', b,'c= ',c) if a % 2 ==0 and b % 2==0 and c % 2==0: a=a/2 b=b/2 c=c/2 if a % 2 ==0 or b % 2==0 or c % 2==0: a=a+(a*0.2) b=b+(b*0.2) c=c+(c*0.2) print(a),print(b),print(c) I did it, but through elif does not go
20th Oct 2018, 9:57 PM
Elaqwe
Elaqwe - avatar
20th Oct 2018, 10:09 PM
John Wells
John Wells - avatar
+ 1
Which last step? Your code is almost perfect. With the elif I added in my version, it is perfect. Your code would do both updates when a started as 4.
20th Oct 2018, 10:28 PM
John Wells
John Wells - avatar
+ 1
It is coded. If the numbers are all odd, you print them without any changes.
20th Oct 2018, 10:33 PM
John Wells
John Wells - avatar
+ 1
I'm sorry to bother you, I'm just a newbie in this business, what else is missing in or code?
20th Oct 2018, 10:44 PM
Elaqwe
Elaqwe - avatar
+ 1
Assuming you use mine, it is perfect for your description. If I coded it, I'd change the input to allow 3 numbers on the first input line. But, it isn't required and isn't a simple change.
20th Oct 2018, 10:49 PM
John Wells
John Wells - avatar
+ 1
You entered a non number character as a value. The entire line is read as a string and every character is processed to make the integer for a. Any non 0 to 9 plus + or - character will cause that exception.
20th Oct 2018, 10:56 PM
John Wells
John Wells - avatar
+ 1
thank you very much I will contact you
20th Oct 2018, 11:33 PM
Elaqwe
Elaqwe - avatar
+ 1
I realized
20th Oct 2018, 11:34 PM
Elaqwe
Elaqwe - avatar
+ 1
Sound complicated so where do you think you should start?
22nd Oct 2018, 5:33 PM
John Wells
John Wells - avatar
+ 1
I have a task to do on Thursday, can you create a plan for the task?
23rd Oct 2018, 1:04 PM
Elaqwe
Elaqwe - avatar
+ 1
You likely want 4 functions. The 3 listed in my previous post and the one that gets passed the looping input data from the top level function and performs the loop calling the bottom two functions. I like passing fixed data into the functions as I test them so I can prove they work before reading the user data. Therefore, I'd code the get y for a given x, a, & b function first. Next, code the plot of y function. Followed by, code the looping function. Finishing with, read the user data function to get it all to work nicely together.
23rd Oct 2018, 2:51 PM
John Wells
John Wells - avatar
+ 1
I have now done the tabulation of a piecewise continuous function. In accordance with the type of function shown in Table 2, calculate the values functions y = f (x) for the values ​​of the argument x, varying in the interval from xstart to xc with step ∆x. Determine the number of the formula for which the value was calculated functions. The initial data for debugging the program (xnach, xkon, ∆x) to choose independently so that the function values ​​are calculated at all three intervals and points branching. Plot the function y = f (x). y {ln (x ** 2) if x more10 y {math.sqrt (math.pow (math.fabs (cosx), 1/3) y {y = 6 you can only write a plan of my actions
29th Oct 2018, 4:19 PM
Elaqwe
Elaqwe - avatar
0
You can test to see if a number is even with n%2 == 0. The following if can split out when you must process the numbers. if firstEven and secondEven and thirdEven: # divide the numbers elif firstEven or secondEven or thirdEven: # increase them by 20% #else they don't change
20th Oct 2018, 9:01 PM
John Wells
John Wells - avatar
0
I could easily give more detail. But, you need to do some of the work or why waste your time learning programming. Code your best guess at it. If it doesn't work, post it here for more help.
20th Oct 2018, 9:25 PM
John Wells
John Wells - avatar