embedded system,Arduino,Raspberry pi,ARM7,MM32,STM32,PIC and Python,Django,Datascience and web development
Monday, March 23, 2020
even or odd using python language
list_of_numbers=[1,2,3,4,5,6]
for number in list_of_numbers:
if number%2==0:
print(number,"is even")
else :
print(number,"is odd")
print("end of the code")
output:
for number in list_of_numbers:
if number%2==0:
print(number,"is even")
else :
print(number,"is odd")
print("end of the code")
output:
1 is odd 2 is even 3 is odd 4 is even 5 is odd 6 is even end of the code
tuple in python
n=input("enter a comma separated number:")
l=n.split(",")
t=tuple(l)
print("l=",l,"t=",t)
print(type(l),"\n",type(t))
output:
enter a comma separated number:2,3,4,5
l= ['2', '3', '4', '5'] t= ('2', '3', '4', '5')
<class 'list'>
<class 'tuple'>
l=n.split(",")
t=tuple(l)
print("l=",l,"t=",t)
print(type(l),"\n",type(t))
output:
enter a comma separated number:2,3,4,5
l= ['2', '3', '4', '5'] t= ('2', '3', '4', '5')
<class 'list'>
<class 'tuple'>
dictionary in python
n=int(input("enter a number:"))
d=dict()
for i in range(1,n+1):
#print("i=",i)
d[i]=i*i
print(d)
output:
enter a number:5
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
d=dict()
for i in range(1,n+1):
#print("i=",i)
d[i]=i*i
print(d)
output:
enter a number:5
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
Subscribe to:
Posts (Atom)
-
After doing different projects on different micro controller i started working with Quectel EC25 driver( 4g LTE) and mc60 and m66. EC2...
-
this is the post explains about the how to connect the arduino with the servo motor. mainly servo motor having 3 pins 1.5v supply 2.gnd...