I've seen a little turtle before. 0 Basic self-study Python,b station with high-definition free resources [av4050443], but as the 0 Foundation is hard to learn, download the Python core programming pdf, here to do some notes.
Although the use of the second edition of the textbook, but I use the python3.5.2, the feeling is not very different, can read.
Here is the beginning of the second chapter of the exercises!
--------------------------------------------------------
2-5: Print with while and for 0-10:
i = 0
While I < 11:
Print (i)
i + = 1
------------
For I in range (11):
Print (i)
---------------------------------------------
2-7: Input string and print, use while and for:
Str_input = input (' Please enter string: ')
i = 0
While I < Len (str_input):
Print (Str_input[i])
i + = 1
-----------
Str_input = input (' Please enter string: ')
For I in Str_input:
Print (i)
--------------------------------------------------------------
2-8: Enter 5 numbers to add:
i = 0
temp = 0
While I < 5:
temp + = Int (input (' Please enter a number: '))
i + = 1
Print (temp)
--------------
temp = 0
For I in range (5):
temp + = Int (input (' Please enter a number: '))
Print (temp)
------------------------------------------------------
2-9: Output The average of five values:
temp = 0
For I in range (5):
temp + = Int (input (' Please enter a number: '))
Arverange = TEMP/5
Print (Arverange)
------------------------------------------------------------
2-10: Determine whether to enter 1 to 100, is to stop, otherwise re-enter:
num = Int (input (' Please enter an integer between 1 and 100: '))
While Num isn't in range (2,101):
Print (' incorrect input ')
num = Int (input (' Please enter an integer between 1 and 100: '))
Print (' You're right! ')
--------------
Using recursion seems troublesome, I'm not quite sure (see below):
def function1 (num):
If 1 < num < 100:
Print (' Your number in (1,100) ')
Else
Print (' The number you are input is not in (1,100) ')
num = Int (input (' please input a number: '))
Function1 (num)
num = Int (input (' please input a number: '))
Function1 (num)
---------------------------------------------------------------
Self-learning Python core programming