+ 7
How to write a program that calculates this? (1-0.5+0.33-0.25.....)
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👍
+ 4
Arsenic i added now😶
+ 4
Kit D. Cat i got it..thank you😊
+ 4
Sunny your question seems separate from this thread.
+ 3
print(eval("1-0.5+0.33-0.25"))
+ 3
You could need % operator.
+ 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.
+ 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)
+ 1
Mohammad Gk باشه فهمیدم..
میشه سوال جدیدمو نگاه کنید☹؟
0
so why does love=happiness
print( I am in love )
gives me error?
0
Hi
0
راستی وقتی میخوای از تابع استفاده کنی فقط یک مقدار بهش بده ینی مقدار n. مثل addition(1). البته میتونی مقدار های دلخواه هم برای x یا y هم به عنوان آرگومان بهش بده.
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
0
Write the output of the following program on execution of x=50
0
nc pubg host
0
Ckgk
0
Hi
- 1
What sunny says is right
- 1
Write a C program to input any character and check whether it is alphabet, digit or special character