Hausaufgabe--Python 04
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Hausaufgabe--Python 04相关的知识,希望对你有一定的参考价值。
0---small games: number guess:
import random
answer = random.randint(1,10)
guess = int(input(‘please input your guess: ‘ ))
i = 2
while i :
if guess != answer:
if (guess > answer):
print(‘oops, your guess is too much, you still have ‘+ str(i) + ‘ chances‘)
else:
print(‘your guess is too small, you still have ‘+ str(i) + ‘ chances‘)
guess = int(input(‘try again: ‘ ))
i = i-1
else:
print(‘correct! The answer is ‘+ str(answer)+ ‘! Did your mother know you are such a clever girl/boy !‘)
break
1--- print a right-angled triangle
number = int(input(‘please input a integer: ‘))
k=number
while k:
for i in range (k):
print(‘ ‘,end=‘‘)
for j in range(k):
print(‘*‘, end=‘‘)
print(‘‘)
k=k-1
以上是关于Hausaufgabe--Python 04的主要内容,如果未能解决你的问题,请参考以下文章
hausaufgabe--python 26 -Dict 2
hausaufgabe--python 16- Sequenz