NEW
Font size
WorksheetsChuyên đề 1. Các kiến thức cơ bản_Python
Total questions: 59
Worksheet time: 30mins
Consider the following Python script.
When you click on the file using a Windows file explorer, the script executes but you are unable to see the output. How would you fix that?
D. There is nothing to output
E. None of the above
What is the output of the following code?
A. JamesJamesJamesJamesJamesJames
B. JamesJamesJamesJamesJames
C. JamesJamesJamesJames
D. JamesJamesJames
E. Error: invalid syntax
4 is 100 in binary and 11 is 1011. What is the output of the following bitwise operators?
A. 15
1
B. 14
1
C. 11
4
D. 15
2
E. 14
2
What is a correct syntax to output "Hello World" in Python?
A. echo("Hello World");
B. p("Hello World")
C. print("Hello World")
D. echo "Hello World"
E. None of the above
What is the value of “Hello”.upper().capitalize()?
A. “Hello”
B. “hello”
C. “HELLO”
D. Runtime Error
E. None of the above
What is the statement evaluates the same to the statement below?
A. print ( 2*27*4)
B. print ( 2*3*4)
C. print ( 2*3**4)
D. print ( 2*3*3*4)
E. None of the above
Which method can be used to replace parts of a string?
A. replaceString()
B. replace()
C. repl()
D. switch()
E. replaceStr()
Which of the following is False?
Which of the following operators has the highest precedence?
A. not
B. &
C. *
D. +
E. -
What is the output of the expression print(-18 // 4)?
A. -4
B. 4
C. -5
D. 5
E. None of the above
Which of the following statements is true?
A. Python is an interpreted language.
B. Python is a high-level programming language.
C. Python is an object-oriented language.
D. All of the above.
E. None of the above
What is output of:
A. foo\bar
baz
B. foo\\barnbaz
C. foo\bar\nbaz
D. foo\\bar\nbaz
E. None of the above
In the Python statement x = a + 5 - b:
A. operators, a statement
B. operands, an expression
C. operands, an equation
D. terms, a group
E. operators, an expression
Which of the following function checks that all characters of a string are in upper case?
A. join(seq)
B. en(string)
C. isupper()
D. ljust(width[, fillchar])
E. None of the above
What will be the output of the following Python code snippet if x = 1?
A. 4
B. 2
C. 1
D. 8
E. 10
Which of the following is correct?
A. Comments are for programmers for better understanding of the program.
B. Python Interpreter ignores comment.
C. You can write multi-line comments in Python using triple quotes, either ''' or """.
D. All of the above
E. None of the above
Consider you import a module (hello) into a Python script (script.py) that you are working
on. Simultaneously you realize that the module is missing a statement, so you update the
module. To make sure your current script imports these new changes in your Python
session, what do you need to do?
A. Import importlib and use reload to import the new changes into the module.
B. The Python interpreter will detect the updates in the module.
C. Import importlib and use reload to import the new changes into the module.
D. Do nothing
E. None of the above
Consider the following code;
After these are executed, what is the value of y?
A. 0
B. 1
C. True
D. False
E. None of the above
What is the output of the print() function call?
A. True
B. False
C. foo
D. bar
E. Syntax Error
What gets printed?
A. Foo
B. foo foo
C. foo 2
D. 2
E. An exception is thrown
What will be the value of x in the following Python expression?
A. 8
B. 4
C. 2
D. 1
E. None of the above
What gets printed assuming the user enters 'foo' at the prompt?
A. f
B. foo
C. Not a number
D. An exception is thrown
E. None of the above
What is the value of the following?
A. 72
B. 72, 101, 108, 108, 111
C. 108
D. 111
E. None of the above
What is the value of code?
A. 1.5
B. 0
C. “12.03-4.5”
D. Runtime Error
E. None of the above
A
B
C
D
E
Consider the following code,
A. True
B. False
C. Undetermined
D. Runtime Error
E. None of the above
Which of the following is not a built-in function?
A. ord()
B. hasattr()
C. callable()
D. nullable()
E. None of the above
Which of the following is False?
A
B
C
D
A
B
C
D
E
Python language was developed in what year?
A. 1985
B. 1820
C. 1991
D. 2001
E. 1979
What is a statement in programming?
A. Expresses an action to be carried out
B. Always returns results like expressions
C. Rules controlling how components in a program are combined
D. An instruction to perform a task, usually one word
E. None of the above
What is the output of the following code?
A. James
B. JamesJamesJamesJamesJamesJames
C. JamesJamesJamesJamesJames
D. Error: invalid syntax
E. None of the above
What output will the console show, if 15 and 30 are entered by the user?
A. Syntax error
B. The concatenation of the two numbers 1530
C. The sum of the two numbers 45
D. Compiler error
E. None of the above
What is the data type of print(type(0xFF))
A. number
B. hexint
C. hex
D. int
E. float
Which is the better statement if x+=1 is removed?
A. There is no difference
B. The loop is infinite
C. The print function is stopped
D. The output equals to 10
E. None of the above
Refer to the following code, which of the following statement is correct?
A. The code doesn’t have errors
B. The code shows unidentified syntax (semicolon)
C. Integer cannot add with float
D. The expression a + b does not have a left hand side operator
E. None of the above
What is the value of code?
A
B
C
D
E
A
B
C
D
E
A
B
C
D
E
A
B
C
D
E
A
B
C
D
E
A
B
C
D
A
B
C
D
A
B
C
D
A
B
C
D
Which method can be used to remove any whitespace from both the beginning and the
end of a string?
A. ptrim()
B. trim()
C. len()
D. strip()
E. None of the above
A
B
C
D
E
A
B
C
D
E
A
B
C
D
E
A
B
C
D
E
A
B
C
D
E
A
B
C
D
E
A
B
C
D
E
A
B
C
D
E
A
B
C
D
E
A
B
C
D
E
A
B
C
D
E
A
B
C
D
E
A
B
C
D
E
