Post History
Python 3, 167 127 118 117 94 63 bytes def f(a,b): y=0 for z in range(len(a)):y+=a[z]*b**z print(y) Try it online! Close gap to @user's lambda answer! Golfed 40 bytes thanks to @user's...
Answer
#7: Post edited
# [Python 3], <s>167</s> <s>127</s> <s>118</s> <s>117</s> 94 bytes- <!-- language-all: lang-python -->
<pre><code>x=float(input());y,z=0,0while 1:	try:a=float(input())	except:break	y+=a*x**z;z+=1print(y)- </code></pre>
[Try it online!][TIO-ksrd0p54]- Golfed 40 bytes thanks to [**@user**](https://codegolf.codidact.com/users/53837)'s [advice](https://codegolf.codidact.com/comments/thread/4089#comment-12772). Golfed another 9 bytes thanks to [**@user**](https://codegolf.codidact.com/users/53837)'s [advice](https://codegolf.codidact.com/comments/thread/4089#comment-12782).
- [Python 3]: https://docs.python.org/3/
[TIO-ksrd0p54]: https://tio.run/##XcqxDsIgEADQmfsKR6BNA1YXGj7mNJgSG0rIGTl@Hpkd3vYy036mtffqX8eJJGPKH5JKbTw3b2YD3z0e4WIdCCrs8K@BCPUZMrlHCfgGwZNHXbVuW5u8hVxiIsmqd7vcwS4GrsM63Ab8AQ "Python 3 – Try It Online"
- # [Python 3], <s>167</s> <s>127</s> <s>118</s> <s>117</s> <s>94</s> 63 bytes
- <!-- language-all: lang-python -->
- <pre><code>def f(a,b):
- 	y=0
- 	for z in range(len(a)):y+=a[z]*b**z
- 	print(y)
- </code></pre>
- [Try it online!][TIO-kttgfxko]
- Close gap to [**@user**](https://codegolf.codidact.com/users/53837)'s [`lambda` answer](https://codegolf.codidact.com/posts/279159/283562#answer-283562)!
- Golfed 40 bytes thanks to [**@user**](https://codegolf.codidact.com/users/53837)'s [advice](https://codegolf.codidact.com/comments/thread/4089#comment-12772). Golfed another 9 bytes thanks to [**@user**](https://codegolf.codidact.com/users/53837)'s [advice](https://codegolf.codidact.com/comments/thread/4089#comment-12782).
- [Python 3]: https://docs.python.org/3/
- [TIO-kttgfxko]: https://tio.run/##K6gsycjPM/7/PyU1TSFNI1EnSdOKi7PS1oCLMy2/SKFKITNPoSgxLz1VIyc1TyNRU9OqUts2MboqVitJS6uKi7OgKDOvRKNS83@aRrShnkGsjqGFkSYXhKNjBBIwAXON9EwhXAM9U2R5HWMgNgFrBEr8BwA "Python 3 – Try It Online"
#6: Post edited
# [Python 3], <s>167</s> <s>127</s> <s>118</s> 117 bytes- <!-- language-all: lang-python -->
- <pre><code>x=float(input());y,z=0,0
- while 1:
- 	try:a=float(input())
- 	except:break
	if z^0:y+=a*x**z;z+=1	else:y+=a;z+=1- print(y)
- </code></pre>
[Try it online!][TIO-ksrcx59d]- Golfed 40 bytes thanks to [**@user**](https://codegolf.codidact.com/users/53837)'s [advice](https://codegolf.codidact.com/comments/thread/4089#comment-12772). Golfed another 9 bytes thanks to [**@user**](https://codegolf.codidact.com/users/53837)'s [advice](https://codegolf.codidact.com/comments/thread/4089#comment-12782).
- [Python 3]: https://docs.python.org/3/
[TIO-ksrcx59d]: https://tio.run/##XcqxDsIgFIXhmfsUHYE2DVhdaHgVEzQ0JRJK8BqBl0eim8M3nJM/FtyPsLSW9eYPg9SF@ELK2FqmqsUk4L07bwepgGAqyvxlQGy@24jqlqx5AHHbUK9ClVEbnjmvax217JF/2u/52zG5gLSw1uR8ATkLOHVLd@7MBw "Python 3 – Try It Online"
- # [Python 3], <s>167</s> <s>127</s> <s>118</s> <s>117</s> 94 bytes
- <!-- language-all: lang-python -->
- <pre><code>x=float(input());y,z=0,0
- while 1:
- 	try:a=float(input())
- 	except:break
- 	y+=a*x**z;z+=1
- print(y)
- </code></pre>
- [Try it online!][TIO-ksrd0p54]
- Golfed 40 bytes thanks to [**@user**](https://codegolf.codidact.com/users/53837)'s [advice](https://codegolf.codidact.com/comments/thread/4089#comment-12772). Golfed another 9 bytes thanks to [**@user**](https://codegolf.codidact.com/users/53837)'s [advice](https://codegolf.codidact.com/comments/thread/4089#comment-12782).
- [Python 3]: https://docs.python.org/3/
- [TIO-ksrd0p54]: https://tio.run/##XcqxDsIgEADQmfsKR6BNA1YXGj7mNJgSG0rIGTl@Hpkd3vYy036mtffqX8eJJGPKH5JKbTw3b2YD3z0e4WIdCCrs8K@BCPUZMrlHCfgGwZNHXbVuW5u8hVxiIsmqd7vcwS4GrsM63Ab8AQ "Python 3 – Try It Online"
#5: Post edited
# [Python 3], <s>167</s> <s>127</s> 118 bytes- <!-- language-all: lang-python -->
- <pre><code>x=float(input());y,z=0,0
- while 1:
- 	try:a=float(input())
- 	except:break
	if z==0:y+=a;z+=1	else:y+=a*x**z;z+=1- print(y)
- </code></pre>
[Try it online!][TIO-ksia37y2]- Golfed 40 bytes thanks to [**@user**](https://codegolf.codidact.com/users/53837)'s [advice](https://codegolf.codidact.com/comments/thread/4089#comment-12772). Golfed another 9 bytes thanks to [**@user**](https://codegolf.codidact.com/users/53837)'s [advice](https://codegolf.codidact.com/comments/thread/4089#comment-12782).
- [Python 3]: https://docs.python.org/3/
[TIO-ksia37y2]: https://tio.run/##XcqxDsIgFIXhmfsUHYE2DVhdaHgYNDQlEkroNQIvj0Q3h284J38suB9haS3rzR8GqQvxhZSxtUxVi0nAe3feDlIBwVSU@cuA2PywEdU9WfME4rahai1UGbVZ66hlD/xpv5tnzuvvjMkFpIW1JucbyFnApVu6a2c@ "Python 3 – Try It Online"
- # [Python 3], <s>167</s> <s>127</s> <s>118</s> 117 bytes
- <!-- language-all: lang-python -->
- <pre><code>x=float(input());y,z=0,0
- while 1:
- 	try:a=float(input())
- 	except:break
- 	if z^0:y+=a*x**z;z+=1
- 	else:y+=a;z+=1
- print(y)
- </code></pre>
- [Try it online!][TIO-ksrcx59d]
- Golfed 40 bytes thanks to [**@user**](https://codegolf.codidact.com/users/53837)'s [advice](https://codegolf.codidact.com/comments/thread/4089#comment-12772). Golfed another 9 bytes thanks to [**@user**](https://codegolf.codidact.com/users/53837)'s [advice](https://codegolf.codidact.com/comments/thread/4089#comment-12782).
- [Python 3]: https://docs.python.org/3/
- [TIO-ksrcx59d]: https://tio.run/##XcqxDsIgFIXhmfsUHYE2DVhdaHgVEzQ0JRJK8BqBl0eim8M3nJM/FtyPsLSW9eYPg9SF@ELK2FqmqsUk4L07bwepgGAqyvxlQGy@24jqlqx5AHHbUK9ClVEbnjmvax217JF/2u/52zG5gLSw1uR8ATkLOHVLd@7MBw "Python 3 – Try It Online"
#4: Post edited
# [Python 3], <s>167</s> 127 bytes- <!-- language-all: lang-python -->
- <pre><code>x=float(input());y,z=0,0
- while 1:
	try:		a=float(input())		if z==0:y+=a;z+=1;continue		y+=a*x**z;z+=1- 	except:break
- print(y)
- </code></pre>
[Try it online!][TIO-kshok75l]- Golfed 40 bytes thanks to [**@user**](https://codegolf.codidact.com/users/53837)'s [advice](https://codegolf.codidact.com/comments/thread/4089#comment-12772). Golfed another 9 bytes thanks to [**@user**](https://codegolf.codidact.com/users/53837)'s [advice](https://codegolf.codidact.com/comments/thread/4089#comment-12782).
>The first revision is now readily available to be ran in [MarkFuncs](https://github.com/JoyrenceMatthewAgas/MarkFuncs). It's a cool program I made that I hope you'll enjoy using. Please read the tutorial before running it if you don't know how it works.- [Python 3]: https://docs.python.org/3/
[TIO-kshok75l]: https://tio.run/##XYpBDsIgFAXXcIougTYErG4gHAYbmhIbIOQ3ApdHdOli3mLmpQpHDGvvxexntEB8SBcQSnVdmhGLwO/Dn26SCiPIdSyyf8@h/D41Y4Sqs7G6zUbqLQbw4XIjfiUrjLVfwciVzSVQz@zsC6fsA5BKe5f8gSUX@DZYB3cuPg "Python 3 – Try It Online"
- # [Python 3], <s>167</s> <s>127</s> 118 bytes
- <!-- language-all: lang-python -->
- <pre><code>x=float(input());y,z=0,0
- while 1:
- 	try:a=float(input())
- 	except:break
- 	if z==0:y+=a;z+=1
- 	else:y+=a*x**z;z+=1
- print(y)
- </code></pre>
- [Try it online!][TIO-ksia37y2]
- Golfed 40 bytes thanks to [**@user**](https://codegolf.codidact.com/users/53837)'s [advice](https://codegolf.codidact.com/comments/thread/4089#comment-12772). Golfed another 9 bytes thanks to [**@user**](https://codegolf.codidact.com/users/53837)'s [advice](https://codegolf.codidact.com/comments/thread/4089#comment-12782).
- [Python 3]: https://docs.python.org/3/
- [TIO-ksia37y2]: https://tio.run/##XcqxDsIgFIXhmfsUHYE2DVhdaHgYNDQlEkroNQIvj0Q3h284J38suB9haS3rzR8GqQvxhZSxtUxVi0nAe3feDlIBwVSU@cuA2PywEdU9WfME4rahai1UGbVZ66hlD/xpv5tnzuvvjMkFpIW1JucbyFnApVu6a2c@ "Python 3 – Try It Online"
#3: Post edited
- # [Python 3], <s>167</s> 127 bytes
- <!-- language-all: lang-python -->
- <pre><code>x=float(input());y,z=0,0
- while 1:
- 	try:
- 		a=float(input())
- 		if z==0:y+=a;z+=1;continue
- 		y+=a*x**z;z+=1
- 	except:break
- print(y)
- </code></pre>
- [Try it online!][TIO-kshok75l]
Golfed 40 bytes thanks to [user](https://codegolf.codidact.com/users/53837)'s [advice](https://codegolf.codidact.com/comments/thread/4089#comment-12772).- >The first revision is now readily available to be ran in [MarkFuncs](https://github.com/JoyrenceMatthewAgas/MarkFuncs). It's a cool program I made that I hope you'll enjoy using. Please read the tutorial before running it if you don't know how it works.
- [Python 3]: https://docs.python.org/3/
- [TIO-kshok75l]: https://tio.run/##XYpBDsIgFAXXcIougTYErG4gHAYbmhIbIOQ3ApdHdOli3mLmpQpHDGvvxexntEB8SBcQSnVdmhGLwO/Dn26SCiPIdSyyf8@h/D41Y4Sqs7G6zUbqLQbw4XIjfiUrjLVfwciVzSVQz@zsC6fsA5BKe5f8gSUX@DZYB3cuPg "Python 3 – Try It Online"
- # [Python 3], <s>167</s> 127 bytes
- <!-- language-all: lang-python -->
- <pre><code>x=float(input());y,z=0,0
- while 1:
- 	try:
- 		a=float(input())
- 		if z==0:y+=a;z+=1;continue
- 		y+=a*x**z;z+=1
- 	except:break
- print(y)
- </code></pre>
- [Try it online!][TIO-kshok75l]
- Golfed 40 bytes thanks to [**@user**](https://codegolf.codidact.com/users/53837)'s [advice](https://codegolf.codidact.com/comments/thread/4089#comment-12772). Golfed another 9 bytes thanks to [**@user**](https://codegolf.codidact.com/users/53837)'s [advice](https://codegolf.codidact.com/comments/thread/4089#comment-12782).
- >The first revision is now readily available to be ran in [MarkFuncs](https://github.com/JoyrenceMatthewAgas/MarkFuncs). It's a cool program I made that I hope you'll enjoy using. Please read the tutorial before running it if you don't know how it works.
- [Python 3]: https://docs.python.org/3/
- [TIO-kshok75l]: https://tio.run/##XYpBDsIgFAXXcIougTYErG4gHAYbmhIbIOQ3ApdHdOli3mLmpQpHDGvvxexntEB8SBcQSnVdmhGLwO/Dn26SCiPIdSyyf8@h/D41Y4Sqs7G6zUbqLQbw4XIjfiUrjLVfwciVzSVQz@zsC6fsA5BKe5f8gSUX@DZYB3cuPg "Python 3 – Try It Online"
#2: Post edited
# [Python 3], 167 bytes- <!-- language-all: lang-python -->
<pre><code>n=[]while True:	try:a=float(input());n.append(a);continue- 	except:break
x=float(input());y=0for i in range(len(n)):	if i==0:y+=n[i];continue	y+=n[i]*x**i- print(y)
- </code></pre>
[Try it online!][TIO-ksgudvzh]Not exactly "golfy", but it's more manageable than C. lmaoThe form of input uses a `while` loop to take the array of numbers, simply `float`s, then the inputting stops if the input can't be converted into a `float`. Then takes another input for basing the calculation. And yes, I wrote the variable names as `n` and `x`.- >The first revision is now readily available to be ran in [MarkFuncs](https://github.com/JoyrenceMatthewAgas/MarkFuncs). It's a cool program I made that I hope you'll enjoy using. Please read the tutorial before running it if you don't know how it works.
- [Python 3]: https://docs.python.org/3/
[TIO-ksgudvzh]: https://tio.run/##Xc2xDoIwFAXQmfcVHVtMCIguJf0LN8JQ8SEvktemKZF@fe3gYBzOcpN7r09xddznzGac4L3ShuIWdtRQxZC0NcvmbJTEfo9SqYEb6z3yQ1o1zI4j8Y5Q4TGjj/oe0L7g@O8k08LigiBBLILlJ8oNWbJS5YUWQca0Op0MjzT9jH6T@qhrAh@Io0wq565p4Vz0xaWw0DXXDw "Python 3 – Try It Online"
- # [Python 3], <s>167</s> 127 bytes
- <!-- language-all: lang-python -->
- <pre><code>x=float(input());y,z=0,0
- while 1:
- 	try:
- 		a=float(input())
- 		if z==0:y+=a;z+=1;continue
- 		y+=a*x**z;z+=1
- 	except:break
- print(y)
- </code></pre>
- [Try it online!][TIO-kshok75l]
- Golfed 40 bytes thanks to [user](https://codegolf.codidact.com/users/53837)'s [advice](https://codegolf.codidact.com/comments/thread/4089#comment-12772).
- >The first revision is now readily available to be ran in [MarkFuncs](https://github.com/JoyrenceMatthewAgas/MarkFuncs). It's a cool program I made that I hope you'll enjoy using. Please read the tutorial before running it if you don't know how it works.
- [Python 3]: https://docs.python.org/3/
- [TIO-kshok75l]: https://tio.run/##XYpBDsIgFAXXcIougTYErG4gHAYbmhIbIOQ3ApdHdOli3mLmpQpHDGvvxexntEB8SBcQSnVdmhGLwO/Dn26SCiPIdSyyf8@h/D41Y4Sqs7G6zUbqLQbw4XIjfiUrjLVfwciVzSVQz@zsC6fsA5BKe5f8gSUX@DZYB3cuPg "Python 3 – Try It Online"
#1: Initial revision
# [Python 3], 167 bytes <!-- language-all: lang-python --> <pre><code>n=[] while True: 	try:a=float(input());n.append(a);continue 	except:break x=float(input());y=0 for i in range(len(n)): 	if i==0:y+=n[i];continue 	y+=n[i]*x**i print(y) </code></pre> [Try it online!][TIO-ksgudvzh] Not exactly "golfy", but it's more manageable than C. lmao The form of input uses a `while` loop to take the array of numbers, simply `float`s, then the inputting stops if the input can't be converted into a `float`. Then takes another input for basing the calculation. And yes, I wrote the variable names as `n` and `x`. >The first revision is now readily available to be ran in [MarkFuncs](https://github.com/JoyrenceMatthewAgas/MarkFuncs). It's a cool program I made that I hope you'll enjoy using. Please read the tutorial before running it if you don't know how it works. [Python 3]: https://docs.python.org/3/ [TIO-ksgudvzh]: https://tio.run/##Xc2xDoIwFAXQmfcVHVtMCIguJf0LN8JQ8SEvktemKZF@fe3gYBzOcpN7r09xddznzGac4L3ShuIWdtRQxZC0NcvmbJTEfo9SqYEb6z3yQ1o1zI4j8Y5Q4TGjj/oe0L7g@O8k08LigiBBLILlJ8oNWbJS5YUWQca0Op0MjzT9jH6T@qhrAh@Io0wq565p4Vz0xaWw0DXXDw "Python 3 – Try It Online"