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

AutoCad Basic Commands

  Learning basic commands  with AutoCA    ✅DRAWING LINES IN AUTOCAD try using the line command again, but instead of picking points in the drawing area with the mouse as you did before, this time enter X and Y coordinates for each point using the keyboard. to see how follow these steps: Ribbon :Draw > Line Menu browser :Draw > Line Roolbar :Draw > Line Toool palettes :Draw > Line command :LINE or  L COPY command  This command is used  to copying sketched objects Ribbon :Draw > Copy Menu browser :Draw > Copy Roolbar :Draw >Copy Toool palettes :Draw >Copy command : COPY MOVE command  This command is used  to Moving sketched objects Ribbon :Draw > Move Menu browser :Draw > Move Roolbar :Draw > Move Toool palettes :Draw > Move command : Move

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...