Python复习题总结

  1. What is CJKV?
CJKV. Initialism of Chinese, Japanese, Korean and 
Vietnamese: East Asian languages heavily influenced 
by the Chinese writing system and vocabulary.
  1. Who is Guido van Rossum?
Guido van Rossum is a noted Dutch computer programmer 
and author, better known for creating the ‘Python’ 
programming language that earned him the title of the 
"Benevolent Dictator for Life" (BDFL). He later stepped 
down as the “BDFL” of Python in July 2018.
  1. What does it mean for programs to be ‘portable’?
Portability, in relation to software, is a measure of 
how easily an application can be transferred from one 
computer environment to another.
  1. What are the two versions of Python?
Python2.x and Python3.x
  1. What character encoding should be used for Python programs?
UTF-8
  1. What is a comment? What are the two types of comment in Python?
''' ''' and #
There are two types of commenting features available 
in Python: These are single-line comments and 
multi-line comments. A single-line comment begins 
with a hash (#) symbol and is useful in mentioning 
that the whole line should be considered as a 
comment until the end of the line.
  1. What is the syntax of a Python variable name?
 A variable name must start with a letter or the 
 underscore character. A variable name cannot start 
 with a number. A variable name can only contain 
 alpha-numeric characters and underscores 
 (A-z, 0-9, and _ )
  1. What is Camel Case?
camelCase is a naming convention in which the 
first letter of each word in a compound word 
is capitalized, except for the first word. 
  1. What is the difference between a declaration (e.g. x = 1) and an assignment (e.g. x = 1 )?
A declaration has a variable and the value about it
Before assignment,variable was declared. 
  1. What is the difference between / and // ?
Such as: 16/2 = 8 and 16//2 = 4
  1. What is the difference between // and %?
Such as:16//2 = 4 and 16 % 2 = 0
  1. What does x ** 2 mean?
x** same as x*x
  1. What does x += 1 mean?
x+=1 same as x = x+1
  1. What is the largest integer in Python?
import sys;
sys.maxsize
9223372036854775807
  1. What is the longest string in Python?
Infinity
  1. In something like:
    university = “Northwest” + “University” +
    “1902”
    What is the purpose of the backslash \ ?
You can use \ to continue onto the next
line
  1. What does this do: ‘exchange rate is %3.1f’ % (9.09)
9.1
  1. What is the difference between “1902” and 1902 ?
"1902" is a string and 1902 is int
  1. What is type casting in Python? Give an example using the str() function
str(1902) = "1902"
  1. [ 18, 19, 20, 21, 22 ] [ -2 ]
21
  1. [ 18, 19, 20, 21, 22 ] [ 2:4 ]
[29,20]
  1. [ 18, 19, 20, 21, 22 ] [ -2:-5:-1 ]
[21,20,19]
  1. input( 'Please enter your name: ’ )
Please enter your name: 
  1. print( ‘a’, end = ‘’ ); print( ‘b’ )
'a''b'

  1. print( ‘a’, ‘b’, ‘c’, sep = ‘’ )
'a''b''c'
  1. What is difference between True and true?
Boolean.TRUE is a reference to an object of the class Boolean, while true is just a value of the primitive boolean type. 
  1. What is difference between elif and else in if statement?
elif same as else if 
  1. for x in [ ‘a’, ‘b’, ‘c’ ]:
    print( x )
 'a'
 'b'
 'c'
 
  1. for x in { ‘a’:1, ‘b’:2, ‘c’:3 }:
    print( x )
'a'
'b'
'c'

  1. for x, y in { ‘a’:1, ‘b’:2, ‘c’:3 }.items():
    print( x, y )
a 1
b 2
c 3

  1. range( 5 )
0,1,2,3,4
  1. range( 0, 5, 2 )
0 2 4
  1. range( 5, 0, -2 )
5 3 1
  1. range( 5, -1, -1 )
5 4 3 2 1 0 -1
  1. What does break do in a while loop
Break will kill the nearest/innermost loop 
  1. for x in range( 0, 4 ):
    print( x )
    if x == 1:
    continue
    print( ‘Last line’ )
0
Last line
1
2
Last line
3
Last line

  1. message1 = ‘Global Variable’
    def my_function():
    global message1 # This is the line which has changed
    message1 = ‘Local Variable’
    print( ‘\nInside the function:’ )
    print( message1, ‘\n’ )
Inside the function:
Local Variable 
38. def some_function( a, b, c=1, d=2, e=3 ):
39. def some_function( a, c=1, d=2, e=3, b ):        
40. def add_numbers( *num ):
        for i in num:
            print( i )
41. def print_member_age( **age ):
        for i, j in age.items():
            print( i, j )
42. 1. fargs
    2. *args
    3. **kwargs
43. import variable_num_params          !!!!!
    add_numbers( 1, 2, 3 )
44. path Environment Variable      
45. pythonpath Environment Variable
46. lab\myfile.txt      # what is the difference?
    c:\lab\myfile.txt
47. dir /b > files.txt
48. import os
    cwd = os.getcwd()
49. import os
    os.chdir( 'c:\\project' )
  1. print( ‘answer’, end = ‘’ )
'answer'
  1. print( ‘a’, ‘word’, sep = ‘’ )
'a''word'
52. f = open( filename, 'r' )
    msg = f.read( 10 )
53. tf = open( target_file, 'wb' )
54. 'Agile' software development
55. Stepwise Refinement software development
56. Space - Time Tradeoff
57. sys.maxsize   9223372036854775807
58. 0b11  0o11  ??  3  9
59. int(  '10', 2 )   2
60. hex( 17 )    0x11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值