First Principles

team-member-1

Rishi Sapra

Technical Community leader, speaker, trainer and evangelist specialising in Power BI and Azure. Formally recognised by Microsoft as a Most Valuable Professional (MVP), Fast Track Recognised Solution Architect (FTRSA) and Microsoft Certified Trainer (MCT).

Tags:

Interpeter and compilers

What is a compiler and how does it differ from Interpreter?

To understand these two terms we need to understand what is a source code. Source Code is   software that contains instructions that the computer follows to execute a task.

The compiler translates this source code into a machine code. You might have heard of binary bits (1, ones, and 0, zeroes) that the CPU can process and understand. The program to be translated is written inside an editor. This process is known is called compilation.

An interpreter is a program which also converts a high-level programming language (like Python, PHP, Perl) into machine code. Although similar to a compiler, the way that code is executed is different for both. Unlike a compiler that simply converts the source code to machine code, an interpreter can be run directly as an executable program. Contrary to a compiler, it converts source code to machine code when the program is running. When we execute a source code, Python compiles it into a byte code.

The Python compiler package is a tool for analyzing Python source code and generating Python bytecode. The compiler contains libraries to generate an abstract syntax tree from Python source code and to generate Python bytecode from the tree. … It can be modified more easily than the built-in compiler.

Numerical Operators

Numerical operators

After understanding numerical data types (integer, float), we now like to introduce Numerical operators. As a modern programming language, Python can perform the most basic numerical operations. We list them below and encourage you to try them out in the console:

Name Operation Example Output comments
+ Addition 13  + 7 20
Subtraction 13 – 7 6
* Multiplication 13 * 7 91
/ Float Division 13 / 2 6.5
// Integer Division 13 // 7 1 13 can be divided only once without the number becoming a float
33 // 7 4 33 can be divided only four times without the number becoming a float
** Exponentation 2 **3
% Remainder 13 % 7 6 13 can be divided only once times without the number becoming a float, the remainder will be 6
33 // 7 33 can be divided only four times without the number becoming a float, the remainder will be 5

 

String operators

Apart from numeric operators, Python also has string operators:

Let’s say we have to two variables called: “a” and “b”

a = hello

b = world

putting in the console

a+b will give: helloworld

3 * b will give: worldworldworld

Why not try the following out in the console:

X = goodbye

Y = friend

What will be the output of

X + Y

2 * X

String Operators

String operators

Apart from numeric operators, Python also has string operators:

Let’s say we have to two variables called: “a” and “b”

a = hello

b = world

putting in the console

a+b will give: helloworld

3 * b will give: worldworldworld

Why not try the following out in the console:

X = goodbye

Y = friend

What will be the output of

X + Y

2 * X

print()

“print()” function

You will be seeing the “print” function quite often so it would be good to give some explanation about it from the start. We will be discussing functions more elaborately in [insert link here].

As the word “print” is followed by “()” it means that this is a function name. A function in Python does two things:

  • evaluate a value or more values
  • execute an action

Using the “print ()” function will evaluate the tasks within the brackets and then show the outcome on the screen.

Functions take arguments. This is what we put in the brackets. The “print()” function also takes argument in the brackets.

The arguments that print takes can be different data types. You will read more about data types here.

While we are at it, let’s introduce another interesting function: input().

The input() function reads a line/value/variable entered on a console by an input device such as a keyboard and convert it into a string. This can then be used for further calculation/processing.

Related Articles

Design a Data Model

Rishi Sapra
0

Power BI How to build a star schema. This topic looks at how to understand what structure of data tables you need, and how to model them using a star schema When data is imported into Power BI, the resulting data model sits at its heart. It drives the kind of analysis that can be… Continue reading Design a Data Model

Read More

Microsoft Fabric Key Concepts: Your Questions Answered!

Rishi Sapra
0
This series of blog posts covers the LDI Microsoft Fabric Syllabus and is also available in e-book format under LDI Content The series is split up into 4 blog posts: Microsoft Fabric Key Concepts (this post) Working with the Lakehouse and Data Warehouse (Coming soon!) Data Science and real-time analytics (Coming soon!) Building a semantic… Continue reading Microsoft Fabric Key Concepts: Your Questions Answered!
Read More

Synapse Delta Lakehouse and Power BI Enterprise Big Data Worked Example. Part 1: Start With the End in Mind

Rishi Sapra
1

Learn How to build an enterprise scale architecture with Synapse (Delta lakehouse) and Power BI working with 2.4 Billion rows of NYC Taxi Data!

This is part 1 of the Blog Post Series.

Read More

Leave a comment