Python题目

2025-12-05 12:07:48
推荐回答(2个)
回答1:

#输出"Hello,world!"
print('hello,world')

#从键盘输入4个整数a,b,c,x计算函数值
a = int(input('请输入a的值:'))
b = int(input('请输入b的值:'))
c = int(input('请输入c的值:'))
x = int(input('请输入x的值:'))
y = (a*x)^ 2 + b*x+c
print('最终的值为:%s'% y)

#计算费波纳契数列的第 n 项的递归程序
def fibonacci(n):
if n == 0 or n ==1:
return n
else:
return fibonacci(n-1) + fibonacci(n-2)
print(fibonacci(3))

#从键盘输入若干个用空格分开的单词,按字典序排序后输出
inputWords = input('请输入几个单词,用空格分开\n')
word = sorted(inputWords.split(' '))
print(word)

回答2:

好基础
不难吧