filmov
tv
Array In Python | Python Tutorial in Hindi | Day 4 | Naveen Sir

Показать описание
Array In Python | Python Tutorial in Hindi | Day 4 | Naveen Sir
----------------------------------------------------------------------------------------------------
while :
repeat the task at any number of time..
syntax :
while text_expression:
body of statement;
rule :
1. variable start
2. condition
3. inc/dec
Example:
find the sum of first n natural number ?
Task :
input a number then find the sum of its digit ?
input : 123
output : 6
123 .............
3
12
2
1
1
0
123 // 10 . ................ 12
123 % 10 ........... 3
====================================================
Array in python....
* it is the collection of same type of data element..
* it used to handle the large volume of data..
* array element represanted by its index value...
* index value of array start from 0 to n-1 ,.... n is the size of array..
* we import array module... ( module is a library )
ex : 10,20,24,21
a= 10
b= 20
c=24
d=21
e = a+b+c+d
print(e)
let us suppose if i am having 5000 numbers ? then what to do ?
Example : 10,20,24,21
program : display all the odd numbers ?
from array import *
rno = array('i',[10,19,24,21])
for n in rno:
if n%2==1:
print(n)
display all the even numbers :
from array import *
rno = array('i',[10,19,24,21])
for n in rno:
if n%2==0:
print(n)
display the sum of all even number ?
from array import *
rno = array('i',[10,19,24,21,12,78,24,90,2,5,9])
sum = 0;
for n in rno:
if n%2==0:
sum = sum + n;
print(sum)
=== remove the data from array...
from array import *
rno = array('i',[10,19,24,21,12,78,24,90,2,5,9])
for n in rno:
print(n)
Tags :
python,python tutorial,python variables,operators in python,learn python,python operators,python programming,variables in python,python variables and data types,variables and data types python,python for beginners,python tutorial for beginners,python arithmetic operators,python comparison operators,python bitwise operators,bitwise operators in python,python assignment operators,variables and operators in python,operators,variable in python,variables,
python,python arrays,arrays in python,array in python,array,python numpy arrays,python array,array python,what is array in python,python programming,python tutorial,python arrays tutorial,arrays,arrays python,python numpy array,python array vs list,python array example,array in python index,python arrays explained,array list in python,arrays in python 3.7,arrays in python numpy,numpy arrays in python,array type codes in python
----------------------------------------------------------------------------------------------------
while :
repeat the task at any number of time..
syntax :
while text_expression:
body of statement;
rule :
1. variable start
2. condition
3. inc/dec
Example:
find the sum of first n natural number ?
Task :
input a number then find the sum of its digit ?
input : 123
output : 6
123 .............
3
12
2
1
1
0
123 // 10 . ................ 12
123 % 10 ........... 3
====================================================
Array in python....
* it is the collection of same type of data element..
* it used to handle the large volume of data..
* array element represanted by its index value...
* index value of array start from 0 to n-1 ,.... n is the size of array..
* we import array module... ( module is a library )
ex : 10,20,24,21
a= 10
b= 20
c=24
d=21
e = a+b+c+d
print(e)
let us suppose if i am having 5000 numbers ? then what to do ?
Example : 10,20,24,21
program : display all the odd numbers ?
from array import *
rno = array('i',[10,19,24,21])
for n in rno:
if n%2==1:
print(n)
display all the even numbers :
from array import *
rno = array('i',[10,19,24,21])
for n in rno:
if n%2==0:
print(n)
display the sum of all even number ?
from array import *
rno = array('i',[10,19,24,21,12,78,24,90,2,5,9])
sum = 0;
for n in rno:
if n%2==0:
sum = sum + n;
print(sum)
=== remove the data from array...
from array import *
rno = array('i',[10,19,24,21,12,78,24,90,2,5,9])
for n in rno:
print(n)
Tags :
python,python tutorial,python variables,operators in python,learn python,python operators,python programming,variables in python,python variables and data types,variables and data types python,python for beginners,python tutorial for beginners,python arithmetic operators,python comparison operators,python bitwise operators,bitwise operators in python,python assignment operators,variables and operators in python,operators,variable in python,variables,
python,python arrays,arrays in python,array in python,array,python numpy arrays,python array,array python,what is array in python,python programming,python tutorial,python arrays tutorial,arrays,arrays python,python numpy array,python array vs list,python array example,array in python index,python arrays explained,array list in python,arrays in python 3.7,arrays in python numpy,numpy arrays in python,array type codes in python