Python:我正在为班级制作一个简单的计算器。此代码有什么问题? [英] Python: I'm making a simple calculator for class. What's wrong with this code?

查看:112
本文介绍了Python:我正在为班级制作一个简单的计算器。此代码有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的老师要求我做一个计算器,可以计算出所提交价格的15%小费。我遵循了此python应用程序的在线教程。在做出老师要求的内容之前,我为练习做了一个简单的加,减,乘,除计算器。在YouTube视频中,我跟随python应用程序在他的计算机上运行。我在Python Shell中收到无效语法错误。我正在使用Python 3.3.0。谢谢。

My teacher requests me to make a calculator that can calculate a 15% tip on a submitted price. I followed an online tutorial for this python application. I made a simple addition, subtraction, multiplication, and division calculator for practice before I make what my teacher requires. In the YouTube video I followed the python application ran on his computer. I get a a "Invalid Syntax" error in the Python Shell. I'm using Python 3.3.0. Thank you.

编辑:我遵循了另一个教程,弄清楚如何完成我的项目。我唯一遇到的问题是同时使用正整数(1、2、3、4等)和浮点整数(4.36、5.45等)。

I followed a different tutorial figured out how to finish my project. The only problem I'm having is using both regular integers (1, 2, 3, 4, etc.) and float integers (4.36, 5.45, etc.).

print("Welcome to the calculator!")

mealPrice = int(input("Enter your meal price:"))

asw = mealPrice * 0.15

print("The tip you owe is: ", asw)


推荐答案

因为y是字符串

y = int(raw_input("Input second integer: "))

这篇关于Python:我正在为班级制作一个简单的计算器。此代码有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