Flashcards: Python Basics and Math Functions — 36 cards

All cards

1Question

What does the print() function display in Python output?

Answer

Text, numbers, and evaluated expressions.

2Question

Which quote styles can Python strings use?

Answer

Single, double, or triple quotes.

3Question

What can triple-quoted strings do that single or double quotes cannot?

Answer

Span multiple lines.

4Question

What does the escape sequence \n do inside a string?

Answer

Inserts a line break.

5Question

What is the result of the expression "python"*4?

Answer

The string repeated four times.

6Question

What does the built-in function abs() return?

Answer

The absolute value of a number.

7Question

What does pow(a,b) calculate?

Answer

The value of a raised to the power of b.

8Question

What does round(number,digits) do when digits is omitted?

Answer

Rounds the number to the nearest integer.

9Question

What does round(number,digits) do when digits is specified?

Answer

Rounds the number to the given decimal places.

10Question

What does ceil() return for a number?

Answer

The smallest integer greater than or equal to the number.

11Question

What does floor() return for a number?

Answer

The largest integer less than or equal to the number.

12Question

What does the factorial function return for an integer n?

Answer

The product of all positive integers from 1 to n.

13Question

What is the value of 5! (factorial of 5)?

Answer

120

14Question

What does 'import math' do in Python?

Answer

It loads the math module for use with the math. prefix.

15Question

How does 'from math import factorial, pi, log2' affect name usage?

Answer

It allows using factorial, pi, and log2 without the math. prefix.

16Question

What does 'import math as M' do?

Answer

It assigns the alias M to the math module.

17Question

How do you call square root using the alias M after 'import math as M'?

Answer

By calling M.sqrt(25).

18Question

What does 'from math import sqrt as jazr' do?

Answer

It imports sqrt under the local alias jazr.

19Question

How do you compute the square root of 25 using the alias jazr?

Answer

By calling jazr(25), which returns 5.

20Question

How does a compiler process code compared to an interpreter?

Answer

A compiler processes the whole program before execution, an interpreter processes line by line.

21Question

Which commands run Python files in Visual Studio Code?

Answer

Run Python File and Run Without Debugging (Ctrl+F5) run Python files.

22Question

How can you open the integrated terminal in Visual Studio Code?

Answer

Through View → Terminal or with Ctrl+ backtick.

23Question

How do you launch a Python file from the integrated terminal?

Answer

By typing python filename or py filename.

24Question

What is a Python library?

Answer

A collection of ready-made code providing reusable functions or tools for a purpose.

25Question

Which Python library is used for data manipulation?

Answer

Pandas is used for data manipulation.

26Question

Which Python library is used for numerical calculations?

Answer

NumPy is used for numerical calculations.

27Question

Which Python library is used for data visualization?

Answer

Matplotlib is used for data visualization.

28Question

Which Python library is used for machine learning?

Answer

Scikit-learn is used for machine learning.

29Question

Which Python library is used for web development?

Answer

Django is used for web development.

30Question

Name a Python library associated with deep learning.

Answer

Keras is associated with deep learning.

31Question

Name two other Python libraries linked to deep learning besides Keras.

Answer

TensorFlow and PyTorch are linked to deep learning.

32Question

How do you calculate the perimeter of a square with side length 5?

Answer

Multiply 4 by 5 to get 20 units.

33Question

What formula calculates the area of a square with side length 5?

Answer

Square the side length: 5 squared equals 25 square units.

34Question

How is the circumference of a circle with radius 5 calculated?

Answer

Use 2π times 5 to find the circumference.

35Question

What formula calculates the area of a circle with radius 5?

Answer

Multiply π by 5 squared to get the area.

36Question

How does the course demonstrate printing a patterned shape with asterisks?

Answer

By placing asterisks and line breaks inside strings passed to print().

Test yourself with the quiz

Test your knowledge with 13 questions on Python Basics and Math Functions.

1. What does Python display when it executes `print(2+5)`?

2. Which type of Python string can contain line breaks directly within its delimiters?

Take the quiz →

Read the revision sheet

Review the complete course in the revision sheet for Python Basics and Math Functions.

See revision sheet →

Similar courses

Create your own flashcards

Import your course and AI generates flashcards in 30 seconds.

Flashcard generator