+ 7

How to write a program that calculates this? (1-0.5+0.33-0.25.....)

https://code.sololearn.com/c1GVz8X4tTPc/?ref=app

25th Nov 2019, 7:42 AM
Parisafarivash
19 Answers
+ 8
Your attempt ?? Just try yourself first. If you fail, then just share your code with us(sololearn community) and we will tell where is the problem and how to overcome it so that you become better at it👍
25th Nov 2019, 7:49 AM
Arsenic
Arsenic - avatar
+ 4
Arsenic i added now😶
25th Nov 2019, 8:09 AM
Parisafarivash
+ 4
Kit D. Cat i got it..thank you😊
25th Nov 2019, 8:39 AM
Parisafarivash
+ 4
Sunny your question seems separate from this thread.
26th Nov 2019, 6:34 AM
Sonic
Sonic - avatar
+ 3
print(eval("1-0.5+0.33-0.25"))
25th Nov 2019, 12:21 PM
Yuval Rosen
Yuval Rosen - avatar
+ 3
You could need % operator.
27th Nov 2019, 7:41 AM
Seb TheS
Seb TheS - avatar
+ 1
To answer Sunny even if it is another thread : maybe make the print as a string like this : ("I am in", love) ? as well as "happiness". But I'm new to coding, so I might be wrong. And sorry for my bad English.
26th Nov 2019, 3:29 PM
Morgane Zabzab
+ 1
recursive function: def addition(n,x=1,y=0.5): return x-y if n==0 else x-y+addition(n-1,x*0.33,y/2)
26th Nov 2019, 5:42 PM
Mohammad Gk
Mohammad Gk - avatar
+ 1
Mohammad Gk باشه فهمیدم.. میشه سوال جدیدمو نگاه کنید☹؟
26th Nov 2019, 7:58 PM
Parisafarivash
0
so why does love=happiness print( I am in love ) gives me error?
25th Nov 2019, 11:05 PM
Sunny
0
Hi
26th Nov 2019, 5:03 PM
Ekpereka Paulinus
Ekpereka Paulinus - avatar
0
راستی وقتی میخوای از تابع استفاده کنی فقط یک مقدار بهش بده ینی مقدار n. مثل addition(1). البته میتونی مقدار های دلخواه هم برای x یا y هم به عنوان آرگومان بهش بده.
26th Nov 2019, 7:52 PM
Mohammad Gk
Mohammad Gk - avatar
0
Sunny i think the right away should be- love = ”Happiness” print(’I am in’+ ’ ’ + love) new to coding: might be wrong open to correction
27th Nov 2019, 6:23 AM
Edem
Edem  - avatar
0
Write the output of the following program on execution of x=50
27th Nov 2019, 4:12 PM
Niharika
0
nc pubg host
27th Nov 2019, 11:40 PM
JESO ROY
JESO ROY - avatar
0
Ckgk
28th Nov 2019, 2:51 AM
Skramjan Ali
Skramjan Ali - avatar
0
Hi
28th Nov 2019, 2:51 AM
Skramjan Ali
Skramjan Ali - avatar
- 1
What sunny says is right
26th Nov 2019, 6:41 AM
Alex Gamer GTA 5
Alex Gamer GTA 5 - avatar
- 1
Write a C program to input any character and check whether it is alphabet, digit or special character
27th Nov 2019, 3:43 AM
Sasikumar Anipireddy
Sasikumar Anipireddy - avatar