What do you want to save?
Add Code snippet
New code examples
-
Python 2022-02-26 21:05:01
write in multiple files python
fn = open("path of input file.txt","r") fnew = fn.read() fs = fnew.split('\n') for value in fs: f = [open("path of output file to write.txt" %i,'w') for i in range(len(list_of_files))] f.write(value) f.close() Add solution -
Python 2022-02-25 20:05:04
kitty's calculations on a tree hackerrank solution
from collections import Counter, defaultdict MOD = 10**9 + 7 def read_row(): return (int(x) for x in input().split()) def mul(x, y): return (x * y) % MOD def add(*args): return sum(args) % MOD def sub(x, y): return (x - y) % MOD n, q... Add solution -
Python 2022-02-25 11:40:03
compute confusion matrix using python
import numpy as np currentDataClass = [1, 3, 3, 2, 5, 5, 3, 2, 1, 4, 3, 2, 1, 1, 2] predictedClass = [1, 2, 3, 4, 2, 3, 3, 2, 1, 2, 3, 1, 5, 1, 1] def comp_confmat(actual, predicted): classes = np.unique(actual) # extract the different classes ... Add solution -
Python 2022-02-24 19:45:12
record and store audio in pythn
import pyaudio import wave chunk = 1024 # Record in chunks of 1024 samples sample_format = pyaudio.paInt16 # 16 bits per sample channels = 2 fs = 44100 # Record at 44100 samples per second seconds = 3 filename = "output.wav" p = pyaudio.PyA... Add solution -
Python 2022-02-23 03:20:02
2d array python
matrix = [input().split() for i in range(no_of_rows)] # if only row is given and the number of coloumn has to be decide by user matrix= [[input() for j in range(no_of_cols)] for i in range(no_of_rows)] # if both row and coloumn has been taken as input fro... Add solution
Best helpers
Ranking is empty