码迷,mamicode.com
首页 > 编程语言 > 详细

Hausaufgabe--Python 04

时间:2017-05-23 00:26:45      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:integer   bsp   input   ever   dom   bre   port   while   eve   

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

标签:integer   bsp   input   ever   dom   bre   port   while   eve   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!