Docsity

PYTHON PROGRAMMING EXAMINATION QUESTIONS AND CORRECT ANSWER WITH EXPLANATION GRADED A+ S, Exams of Programming Languages

Toggle sidebar
bg1
PYTHON PROGRAMMING EXAMINATION QUESTIONS
AND CORRECT ANSWER WITH EXPLANATION GRADED
A+ STUDY GUIDE SOUTHERN NEW HAMPSHIRE
UNIVERSITY
1. Python is:
A. Hardware language
B. High-level programming language
C. Database system
D. Operating system
Answer: B
Rationale: Python is a high-level programming language.
2. Python was created by:
A. Bill Gates
B. Guido van Rossum
C. Elon Musk
D. James Gosling
Answer: B
Rationale: Python was developed by Guido van Rossum.
3. Python is:
A. Compiled only
B. Interpreted language
C. Machine code
D. Assembly only
Answer: B
Rationale: Python executes line by line.
4. Python file extension is:
A. .java
B. .py
C. .exe
D. .cpp
Answer: B
Rationale: Python source files use .py.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Partial preview of the text

Download PYTHON PROGRAMMING EXAMINATION QUESTIONS AND CORRECT ANSWER WITH EXPLANATION GRADED A+ S and more Exams Programming Languages in PDF only on Docsity!

PYTHON PROGRAMMING EXAMINATION QUESTIONS

AND CORRECT ANSWER WITH EXPLANATION GRADED

A+ STUDY GUIDE SOUTHERN NEW HAMPSHIRE

UNIVERSITY

  1. Python is: A. Hardware language B. High-level programming language C. Database system D. Operating system Answer: B Rationale: Python is a high-level programming language.
  2. Python was created by: A. Bill Gates B. Guido van Rossum C. Elon Musk D. James Gosling Answer: B Rationale: Python was developed by Guido van Rossum.
  3. Python is: A. Compiled only B. Interpreted language C. Machine code D. Assembly only Answer: B Rationale: Python executes line by line.
  4. Python file extension is: A. .java B. .py C. .exe D. .cpp Answer: B Rationale: Python source files use .py.
  1. print() function is used for: A. Input B. Output C. Looping D. Deleting Answer: B Rationale: Displays output.
  2. input() function is used for: A. Output B. User input C. Deleting files D. Looping Answer: B Rationale: Reads user input.
  3. Variable in Python is: A. Fixed value B. Storage for data C. Function only D. OS component Answer: B Rationale: Holds data values.
  4. Python is case-sensitive: A. False B. True C. Sometimes D. Never Answer: B Rationale: Upper/lowercase matters.
  5. Comments in Python start with: A. // B. # C. /* */ D. $$ Answer: B Rationale: # is comment symbol.
  1. List in Python is: A. Immutable B. Ordered and changeable collection C. Single value D. Integer only Answer: B Rationale: Mutable collection.
  2. Tuple is: A. Changeable list B. Immutable collection C. Function D. Variable Answer: B Rationale: Cannot be changed.
  3. Dictionary stores data in: A. List form B. Key-value pairs C. Numbers only D. Strings only Answer: B Rationale: Key-value structure.
  4. Set is: A. Ordered collection B. Unordered unique items C. Fixed array D. Function Answer: B Rationale: No duplicates.
  5. len() function returns: A. Data type B. Length of object C. Sum D. Average Answer: B Rationale: Counts items.
  1. type() function shows: A. Size B. Data type C. Value D. Error Answer: B Rationale: Identifies type.
  2. Arithmetic operator + means: A. Subtraction B. Addition C. Division D. Modulus Answer: B Rationale: Adds values.
  3. ** operator means: A. Multiply B. Power C. Divide D. Add Answer: B Rationale: Exponentiation.
  4. // operator means: A. Division B. Floor division C. Addition D. Modulus Answer: B Rationale: Integer division.
  5. % operator is: A. Power B. Modulus C. Add D. Multiply Answer: B Rationale: Remainder.
  1. FOR loop is used when: A. Unknown iterations B. Known iterations C. No repetition D. Input only Answer: B Rationale: Fixed loop count.
  2. WHILE loop runs while: A. False condition B. Condition is true C. Program ends D. Input only Answer: B Rationale: Condition-based loop.
  3. Infinite loop is: A. Loop that never ends B. Single run C. Error D. Function Answer: A Rationale: Continuous loop.
  4. break statement: A. Continues loop B. Stops loop C. Skips program D. Deletes code Answer: B Rationale: Exits loop.
  5. continue statement: A. Stops loop B. Skips current iteration C. Ends program D. Deletes variable Answer: B Rationale: Skip step.
  1. Function in Python is: A. Variable B. Reusable block of code C. Loop D. OS Answer: B Rationale: Code reuse.
  2. def keyword is used to: A. Delete function B. Define function C. Call function D. Stop program Answer: B Rationale: Function creation.
  3. return keyword: A. Input B. Sends value back C. Loop D. Print Answer: B Rationale: Function output.
  4. Parameter is: A. Output B. Input to function C. Variable type D. Loop Answer: B Rationale: Function input.
  5. Argument is: A. Function name B. Value passed to function C. Loop D. Output Answer: B Rationale: Actual value.

