---56---
Question:
>Print a unicode string "hello world".
Hints:
>Use u'strings' format to define unicode string.
Solution:
---57---
Question:
>Write a program to read an ASCII string and to convert it to a unicode string encoded by utf-8.
Hints:
>Use unicode()/encode() function to convert.
Solution:
---58---
Question:
Write a special comment to indicate a Python source code file is in unicode.
---59---
Question:
>Write a program to compute 1/2+2/3+3/4+...+n/n+1 with a given n input by console (n>0).
Example:
>If the following n is given as input to the program: 5
>Then, the output of the program should be: 3.55
Hints:
>Use float() to convert an integer to a float.Even if not converted it wont cause a problem because python by default understands the data type of a value
Solution:
---60---
Question:
>Write a program to compute: f(n)=f(n-1)+100 when n>0
and f(0)=0
>with a given n input by console (n>0).
Example:
>If the following n is given as input to the program: 5
>Then, the output of the program should be: 500
Hints:
>We can define recursive function in Python.
网友评论