首页 > 编程语言 > 详细

Hausaufgabe--Python 04

时间:2017-05-22 23:59:32      阅读:422      评论:0      收藏:0      [点我收藏+]

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

原文:http://www.cnblogs.com/Shareishappy/p/6891869.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!