InfinityCodeX

Unlock the power of Python, Data Science, Machine Learning, and Deep Learning with our comprehensive guides! Whether you're a beginner eager to dive into AI or an experienced professional looking to sharpen your skills, our blog offers easy-to-follow tutorials, insightful tips, and expert advice to fuel your AI career. Dive in today and start mastering the cutting-edge technologies shaping the future!

Basic Concepts of Python


Before directly diving into the coding part let us discuss few concepts which are essential & help us to understand further up coming concepts & ideas.

So lets list down the concepts that we are going to learn :

  1. Variables
  2. Datatypes
  3. Literals & Types of Literals
  4. Unicode Encoding
  5. Operators

1.) Variables :

A name that is assigned to the value is called a variable.

eg : 
a = 5 , b = 10,

cost = 500

avg = 5.9

val_1 = True , val_2 = False

s = "John"       

Variable Names

A variable can have a short name (like x and y) or a more descriptive name (age, cost, total_volume). 

Rules for Python variables:
  • 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.A variable is created the moment you first assign a value to it.

Now type IDLE at your search bar & open the python which you had installed here I had installed python 3.6 that's why it is showing me that and just click open.

Now you will see shell like that in which we can write code too.But i'll rather create new file & write my code in it.
 Now just click on File > New File or just click any where on the shell & press ( Ctrl + N ).

Now you will see an untitled file which is created. Now we are ready to goo.
Get ready guys because we are going to write our very first code.
Now just assign values to the variable we just created. You would be thinking what is print; print is nothing but it will print your output in the shell.
To run our code go to Run > Run module F5 or simply click F5.


Variables do not need to be declared with any particular type and can even change type after they have been set.


Which will give output :





Look guys for me this much knowledge is sufficient and which will surely help me in long run. If you want to know this concept in detail i'll suggest you to check out sites such as :

To know the concept in video format do checkout this youtube video which will help you to know this topic in a better way :



2.) Datatypes :
Python Data Types are used to define the type of a variable. 
Let's get started with types of variables.

Numeric 

A numeric value is any representation of data which has a numeric value. Python identifies three types of numbers:
  • Integer: Positive or negative whole numbers (without a fractional part)
  • eg : X = 5
  • Float: Any real number with a floating point representation in which a fractional component is denoted by a decimal symbol or scientific notation
  • eg : marks = 99.99

  • Complex number: A number with a real and imaginary component represented as x+yj. x and y are floats and j is -1(square root of -1 called an imaginary number)
  • eg : complex_num = 4 + 3j
Boolean
Data with one of two built-in values True or False. Notice that 'T' and 'F' are capital. true or false are not valid booleans and Python will throw an error for them.
Remember Python is an case sensitive language.




Sequence Type

A sequence is an ordered collection of similar or different data types. Python has the following built-in sequence data types:
  • String: A string value is a collection of one or more characters put in single, double or triple quotes. Strings are mutable


  • List : A list object is an ordered collection of one or more data items, not necessarily of the same type, put in square brackets. Lists are mutable.




  • Tuple: A Tuple object is an ordered collection of one or more data items, not necessarily of the same type, put in parentheses. Tuples are immutable.
  

Dictionary

A dictionary object is an unordered collection of data in a key:value pair form. A collection of such pairs is enclosed in curly brackets. 


To know the concept in video format do checkout this youtube video which will help you to know this topic in a better way :

Did you understood the topics which I mentioned above do comment below & share this blog with your friend & family.

No comments:

No Spamming and No Offensive Language

Powered by Blogger.