D. Loop Answer: B Rationale: Real entity.

  1. init method is: A. Destructor B. Constructor C. Loop D. Variable Answer: B Rationale: Initializes object.
  2. self keyword refers to: A. Class B. Current object C. Function D. Loop Answer: B Rationale: Object reference.
  3. Inheritance allows: A. Code deletion B. Reuse of class features C. Looping D. Input only Answer: B Rationale: Code reuse.
  4. Encapsulation means: A. Open data B. Hiding data C. Deleting data D. Printing data Answer: B Rationale: Data protection.
  5. Polymorphism means: A. One form B. Many forms C. No form

D. Variable only Answer: B Rationale: Multiple behaviors.

  1. Abstraction means: A. Showing details B. Hiding complexity C. Printing data D. Looping Answer: B Rationale: Simplification.
  2. try block is used for: A. Loops B. Error handling C. Printing D. Input Answer: B Rationale: Exception handling.
  3. except block handles: A. Success B. Errors C. Loops D. Variables Answer: B Rationale: Catches errors.
  4. finally block always runs: A. False B. True C. Sometimes D. Never Answer: B Rationale: Always executes.
  5. Import keyword is used to: A. Delete modules B. Use external libraries C. Run loops

D. Adds items Answer: B Rationale: Ordering.

  1. string.upper() converts to: A. Lowercase B. Uppercase C. Number D. Boolean Answer: B Rationale: Capital letters.
  2. string.lower() converts to: A. Uppercase B. Lowercase C. Number D. List Answer: B Rationale: Small letters.
  3. slicing is used to: A. Cut strings/lists B. Delete files C. Compile code D. Loop program Answer: A Rationale: Extract parts.
  4. index() returns: A. Length B. Position of element C. Sum D. Type Answer: B Rationale: Element position.
  5. pop() removes: A. First item always B. Last item by default C. All items

D. None Answer: B Rationale: Removes element.

  1. dictionary keys are: A. Unique B. Duplicate allowed C. Ordered always D. Numeric only Answer: A Rationale: Unique identifiers.
  2. values() returns: A. Keys B. Dictionary values C. Errors D. Types Answer: B Rationale: Data values.
  3. items() returns: A. Keys only B. Key-value pairs C. Errors D. Lists only Answer: B Rationale: Full pairs.
  4. len(dictionary) returns: A. Values B. Number of keys C. Errors D. Size only Answer: B Rationale: Key count.
  5. file open mode "r" means: A. Write B. Read C. Delete

D. Loop Answer: B Rationale: Runtime error.

  1. indentation in Python is used for: A. Decoration B. Code structure C. Output D. Input Answer: B Rationale: Block definition.
  2. Python uses indentation instead of: A. Brackets B. Variables C. Functions D. OS Answer: A Rationale: No curly braces.
  3. indentation error means: A. Hardware issue B. Wrong spacing C. Internet error D. OS crash Answer: B Rationale: Formatting error.
  4. module is: A. Full program B. Reusable code file C. Hardware D. OS Answer: B Rationale: Code library.
  5. package is: A. Single function B. Collection of modules C. Variable

D. Loop Answer: B Rationale: Module grouping.

  1. pip is used for: A. Hardware setup B. Installing Python packages C. Writing code D. Running OS Answer: B Rationale: Package manager.
  2. print formatting uses: A. % operator or f-strings B. Loops C. Functions only D. OS commands Answer: A Rationale: Output formatting.
  3. f-string starts with: A. f"" B. $"" C. #"" D. @"" Answer: A Rationale: Modern formatting.
  4. Python supports: A. Only OOP B. OOP, procedural, functional C. Hardware only D. Networking only Answer: B Rationale: Multiple paradigms.
  5. map() function is used for: A. Looping manually B. Applying function to all items C. Deleting data

D. Installing software Answer: B Rationale: Error correction.

  1. main advantage of Python is: A. Difficult syntax B. Simple and readable C. Low usage D. Hardware dependency Answer: B Rationale: Easy to learn.