+ 2
Помогите решить,пайтон
Помогите решить:даны три целых положительных числа.Если все они четные,каждое число уменьшить в два раза,если хотя бы одно из них четное, увеличить каждое число на 20%,если чётных чисел нет,оставить без изменения
30 Réponses
+ 2
Nice job putting the code together!
+ 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.
+ 2
sure, what did you submit as your input at the prompt?
+ 1
Thank you, but you could not explain more in detail the last step
+ 1
Thank you again, I will work on
+ 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
+ 1
Worked fine for me:
https://code.sololearn.com/cYbaUXmCj8dU
+ 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.
+ 1
It is coded. If the numbers are all odd, you print them without any changes.
+ 1
I'm sorry to bother you, I'm just a newbie in this business, what else is missing in or code?
+ 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.
+ 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.
+ 1
thank you very much I will contact you
+ 1
I realized
+ 1
Sound complicated so where do you think you should start?
+ 1
I have a task to do on Thursday, can you create a plan for the task?
+ 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.
+ 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
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
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.