Skip to main content

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

Popular posts from this blog

mcq for civil engineer

Civil Engineering MCQs 1. prthvee kee vakrata ke kaaran truti aur apavartan ka upayog karake theek kiya jaana hai (a) = 0.0136 D² (b) = 0.0673 D² (c) = 0.0785 D² (d) = 0.0112 D² 2. kisee bhavan ka skraip mooly lagabhag ho sakata hai nirmaan kee kul laagat ka ____ pratishat. (a) 5% (b) 1% (c) 10% (d) 7% 3.saamaany kaanch ko _____ ke roop mein jaana jaata hai. (a) Potash lead glass (b) Soda-lime glass (c) Bottle glass (d) Borosilicate glass 4.chinaee mein koee katautee nahin kee jaatee hai (a) Opening each upto 10000 sq. cm ( b) Opening each upto 1000 sq. cm (c) Opening each upto 1500 sq. cm (d) Opening each upto 1800 sq. cm 5.leses ko pratirodh ke adheen kiya jaata hai a_____ ka anuprasth aparoopan. (a) 2.8% of axial force in the member (b) 2.75% of axial force in the member (c) 2.5% of axial force in the member (d) 2.25% of axial force in the member 6.kis prakaar ke kan mein svayan kee saphaee sabase kam hotee hai veg? (a) Fine gravel (b) Fine clay and silt (c) Coarse sand (d) Fine san

Core Python Programming, 3ed: Covers fundamentals to advanced topics like OOPS, Exceptions, Data structures, Files, Threads, Net

  Core Python Programming, 3ed: Covers fundamentals to advanced topics like OOPS, Exceptions, Data structures, Files, Threads, Net This book covers all concepts in simple and easy to understand English. It helps to build logic, which becomes a stepping stone for programming. Hundreds of solved programs help students of different universities do well in their examinations and job interviews. It works like a handy reference to the Software professionals in their programming. Every chapter is supplemented with ‘Points to Remember’ to recap and retain the subject.