python tutorial for free learn || python intro

Python tutorial


python

 

Python intro: 

Python is a popular programming language. It was created by Guido van Rossum and released in 1991.

 



Python comment : single line comment - #

                                   : multiline comment - ‘’’   ‘’’


Python variables : Variables are containers for storing data values


Creating Variables: x=5

Multiple Variables : x,y,z=23,56,76


Global variables:

Global variables are created outside of a function .It can be used by everyone, both inside of functions and outside.


Variable Names

  •  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)



Python data types: variables can hold values and every value has a data-type. Python is a dynamically typed language . python provides us the type () function, which returns the type of the variable. Print (type(x))

The data types defined in python are 

  1. Number

  • Complex

  • Float

  • Integer

2. Sequence type

  • tuple

  • List

  • String

3. Dictionary


4.Boolean


5.Set



Python Numbers

Complex : 

Complex numbers are imaginary part that blowe

x=5+3j

Float :

Float number is positive or negative or decimals.

x=23.32


Integer : 

Integer number  is a whole number, positive or negative, without decimals. x=1254

Type casting :x=2 # int

y= 2.5 # float

Z = 5j # complex

b= float(x)

C= complex(y)



2. Sequence type


Strings: 


 x= “ Hello world ”

 Multi strings : 

x= “‘ hello 

Python ’’’




Method Description

capitalize() the first character to upper case converted

 x = "hello, and welcome to python "

 y =x.capitalize()

 print(y)

-----------------------

 Out put 

 Hello, and welcome to pythom

 


casefold() The string into lower case converted

 x = "Hello, and Welcome to Python "

 y = x.casefold()

 print(y)

-----------------

Out put

hello, and welcome to python

 


center() Returns a center string

x = "Hello, and Welcome to Python "

y = x.center(40,”0”)

 

print(y)

--------------

Out put

00000Hello, and welcome to python00000 


count() The string specified  value  is a returns

x = "Hello, and Welcome to Python "

y = x.count(“and”,0,20)(value, start,end)

print(y)    

---------

out put 

 1


encode() Encoded version returns in a  string

x = "Hello, and Welcome to Python "

y=x.encode()

print(y)

-------------------

B’Hello, and welcome to python’



endswith() Returns true if the string ends with the specified value

x = "Hello, and Welcome to Python "

y=x.endswith(‘n’)

print(y)

----------------

ture

 

 

Comments