执行职能

时间:2015-10-01 20:36:45

标签: python function

我知道这是一个问题,但我似乎无法找到它。 我要求用户每个月下雪多少,这很容易

gets

但我的教授后来发了一封电子邮件,"这应该使用一个输入语句来实现,而不是三个。"我们目前正在学习函数和year=print(input("Hello, what year of snowfall are you checking? ")) count=0 jan=print(input("How much snow fell during the month of January? ")) feb=print(input("How much snow fell during the month of Febuary? ")) mar=print(input("How much snow fell during the month of March? ")) 的使用,我无法找到它们的实现 我想出了一个"一条输入线"但我不认为这就是他希望我这样做的方式

def

提前感谢,在大学之前,我对编程一无所知。

2 个答案:

答案 0 :(得分:0)

corpus.f <- file.path (stuff)
corpus <- list.files(corpus)
corpus <- lapply(corpus, ReadLines)
corpus.df <- as.data.frame(c(corpus.f,corpus))
corpus.info <- read.csv(stuff.csv)

然后调用该月的函数。

答案 1 :(得分:0)

两种方法:一种带有循环,另一种带有功能

使用循环:

for month in ["January", "February", "March"]:
    print(input("How much snow fell during the month of %s" % month))

有功能:

def ask(month):
    print(input("How much snow fell during the month of %s" % month))
ask("January")
ask("February")
ask("March")