Docsity

PYTHON PROGRAMMING EXAMINATION QUESTIONS AND CORRECT ANSWER WITH EXPLANATIONGRADED A+ ST, Exams of Programming Languages

Toggle sidebar
bg1
PYTHON PROGRAMMING EXAMINATION QUESTIONS
AND CORRECT ANSWER WITH EXPLANATIONGRADED A+
STUDY GUIDE SOUTHERN NEW HAMPSHIRE UNIVERSITY
1. Python is a:
A. Programming language
B. Hardware device
C. Browser
D. Operating system only
Answer: A
Rationale: Python is a high-level programming language.
2. Python was created by:
A. Guido van Rossum
B. Bill Gates
C. Elon Musk
D. James Gosling
Answer: A
Rationale: Guido van Rossum designed Python.
3. Python is known for being:
A. Easy to read and write
B. Machine-only language
C. Very complex only
D. Hardware-based
Answer: A
Rationale: Python has simple syntax.
4. A Python program is executed by:
A. Interpreter
B. Compiler only
C. CPU only
D. Browser
Answer: A
Rationale: Python is interpreted.
5. Python file extension is:
A. .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 EXPLANATIONGRADED A+ ST and more Exams Programming Languages in PDF only on Docsity!

PYTHON PROGRAMMING EXAMINATION QUESTIONS

AND CORRECT ANSWER WITH EXPLANATIONGRADED A+

STUDY GUIDE SOUTHERN NEW HAMPSHIRE UNIVERSITY

  1. Python is a: A. Programming language B. Hardware device C. Browser D. Operating system only Answer: A Rationale: Python is a high-level programming language.
  2. Python was created by: A. Guido van Rossum B. Bill Gates C. Elon Musk D. James Gosling Answer: A Rationale: Guido van Rossum designed Python.
  3. Python is known for being: A. Easy to read and write B. Machine-only language C. Very complex only D. Hardware-based Answer: A Rationale: Python has simple syntax.
  4. A Python program is executed by: A. Interpreter B. Compiler only C. CPU only D. Browser Answer: A Rationale: Python is interpreted.
  5. Python file extension is: A. .py

B. .exe C. .doc D. .html Answer: A Rationale: Python scripts use .py extension.

  1. print() function is used to: A. Display output B. Store data C. Take input D. Delete files Answer: A Rationale: It outputs text to screen.
  2. input() function is used to: A. Take user input B. Print output C. Delete data D. Run loops Answer: A Rationale: It reads user input.
  3. Variable in Python is: A. Storage location for data B. Constant value C. Function only D. File type Answer: A Rationale: It stores values.
  4. Python variable naming rules require: A. No spaces B. Must start with number C. Must use symbols only D. Must be uppercase only Answer: A Rationale: Names must follow syntax rules.
  5. Data type int represents: A. Whole numbers

B. Mutable list C. Function D. Variable only Answer: A Rationale: Tuples cannot be changed.

  1. Dictionary stores data as: A. Key-value pairs B. Single values C. Only numbers D. Only text Answer: A Rationale: Maps keys to values.
  2. Set is: A. Unordered unique collection B. Ordered list C. Function D. File Answer: A Rationale: No duplicates allowed.
  3. if statement is used for: A. Decision making B. Looping C. Printing D. Storing files Answer: A Rationale: Controls flow.
  4. else is used when: A. Condition is false B. Condition is true C. Loop ends D. Function starts Answer: A Rationale: Alternative condition.
  5. elif means: A. Else if condition

B. End loop C. Exit program D. Error handling Answer: A Rationale: Multiple conditions.

  1. for loop is used for: A. Iteration B. Decision making C. Printing only D. Deleting data Answer: A Rationale: Repetition over sequence.
  2. while loop runs: A. Until condition is false B. Once only C. Randomly D. Never Answer: A Rationale: Condition-based repetition.
  3. break statement: A. Stops loop B. Continues loop C. Starts loop D. Deletes variable Answer: A Rationale: Exits loop early.
  4. continue statement: A. Skips current iteration B. Stops program C. Ends function D. Deletes data Answer: A Rationale: Skips one cycle.
  5. function in Python is: A. Reusable block of code

B. Loop structure C. Variable type D. Error type Answer: A Rationale: Reusable code file.

  1. import is used to: A. Bring modules B. Delete files C. Run loops D. Stop program Answer: A Rationale: Load external code.
  2. built-in function example: A. len() B. myfunc() C. run() D. start() Answer: A Rationale: Predefined function.
  3. len() returns: A. Length of object B. Sum C. Error D. File size only Answer: A Rationale: Counts items.
  4. type() returns: A. Data type B. Value C. Length D. Error only Answer: A Rationale: Shows variable type.
  5. Python indentation is used for: A. Defining code blocks

