我正在制作一个数学求解程序,它将整数打印为小数.像1是1.0,5是5.0,我的代码是:
print("Type in the cooridinates of the two points.")
print("")
print("---------------------")
print("First point:")
x1 = int(input("X: "))
y1 = int(input("Y: "))
print("")
print("---------------------")
print("Second point:")
x2 = int(input("X: "))
y2 = int(input("Y: "))
m = (y1-y2) / (x1-x2)
b = y1 - m * x1
round(m, 0)
round(b, 0)
print("Completed equation:")
print("")
if b < 0:
print("Y = "+ str(m) +"X - "+ str(b) +".")
elif b > 0:
print("Y = "+ str(m) +"X + "+ str(b) +".")
elif b …Run Code Online (Sandbox Code Playgroud) 你好python用户,我提出了一个我一直想知道的问题.我喜欢python,并用它制作了许多程序.现在我想做的是(或者知道怎么做)创建一个python程序,但是在一个窗口中运行它,你点击的按钮而不是输入数字来选择东西.我想知道天气与否我能做到这一点,如果可以,请告诉我去哪里学习.好吧,它不适合iPhone,对不起,我不清楚,我没有意识到iPhone是其中一个标签.
我正在创建一个用于播放字谜的单词生成器,它适用于大约六个单词,然后说"列表索引超出范围".
这是我的代码:
def selection(word):
while True:
from random import randint
sel = randint(1,10)
print(word[sel])
input("\nPress enter to select a new word.")
print("Type in ten words to add to the list.")
words = []
words.append(input("1st word: "))
words.append(input("2nd word: "))
words.append(input("3rd word: "))
words.append(input("4th word: "))
words.append(input("5th word: "))
words.append(input("6th word: "))
words.append(input("7th word: "))
words.append(input("8th word: "))
words.append(input("9th word: "))
words.append(input("10th word: "))
input("\nPress enter to randomly select a word.")
selection(words)
Run Code Online (Sandbox Code Playgroud) 可能重复:
我正在制作PEMDAS解算器而不知道写什么
我正在制作一个pemdas求解器程序,我似乎无法解决用户写入程序的等式.我目前的代码是:
def pemdas():
print("type in your pemdas problem.")
prob = int(input())
solve(prob)
print(str(prob))
input()
pemdas()
Run Code Online (Sandbox Code Playgroud)