Source-to-Source Compiler Quiz

PunctualModernism avatar
PunctualModernism
·
·
Download

Start Quiz

Study Flashcards

29 Questions

What is the purpose of the self parameter in a class method?

It refers to the current instance of the class and is used to access variables that belong to the class.

Which of the following is a valid way to access an object's property in Python?

Using the object name and the property name, e.g. p1.age.

How can you modify an object's property in Python?

By using the object name and the property name, e.g. p1.age = 40.

Which of the following is a valid way to delete an object in Python?

Using the del keyword, e.g. del p1.

What is the purpose of the __init__ method in a Python class?

It is used to initialize the object's properties when it is created.

What is the purpose of inheritance in Python?

It allows you to define a class that inherits all the methods and properties from another class.

What is the main function of a source-to-source compiler?

Translate source code from one programming language to another

What is characteristic of a program written in a High-Level Language (HLL)?

Contains preprocessor directives like #define and #include

Which stage does the pre-processor handle in a language processing system?

Removing #include directives and expanding #define directives

What is the main characteristic of Assembly Language?

Intermediate state between binary form and high-level language

What specifically does an assembler provide for a platform?

Conversion of assembly language into machine code specific to the platform

What distinguishes a transcompiler from other types of compilers?

Translates source code between different programming languages

What is the purpose of the eye() function in NumPy?

To create an identity matrix

What is the purpose of the k parameter in the eye() function?

It specifies the diagonal we require, with k > 0 meaning the diagonal above the main diagonal and k < 0 meaning the diagonal below the main diagonal

What is the purpose of the eval() function in Python?

To evaluate a string as a valid Python expression and execute it

What is the purpose of the swapcase() method in Python?

To convert all lowercase letters to uppercase and all uppercase letters to lowercase

What is the purpose of the join() method in Python?

To insert a specified character between the elements of an iterable and join them into a single string

What is the purpose of the partition() method in Python?

To search for a specified string and return a tuple containing three elements: the part before the specified string, the specified string, and the part after the specified string

What is a parent class?

The class being inherited from

What is a child class?

The class that inherits from another class

How do you create a child class that inherits from a parent class?

By sending the parent class as a parameter when creating the child class

What does the pass keyword do in a class definition?

It defines an empty class with no properties or methods

How do you add the __init__() function to a child class?

By defining the __init__() method in the child class

What is the purpose of the __init__() method in a class?

To create a new instance of the class

What is the purpose of the break statement in a loop?

To terminate the loop entirely, regardless of the condition

What does the continue statement do in a loop?

It skips the current iteration and moves to the next one

Which of the following is a valid example of a for loop in Python?

for x in [1, 2, 3, 4, 5]: print(x)

What is the main difference between a while loop and a for loop in Python?

A for loop is used for iterating over a sequence, while a while loop is used for conditional execution

What is printed by the following code?

fruits = ["apple", "banana", "cherry"] for x in fruits: if x == "banana": continue print(x)

apple cherry

Test your knowledge on source-to-source compilers, also known as transcompilers or transpilers, which translate code from one programming language to another. Explore language processing systems and the role of compilers in converting high-level languages to machine-understandable instructions.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free
Use Quizgecko on...
Browser
Browser