This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
admusing System; | |
using System.Data; | |
using System.Data.SqlClient; | |
namespace DataServices | |
{ | |
public class DataService : IDataService | |
{ | |
public string InsertData(string Name, String Email, string Message) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
sample_text = "My name is Ayub and I love Python".encode('utf-8') | |
sample_output = hashlib.md5(sample_text).hexdigest() | |
print(sample_text) | |
#sample_text: b'My name is Ayub and I love Python' | |
print(sample_output) | |
# sample_ouput: adf6af4969819ab07fa8349415707a67 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import sqlite3 | |
conn = sqlite3.connect('rosterdb.sqlite') | |
cur = conn.cursor() | |
# Do some setup | |
cur.executescript(''' | |
DROP TABLE IF EXISTS User; | |
DROP TABLE IF EXISTS Member; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 as cv | |
#Reading Images | |
# img = cv.imread('photos/kids.jpg') | |
# cv.imshow('Kids', img) | |
# cv.waitKey(0) | |
#Reading Videos | |
capture = cv.VideoCapture('video.mp4') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def toHex(dec): | |
digits = "0123456789ABCDEF" | |
x = (dec % 16) | |
rest = dec // 16 | |
if (rest == 0): | |
return digits[x] | |
return toHex(rest) + digits[x] | |
# numbers = [0, 11, 16, 32, 33, 41, 45, 678, 574893] | |
# for x in numbers: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To complete this assignment, you should use this API endpoint that has a static subset of the Google Data: | |
# http://py4e-data.dr-chuck.net/json? | |
# This API uses the same parameter (address) as the Google API. This API also has no rate limit so you can test as often as you like. | |
# If you visit the URL with no parameters, you get "No address..." response. | |
# To call the API, you need to include a key= parameter and provide the address that you are requesting as the address= parameter that | |
# is properly URL encoded using the urllib.parse.urlencode() function as shown in http://www.py4e.com/code3/geojson.py | |
# Make sure to check that your code is using the API endpoint is as shown above. | |
# Please run your program to find the place_id for this location: University of Akron | |
# Make sure to enter the name and case exactly as above and enter the place_id and your Python code below. Hint: The first seven characters of the place_id are "ChIJbye ..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def student_grade(name, grade): | |
# return "" | |
return "{} received {}% on the exam".format(name, grade) | |
print(student_grade("Reed", 80)) | |
print(student_grade("Paige", 92)) | |
print(student_grade("Jesse", 85)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
file = input("Import CSV file: " ) | |
with open(file, newline='') as csvfile: | |
reader = csv.DictReader(csvfile) | |
for row in reader: | |
print(row['Surname'], row['Other_Names'], row['Email'], row['Phone']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Data file url: http://py4e-data.dr-chuck.net/comments_1070214.xml | |
#VERSION 1: | |
import urllib.request | |
import xml.etree.ElementTree as ET | |
import ssl | |
# Ignore SSL certificate errors | |
ctx = ssl.create_default_context() | |
ctx.check_hostname = False | |
ctx.verify_mode = ssl.CERT_NONE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def initials(phrase): | |
words = phrase.split() | |
result = "" | |
for word in words: | |
result += word[0].upper() | |
return result | |
print(initials("Universal Serial Bus")) # Should be: USB | |
print(initials("local area network")) # Should be: LAN | |
print(initials("Operating system")) # Should be: OS |
NewerOlder