About user interaction

Undoubtedly, user interaction experience in software product is a vital part of the so-called interaction with the user , a personal opinion, that is programs and users exchange information.

As the following example:

. 1  Print ( ' ----------------------- guess the number of bars within 100 -------------- \ n- ' )
 2 RES = ' 90 ' 
. 3 GUESS = 0
 . 4  the while gUESS == ' the Y '  or gUESS == ' Y '  or gUESS == 0:
 . 5      COUNT = 0
 . 6      the while COUNT <. 3 :
 . 7          gUESS = iNPUT ( ' enter your guess numbers: ' )
 . 8          IF gUESS = = RES:
 . 9              Print( ' Congratulations, you guessed it, really powerful \ the n-! ' )
 10              BREAK 
11          elif GUESS < RES:
 12              Print ( ' guess a little, do not be discouraged, again ~ ' )
 13              IF COUNT == 0:
 14                  Print ( ' there are two opportunities oh ~ \ the n- ' )
 15              elif COUNT == 1 :
 16                  Print ( ' left once chance Oh ~ \ the n- ' )
 17              the else :
 18                  Print ( ' three chances to run out of it \ the n-! ' )
 19         the else :
 20              Print ( ' guess big, make persistent efforts ' )
 21              IF COUNT == 0:
 22                  Print ( ' there are two opportunities oh ~ \ the n- ' )
 23              elif COUNT == 1 :
 24-                  Print ( ' left once chance Oh ~ \ the n- ' )
 25              the else :
 26                  Print ( ' ! three chances to run out of it \ the n- ' )
 27          COUNT + 1 =
 28      GUESS the INPUT = ( ' whether it would like to do it again (a press Y / N press N): ' )
Guess source
Guess it within 50 ------------ -------------- number 

, please enter the number you guess: 50 
guess big, make persistent efforts 
there are two opportunities Oh ~ 

enter the number you guess: 15 
guess small, do not be discouraged, again - 
left once chance Oh ~ 

enter the number you guess: 24 
Congratulations, you guessed it, really amazing! 

Whether it would like to do it again (is press the Y- ):

In this case, it reflected a process of user interaction with the program, I think about user interaction at least to note the following:

  1. capable of guiding the user should do. (Such as the title prompts, as well as the end of the inquiry, and examples of what should be entered)

  2. allow users to receive timely feedback. (For example, users will be prompted to guess big or small, and prompts the remaining opportunities)

 

Input and output on the python

Entry

The input python3

  Keywords: input ()

  The user inputs the acquired input python3 Unified string type to keep all

 

>>> name = input('please input>>:')
please input>>:bitten
>>> type(name)
<class 'str'>
>>> name = input('please input>>:') please input>>:[1,2,3,4,5] >>> type(name) <class 'str'>
>>> name = input('please input>>:') please input>>:89 >>> type(name) <class 'str'>

 

  Python2 the same effect input and raw_input python3, the data will be stored as a unified user input string.

Python 2.7.10 (default, Oct 6 2017, 22:29:07) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwinType "help", "copyright", "credits" or "license" for more information.
>>> name = raw_input('please input>>:')
please input>>:bitten
>>> type(name)
<type 'str'>

>>> name = raw_input('please input>>:')
please input>>:[1,2,3,4,5]
>>> name
'[1,2,3,4,5]'  #输出形式是字符串形式
>>> type(name)
<type 'str'>

>>> name = raw_input('please input>>:')
please input>>:'bitten'
>>> type(name)
<type 'str'>

  python2 of input requires human input to tell you what type of input

 1 >>> name = input('please input>>:')
 2 please input>>:bitten
 3 
 4 Traceback (most recent call last):
 5   File "<stdin>", line 1, in <module>
 6   File "<string>", line 1, in <module>
 7 NameError: name 'bitten' is not defined   #直接输入英文名,会报错说未定义
 8 
 9 >>> name = input('please input>>:')
 10 Please >> INPUT: ' Bitten '    # as an input character string is no problem 
. 11 >>> type (name)
 12 is <type ' STR ' >
 13 is  
14 >>> name = INPUT ( ' Please >> INPUT: ' )
 15 Please >> iNPUT: [1,2,3,4,5]    # here is a list input 
16 >>> type (name)
 . 17 <type ' list ' >

Export

Formatted output

# Method. 1 
name = INPUT ( ' Please INPUT your username: ' ) 
Age = INPUT ( ' Please INPUT your Age: ' )
 Print ( ' My name IS ' , name, ' My Age IS ' , Age)
 # or print ( ' my name is% S, my age is% S '% (name, Age)) 
# result username my name is entered, the age my age is entered 

# method 2 
Print ( ' my name is% S my age is S% ' % ( ' Bitten ' , 18 is ))
 #Or Print ( 'My name IS% s My Age IS% D'% ( 'Bitten', 18 is))

# on% s and% D Print ( ' My name IS% s My Age IS% s ' % ( ' Bitten ' , [l, 2,3 ])) # % S may receive any type of value Print ( ' My name My Age iS iS S% D% ' % ( ' Bitten ' , ' XXX ' )) Traceback (MOST Recent Last Call ): File " <stdin> " , Line. 1, in <Module1> TypeError: % D the format:a number is required, notSTR # % D can receive a digital type

 

Guess you like

Origin www.cnblogs.com/PowerTips/p/11116332.html