I am trying to make a price calculator to put in a iframe on a joomla site. Today we use a embed excel sheet, but this is not working like we want. I know the basic of python and I think that was the way to go. So I did make the code in pycharme and it is working the way I want. So my problem now is to get this thing out on the web. After googling for hours to find a simple solution I found Anvil. Now I have siting with my computer for hours, and I am a bit closer to a end result, but this is a project that should be finish in 3 days. I have taking the “guessing” example to have something to start with and it works, but when it come to calculation I have problem. Can someone please help me with this one?
The code is this:
This is how many studets there are
price = int(input("How many students: "))
The price for 20 students or less
if price <= 20:
print("Your price is: 400,- ")
print(“Your price is with tax:”, 400 * 1.25)
elif price>=21 and price<=50:
print("Your price is: ", price20)
print(“Your price is with tax:”, (price20)1.25)
elif price>=51 and price<=100:
print(“Your price is:”, price8+600)
print("Your price is with tax: ",(price* 8+600)1.25)
elif price>=101 and price<300:
print("Your price is: ", price3+1100)
print(“Your price is with tax:”, (price* 3 + 1100)*1.25)
Welcome to the forum.
It’s hard to say for sure without seeing the rest of the code, but there are a couple of obvious errors :
should be something like :
print(“Your price is with tax:”, (price20 * 1.25))
Also, when I cut/paste your code some of your double quotes ( " ) were odd characters and causing Anvil to report bad input in the IDE.
Can you publish your project and post the link under “Allow someone to copy my app”? Then I can clone it and see if i can help more. To publish, click the cog icon in the App Browser window (top left) and you’ll see that option in the drop down menu.
Welcome to the Anvil forums! As well as the syntax fix, you probably want to modify your code to get your input from a text box on the web page, and display the output on the web page too!
Here’s a link to a fully worked example - it doesn’t do price calculations, but it does get the user’s input from a TextBox component, process it with Python, and display the result on a Label component: https://anvil.works/ide#template:hello_world
The start of the video here shows how you could build this kind of app. (It then goes on to show lots of more advanced features, which you can learn all about from our other video tutorials).