50 Short Python code samples (for social media posts)
Project detail
We want you to collect or make a collection of Python programming language short sample code lines.
Goal :
We want to use the code samples to post them on social media as engaging posts
Requirements:
– You should deliver for us a document with python codes and a text describing their job
– You should deliver at least 50 code samples
– The code samples should be short (a maximum of 7 lines per code sample)
– The code samples collection should include variety of programming topics and python trick
– Try your best to show the power of python and its simplicity of doing things
Examples on code samples that we have :
– ********** How to remove a file with Python **********
import os
if os.path.exists(“demofile.txt”):
os.remove(“demofile.txt”)
else:
print(“The file does not exist”)
– ********** How to read a text file with python **********
f = open(“your_text_file.txt”, “r”)
print(f.read())
– ********** How to print a specific month calendar with python ? **********
import calendar
yy = 2014 # year
mm = 11 # month
# display the calendar
print(calendar.month(yy, mm))
-********** How to make HTTP request with python ? **********
import requests
result = requests.get(“https://www.freelancer.com”)
print(result.text)