由于此错误,无法形成Scikit模糊规则。Skfuzzy码和错误消息如下所示
import matplotlib.pyplot as pit
import skfuzzy as fuz
import numpy as np
from skfuzzy import control as ctrl
s=ctrl.Antecedent(np.arange(0,11,1),'service')
q=ctrl.Antecedent(np.arange(0,11,1),'quality')
t=ctrl.Antecedent(np.arange(0,26,1),
下面用PYTHON编写的代码集,使用SKFUZZY从SCI学习:
import skfuzzy as fuzz
import numpy as np
from skfuzzy import control as ctrl
import matplotlib.pyplot as plt
# New Antecedent/Consequent objects hold universe variables and membership
# functions
quality = ctrl.Antecedent(np.arange(0, 11, 1),'quality')
serv
在将最终结果舍入到Python的小数点2位时,我遇到了问题。它总是只显示一个小数点。我想要33.60美元
#tip calculator
bill = float (input("what is the total bill? "))
tip = float (input ("percentage tip 10%, 20% etc. ? "))
ppl = int (input ("number of people to split the bill? "))
tip_decimal = tip/100+1
calc = (bill/p
我刚开始学习python,几天来我一直在努力学习编码。我写了账单计算代码,但有一点我不明白。
当我编写10、15、20以外的数字时,我希望在其他部分中出现我所写的文本,但是除了20之外,这是行不通的。我该怎么办?
print("\t Welcome to Tip Calculator")
bill = float(input("What was the total bill? $"))
people = int(input("How many people split to bill? "))
tip_percantage = int(in
我用Python,Django框架编写了以下代码:
class ImageGenerator:
def __init__(self, tip):
self.tip = tip
def remove_transparency(self, im, bg_colour=(250, 250, 250)):
if im.mode in ('RGBA', 'LA') or (im.mode == 'P' and 'transparency' in im.info):
a
我目前正在学习Python,并致力于编写一个小程序,这是我正在完成的书中的一个任务。我正在使用round()函数,并且在很大程度上它是有效的。有一句话不是这样的,我无论如何也想不出来。任何帮助都是非常感谢的。不起作用的部分是:
billtip1 = bill + tip1
round(billtip1, 2)
在这段代码的末尾:
bill = input("\nEnter in the bill total: $ ")
bill = float(bill)
tip1 = bill * .15
tip2 = bill * .20
tip1 = round(tip1, 2)
t
我试图让Python将一个简单的Tip Calculator程序的输出四舍五入到小数点后两位,但到目前为止我还没有找到答案。下面是代码的相关部分。我希望以传统的美元和美分格式打印输出(例如,$XX.XX)
bill = float(input("\n\nWhat is the bill for your meal?: $"))
low_tip = bill * .15
print("\nIf you would like to tip the waiter 15%, the amount of the \ntip is: $", low_tip)
low_t
和其他新手一样,我试图创建一个小费计算器,当然我遇到了一个问题。大部分代码运行良好,但我不知道如何将用户输入用于提示,并将其合并到总计中。
这个页面是一个很好的资源,并告诉我需要指向python的方向来将输入解释为解决方案中使用的数学。不过,我无法将它在我的脑海中转换成我的代码。
# Tip Calculator
import random
bill = input("How much was your bill? ")
x = float(bill)
tip10 = x * .10
tip15 = x * .15
tip20 = x * .20
tip10 = floa
我正在使用Sphinx来记录python项目,并尝试创建一个可重用的提示,以便在多个位置使用。
通常,我将在python文件中使用以下语法:
"""
.. tip::
I want this tip to be used in several locations. Why?
- Save time
- Work less
"""
现在,不管我把它放在文件的开头,还是在类定义下,还是在函数定义下,这都是可行的。
我找到了 for :ref:,它建议使用标签:
.. _my_reusable_tip:
我正在用Python做一个小费计算器,它现在基本上可以工作了,除了我想让结果小费金额显示两个小数点,包括在必要时强制输入0(比如8.50美元而不是8.5美元)。
我试着搜索这个问题,我想我必须以某种方式合并%.02f,但找不到把它放在哪里。
代码如下:
bill = input("How much did your bill come out to? ")
bill2 = float(bill.strip("$"))
#created a new 'bill2' variable to strip any $ from the input a
我最近通过一个课程学习了python。除了我使用view方法之外,一切都很顺利。有没有人也有这个问题? 我甚至用https://pythonhosted.org/scikit-fuzzy/auto_examples/plot_tipping_problem_newapi.html#example-plot-tipping-problem-newapi-py编写了一个示例代码。(链接已更新) import numpy as np
import skfuzzy as fuzz
from skfuzzy import control as ctrl
quality = ctrl.Antecede
我正在为绝对初学者(第三版)使用Python编程,不幸的是,在游戏的早期就遇到了问题。
有人能告诉我下面的代码有什么问题吗?
price = float(input("Uh oh, looks like dinner is over. Time to calculate the tip! How much was the bill?"))
price_15 = price * .15
price_20 = price * .20
print("If you're feeling cheap you can give a 15% tip, which wou
我是一个新手(大概两周),正在尝试学习Python2.7x。我正在尝试做一个基本的程序,有一个用户输入一顿饭的费用,它输出多少钱,它将与.15小费。我希望输出看起来像23.44 (显示2个小数)
我的代码:
MealPrice = float(raw_input("Please type in your bill amount: "))
tip = float(MealPrice * 0.15,)
totalPrice = MealPrice+tip
int(totalPrice)
print "Your tip would be:
我的模特班:
class Ticket(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
ticket_number = models.IntegerField('Ticket Number', null=True)
date = models.DateTimeField('Date', default=datetime.now())
name = models.CharField('Cus
我的代码如下所示。我正在练习Python,想做一个简单的餐厅小费计算器。它工作得很好,但我觉得我太依赖while循环了。对于每个输入提示,我希望让脚本检查输入是否是int/float,如果不是,它将继续循环,直到给出正确的输入。
有人对这是不是一种好的“检查”方式有什么建议?
另外:
在我将"#DETERMINING PERCENTAGE BASED ON QUALITY“和下面的章节放在自己的while循环中(它们最初是自己放在代码的末尾,而不是在循环中)之前,我无法让脚本移动到”你的服务质量如何?“之后的那些章节。部分。脚本一直只循环这一节。知道为什么吗?它的格式看起来和它前面的2
我是python的新手,我正在尝试从多个文本文件中提取值。我可以用循环很好地打开文件,但是我正在寻找一种直接的方式来搜索字符串,然后返回它之后的值。
我的结果文本文件如下所示
SUMMARY OF RESULTS
Max tip rotation =,-18.1921,degrees
Min tip rotation =,-0.3258,degrees
Mean tip rotation =,-7.4164,degrees
Max tip displacement =,6.9956,mm
Min tip displacement =,0.7467,mm
Mean tip displacemen
好吧,所以我对编程很陌生。我已经开始教自己python3.2,并试图编写一个程序,显示任何餐馆的账单,15%的小费和20%的小费。我一直在想:
Traceback (most recent call last):
File "/home/marian/restaurantbilltotal.py", line 6, in <module>
print(fifteen ("Plus a 15% tip: "))
TypeError: 'int' object is not callable tip
我所写的代
对于Python来说是新手,一般情况下是新代码。我“知道”如何使用圆函数,并可以将其用于小数点以上2位以上的数字。我的问题是,如何得到只有小数点1位的数字才能将0加到小数点的2位。比如美元金额?
这是我写的东西,任何关于话题或批评的建议都是受欢迎的。我已经知道我的数学有点“创造性”了。我可以保证有一个更简单的方法,但我只是让它发挥作用。如果有人能向我解释一下我怎么能在这段代码中用到一个f-字符串,那就太棒了。
谢谢
print("Welcome to the tip calculator!")
total = input("What was the total bill
在使用mercurial进行的每一次提交之后,我可以在哪里运行代码?具体来说,我想在我的项目根目录下的文件夹中维护一个名为“最新版本”的文件--该文件将保存最近提交的修订号和哈希码。关于同样的话题,我如何才能在python中得到这些信息呢?
# get mercurial version hash
ver = ?
# get mercurial revision number
rev = ?
# is there a shortcut to this folder through mercurial?
f = open('/path/to/.hg/latest', '
def main():
dollars = dollars_to_float(input("How much was the meal? "))
percent = percent_to_float(input("What percentage would you like to tip? "))
tip = dollars * percent
print(f"Leave ${tip:.2f}")
def dollars_to_float(d):
d = d.replace('$', '')
d =
我试图用Python编写一个简单的提示计算器,但我需要它始终输出两个小数位。对于一些整数,比如100,它只会给出一个小数点,我该怎么办?
这是我的代码:
print("Only input numbers, do not input dollar signs or letters")
subtotalprice = eval(input("What is the bill total?: "))
percent10 = subtotalprice * 0.1
percent15 = subtotalprice * 0.15
percent20 = subt
我一直在研究如何开始用pygame和python开发游戏,而我在定义有争议的函数方面遇到了麻烦。第一种方法起作用了,我只想用一个参数来制作一个更简单的版本。它不停地说,当c明确的时候,它是没有定义的。我不明白为什么。对此有什么建议或想法吗?我也有
def fugu_tip(price, num_plates, tip):
total = price * num_plates
tip = total * (tip / 100.)
return tip
def Character(c):
a = input("Enter a number 1 - 100&
我正在尝试将我的计算函数绑定到提交按钮。我是Kivy的新手,正在尝试一些实践。任何学习的技巧或技巧都是非常感谢的。下面是我的代码: Python文件: import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from kivy.uix.widget import Widget
所以对于我的学校,我必须制作这个脚本来计算一顿饭的小费和税金。我比班上的每个人都领先,所以没有其他人有过这个问题。
代码在我的PC上空闲的Python3中工作得很好,在上也很好。奇怪的是,在我的学校闲着,这是私人的,的小费和税收没有正确计算。
此外,还有其他一些错误,比如显示额外的数字或没有显示足够的数字。我尽了最大的努力用字符串切片来修复这个问题,但没有奏效。我知道的唯一其他方法是使用不允许的if语句。
如能提供任何帮助,将不胜感激。
代码:
#Name
#9/20/16
#This program calculates the total cost of a meal.
def main
我是这里的初学者,也是Python编程的初学者,目前我正在使用code academy来帮助我学习。所以我决定冒险自己做一个程序,并且一直被错误信息所困扰: can't multiply sequence by non-int of type 'float‘
这个程序非常简单,它是一个小费计算器,它要求用户输入信息,让程序确定小费金额和账单总额。在数学问题出现之前,它确实没问题。我知道这并不“漂亮”,但这只是我真的在努力弄清楚如何使用它。任何帮助都将不胜感激!
这是我到目前为止所知道的:
print ("Restuarant Bill Calculator")
我想同时运行两个进程。1将继续每秒钟打印'a‘,另一个将要求输入,当输入为'Y’时,第一个进程将停止打印'a‘。我对Python很陌生,我搞不懂.
到目前为止,这就是我想出来的:
from multiprocessing import Process
import time
go = True
def loop_a():
global go
while go == True:
time.sleep(1)
print("a")
def loop_b():
global go
text
我试图在python中创建一个数组,它将包含系统发育树上每一对节点之间的所有配对距离。我现在用树枝状来做这件事。(我一开始看过生物工程,但找不到一个选项来做这个)。到目前为止,我的代码如下所示:
import dendropy
tree_data = []
tree = dendropy.Tree.get(path="gonno_microreact_tree.nwk",schema="newick")
pdc = tree.phylogenetic_distance_matrix()
for i, t1 in enumerate(tree.taxon_nam
我这里有个python函数。但是,当运行时,我得到一个错误“无法将字符串转换为浮动:'$50.50'”。我需要将输入添加为字符串,包括"$“符号,然后将其转换为后端的浮点数。该函数似乎只需要添加"50.50“作为输入。
def main():
dollars = dollars_to_float(input("How much was the meal? "))
percent = percent_to_float(input("What percentage would you like to tip? "))
我在python中用selenium编写了一个脚本,可以单击网页中的某个链接来下载excel文件。但是,当我执行我的脚本时,它会引发timeout异常。我怎么才能让它起作用?任何帮助都将不胜感激。
链接到网站:
我试过的脚本:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditi
有时我会收到来自globalleaks的邮件,但我找不到任何问题。
有没有人也有同样的问题?
我们始终将更新为最新版本
我认为请求一些条目是错误的,这些条目在句号之后被删除
下面是错误消息:
sqlalchemy.orm.exc.NoResultFound A database result was required but none was found.
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1416,