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
class | Attributes | |
---|---|---|
date | year, month, day | |
time | hour, minute, second, microsecond, tzinfo | |
datetime | year, month, day, hour, minute, second, microsecond, tzinfo |
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
mode | read | write | create | truncate | cursor position | |
---|---|---|---|---|---|---|
r | * | start | ||||
w | * | * | * | start | ||
a | * | * | end | |||
r+ | * | * | start | |||
w+ | * | * | * | * | start | |
a+ | * | * | * | end | ||
x | * | start |
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
method/keyword | parameters | uses | |
---|---|---|---|
open() | filename and open mode (optional) | create a file object by opening/creating the file in the specified read/write mode | |
with | - | use it together with open(); closes the file after the suite completes | |
read() | size (optional) | read the file up to the size specified if set | |
readline() | size (optional) | read a single line with a size limit if set | |
readlines() | size (optional) | create a list of the read lines with an optional size hint | |
for loop | - | iterate the lines of the file | |
write() | the string | write the string to the file that is opened with a certain writeable mode | |
writelines() | the list of strings | write the list of strings to the file that is opened with a certain writeable mode | |
close() | - | close the opened file |
We can make this file beautiful and searchable if this error is corrected: It looks like row 10 should actually have 6 columns, instead of 5. in line 9.
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
Number, Experiment, Array_Time, Set_Time, t_value, p_value | |
1, "Initialization Without Elements", 7.540121674537659, 7.916748523712158, -3.457562191664637, 0.003846372791488026 | |
2,"Initialization With Elements", 8.958488702774048, 24.988874793052673, -49.77387985600688, 3.71485625191658e-17 | |
3,"Iterate Elements", 337.66061067581177, 44.00688409805298, 21.476253166244224, 4.086700260362606e-12 | |
4,"Count Elements", 8.78673791885376, 8.702144026756287, 0.5112195802639851, 0.6171643091164576 | |
5,"Check If Empty", 9.673908352851868, 9.035870432853699, 3.3699231118055515, 0.004578823247822731 | |
6,"Check If Element Exists (When True)", 44.153839349746704, 9.419366717338562, 17.398721378711933, 7.04543940804122e-11 | |
7,"Check If Element Exists (When False)", 357.1058511734009, 9.227603673934937, 44.28782375256025, 1.8869990362188217e-16 | |
8,"Find Element Index (When Found)", 38.447365164756775, 9.576007723808289, 38.59760754000621, 1.2750267004908994e-15 | |
9,"Find Element Index (When nil)", 276.5122652053833, 9.49104130268097, 75. |
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
var comparisonRecords = [(String, Int, Double, Double)]() | |
let trials = 10 | |
func compareOperations(name: String, repeats: Int, arrayOperation: ()->(), setOperation: ()->()) { | |
for trial in 1...trials { | |
let arrayStartTime = CFAbsoluteTimeGetCurrent() | |
for _ in 1...repeats { | |
arrayOperation() | |
} | |
let arrayTimeInterval = (CFAbsoluteTimeGetCurrent() - arrayStartTime)*1000 |
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 pandas as pd | |
from scipy.stats import ttest_ind | |
with open('array_set.txt', 'r') as file: | |
data_text = file.read() | |
splitted = data_text.strip('[(').strip(')]').strip(')]\n').split('), (') | |
data_list = [] | |
for record in splitted: |
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
compareOperations(name: "Initialization Without Elements", repeats: 10000, arrayOperation: { | |
let _ : [Int] = [] | |
}) { | |
let _ : Set<Int> = [] | |
} | |
compareOperations(name: "Initialization With Elements", repeats: 10000, arrayOperation: { | |
let _ : [Int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] | |
}) { | |
let _ : Set<Int> = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] |
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
Element Type | Element Number | count == 0 | isEmpty | |
---|---|---|---|---|
Int | 0 | 92.98 | 78.63 | |
Int | 1 | 76.66 | 79.90 | |
Int | 10 | 76.92 | 78.67 | |
Int | 100 | 76.04 | 77.78 | |
Int | 1000 | 74.46 | 78.05 | |
Int | 10000 | 78.50 | 79.11 | |
Int | 100000 | 75.58 | 78.18 | |
Int | 1000000 | 75.15 | 77.57 | |
Int | 10000000 | 76.12 | 79.11 |
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 UIKit | |
var records = [(String, Double, Double)]() | |
func compareOperations(name: String, repeats: Int, operations: [()->()]) { | |
var record = (name, 0.0, 0.0) | |
for (index, opertion) in operations.enumerated() { | |
let startTime = CFAbsoluteTimeGetCurrent() | |
for _ in 1...repeats { | |
opertion() |
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
let articleURLs = [ | |
"https://medium.com/better-programming/10-awesome-javascript-libraries-for-front-end-developers-in-2020-d450b9ed66d1", | |
"https://medium.com/better-programming/d3-responsive-and-dynamic-visualizations-for-data-and-other-easy-recipes-68e37b451822", | |
"https://medium.com/better-programming/build-reusable-swiftui-component-libraries-with-the-swift-package-manager-23343681a8f3", | |
"https://medium.com/better-programming/my-one-tip-to-be-effective-at-learning-a-new-programming-language-45789bacf730", | |
"https://medium.com/better-programming/build-a-react-app-using-aws-amplify-in-simple-steps-part-3-12c1b7746450", | |
"https://medium.com/better-programming/convert-json-to-xlsx-file-in-javascript-e7611a975916", | |
"https://medium.com/better-programming/how-to-set-up-a-local-dynamodb-in-a-docker-container-and-perform-the-basic-putitem-getitem-38958237b968", | |
"https://medium.com/better-programming/introduction-to-waitress-a-wsgi-server-for-python-2-and-3-c77e20cb292b", | |
"https://m |