top of page
Search
Writer's pictureHarshit Sharma

INTRODUCTION TO PYTHON.

PYTHON:It is a high level programming language with applications to compute artificial intelligence ,computing ,data science and web programming.It is really very popular and an open source platform.The python program using just some basic syntax similar to somewhat of c++ is used to run the code directly with the interface of the python which is similar to a command prompt.Python relies on indentation, using white space, to define scope; such as the scope of loops, functions and classes. Other programming languages often use curly-brackets for this purpose.


The two types of modes in Python are

  1. Interactive mode :The interactive mode enables perform various tasks:

If we want to print a simple message say hello world we just need to type a message in the interface as follow:

Example:>>>print(‘Hello world’)

Simple Operations: We can also perform simple operations directly in the python interface without writing a long code but just with writing the desired statement.

Example: >>>2+2

RESULT: 4

We can perform any print statement printing a statement or any addition subtraction or multiplication but even we can use it to give a exponentian operation by using two asterisk signs

>>>2**5

RESULT: 32

We can also very easily perform string concentration in python by just using a + sign in between the string we need to combine

>>>”Spam”+”eggs”

Spameggs

Strings can also be multiplied on the number of times we want to multiple the strings

>>>print(“spam,”*3)

Spamspamspam


Variable: A variable allows to store a value assigning a name to it which can be used in program later.For example in making a game we can stores points of the game in variable

To assign a value just define the name of variable and equal to sign and value.

Variable name can have letters,numbers and underscore and cannot start with numbers.

A variable name must start with a letter or the underscore character.

A variable name cannot start with a number.

A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )

Variable names are case-sensitive (age, Age and AGE are three different variables)

Unlike other programming languages, Python has no command for declaring a variable.


Getting the Data Type

You can get the data type of any object by using the type() function:

1 view0 comments

Recent Posts

See All

Comments


Post: Blog2_Post
bottom of page