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
{ | |
"name": "ps_python_printing_file_contents", | |
"description": "", | |
"instructions": "Construct a program that opens up a file and prints out each line of the file", | |
"initial": "try:\n\tmyfile=open(filename, \"r\")\n\tlinenum=1\n\tfor line in myfile:\n\t\twords = line.split()\n\t\tword=words[2]\n\t\tprint(\"The third work in line\",linenum,\"is\",word)\n\t\tlinenum+=1\nexcept OSError:\n\tprint(\"Error reading the file.\")\n", | |
"vartests": "[{ initcode : \"class OSError():\n\tdef __init__(self,text):\n\t\tpass\nfile_opened = 'False'\nfilename = 'text.txt'\nclass MockFile:\n\tdef __init__(self):\n\t\tglobal file_opened\n\t\tfile_opened = 'True'\n\t\tself.content = ['Some','sample','text']\n\t\tself.counter = 0\n\tdef readline(self):\n\t\tif file_opened == 'False':\n\t\t\traise ValueError('I/O operation on closed file')\n\t\tif self.counter < len(self.content):\n\t\t\tline = self.content[self.counter] + '\\\n' \n\t\t\tself.counter = self.counter + 1\n\t\telse:\n\t\t\tline = ''\n\t\treturn line\n\t |
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
{"settings":{"code":"left","heapHeight":"80","stackHeight":"150","width":"800"},"init":[["setLine",1],["createFunction","range","range(a, b)",2,"-1"],["createOperator","%","lr"],["createOperator","==","lr"],["createOperator","and","l"],["createFunction","print","print(a, ...)",-1,"-1"],["createFrame"]],"steps":[["addFunction","range","0",2],["addValue","1","0/0/0","int"],["addValue","101","0/1/0","int"],["evaluateFunction","0"],["clearEvaluationArea_"],["_createIterator","i1","-1"],["_label","l1"],["_iterate","i1","@l2","@l3"],["_label","l2"],["takeNext","i1","0"],["assign","i"],["setLine",2],["addValueFromVariable","i","0"],["addOperator","%","1"],["addValue","5","2","int"],["evaluateOperator","1"],["addOperator","==","1"],["addValue","0","2","int"],["evaluateOperator","1"],["addOperator","and","1"],["evaluateOperator","1"],["_conditionalJump","@l8","@l9"],["_label","l8"],["removeElement_","0"],["addValueFromVariable","i","0"],["addOperator","%","1"],["addValue","7","2","int"],["evaluateOperator","1"],["addO |
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 OF TREES | |
if __name__ == '__main__': | |
fptr = open(os.environ['OUTPUT_PATH'], 'w') | |
edges = input().strip() | |
edges = edges.replace('{', '').replace('[', '').\ | |
replace('}]', '}, ').replace(']', '').split('}, ') | |
graph = {} | |
for edge in edges[:-1]: |
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
grid = [ | |
["1","1","1","1","0"], | |
["1","1","0","1","0"], | |
["1","1","0","0","0"], | |
["0","0","0","0","0"] | |
] | |
island = 0 | |
seen = set([]) | |
i = 0 | |
while i < len(grid): |
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 | |
import pingouin as pg | |
import researchpy as rp | |
import scipy.stats as stats | |
df = pd.read_csv('EduCHI_data_2019.csv', index_col=[0]) | |
violation_columns = ['Heuristic evaluation lab (violations)', | |
'401 evaluation lab (violations)', | |
'P1 Individual (violations)', |
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 | |
import pingouin as pg | |
from scipy import stats | |
df = pd.read_csv('EduCHI_data_2019.csv', index_col=[0]) | |
violation_columns = ['Heuristic evaluation lab (violations)', | |
'401 evaluation lab (violations)', |
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 argparse | |
import re | |
def compute_accuracy(filename): | |
language_re = r'udhr-([a-zA-Z0-9_]*)\.' | |
correct = 0 | |
total = 0 | |
f = open(filename, 'r') | |
for line in f.readlines()[1:]: |
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 matplotlib.pyplot as plt | |
import pandas as pd | |
import numpy as np | |
import re | |
ordered_responses = { | |
'Strongly Disagree': 0, | |
'Disagree': 1, | |
'Neutral': 2, | |
'Agree': 3, |
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 matplotlib.pyplot as plt | |
import numpy as np | |
import pandas as pd | |
import random | |
def create_x_values(): | |
values = [[0, 1, 2, 3, 4, 5], | |
[-0.0375, 1, 2, 3, 4, 5], | |
[-0.025, 0.9625, 2, 3, 4, 4.9625], | |
[0.025, 0.975, 1.9625, 3, 4, 5], |
NewerOlder