B. Decoration C. Comments only D. Output formatting Answer: A Rationale: Structure of code.

  1. comment in Python starts with: A. # B. // C. D. * Answer: A Rationale: Used for notes.
  2. syntax error occurs when: A. Rule is broken B. Program runs fine C. Output is correct D. No code exists Answer: A Rationale: Invalid structure.
  3. exception is: A. Runtime error B. Syntax rule C. Variable type D. Loop type Answer: A Rationale: Execution error.
  4. try block is used for: A. Error handling B. Looping C. Printing D. Deleting data Answer: A Rationale: Handles exceptions.
  5. except block handles: A. Errors

B. Function name C. Variable type D. Module Answer: A Rationale: Object reference.

  1. inheritance means: A. Reusing class features B. Deleting class C. Creating variables D. Looping Answer: A Rationale: Code reuse.
  2. polymorphism means: A. Many forms B. One form C. No form D. Error handling Answer: A Rationale: Multiple behaviors.
  3. encapsulation means: A. Hiding data B. Showing everything C. Deleting data D. Looping Answer: A Rationale: Data protection.
  4. abstraction means: A. Hiding complexity B. Showing everything C. Error handling D. Printing only Answer: A Rationale: Simplification.
  5. list indexing starts at: A. 0

B. 1

C. - 1

D. 10

Answer: A Rationale: Zero-based indexing.

  1. negative indexing means: A. Counting from end B. Error indexing C. Random access D. Forward indexing Answer: A Rationale: Reverse access.
  2. slicing is used to: A. Extract part of sequence B. Delete file C. Run loop D. Print text only Answer: A Rationale: Subset extraction.
  3. append() is used to: A. Add item to list B. Remove item C. Sort list D. Copy file Answer: A Rationale: Adds element.
  4. remove() is used to: A. Delete item B. Add item C. Sort data D. Print data Answer: A Rationale: Removes element.
  5. pop() removes: A. Last item

B. Numbers C. Strings D. Lists Answer: A Rationale: Unique elements only.

  1. lambda function is: A. Anonymous function B. Loop C. Class D. Module Answer: A Rationale: Small unnamed function.
  2. map() is used to: A. Apply function to items B. Sort data C. Delete items D. Print only Answer: A Rationale: Functional programming.
  3. filter() is used to: A. Select items B. Add items C. Sort items D. Print items Answer: A Rationale: Conditional selection.
  4. reduce() is used to: A. Aggregate values B. Expand list C. Print data D. Delete data Answer: A Rationale: Combines elements.
  5. file handling is used to: A. Work with files

B. Run loops C. Create variables D. Print output only Answer: A Rationale: Data storage operations.

  1. open() function is used to: A. Open file B. Close program C. Run loop D. Create variable Answer: A Rationale: File access.
  2. read() method: A. Reads file content B. Writes file C. Deletes file D. Closes file Answer: A Rationale: Input from file.
  3. write() method: A. Writes to file B. Reads file C. Deletes file D. Opens file Answer: A Rationale: Output to file.
  4. close() is used to: A. Close file B. Open file C. Delete file D. Copy file Answer: A Rationale: Ends file access.
  5. mode "r" means: A. Read mode

B. Sorting data C. File handling D. Printing Answer: A Rationale: Generates randomness.

  1. randint() generates: A. Random integer B. Decimal only C. String only D. List only Answer: A Rationale: Integer random value.
  2. debugging means: A. Fixing errors B. Writing code C. Deleting programs D. Running system Answer: A Rationale: Error correction.
  3. IDE stands for: A. Integrated Development Environment B. Internal Data Engine C. Internet Data Entry D. Integrated Design Editor Answer: A Rationale: Coding environment.
  4. examples of IDEs include: A. PyCharm, VS Code B. Chrome, Firefox C. Excel, Word D. Windows, Linux Answer: A Rationale: Programming tools.
  5. compilation error happens: A. Before execution

B. After execution C. During runtime only D. Never Answer: A Rationale: Syntax checking stage.

  1. runtime error occurs: A. During execution B. Before coding C. During design only D. Never Answer: A Rationale: Execution phase error.
  2. logical error produces: A. Wrong output B. No program C. Compilation failure D. Hardware failure Answer: A Rationale: Incorrect logic.
  3. Python is case sensitive: A. Yes B. No C. Sometimes D. Only in files Answer: A Rationale: Case matters in syntax.
  4. indentation error occurs when: A. Spaces are incorrect B. Code is correct C. File is missing D. Internet fails Answer: A Rationale: Block structure issue.
  5. string concatenation means: A. Joining strings

B. Draw images only C. Avoid computation D. Only store files Answer: A Rationale: Core purpose of programming.