60 Questions
In programming, what is the syntax?
The set of legal structures and commands that can be used in a particular programming language.
What is the purpose of compiling in programming?
To translate the program into a form that the machine understands.
What does the Python interpreter provide?
An interactive environment to play with the language.
In programming, what is an expression?
A data value or set of operations to compute a value.
What does the function len(string) do?
Returns the number of characters in a string
What does the function ord(text) do?
Returns the ASCII value of the character
What does the function chr(number) do?
Converts a number into a string
What does the function str.lower(string) do?
Returns the lowercase version of a string
What is the output of the code: for c in 'booyah': print c ?
b o o y a h
What is the result of ord('b') - ord('a')?
1
What is the result of chr(99)?
c
What does the function raw_input() do?
Reads a string of text from user input
Which operator in Python computes the remainder from a division of integers?
%
Which function in Python converts a value to a floating point?
float()
What does the print statement do in Python?
Produces text output on the console
What does the input function do in Python?
Reads a number from user input and stores the result in a variable
What do variables in Python do?
Store values and can be used in expressions
What does the for loop in Python do?
Repeats a set of statements over a group of values
What does the range function in Python specify?
A range of integers
What do cumulative loops in Python do?
Compute a value that is initialized outside the loop
What does the if statement in Python do?
Executes a group of statements only if a certain condition is true
Which operator in Python performs integer division resulting in an integer quotient?
//
Which commands in Python are used for performing calculations?
abs(), ceil(), and log()
Which operator in Python manipulates real numbers?
/
Which of the following is true about Python dictionaries?
Dictionaries are mutable collections of key-value pairs.
What operations can be performed on Python sets?
Union, intersection, and difference
Which of the following is a mutable data type in Python?
Lists
What can be done with Python functions?
Assigned to variables, passed as parameters, and returned from other functions
What are lambda expressions in Python used for?
Creating anonymous functions
What do higher-order functions like map, filter, and reduce do in Python?
Process sequences based on given functions
What is true about parameters in Python functions?
They can have default values and can be called by name
What are modules in Python?
The highest level structures in Python with their own namespace
How are characters in a string numbered in Python?
With indexes starting at 0
What is true about strings in Python?
They are sequences of text characters
What operations can be performed on Python strings?
Handling strings, indexes, and special characters within strings
What are the properties of Python sets?
They contain unique elements and support set operations
Which loop in Python is suitable for indefinite loops?
while loop
What is the output of the code: print(3 == 5) in Python?
False
Which statement alters the flow of loops in Python?
pass
What does range(5) generate in Python?
a list of numbers from 0 to 4
Which data type in Python is immutable?
tuple
What is the syntax for string formatting in Python?
% operator
Which function is used to add an element to a list in Python?
append()
What is the result of len({1, 2, 3}) in Python?
3
Which operator is used for checking if a value is present in a dictionary in Python?
in
What is the output of the code: print('Python'[1:4]) in Python?
yth
What is the result of 7 / 3 in Python?
What does the continue statement do in Python?
skips the current iteration and continues with the next
Which loop in Python is suitable for indefinite loops?
while loop
What are the loop control statements used for altering the flow of loops in Python?
break, continue, pass
Which operator is used for combining logical expressions in Python?
&&
What does range(N) generate in Python?
a list of numbers from 0 to N-1
Which data type in Python is an immutable version of lists?
tuples
What is used for string formatting in Python?
format() function
Which statement is used to execute a group of statements based on a condition in Python?
if
Which of the following is a mutable data type in Python?
dictionaries
What does the 'not' logical operator do in Python?
negates the value
Which of the following is not a loop control statement in Python?
halt
Which of the following is an example of a complex number data type in Python?
2+3j
What is the property of an object in Python, not the variable?
Data type
Study Notes
Python Programming Basics
- Python supports conditional statements like if, elif, else for decision making in the program
- The while loop in Python executes a group of statements as long as a condition is true and is suitable for indefinite loops
- Logical expressions in Python use relational operators like ==, !=, <, >, etc., and can be combined with logical operators like and, or, not
- Loop control statements in Python include break, continue, and pass for altering the flow of loops
- Python has for loops for iterating through a list of values, and range(N) generates a list of numbers from 0 to N-1
- In Python, everything is an object, including functions and classes, and data type is a property of the object, not the variable
- Python supports different data types such as integers, long integers, floating-point numbers, complex numbers, and string literals
- String formatting in Python is similar to C's printf, using %s for converting objects to their string representation
- Python has data collection types like lists (ordered, mutable), sets (unordered, no duplicates), and dictionaries (pairs of values)
- Lists in Python are mutable and support various functions like append, insert, remove, pop, index, count, sort, and reverse for modifying content
- Tuples in Python are immutable versions of lists, and sets are unordered collections with no duplicates
- Python supports a wide range of data types and control structures for programming and data manipulation.
Test your knowledge of Python programming basics and overview with this quiz. Topics include data types, functions, conditional statements, loops, and data collection types.
Make Your Own Quizzes and Flashcards
Convert your notes into interactive study material.
Get started for free