blob_id large_string | repo_name large_string | path large_string | src_encoding large_string | length_bytes int64 | score float64 | int_score int64 | detected_licenses large list | license_type large_string | text string | download_success bool |
|---|---|---|---|---|---|---|---|---|---|---|
ba00057a88501d34a46af2f0245fc0b5ca27eced | DV512/nopecommerce | /testCases/test_SearchCustomerByName.py | UTF-8 | 1,818 | 2.796875 | 3 | [] | no_license | import pytest
import time
from Utilities.readProperties import ReadConfig
from Utilities.CustomLogger import LogGen
from pageObjects.LoginPage import LoginPage
from pageObjects.AddCustomerPage import AddCustomers
from pageObjects.SearchCustomer import SearchCustomer
class Test_SearchCustomerByName_005:
baseURL = R... | true |
1a83105d634743bcab100c0920170fc09d01ae78 | Madhav-Somanath/LeetCode | /June/30-WordSearchII.py | UTF-8 | 2,479 | 3.8125 | 4 | [] | no_license | """
Given a 2D board and a list of words from the dictionary, find all words in the board.
Each word must be constructed from letters of sequentially adjacent cell,
where "adjacent" cells are those horizontally or vertically neighboring.
The same letter cell may not be used more than once in a word.
"""
# SOLUTION
d... | true |
715422b7056c76cbb1e7522b9b15d468d7c555d0 | wangmengyu/pythontutorial27 | /ch05/list_queue.py | UTF-8 | 322 | 3.609375 | 4 | [] | no_license | # -*- coding: utf-8 -*
# 把list当作队列使用,先进先出
# 使用collections.deque可以快速在首尾两端插入和删除
from collections import deque
queue = deque(["Eric", "John", "Michael"])
queue.append("Terry")
queue.append("Graham")
print queue.popleft()
print queue
print queue.popleft()
print queue
| true |
0bd8716a10b6c7051dd5a2f5ee08e2022e9d752e | cxf78/- | /1607104242袁宇/CrossValidation.py | UTF-8 | 1,281 | 2.75 | 3 | [] | no_license | import numpy as np
import random
from Knn import Knn
# 用于计算准确度
def caculate_accuracy(predictRsl,origiRsl):
dominator=len(predictRsl)
numerator=0
for i in range(dominator):
if predictRsl[i] == origiRsl[i]:
numerator+=1
accuracy=numerator/dominator
return accuracy
#... | true |
7f3ce10bddeb16bdd5e0184efd3ad41ebaa14e90 | pedromxavier/covid | /api_lib/progress.py | UTF-8 | 3,856 | 3.21875 | 3 | [] | no_license | from time import perf_counter as clock
from time import sleep
import multiprocessing as mp
import _thread as thread
class Progress:
__slots__ = (
'text', '__lapse', '__total', '__lock', '__done', '_done',
'__start_time', '__last_length', '__finished',
)
STEPS = 20
def __init__(self, ... | true |
408fb791053ba9d60b0d1674cf7df4c50be5b314 | upul/WhiteBoard | /algorithm/elements/first_non_reporting.py | UTF-8 | 509 | 3.609375 | 4 | [] | no_license | from collections import defaultdict
def first_non_repeating_char(string):
char_map = defaultdict(int)
for c in string:
char_map[c] += 1
for key in char_map.keys():
if char_map[key] == 1:
return key
return None
if __name__ == '__main__':
assert first_non_repeating_char... | true |
a6e43f76e05a611a62db2983e8692bf20f2e0e06 | brandle26/Learning | /Section 7 - Wokrking with data part 3/Lec 46 - Cross Tabulation/Cross_Tabulation.py | UTF-8 | 371 | 3.046875 | 3 | [] | no_license | import pandas as pd
import numpy as np
from pandas import Series,DataFrame
from io import StringIO
data="""\
Sample Animal Intelligence
1 Dog Smart
2 Dog Smart
3 Cat Dumb
4 Cat Dumb
5 Dog Dumb
6 Cat Smart"""
dframe=pd.read_table(StringIO(data),sep="\s+")
print(dframe)
print("="*50)
pd.crossta... | true |
3f1cad9ab9e9c39379e25d79c3b9cd4555221148 | ludmilai/markov_model | /fail_recover_graph.py | UTF-8 | 7,456 | 3.578125 | 4 | [] | no_license | """
The Markov states model of fail-recovery.
Given the state graph it calculates the exact solution
for the mean time to first failure (MTTFF)
and asymptotic estimation in symbolic form.
"""
from sympy import Matrix, zeros, factor
from sympy.core.numbers import Zero, One
from collections import namedtuple, defaultdic... | true |
591449a8429e684e561840eb2da71a726a9468a5 | sgdy3/computer-vision | /his_equal.py | UTF-8 | 1,464 | 2.875 | 3 | [] | no_license | import cv2
import numpy as np
import matplotlib.pyplot as plt
import datetime
img = cv2.imread(r'E:\python trial\python now\test\source\s1\10.png',0)
old_time1=datetime.datetime.now()
lut = np.zeros(256, dtype = img.dtype )#创建空的查找表
hist,bins = np.histogram(img.flat,256,[0,256]) #得到灰度分布列表
cdf = hist.cumsu... | true |
412f69ddb97d31443229956dc85d625ebd9908fc | theguyoverthere/CMU15-112-Spring17 | /src/Week4/1D Lists/Creating Lists/Empty List.py | UTF-8 | 138 | 3.828125 | 4 | [] | no_license | print("Two standard ways to create an empty list:")
a = []
b = list()
print(type(a), len(a), a)
print(type(b), len(b), b)
print(a == b)
| true |
e961eb18b124ea389958d46dd23674ce9df2514b | bohongbobo/draft-GUI | /MV/combinedRun.py | UTF-8 | 881 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env python3
import machineVision as mv
import camera as c
import objects as o
# CONSTANTS
#//////////////////////////////////////////////////////////////////////////////#
## Cameras ##
webcam = c.Camera(fps = 30, res = [1280, 720], video = 0) #Testing webcam
vehicle = c.Camera(fps = 60, res = [1280, 720],... | true |
90df0ff56a24439599eaae6495dc0b1fe19e068e | GSKryachko/CipherBreaker | /Modules/encryptor.py | UTF-8 | 507 | 3.421875 | 3 | [] | no_license | from Modules.alphabets import Alphabet
class Encryptor:
def __init__(self, cipher, alphabet=Alphabet.EN.value):
self.cipher = cipher
self.alphabet = alphabet
@staticmethod
def replace(text, cipher):
new_text = []
for i in text:
if i.lower() in cipher:
... | true |
6d8c270a9c1581663ad022aee1907d5d9451d149 | k1c/Facebook-User-Predictions | /datasets/generate_synthetic_data.py | UTF-8 | 2,800 | 2.609375 | 3 | [] | no_license | import pathlib
import random
import shutil
import uuid
from typing import List
import pandas as pd
def generate_relations_dir(user_ids: List[str], num_relations: int):
random_like_ids = [46688639082 + i for i in range(10)]
user_relations = {
user_id: [random.choice(random_like_ids) for _ in range(nu... | true |
a959056f8a6fd7d0cefbe2b19aef0a0597410490 | heyheycel/advent-of-code | /2017/code_day5.py | UTF-8 | 679 | 3.25 | 3 | [] | no_license | instructions = []
with open('day5_input.txt') as f:
for num in f:
instructions.append(int(num))
address = 0
counter = 0
#print(instructions)
while address<len(instructions):
next = address+instructions[address]
instructions[address] = instructions[address] + 1
address = next
counter =counter+1
print... | true |
af99fda5e2108f53eaf1cb1076a43f88525195da | ankjainur11/LB_python | /f2.py | UTF-8 | 30 | 2.65625 | 3 | [] | no_license | a=1
b=2
c=3
d=a+b+c
Print (d)
| true |
e008e43f5c2267e674368dbf02e46f0b7eb307e6 | vinayakumarvs/repo | /gdrive/image.py | UTF-8 | 1,085 | 3.0625 | 3 | [] | no_license | from ..imports import *
def replace_slice(input_: tf.Tensor, replacement, begin) -> tf.Tensor:
"""
replace slice. Randomly cuts a h by w whole in the image, and fill the whole with given pixels.
:param input_: Input image.
:param replacement: replacement pixels
:param begin: pixel from where the r... | true |
f2ccc9c44c381d94f6ed64003f3ae45928d9f053 | dockerizeme/dockerizeme | /hard-gists/2172888/snippet.py | UTF-8 | 707 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | from django.core.files.temp import NamedTemporaryFile
def save_image_from_url(self):
"""
Save remote images from url to image field.
Requires python-requests
"""
r = requests.get(self.image_url)
if r.status_code == 200:
img_temp = NamedTemporaryFile(delete=T... | true |
b9fcb3782915aae168004a26d63c829a51ae0ed6 | B2SIC/python_playground | /Data Structure/collections/collections01.py | UTF-8 | 967 | 3.984375 | 4 | [] | no_license | # Collections Counter
# 컨테이너에 동일한 값의 자료가 몇 개인지를 파악하는데 사용하는 객체
import collections
print(collections.Counter(['aa', 'cc', 'dd', 'aa', 'bb', 'ee']))
print(collections.Counter({"가": 3, "나": 2, "다": 4}))
print(collections.Counter(a=2, b=4, c=1))
container = collections.Counter()
print(container)
container.update("aabcde... | true |
2deeb9be8946d9db480dc0cc489651de957c9488 | Muratozturknl/7.hafta-odevler | /week07_passwordcoding.py | UTF-8 | 1,786 | 3.5 | 4 | [] | no_license | import time
print('Simple Encryption, Please Choose A Transaction')
coding = {
"A":"K",
"a":"k",
"B":"I",
"b":"i",
"C":"P",
"c":"p",
"Ç":"R",
"ç":"r",
"D":"H",
"d":"h",
"E":"İ",
"e":"İ",
"F":"G",
"f":"g",
"G":"F",
"g":"f",
"Ğ":"Ö",
"ğ":"ö",
"H":"D",
"h":"d",
"I":"B",
"i":"b",
"İ":"E",
"İ":"e",
"J":"S",
"j":"s",
"K... | true |
9d46a3d1d643cf1bf25fd0094e95fe5de5c153df | aksvarun007/OpenCV | /optimal_face_tracking.py | UTF-8 | 1,704 | 2.578125 | 3 | [] | no_license | import cv2
import cv2.cv as cv
import numpy as np
def camshift_tracking(img1, img2, bb):
hsv = cv2.cvtColor(img1, cv.CV_BGR2HSV)
mask = cv2.inRange(hsv, np.array((0., 60., 32.)), np.array((180., 255., 255.)))
x0, y0, w, h = bb
x1 = x0 + w -1
y1 = y0 + h -1
hsv_roi = ... | true |
8740802320235e0d3d1e76588ff91b7eb4710dcf | elishaayinla/pythonProject | /main.py | UTF-8 | 875 | 3.765625 | 4 | [] | no_license | # this is a program that calculates the total score for a students result
# when line 16 is in line 14 it says "this code is unreachable"
# Line 16 displays before the RETRUN code in line 13, WHY? It is supposed to be the reverse
#Enter first test score
#Enter exam score
test = 30
def total_scores(score_int):
if... | true |
36baa804a1727e4006eb92469a149a03349e055c | Lomzem/lomzem-python | /youtube-dl.py | UTF-8 | 1,153 | 2.71875 | 3 | [] | no_license | import os
import pyperclip
import sys
youtube_url = pyperclip.paste()
arguments = sys.argv
# By default, youtube-dl will extract a single video
EXTRACT_AUDIO = True
SINGLE_OR_PLAYLIST = 'single'
for arg in arguments[1:]:
if arg == 'help':
print('Current Options: "single", "playlist", "video", "audio"... | true |
f67f5979b54329ef7dfb229298c69aebf417d442 | meleslilijing/LearningPythonInHardWay | /ex33.py | UTF-8 | 291 | 4.09375 | 4 | [] | no_license | #__coding:utf-8__
''' while-loop '''
def doWhile(n):
i = 0
while i < n:
print "At the top i is %d" % i
numbers.append(i)
i = i +1
print "Numbers now: ", numbers
print "At the bottom i is %d" % i
numbers = []
doWhile(3)
print "The numbers: "
for num in numbers:
print num
| true |
68282c01e8d1698a1be477aeac060a529cba1cb2 | andressl91/ArduinoProjects | /weatherstation/server/server.py | UTF-8 | 5,594 | 2.59375 | 3 | [] | no_license | import socket
import time
import logging
from typing import List, Dict
from pathlib import Path
import shyft.api as sa
from squealer.sql_table_tools import DataTableTools
from squealer.sqlite_session import SqliteSession
## Set log to show in terminal
def get_white_list():
"""White list servers"""
return ... | true |
f791ae21f713c1fdf19f100262ef64815af745dd | DRMPN/PythonCode | /CS50/ProblemSet6/mario/more/mario.py | UTF-8 | 490 | 3.875 | 4 | [] | no_license | # Print double pyramid of height N in terminal
from cs50 import get_int
# ensure that input is in range of (0,8]
while True:
height = get_int("Height: ")
if height > 0 and height <= 8:
break
# produce pyramid
for i in range(height):
# build left part of the pyramid
print(' ' * (height - (i + ... | true |
587aafdeac42ee1e1c046aed0eac56d08d89c749 | Serghom/TheMarketRush | /vkToken.py | UTF-8 | 838 | 2.921875 | 3 | [
"MIT"
] | permissive | from selenium import webdriver
import re
def getTokenFromWeb():
driver = webdriver.Chrome(executable_path='driver/chromedriver.exe')
driver.get("https://vk.cc/8GIRRY")
url = ''
done = True
while done:
result = re.match(r'http://api.vk.com/blank', driver.current_url)
if result is not... | true |
e1b9a32a0bb4fa756a024b63ae35fb58f7c45977 | WagnerSF10/curso_intensivo_python | /python_work/chapter6/pessoas.py | UTF-8 | 327 | 3.203125 | 3 | [] | no_license | p1 = {
'nome': 'wagner',
'nascimento': '15 de fev',
'profissao': 'desenvolvedor',
'pais': 'brasil',
}
p2 = {
'nome': 'rose',
'nascimento': '15 de mar',
'cidade': 'campinas',
}
p3 = {
'nome': 'alyson',
'profissao': 'advogado',
}
people = [p1,p2,p3]
for pessoa in people:
print(... | true |
790b59000bc7db80c5438f059e284bfdfff7674e | 0000duck/feature_constraints_controller | /feature_constraints_utils/arm_sensor_response.py | UTF-8 | 3,242 | 2.8125 | 3 | [] | no_license | #!/usr/bin/python
from math import *
import time
import roslib; roslib.load_manifest('motionControl')
import yarp
import yarp_tools
class JoystickTrigger:
def __init__(self, btn_index, callback=(lambda : 0)):
self.btn_index = btn_index
self.callback = callback
import roslib
roslib.load_manifest... | true |
1b875425bec5766c2818b7a61656cb9033b853f4 | anna-marie-vos/Python-introduction | /Tut1/dateNTime.py | UTF-8 | 322 | 3.234375 | 3 | [] | no_license | import datetime
import time
now = datetime.datetime.now()
formatted = now.strftime("%Y-%M-%D-%H-%M")
# yesterday = datetime.datetime(2017-04,15,10,15,0)
# difference = now - yesterday
print(formatted)
lst = []
for i in range(5):
lst.append(datetime.datetime.now())
time.sleep(1) #creates a time delay
print(lst... | true |
a4513faffc172175c9a560b632aa65d0249e45b7 | sqrhussain/structure-in-gnn | /src/data/add_2hop_edges.py | UTF-8 | 1,560 | 2.765625 | 3 | [
"MIT"
] | permissive | import networkx as nx
import numpy as np
import os
def add_2hop_edges(dataset,percentage=1,seed=0):
# assert percentage <= 100 and percentage >= 0
assert type(percentage) is int
fin = f'data/graphs/processed/{dataset}/{dataset}.cites'
g = nx.read_edgelist(fin,create_using=nx.DiGraph())
ug =... | true |
12b251d42669a66c5a1d8a53b647217fcfedbd84 | helloprasanna/python | /Map Filter Reduce (1).py | UTF-8 | 770 | 3.890625 | 4 | [
"MIT"
] | permissive |
# coding: utf-8
# Demonstrates the Map function
# which applies function to list of values
# In[4]:
import math
def area(n):
return math.pi * (n**2)
radii=[3,4,5,8,10,38]
print(radii)
print(list(map(area,radii)))
# ### Applying Map
# In[5]:
li = [('a',1),('b',2),('c',3)]
conv = lambda data: (data... | true |
bb4354fbaa32de08d2573b61010698df1972c2b0 | katms/Minesweeper | /minesweeper.py | UTF-8 | 15,415 | 3.125 | 3 | [] | no_license | import tkinter
import tkinter.messagebox
import random
import timer
class Minesweeper(tkinter.Frame):
COLUMNS = range(8, 41)
ROWS = range(8, 21)
MIN_MINES = 10
TIMER_WIDTH = 3
COUNT_WIDTH = 4
# difficulties
EASY = (10,10,10)
MEDIUM = (16,16,40)
HARD = (30,15,80)
@staticmetho... | true |
5098724ef9bac74afb321626d865c771725f3c9d | rhoposit/tacotron2 | /generate_training_list.py | UTF-8 | 1,515 | 2.578125 | 3 | [
"BSD-3-Clause"
] | permissive | # ==============================================================================
# Copyright (c) 2018, Yamagishi Laboratory, National Institute of Informatics
# Author: Yusuke Yasuda (yasuda@nii.ac.jp)
# All rights reserved.
# ==============================================================================
"""Generate ... | true |
0828df7794ae2c23e9390a6ff8dc2cbd6d9f2bfb | kellietay/play | /LeetCode/05.02-CasinoOwner.py | UTF-8 | 2,755 | 4.4375 | 4 | [] | no_license | """
Using a deck of cards, the player draws exactly N cards.
Player wins if the sum of the values of all cards drawn is equal to W.
For a given deck, compute N and W that minimize the probability of winning,
such that the probability of winning is still > 0
Example:
Cards = {"1","1","2"}
N=1, W=1 gives 2/3 chance
N... | true |
d38685aaff93073ac0957e743adc014a869d071c | SergeyKorobenkov/softlogic-test | /api/models.py | UTF-8 | 558 | 2.515625 | 3 | [] | no_license | from django.db import models
import uuid
# Create your models here.
class Person(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
first_name = models.CharField(max_length=50) # имя
last_name = models.CharField(max_length=50) # фамилия
vector = models.TextFiel... | true |
6458528ec8f584df1ab4d71037151409620c21c0 | Aasthaengg/IBMdataset | /Python_codes/p02939/s878652557.py | UTF-8 | 143 | 3.3125 | 3 | [] | no_license | s = input()
i = 0
lst = [""]
for j in range(1,len(s)+1):
if lst[-1] != s[i:j]:
lst.append(s[i:j])
i = j
print(len(lst)-1) | true |
b25cdf499da54b3e816eaeabfffa07e23c8ec00f | GustavoChichanoski/Covid3D | /src/data/generator.py | UTF-8 | 2,093 | 2.828125 | 3 | [] | no_license | from pathlib import Path
from src.images.read_image import read
from typing import Any, List, Tuple, Union
from tensorflow.python.keras.utils.data_utils import Sequence
import numpy as np
class Generator(Sequence):
def __init__(
self,
data: Tuple[str, str],
batch_size: int = 32,
d... | true |
eb09a92ad9f568abc619c5687d85a4daaa34b32e | tade82/aoc2020 | /2.py | UTF-8 | 540 | 3.296875 | 3 | [] | no_license | def read_lines(file_name):
with open(file_name) as fp:
return fp.readlines()
if __name__ == '__main__':
lines = read_lines("2.txt")
total = 0
for line in lines:
policy = line.split(':')[0]
num = policy.split(" ")[0]
p1 = int(num.split('-')[0])
p2 = int(num.split... | true |
912877a327fe29fe19ce28dcd3ef67306bb6e604 | jtruong04/cavity-coupling | /python/src/Noise.py | UTF-8 | 3,860 | 3.515625 | 4 | [] | no_license | import numpy as np
class Noise:
def __init__(self):
pass
def __call__(self, t, w1, w2):
return self.J(t, w1, w2)
# ==============================================================
#
# The following functions need to be overloaded when inherited
#
# Simply define S(w). Nor... | true |
b3ecff2497be9b41fcad21b7125061f1378350ee | BeranekP/advent_of_code | /2/dayTwo.py | UTF-8 | 1,312 | 3.234375 | 3 | [] | no_license | import csv
import random
import math
with open('input.txt') as csv_file:
programInstructions = list(csv.reader(csv_file, delimiter=','))[0]
programInstructions = [int(instr) for instr in programInstructions]
processedInstr = programInstructions[:]
def processInstructions(processedInstr):
processedInstr2 = p... | true |
c9d3ff8600af24d6d6e553a43d4b9df995ca13f1 | Fonglulu/Multigrid | /Spline1.py | UTF-8 | 14,855 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 2 18:07:40 2018
@author: shilu
The test is aiming to approximate a two dimensional surface
"""
import numpy as np
from numpy import pi, sin, cos, exp, inf
from scipy import zeros, linalg
from grid.Grid import Grid
from BuildSquare import bui... | true |
39861dde8feaf810c6c9d30c621786ca9111661d | ParrotSec/vbyscan | /cores/utils.py | UTF-8 | 1,586 | 2.546875 | 3 | [] | no_license | def dummy(*args, **kwargs):
pass
def print_verbose(message):
print(f"[+] {message}")
def print_vulnerable(name, uri=""):
# Bright Magenta
print(f" [\033[96m*\033[0m] \033[95m{name}\033[0m is\033[91m vulnerable\033[0m")
if uri:
# Bright Cyan
print(f" \033[96m{uri}\033[0m")
def... | true |
75196a5dd005e697239eb62f4e6713d8a4d79894 | evertheylen/coding | /coding/util/sympy_wrapper.py | UTF-8 | 591 | 3.140625 | 3 | [] | no_license |
from sympy import Symbol, degree, Poly as _Poly
__all__ = ['Symbol', 'Poly', 'degree']
# A note on sympy:
# Sympy is a big library and basically everything (esp. the field stuff) is already
# implemented there. For this reason; we clearly define what will be used from sympy
# and what not. Sympy is used solely for t... | true |
185a1af3665c4fdc6582968114478154861e6789 | kaory-china/python | /CC1_2 Week/square_area_perimeter.py | UTF-8 | 303 | 3.765625 | 4 | [] | no_license | 'it calculates square perimeter and area based on user int input of the square side size'
MedidaLadoQuadrado = int(input("Digite o valor correspondente ao lado de um quadrado:"))
Perimetro = MedidaLadoQuadrado * 4
Area = MedidaLadoQuadrado ** 2
print("perímetro:", Perimetro,"-","área:", Area)
| true |
73d3e17de3878bca24aed9b5fac6a8cf2b54273e | simshi/d2idol | /tests/test_earitem.py | UTF-8 | 1,030 | 2.609375 | 3 | [] | no_license | import unittest
import os
from lib import EarItem
from lib import OBitStream
from . import FILE_ROOT_DIR
class MemStream():
def __init__(self):
self._v = ""
def __str__(self):
r = []
for i in range(0, len(self._v), 8):
bits = self._v[i:i+8][::-1]
r.append(int(bits, 2))
return ' '.join(map('{0:02x}'.... | true |
610421c1928119a4f4232a881635dba0c041a431 | zhaosaisai/python-trainings | /source/4.找出文件中出现次数最到的单词,并记录数目.py | UTF-8 | 272 | 3.03125 | 3 | [] | no_license | #!/usr/bin/env python
#-*- coding:utf-8 -*-
import re
from collections import Counter
# 读取文件
txt_str = open('sentence.txt').read()
# 分隔字符串
txt_list = re.split('\W+', txt_str)
# 出现次数最高的前十的单词
print Counter(txt_list).most_common(10)
| true |
c7697147b8f9a761fc7b1f98b26f5deae483914c | LeonidMurashov/Python_Projects | /Keras/Wormax/digits_classifier/generateClassifier.py | UTF-8 | 1,421 | 2.875 | 3 | [] | no_license | import numpy as np
from scipy.ndimage import convolve
from sklearn.neural_network import MLPClassifier
from sklearn.datasets import fetch_mldata
from sklearn.model_selection import train_test_split, cross_val_score, GridSearchCV
from sklearn.externals import joblib
import os.path
PATH = "digits_cls2.pkl"
if __name__ ... | true |
782ae8654c0c8e1869f1be3a439e911a6f3dd2f0 | jmkobyluck/web-335 | /week-8/kobyluck-calculator.py | UTF-8 | 566 | 4.4375 | 4 | [] | no_license | # /*
# ;============================================
# ; Title: Exercise 8.3
# ; Author: Professor Krasso
# ; Date: 21 June 2020
# ; Modified By: Jonathan Kobyluck
# ; Description: Python in Action
# ;===========================================
# */
first_name = 'Johnny'
last_name = 'Kobyluck'
print(first_name + ' ' +... | true |
b1d8e22b2c5e81dba521a4e61932e9002c607f8e | yinxiangshi/codebase-of-pic | /heatmap.py | UTF-8 | 6,056 | 2.75 | 3 | [] | no_license | import matplotlib.pyplot as plt
import numpy as np
import json
import seaborn as sns
import pandas as pd
import os
from matplotlib.tri import Triangulation
import matplotlib
'''
this func could help you find out the trick range
And please customize the parameters u need:
alpha_range & beta_range
'''
def find_trick_r... | true |
a67dff1616e5408cdfd58373baae70095404977b | Matherunner/pystrafe | /pystrafe/tests/test_motion.py | UTF-8 | 13,169 | 2.546875 | 3 | [
"MIT"
] | permissive | import math
import itertools
import numpy as np
from pytest import raises, approx
from pystrafe import motion
def test_strafe_K():
with raises(ZeroDivisionError):
motion.strafe_K(0, 0, 0, 0)
assert motion.strafe_K(30, 0.001, 320, 0) == 0.0
assert motion.strafe_K(30, 0.01, 320, 10) == approx(90000)
... | true |
c784913d264619103f69040da86195425febe337 | bowilliams/sublime-packages | /Packages/User/FixAscii.py | UTF-8 | 771 | 2.59375 | 3 | [] | no_license | import sublime, sublime_plugin
from unidecode import unidecode
class FixAsciiCommand(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
regions = view.sel()
# if there are more than 1 region or region one and it's not empty
if len(regions) > 1 or not regions[0].empty... | true |
2b67f8994228495ce7f7a6e8262c7c1bca98b7a6 | frhrdr/pixeldp | /utils/robustness.py | UTF-8 | 3,229 | 2.78125 | 3 | [] | no_license | import numpy as np
import math
import scipy.stats
# UB and LB from:
# https://gist.github.com/DavidWalz/8538435
# http://www.statsmodels.org/dev/_modules/statsmodels/stats/proportion.html#proportion_confint
# using the Clopper–Pearson interval:
# https://en.wikipedia.org/wiki/Binomial_proportion_confidence_interva... | true |
31cb0e57d3736cfc124b67d6620ae16b8cb3af62 | tculpepp/programming_classes | /6.0001/ps1b.py | UTF-8 | 1,643 | 3.84375 | 4 | [
"MIT"
] | permissive | # In ps1b.py, copy your solution to Part A (as we are going to reuse much of that machinery). Modify
# your program to include the following
# 1. Have the user input a semi-annual salary raise semi_annual_raise (as a decimal percentage)
# 2. After the 6th month, increase your salary by that percentage. Do the same af... | true |
11600cf770a080670931589dde51c4f38324c14a | nikillpop/js-wikireader | /app/tools/indexer.py | UTF-8 | 1,329 | 2.734375 | 3 | [] | no_license | action = 0
title = ""
done = 0
unsorted = open("unsorted.txt","w")
uncompressed = open("uncompressed.txt","w")
import htmlentitydefs, re
def slugfy(text, separator = ""):
ret = ""
for c in text.lower():
try:
ret += htmlentitydefs.codepoint2name[ord(c)]
except:
ret += c
ret = re.sub("([a-zA-Z... | true |
3ff6ce965bceadc81dc54dcd8a1c7aebe702ae2f | victorvg17/HackerRank | /python/validate-list-of-email-address-with-filter.py | UTF-8 | 806 | 3.046875 | 3 | [] | no_license | def fun(s):
# return True if s is a valid email, else return False
if s.count("@") != 1:
return False
username, site_and_extension = s.split("@")
if len(s.split("@")) != 2:
return False
f1 = all([f.isalnum() or f in ["-", "_"] for f in username])
site = site_and_extension.split("... | true |
979ba348e0147717de419217393fadf74755891a | omadahealth/ansible-module-consul_stateful_acl | /test/unit/consul_stateful_acl_module_units.py | UTF-8 | 1,863 | 2.546875 | 3 | [] | no_license | import unittest
import mock
import consul
import modules.consul.consul_stateful_acl as ConsulStatefulACL
class ConsulStatefulACLTestCase(unittest.TestCase):
@mock.patch('ansible.module_utils.basic.AnsibleModule')
def setUp(self, mock_module):
self.module = mock_module
self.module.params = dict... | true |
d05ad704c5c7e46ad6d11353c2614c39aea461cc | heethesh/hivex | /esp-ota/terminal.py | UTF-8 | 1,023 | 3.140625 | 3 | [
"MIT"
] | permissive | import socket
import threading
import time
FINISHED = False
esp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ip = '192.168.4.1'
port = 23
esp.connect((ip, port))
esp.settimeout(1)
print 'ESP Connected at %s:%d'%(ip, port)
def send():
global FINISHED
while(1):
msg = raw_input('\... | true |
1f6dbe9eb69eaa3168d4793ce98539b03bbebf88 | jessykate/4D-Network | /goal_or_project.py | UTF-8 | 1,828 | 3.109375 | 3 | [] | no_license | #!/usr/bin/python
# an interactive script to help you annotate each of the millenium
# subgoals as either a goal or a project. will save results to a file
# called goals_project_index.txt. this file will get overwritten each
# time the script is run if the previous copy is not moved to another
# location.
import os, ... | true |
7c8ae3b376b75b8e7fa2593aa2682dcbd913ab81 | AnilDaoud/primes | /primes.py | UTF-8 | 17,963 | 3.28125 | 3 | [] | no_license | from math import sqrt, ceil
# bruteforce function, slow but still faster than double loop (pythonic) and popprime implementation
def naiveprimes(n):
i = 2
primes = []
while i < n:
for x in range(2, int(sqrt(i) + 1)):
if i%x==0:
break
else:
primes.appe... | true |
c6fdcd95bdd20e97f831893bec80f2a8a6ad1e65 | kuanghh/studyPython | /com/python_object-oriented programming_6/Attribute_5.py | UTF-8 | 1,093 | 4.78125 | 5 | [] | no_license | # 实例属性 和 类属性
# 由于Python是动态语言,根据类创建的实例可以任意绑定属性。
#
# 给实例绑定属性的方法是通过实例变量,或者通过self变量:
class Student(object):
score = 10 # 类的属性
def __init__(self, name):
self.name = name # name是实例的属性
# 当我们定义了一个类属性后,这个属性虽然归类所有,但类的所有实例都可以访问到。来测试一下:
s1 = Student("Mike")
s2 = Student("Tom")
print(s1.score) # 输出1... | true |
1db9967390dac36c818ba284ff3fedabc6fa154e | marannan/repo_1 | /Interview/Code_Snippets/python/remove_dups.py | UTF-8 | 1,148 | 3.25 | 3 | [] | no_license | hash_table = {}
def to_string(list):
return "".join(list)
def check_hash_table(item):
if item in hash_table.keys():
return True
else:
hash_table[item] = True
return False
def remove_dup(array):
if len(array) <= 1:
return array
for i in range... | true |
c6ef8be269af2321238e42fd07ddbcb8fe3cf8df | hermesdt/breakout-reinforcement-learning | /dqn.py | UTF-8 | 2,206 | 2.546875 | 3 | [] | no_license | import torch
from torch import nn
import numpy as np
import math, os, re
from collections import OrderedDict
class DQN(nn.Module):
def __init__(self, env, gamma=0.99, lr=0.00001, target_dqn=None):
super().__init__()
self.lr = lr
self.num_actions = env.action_space.n
self.gamma = ga... | true |
916fa9b3a0437ffa6390341d8b7ca160e448fa5e | chenxc2014/PythonDemo | /socket_demo/client.py | UTF-8 | 455 | 2.65625 | 3 | [] | no_license | # _*_ coding:utf-8 _*_
# author:chenxc
# datetime:2019/7/13 23:22
# function:
# 导入 socket、sys 模块
import socket
import sys
# 创建 socket 对象
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# 获取本地主机名
host = socket.gethostname()
# 设置端口号
port = 9999
# 连接服务,指定主机和端口
s.connect((host, port))
# 接收小于 1024 字节的数据
msg = s... | true |
095a940ce44c05be7257b0307ea50cc601a2cadb | protoss70/Coding-Interview-Questions | /Coding Interview Questions/Google's Question!!!/Soru5.py | UTF-8 | 388 | 3.703125 | 4 | [] | no_license | giriş = ")(()) )))((((("
def Finder():
ToRemove = 0
AçıkParantez = 0
for i in range(len(giriş)):
if giriş[i] == "(":
AçıkParantez += 1
elif giriş[i] == ")" and AçıkParantez == 0:
ToRemove += 1
elif giriş[i] == ")":
AçıkParantez -= 1
... | true |
2c0f7b44793c59b50c88dc3e550bbe6d8a878578 | wanxiang-blockchain/2021Wanxiang-Blockchain-Hackathon-Athena | /base/exceptions.py | UTF-8 | 288 | 2.609375 | 3 | [] | no_license |
class MaxTimeExceed(Exception):
def __init__(self, max_times, *args, **kwargs):
self.max_times = max_times
super(*args, **kwargs)
class UnAuthorizedException(Exception):
pass
class ValidateError(Exception):
def __init__(self, msg):
self.msg = msg
| true |
f2837e58b44769c4bce38ce7d7154c4006f97ad4 | sosacwork/ss-sqlalchemy | /ss-sqlalchemy/app.py | UTF-8 | 3,655 | 3 | 3 | [
"MIT"
] | permissive | from flask import Flask
from sqlalchemy import create_engine, text, Table, Column, Integer, String, MetaData, insert
from sqlalchemy.orm import Session
from sqlalchemy.sql.expression import select
from sqlalchemy.sql.schema import ForeignKey
from .settings import Config
app = Flask(__name__)
app.config.from_object(Co... | true |
17b03d21447790ae422fdd1d538276e56b252fc0 | joswoo/RPI_LED | /hw1.py | UTF-8 | 561 | 2.984375 | 3 | [] | no_license | import RPi.GPIO as GPIO
import time
led_red = 12
led_yellow = 16
led_green = 22
GPIO.setmode(GPIO.BOARD)
GPIO.setup(led_red, GPIO.OUT)
GPIO.setup(led_yellow, GPIO.OUT)
GPIO.setup(led_green, GPIO.OUT)
try:
while(True):
GPIO.output(led_red,GPIO.HIGH)
GPIO.output(led_yellow,GPIO.HIGH)
GPIO.... | true |
594a0513065b495bfb7616be05465ddae1d96a30 | DavidWalshe93/Python_Protobuf | /enums/enums.py | UTF-8 | 475 | 3.15625 | 3 | [] | no_license | """
Author: David Walshe
Date: 18/04/2020
"""
import enums.enum_example_pb2 as enum_example_pb2
def create_enum_protobuf():
"""
Creates a enum protobuf
"""
enum_message = enum_example_pb2.EnumMessage()
enum_message.id = 345
enum_message.day_of_the_week = enum_example_pb2.... | true |
857ddeb67516a76a08f4c5660f26d86f1c7bb809 | xenking/lightdataparser | /lightdataparser/datatype.py | UTF-8 | 5,995 | 3.40625 | 3 | [
"MIT"
] | permissive | """
Используемые структуры
"""
from collections.abc import MutableSequence
from functools import singledispatch, update_wrapper
def method_dispatch(func):
"""
Переопределение единой диспетчеризации для методов класса
https://stackoverflow.com/questions/24601722/how-can-i-use-functools-singledispatch-with-instance... | true |
8c0fc15c2ad29b8f530a0f7bcc00c11ff750493e | ZhikunWei/hw2020 | /data_secure/hw1/enigma/hack_enigma.py | UTF-8 | 1,819 | 3.34375 | 3 | [] | no_license | #!/usr/bin/python
# -*-coding:utf-8 -*-
__author__ = '99K'
from enigma import Enigma, Roter
class EnigmaHacker:
def __init__(self):
self.encrypted_key = []
self.letters = 'abcdefghijklmnopqrstuvwxyz'
self.enigma = Enigma(r1='a', r2='a', r3='a', r4='a', r5='a', swap_num=0)
def ha... | true |
27b64abb79af38cf9265717a16e6d2226ee619ea | JhansiSai/Pythontrng | /break_program.py | UTF-8 | 197 | 2.796875 | 3 | [] | no_license | i = 10
j = 20
for i in range(10, 15):
print(i)
break
for i in range(5,15):
if i==12:
print(i)
continue
print(i)
for k in range(1,10):
pass
print("hello")
| true |
cc34d3309ab2c360bd25a056c9c1817c3e3d8d09 | synic/frf | /frf/utils/conf.py | UTF-8 | 1,061 | 3 | 3 | [
"Apache-2.0"
] | permissive | from frf import conf as baseconf
class OverrideSettingsManager(object):
"""Temporarily override settings in a context manager.
Use the ``override_settings`` alias.
Usage example:
.. code-block:: python
from frf import conf
from frf.utils.conf import override_settings
conf[... | true |
16f293d3d16d52da6e673d33b39e7f892254be35 | Pavless/VGE | /app.py | UTF-8 | 6,832 | 3.203125 | 3 | [
"MIT"
] | permissive | """Application for visualization of polygon triangulation"""
import math
import sys
from argparse import ArgumentParser
import cairo
import pygame
from helpfunctions import check_points_on_line, check_intersections
from point import Point
from earclipping_anim import EarClippingAnim
from drawing import rgba_to_bgra
... | true |
2704774e987a2d2d6979746809acd71f1a37d4ad | eugenioLR/Rubik-s-Cube-python | /rubikNotation.py | UTF-8 | 8,208 | 3.28125 | 3 | [] | no_license | import numpy as np
def invertMov(mov):
"""
str -> str
OBJ: returns the inverted movement as the one given
R -> R'
U2 -> U2
F' -> F
"""
result = mov
if mov[-1] == "'":
result = mov[0]
elif mov[-1] != "2":
result += "'"
return result
def groupAlg(alg):
"""... | true |
680f839b994dc053343220893be447bdc30acc4c | ravindikumarasinghe/Vend-mac | /application.py | UTF-8 | 1,377 | 3.265625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on: 29/05/2020
@author: Rohan Kumara
"""
import userFunctions
def login():
user=input("\n\nPlease enter your \n\t> MIT Employee ID exxx\n\tor \n\t> MIT Student ID sxxx:")
if 'e' in user:
menuStaff()
elif 's' in user:
menuStudent()
else:... | true |
c3d92bde29d1a520199c0041eb5d89d2bc80e7a1 | Corralo/Grupo-13---ECO-2018-A | /Exercício 4.3.py | UTF-8 | 730 | 4.40625 | 4 | [] | no_license | # Exercício 4.3
# Imprimir o maior e o menor número dentre três dados
n1=int(input("Escreva seu primeiro número:"))
n2=int(input("Escreva seu segundo número:"))
n3=int(input("Escreva seu terceiro número:"))
if n1>n2>n3:
print('Seu menor número é %d e seu maior número é %d' %(n3, n1))
if n2>n1>n3:
print('Seu me... | true |
e479ef1cd99d3e7ef031bcbf7a775e840138060e | Emma-GZ/CPS3320W01-Luna-Emma | /level3_SURF.py | UTF-8 | 2,434 | 2.921875 | 3 | [] | no_license | # Reference:https://blog.csdn.net/weixin_43823854/article/details/102017382
import numpy as np
import cv2
from matplotlib import pyplot as plt
imgname_01 = 'path{image1.jpg}'
imgname_02 = 'path{image2.jpg}'
# Set a threshold, the larger the threshold, the fewer features that can be recognized
#surf = cv2.xfeatures2d.S... | true |
e5dcba09bd815dc2add036e28fc4b2c6e5b5a748 | nikitamatveenko0909/tic-tac-toe | /x_o.py | UTF-8 | 3,687 | 3.921875 | 4 | [] | no_license | X = "X"
O = "O"
EMPTY = " "
TIE = "Tie"
NUM_SQUARES = 9
def display_instruct():
print("Welcome to tic tac toe")
def ask_yes_no(question):
response = None
while response not in ("y", "n"):
response = input(question).lower()
return response
def ask_number(question, low, high):
... | true |
80501e15ffbda8d0fe88b313b811c4906f43ea55 | TarrySingh/webdnn | /test/webdnn_test/optimizer_test/sub_rules_test/simplify_associative_operator_test.py | UTF-8 | 3,115 | 2.609375 | 3 | [
"Zlib",
"MIT"
] | permissive | import numpy as np
from webdnn.graph.graph import Graph
from webdnn.graph.order import OrderNCHW
from webdnn.graph.variable import Variable
from webdnn.graph.variables.constant_variable import ConstantVariable
from webdnn.optimizer.sub_rules.simplify_associative_operator import SimplifyAssociativeOperatorLeftHand, \
... | true |
e21102315e1e5ea3822fb997984475a2a67ba891 | JorgeAGR/seismology | /join_pred_csv.py | UTF-8 | 832 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 4 15:40:30 2020
@author: jorgeagr
"""
import os
import argparse
import pandas as pd
parser = argparse.ArgumentParser(description='Join prediction CSVs from a multijob prediction.')
parser.add_argument('file_path', help='Path to the files', type=s... | true |
d1f6d72f2989bafb50d8bf7f474d033f0835fbd8 | modimanz/PixelDorpLaser | /main.py | UTF-8 | 5,012 | 3.1875 | 3 | [] | no_license | """
PixelDorpLaser
Description: We are going to turn a beautiful colorful image into grayscale.
then we are going to colorize it into 8 colors that will be defined by different
laser scanning profile when we print on the laser printer. What will happen??? I
guess we will find out soon.
Author: Morgan Massens
Date: ... | true |
b5d81054584dfc0195907dfcfaac44a552fea7d5 | GabDn/sistop-2019-2 | /tareas/3/MoralesCarlos-PerezQuirozMiguel/DEFINITIVO.py | UTF-8 | 10,579 | 3.171875 | 3 | [
"CC-BY-4.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | import random
def gen_list():
procesos = []
diccionario = {0:'A',1:'B',2:'C',3:'D',4:'E'}
num_procesos = 5
llegada = 0
for i in range(num_procesos):
duracion = random.randint(1,8)
procesos.append([diccionario[i],llegada,duracion])
llegada += random.randint(0,duracion-1)
... | true |
0883ab6ab47ee87f55e478cbe04f408767c965c1 | littletao08/wechat | /my_app/main/receive.py | UTF-8 | 11,697 | 2.609375 | 3 | [] | no_license | # coding: utf-8
"""微信接收消息模块
包含各类微信消息时间的模块, 并有解析消息函数, 每个消息类有保存方法
"""
import time
import xml.etree.ElementTree as ET
from .. import models
def parse_xml(data):
"""接收消息方法
将接收到的微信消息/事件的xml字符串解析成相应的消息类
Args:
data: 微信服务器推送的的原始xml字符串消息
Returns:
返回相应的接收消息类
"""
if len(data) == 0:... | true |
ebddcff40abcd4e2400e5c688024f0ee93b66244 | han8909227/pyramid-learning-journal | /learning_journal/models/mymodel.py | UTF-8 | 795 | 2.640625 | 3 | [
"MIT"
] | permissive | from sqlalchemy import (
Column,
Unicode,
DateTime,
Index,
Integer
)
from .meta import Base
class MyModel(Base):
__tablename__ = 'models'
id = Column(Integer, primary_key=True)
title = Column(Unicode)
body = Column(Unicode)
creation_date = Column(DateTime)
def __init__(se... | true |
81d00bd78774d73b07c24448c837e2fb1237ef44 | fomodj/python-school | /classdeomo/student_test.py | UTF-8 | 272 | 2.953125 | 3 | [] | no_license | from classdeomo.student import Student
import random
s = Student("Marry",5)
print(s)
s.setScore(1,100)
print(s)
for i in range(1,s.getNumber()):
s.setScore(i+1,random.randint(1,100))
print(s)
print("High score:",s.getHighScore())
print("Average score:",s.getAverage()) | true |
9b689fd0d4f7aa2b171cbe9c7408a3484050e136 | ovifrisch/Python-Data-Structures | /heaps/d_heap.py | UTF-8 | 2,827 | 4.125 | 4 | [] | no_license |
"""
a *max* heap has the property that each node is greater than its children
"""
import math
class DHeap:
def __init__(self, has_priority, d):
self.d = d
self.has_priority = has_priority
self.array = [None] * 10
self.size = 0
def find_min(self):
if (self.size == 0):
raise Exception("heap is empty")
... | true |
adb2b7701600b98cc468fbe595310d354cf6e77f | cmdouglas/toy_roguelike | /rl/world/board/generator/painters/tunnel.py | UTF-8 | 2,378 | 2.6875 | 3 | [] | no_license | import random
from rl.world.entities.terrain import wall
from rl.util import dice, geometry
from rl.world.board.generator.painters import Painter
class TunnelPainter(Painter):
@classmethod
def region_meets_requirements(cls, region):
# no dead end tunnels
return len(region.connections) >= 2
c... | true |
c448271f6a19497e8605935e70c17a6caa903a4f | pabnas/IA_tarea1 | /lab.py | UTF-8 | 2,030 | 3 | 3 | [] | no_license | import pygame
import sys
import numpy as np
grid = sys.argv[1]
LEFT = 1
RIGHT = 3
from pygame.locals import *
#funciones
def pintar_cuadro(x,y,num):
pygame.draw.rect(ventana, color[num],(cuadro_size*x,cuadro_size*y,cuadro_size,cuadro_size))
if grid == "-g":
for x in range(20):
pygame.draw.line(ventana,color[19... | true |
2aded70630d487706b72e4219495509c4811dff6 | okaymunsi/sandbox | /code_challenges/6_xsos.py | UTF-8 | 1,060 | 4.875 | 5 | [] | no_license | """
Create a Python function that accepts a string.
This function should count the number of Xs and the number of Os in the string.
It should then return a boolean value of either True or False.
If the count of Xs and Os are equal, then the function should return True.
If the count isn't the same, it should return ... | true |
10015dc5c73a317b6d1c0b05ba7ea6410093c3b5 | longliljl/learn1 | /venv/include/down_file.py | UTF-8 | 1,755 | 2.765625 | 3 | [] | no_license | # coding=utf-8
# !/usr/bin/python
import os
import requests
from bs4 import BeautifulSoup
# 给请求指定一个请求头来模拟chrome浏览器
global headers
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'}
# 定义存储位置
global save_path
save_path =... | true |
dceca5673a6971d084a06faef3fa152e66c20827 | will-snavely/adventofcode | /aoc2020/day16.py | UTF-8 | 3,875 | 2.890625 | 3 | [] | no_license | import functools
import pyparsing as pp
test_inputs = [
"inputs/day16_sample",
"inputs/day16",
]
Integer = pp.Word(pp.nums).setParseAction(pp.tokenMap(int))
ValidationRange = pp.Group(Integer("start") + pp.Suppress("-") + Integer("end"))
ValidationExpression = ValidationRange + pp.ZeroOrMore(pp.Suppress("or"... | true |
5b52f52f4679d93965e62504cd7f0d15baf13981 | ZhangRRz/py_class | /HW5/PA5.py | UTF-8 | 7,290 | 3.4375 | 3 | [] | no_license | # This programming assignment is due May 18th, at 11:59pm. Save you answer as
# PA5.py, and submit to the cyber university.
#
# This file is a template, containing four ... regions that you need to fill in.
# Your solution must use all of the following imported functions:
from functools import reduce, partial
fro... | true |
f37c62cbfd17db4282ee75c6649adc249848174b | ruralkan/basicsPython | /data_types/tuples.py | UTF-8 | 795 | 4.375 | 4 | [] | no_license | # Indexing
x = (1,2,3)
x[0] # 1
x[1] # 2
x[2] # 3
x[-1] # 3
x[-2] # 2
x[-3] # 1
x[:-1] #(1,2)
x[-1:] # (3,)
# Tuples dont have .append, .extend
# += operator can be used like append to a tuple
t = (1,2)
q = t
t += (3,4) # (1,2,3,4)
q # (1,2)
t = tuple("lupins") # ('l', 'u', 'p', 'i', 'n', 's')
# Reversing elements... | true |
1a6af7975d642a56e40413abb0efe24fa1fbaeca | ImNotNikola/HackerRank | /Python/30 Days of Code/Day0.py | UTF-8 | 489 | 4 | 4 | [] | no_license | int main() {
// Declare a variable named 'input_string' to hold our input.
char inputString[105];
// Read a full line of input from stdin and save it to our variable, input_string.
scanf("%[^\n]", inputString);
// Print a string literal saying "Hello, World." to stdout using printf.
... | true |
6154626fd9fc1c0ad56041db923e32d918d2acac | thedoodlebakery/cheese | /everycheese/cheeses/tests/test_models.py | UTF-8 | 376 | 2.96875 | 3 | [
"MIT"
] | permissive | from test_plus.test import TestCase
from ..models import Cheese
class TestClass(TestCase):
def test__str__(self):
cheese = Cheese.objects.create(
name="Stracchino",
description="Semi-sweet cheese that goes well with starches.",
firmness=Cheese.FIRMNESS_SOFT,
)
... | true |
4641ea3b3ee97b952fc1af422a2b7d91f51b3e45 | mainrs/MLFoodPairing | /food2fork/scrapers/closetcooking.py | UTF-8 | 790 | 2.546875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
.. module:: food2fork.scrapers.closetcooking
.. moduleauthor:: Julien Spronck
.. created:: April 2018
'''
from food2fork.scrapers.base import Scraper, checkstatus
class ClosetCooking(Scraper):
'''ClosetCooking scraper class
'''
@checkstatus
def get_... | true |
f971e873e56f0e1fbde9b88520bfd9b1db6836db | SkillfulGuru/Selenium-webdriver | /web12.py | UTF-8 | 1,542 | 2.796875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import os
import datetime
# import requests
import time
from selenium import webdriver
# import selenium
##=================================================================================
save2htmlpath = 'E:\\PythonExercises\\'
myurl = 'https://www.anz.... | true |
fb80c307883c87bacc5607643704774832f310c2 | daniel-toncu/N-Queens | /src/main.py | UTF-8 | 1,759 | 3.34375 | 3 | [
"MIT"
] | permissive | """
"""
import sys
from solvers.backtracking import BacktrackingSolver
from solvers.backtracking_imp import BacktrackingImpSolver
from solvers.cp_sat import CpSatSolver
if __name__ == "__main__":
"""
"""
print()
if len(sys.argv) != 4:
print(" Usage: python %s <solver> <board-size> <print-... | true |
55354650a697663f4257671420166bd722562b3b | Spidy88/rosalind.info | /07_Mendels_First_Law/main.py | UTF-8 | 1,163 | 3.109375 | 3 | [] | no_license | def calculate_dom_prob(hom_dom, hetero, hom_rec):
total = hom_dom + hetero + hom_rec
p_hom_dom__hom_dom = (hom_dom / total) * ((hom_dom-1) / (total-1))
p_hom_dom__hetero = (hom_dom / total) * (hetero / (total-1))
p_hom_dom__hom_rec = (hom_dom / total) * (hom_rec / (total-1))
p_hetero__hetero = (het... | true |
9efe3a74b17c4659ce38e34c6d5450d5f23cc736 | ikegami5/Website | /cgi-bin/question.py | UTF-8 | 1,087 | 2.875 | 3 | [] | no_license | #!/usr/local/bin/python3
# coding: utf-8
from httpHandler import Response, Request
from htmlTemplate import Form
from generateQuestion import IntQuestion
def main():
br = "<br />"
request = Request()
name = request.data["name"].value
number = int(request.data["number"].value)
score = int(request.data["score"].val... | true |