January 15, 2019
#آموزش
نوشتن در فایل اکسل با پایتون
❇️ How to Write to a CSV File in Python
import csv
studentsdata= [["Jessica Wallens", 1987], ["Samantha Peters", 1988],
["Jessica Warren", 1990]]
with open ("Students.csv", "w", newline="") as file:
writedata= csv.writer(file)
writedata.writerows(studentsdata)
🔰 @raspberry_python
نوشتن در فایل اکسل با پایتون
❇️ How to Write to a CSV File in Python
import csv
studentsdata= [["Jessica Wallens", 1987], ["Samantha Peters", 1988],
["Jessica Warren", 1990]]
with open ("Students.csv", "w", newline="") as file:
writedata= csv.writer(file)
writedata.writerows(studentsdata)
🔰 @raspberry_python
January 16, 2019
January 17, 2019
January 17, 2019
January 17, 2019
January 17, 2019
January 17, 2019
January 17, 2019
January 17, 2019
January 17, 2019
January 18, 2019
January 18, 2019
January 18, 2019
#آموزش دستورات شرطی در پایتون
Condition in python
age = 12
name = 'ali'
language = 'python'
if age == 12:
print("age is 12")
#output : age is 12
if age is 12:
print("age is 12")
#output : age is 12
if age == 13:
print("ok")
else:
print("less than 13")
#output : less than 13
if age == 14:
print("age is 14")
elif age == 13:
print("age is 13")
elif age == 12:
print("age is 12")
if age is not 13:
print("age is not 13")
#output : age is not 13
if age >= 12:
print("ok")
#output : ok
if age <= 13:
print("ok")
#output : ok
if age != 12:
print("ok")
# مخالف ۱۲ نیستشage اجرا نمیشه چون
if name == 'ali' and age == 13:
print("welcome1")
#output : اجرا نمیشه چون شرط دوم برقرار نشده و شرط کلی اجرا نمیشه
if name == 'ali' or age == 13:
print("welcome")
#output : welcome
if name == 'ali' and (age == 14 or language == 'python'):
print("welcome")
#output : welcome
lst = [1, 2, 3 , 4]
if 1 in lst:
print("1 is in list")
#output : 1 is in list
if 6 not in lst:
print("6 is not in list")
#output : 6 is not in list
age = 14
name = "ali" if age < 12 else "mohammad"
print(name)
#output : mohammad
name = 'ali' if age < 15 else 'vali' if age > 15 else 'hasan'
print(name)
#output : ali
if age < 15:
if age > 15:
print('vali')
else:
print('ali')
else:
print('hasan')
#output : ali
name = (('vali', 'mohammad')[age > 12])
print(name)
#output : mohammad
name = (('vali', 'mohammad')[True])
print(name)
#output : mohammad
name = ('hasan', 'babak')[age < 12]
print(name)
#output : hasan
name = ('hasan', 'babak')[False]
#output : hasan
name = (age < 20) and 'ali' or 'hasan'
print(name)
#output : ali
name = {True: 'ali', False: 'hasan'}[age < 20]
print(name)
#output : ali
name = ((age > 20) and ['ali'] or ['hasan'])
print(name)
#output : ['hasan']
name = ((age > 20) and ['ali'] or ['hasan'])[0]
print(name)
#output : hasan
x = [True, True, False]
if any(x):
print("At least one True")
#output : At least one True
if all(x):
print("Not one False")
else:
print("At least one False")
#ouput : At least one False
if any(x) and not all(x):
print("At least one True and one False")
#output : At least one True and one False
با تشکر از مهندس
@milad_ghasemi_1
❇️ @raspberry_python
Condition in python
age = 12
name = 'ali'
language = 'python'
if age == 12:
print("age is 12")
#output : age is 12
if age is 12:
print("age is 12")
#output : age is 12
if age == 13:
print("ok")
else:
print("less than 13")
#output : less than 13
if age == 14:
print("age is 14")
elif age == 13:
print("age is 13")
elif age == 12:
print("age is 12")
if age is not 13:
print("age is not 13")
#output : age is not 13
if age >= 12:
print("ok")
#output : ok
if age <= 13:
print("ok")
#output : ok
if age != 12:
print("ok")
# مخالف ۱۲ نیستشage اجرا نمیشه چون
if name == 'ali' and age == 13:
print("welcome1")
#output : اجرا نمیشه چون شرط دوم برقرار نشده و شرط کلی اجرا نمیشه
if name == 'ali' or age == 13:
print("welcome")
#output : welcome
if name == 'ali' and (age == 14 or language == 'python'):
print("welcome")
#output : welcome
lst = [1, 2, 3 , 4]
if 1 in lst:
print("1 is in list")
#output : 1 is in list
if 6 not in lst:
print("6 is not in list")
#output : 6 is not in list
age = 14
name = "ali" if age < 12 else "mohammad"
print(name)
#output : mohammad
name = 'ali' if age < 15 else 'vali' if age > 15 else 'hasan'
print(name)
#output : ali
if age < 15:
if age > 15:
print('vali')
else:
print('ali')
else:
print('hasan')
#output : ali
name = (('vali', 'mohammad')[age > 12])
print(name)
#output : mohammad
name = (('vali', 'mohammad')[True])
print(name)
#output : mohammad
name = ('hasan', 'babak')[age < 12]
print(name)
#output : hasan
name = ('hasan', 'babak')[False]
#output : hasan
name = (age < 20) and 'ali' or 'hasan'
print(name)
#output : ali
name = {True: 'ali', False: 'hasan'}[age < 20]
print(name)
#output : ali
name = ((age > 20) and ['ali'] or ['hasan'])
print(name)
#output : ['hasan']
name = ((age > 20) and ['ali'] or ['hasan'])[0]
print(name)
#output : hasan
x = [True, True, False]
if any(x):
print("At least one True")
#output : At least one True
if all(x):
print("Not one False")
else:
print("At least one False")
#ouput : At least one False
if any(x) and not all(x):
print("At least one True and one False")
#output : At least one True and one False
با تشکر از مهندس
@milad_ghasemi_1
❇️ @raspberry_python
January 18, 2019
January 20, 2019
https://medium.com/conectric-networks/playing-with-raspberry-pi-traffic-lights-with-a-finite-state-machine-c6dc7035b8a1
🔰 @raspberry_python
🔰 @raspberry_python
Medium
Playing with Raspberry Pi: Traffic Lights with a Finite State Machine
This is the third article in our series where we’re playing with the Low Voltage Labs LED Traffic Lights using Python on the Raspberry Pi…
January 20, 2019
January 20, 2019
https://blog.hackster.io/protect-your-credit-card-by-building-a-skimmer-detector-with-a-raspberry-pi-f670f94ffcb2
🔰 @raspberry_python
🔰 @raspberry_python
Hackster.io
Protect Your Credit Card By Building a Skimmer Detector with a Raspberry Pi
Credit card skimmers are so effective because they’re very simple. Usually, they’re small modules that are connected to the magnetic stripe…
January 20, 2019
https://blog.hackster.io/the-zerophone-a-linux-smartphone-powered-by-the-raspberry-pi-zero-286f36a25fd4
🔰 @raspberry_python
🔰 @raspberry_python
Hackster.io
The ZeroPhone, a Linux Smartphone Powered by the Raspberry Pi Zero
We took a look at early prototypes of the ZeroPhone by Arsenij Pichugin back in January 2017 when the hardware was in a far less mature…
January 20, 2019