blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
42ae101d9f907a251227634503e7c27f782f340f
sharathcshekhar/dyads-grid-ftp-client
/metadata_proto/ftp_dirListing.py
566
3.5
4
#!/usr/bin/python import pickle # # This file does not run on its own! import to a python # intereter and call ftp_list("path_name") to get the listing # of that directory # # default database name is ftp_db def ftp_loadDB(db_file="ftp_db"): fd = open(db_file, 'r') # ugliest way possible is to load the entir flat-fi...
9bea275cf3b9e9c72d53a423b18f10e6d4613599
guojia60180/algorithm
/算法题目/算法题目/树/LeetCode572判断子树.py
665
3.859375
4
#Author guo # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def isSubtree(self, s, t): if s==None: return False return self.issubtreeWithRoot(s,t) or self.is...
68ab0fe0a454e2d5af0f8146ccda1b7d6f534ced
DuNG-bot/nguyenthedung-fundamental-C4EP35
/Lesson2/Class.py
1,122
3.65625
4
# i=5 # print('nam nay toi',i,'tuoi') # i=int(input()) # print((i**2)**0.5) # age=int(input('tuoi cua ban la')) # if 0<age<10: # print('baby') # elif 10<=age<18: # print('teen') # else: # print('adult') # age=10 # is_baby=age<10 # print(is_baby) # num=101 # is_odd=num%2==1 # print(is_odd) # text='xin c...
e40c1734fbd31b72c916e9ab75b8cd3c1d8698c4
xiang-123352/code_snippets
/python/beispiele/17_Parallele_Prog/08_threading_timer.py
420
3.515625
4
# -*- coding: utf-8 -*- """ Entspricht einem Delay """ import time, threading def wecker(gestellt): print("RIIIIIIIIIING!!!") print("Der Wecker wurde um {0} Uhr gestellt.".format(gestellt)) print("Es ist {0} Uhr".format(time.strftime("%H:%M:%S"))) timer = threading.Timer(30, wecker, [time...
55df09df143a4b41f1b3f896431a2e7e518e8299
kiranraju03/PractiseCode
/HackerRank/ValleysCounter.py
920
4.40625
4
""" Find the number of valleys covered by the traveller 'U' being the Uphill and 'D' being the downhill and the traveller has to return to sea level Valley : Covering the downhill and reaching back the sea_level Mount : Covering the uphill and reaching back to sea_level Assumptions made : add 1 to sea_level when the ...
13005cadda9902633d04ef0523f9029b40487e8d
LLNL/csld
/csld/lattice.py
32,472
3.8125
4
#!/usr/bin/env python3 """ This module defines the classes relating to 3D lattices. """ # adapted from original version in pymatgen version from pymatgen import math import itertools import numpy as np from numpy.linalg import inv from numpy import pi, dot, transpose, radians from .coord_utils import pbc_images c...
8baa08c3dc84fafea49c63eacf2403e7d3ab7dad
singhbhupender1/Python_excercises
/Topic6_list.py
5,828
4.53125
5
#T6Q1 #A list behaves like a container, and it is able to contain more than one value. Create a list with the #values as shown in the example below. aList = ['Hello', 0, 20.0, 'World'] #T6Q2 #A list can be modified, and more elements can be added to an existing list. Use the append(x) function #to add some more items ...
6f3f4bc5b8afe1375b8676bb1809098097dfef9f
Gustee/CodingInterview-Chinese-version2
/chap6/16.py
978
3.859375
4
# 扑克牌中的顺子 # 从扑克牌中随机抽取5张牌,判断是不是一个顺子,即这5张牌是不是连续的。 # 2~10为数字本事,A为1,J为11,Q为12,K为13,大小王为0可以看成任意数字 ''' 思路: 首先把数组排序 然后统计数组中0的个数 最后统计排序之后的数组中相邻数字之间的空缺总数 ''' class Solution: def IsContinuous(self, numbers): if not numbers: return False numbers.sort() numOfZero = 0 numOfGap = 0 ...
a88c235a381888812694492733a59c97f1ce61be
SurajMishra-07/Code-with-harry-Python-Course
/prac.py
1,467
3.59375
4
# def revstr(st,n): # '''here str is sting and n=index value of last element''' # # if n==0 : # return (str[0]) # elif n>0: # # return str[n] + revstr(st,n-1) # # # print(help(revstr)) # # # __main__ # str=input("enter the string") # n=len(str)-1 # print(revstr(str,n)) # # # # # gcd # def gc...
e97880f5f29938e3e8127323739f233838ed6340
alifa-ara-heya/My-Journey-With-Python
/day_03/print_magic.py
594
3.734375
4
#Day_2: July/30/2020 #In the name 0f Allah.. #Me: Alifa Ara Heya print(12) print(1, 2, 3, 4, 5) #output: 1 2 3 4 5 print((1, 2, 3, 4, 5)) #output: (1, 2, 3, 4, 5) ;tuple type print(1, 2, 3, 4, 5, sep=", ") #wow! output: 1, 2, 3, 4, 5 print(1, 2, 3, 4, ...
4bac220b4dbf9604de8b3a81098834045b6b6c69
LRBeaver/Stock_Market
/Stock_Market_Branch.py
5,119
3.59375
4
__author__ = 'lyndsay.beaver' #import sqlite3 as sq1 import random as rnd #"{:,}".format(value) starting = 10000 balance = starting portfolio = {} goto_menu = True stockList = [] class Stock: def __init__(self, name, ticker, starting_price, current_price, volatility): self.name = name self.ticker...
b496292d766115e9335a17dd1d23e4efce4624db
abhimita/udacity-datastructure
/file_recursion/src/file_recursion.py
1,450
4.28125
4
import os class FileRecursion: """ Private method to find file with a given suffix Arguments: suffix : File extension e.g. .c path : File path to be search for file with given suffix. File path can be a regular file as well file_list: Result set returned """ @staticmet...
d0a1faf6b2d636627d7677bf01c2952fb9311049
taejinkim3/Python_Toy
/movie_reservation/movie.py
10,743
3.625
4
class movieTheater(object): def __init__(self, name, time, money): self.name = name self.time = time self.money = money def showTime(self): print(self.time) def earnMoney(self, newMoney): self.meney = self.money + newMoney class Seat(object): #Seat 클래스는 좌석 예매 기능을...
997cdac4fb545f86d5126063fe296130940729db
DiasDogalakov/PP2_summer2020
/Contest(16.06.20)/from K to end/ZA.py
849
3.65625
4
str = input() def function(str): a = "@" dot = "." aPOS = 0 tPOS = 0 PROSTOcnt = 0 cntT = 0 cntA = 0 for i in range(0, len(str)): if(str[i] == a): cntA += 1 elif(str[i] == dot): cntT += 1 if(cntA == 1 and cntT == 1): for i in rang...
540a2c1f4bb02ce681f1456d99f1c43e7ad672ef
dpocheng/SIMPLESEM-Compiler-Semantic
/C1.py
213
3.6875
4
a, b, c = 3, 1, -1 def main(): global a, b while a > c: if a == 0: print b else: b = b + a a = a - 1 print a print b print c main()
65272a78448df4cea2141e6123e8cea65482b43b
Lamela/CodingInterviews
/13_机器人的运动范围.py
1,323
3.59375
4
def moving_count(matrix, k): if k < 0 or len(matrix) <= 0 or len(matrix[0]) <= 0 or not isinstance(matrix, list): return 0 rows = len(matrix) cols = len(matrix[0]) for i in range(rows): if not isinstance(matrix[i], list) or len(matrix[i]) != cols: return 0 visited = [[...
d2cd88b27574aab469e49d4083b3a7472980e8e3
jwseo4074/Leetcode_Python
/leetcode_17.py
606
3.65625
4
# class Solution: # def letterCombinations(self, digits: str) -> List[str]: digits = "23" answer = [] table = { "2" : "abc" , "3" : "def", "4" : "ghi", "5" : "jkl", "6" : "mno", "7" : "pqrs", "8" : "tuv", "9" : "wxyz" } index = 0 path = "" def dfs(index, path): if len(digits) == len(path): ...
7382716a8286edf15b64ecb4362ca5dd1a9ea654
alswl4304/Programming-Python-
/패키지/1학기/ex_poket_money.py
642
3.5
4
#국어, 영어, 수학, 자바, 파이썬, JSP #총점, 평점 구하기 #용돈구하기 k = input ("국어 점수는?") m = input ("수학 점수는?") e = input ("영어 점수는?") j = input ("자바 점수는?") p = input ("파이썬 점수는?") js = input ("JSP 점수는?") sum = int(k) + int(m) + int(e) + int(j) + int(p) + int(js) print("총점은",sum) avg = sum/6 print("평균은", round(avg,2)) #4 if avg >= 90: pri...
62caef003eecdd66836f31e2689e4b1f6f284541
qoo199612/pythonclass
/main.py
14,962
3.90625
4
""" x = 2 y = 5 print(x+y) print(x-y) print(x*y+x) print(x**y) print(y%x) print(y//x) print(round(4.9555)) 值的計算 """ """ 我知道我很帥 """ """ 針對List進行選擇顯示哪個位置的數字 mathscores = [60, 70, 10, 20, 81, 63, 4] mathscores[2] print(mathscores[2]) mathscores[1:6] print(mathscores[1:6]) print(mathscores[-1]) print(mathscores[6]) print...
ed317d2a7955c7e32380e00b4384627dc7ea5e03
Sunil-Y/INFO6205
/Python/src/randomwalk/random_walk.py
2,429
4.03125
4
import argparse import math import sys from random import Random class RandomWalk: x = 0 y = 0 random = Random() def move(self, dx: int, dy: int) -> None: """ Method to move the current position, that's to say the drunkard moves :param dx: the distance he moves in the x dire...
2661b04304b5d776ac4371035bed974cc0459c5c
Aasthaengg/IBMdataset
/Python_codes/p02865/s015011296.py
105
3.6875
4
import math N = int(input()) ans = math.floor(N / 2) if N % 2 == 0: print(ans - 1) else: print(ans)
c7f4bcc0560656e40bac96845f18b22f671baab2
alvas-education-foundation/Krishna_Katira
/coding_solutions/10-06-20.py
155
3.890625
4
s1=raw_input("Enter first string:") s2=raw_input("Enter second string:") a=list(set(s1)&set(s2)) print("The common letters are:") for i in a: print(i)
5ae1485c55d75182dcb43bf15985688f2664a8d9
PalakSaxena/PythonAssigment
/Python Program to find second largest number in a list.py
253
4.3125
4
NumberList = [] num = int(input(" Enter Number of Elements in List : ")) for i in range(0, num): ele = int(input(" Enter the Element : ")) NumberList.append(ele) NumberList.sort() print(" Second Largest Element in List : ", NumberList[-2])
a2dfae52f092b2156854093d9845929e56612691
Myrzaeva/Seamlessly_Python
/src/Generators/Own.py
476
3.796875
4
def count_up_to(max): count = 1 while count <= max: yield count count += 1 counter = count_up_to(5) print(next(counter)) print(next(counter)) print(next(counter)) print(next(counter)) print(next(counter)) def yes_or_no_gener(): answer = "yes" while True: yield answer ...
f1e739b73fbe473ba32ffeeab0de089811af328b
sairam-py/CodeForces-1
/InitialBet.py
571
3.609375
4
__author__ = 'Devesh Bajpai' ''' https://codeforces.com/problemset/problem/478/A Solution: Since every player is given same amount of coins, the total coins at the end of the game should still be divisible by the total number of players. Check and return the result accordingly. Take care of the total coins as 0 case...
ac455b65934c93365c1e326995ba1382b3ffed04
wangycthu/Vectorize
/src/data_filter.py
1,496
3.765625
4
# -*- coding=utf-8 -*- import config import json def get_text_from_file(path): """ get the pure chinese line from file Parameters: ----------- path: the data path in the system. Return: ------- texts: format: [["aa bb cc"],["a sd d"].. ] all the character here is Chinese ...
709fe08686ddcb0ab1216b02e64caddf9b0772df
sumanblack666/datacamp-python-data-science-track
/Importing Data in Python pt2/Chapter 3 - Diving deep into the Twitter API.py
1,837
3.859375
4
#Chapter 3 -Diving deep into the Twitter API #API Authentication # Import package import tweepy # Store OAuth authentication credentials in relevant variables access_token = "1092294848-aHN7DcRP9B4VMTQIhwqOYiB14YkW92fFO8k8EPy" access_token_secret = "X4dHmhPfaksHcQ7SCbmZa2oYBBVSD2g8uIHXsp5CTaksx" consumer_key = "nZ6EA...
28b7623220b932fe94fa8ec2bef44a571457108f
ArilessTir/pyhton_exercism
/scrabble-score/scrabble_score.py
318
3.59375
4
def score(word): rules={'A':1,'E':1,'I':1, 'O':1, 'U':1, 'L':1, 'N':1, 'R':1, 'S':1, 'T':1,'D':2,'G':2,'B':3, 'C':3, 'M':3, 'P':3,'F':4, 'H':4, 'V':4, 'W':4, 'Y':4,'K':5,'J':8,'X':8,'Q':10,'Z':10} word = word.upper() if len(word) >0: return sum([rules[i] for i in word]) else: return 0
88842d800523d08a40fa0401d851e1975e8b2fdb
byzckmk/Python-Pandas
/indexingAndSlicing.py
451
3.75
4
import pandas as pd notes = pd.read_csv("grades.csv") notes.columns = ["First name","Last name", "SSN","Test1", "Test2", "Test3", "Test4", "Final", "Grade"] print(notes) print(notes.loc[:,"First name"]) print(notes.loc[:5,"First name"]) print(notes.loc[:5,"First name...
24a1e99674eaaf6fc154bca0021a0e145f246a74
miminas/CodingBootcampExercises
/pythonTutorial2/exercise4.py
349
3.875
4
x = input("Please enter an 9-digit number: ") r1, r2, r3 = [], [], [] if len(x) != 9: print("Not a 9-digit number") else: for a in range (9): if a%3 == 0: r1.append(int(x[a])) elif a%3 == 1: r2.append(int(x[a])) else: r3.append(int(x[a])) print(*r1) ...
a00d0f543203a1e9ba52368cb5826b43dcc9aa0d
etwum/Python-Portfolio
/Intro_to_Python/Module 07/module 07 practice.py
2,149
3.546875
4
# -*- coding: utf-8 -*- """ Created on Tue Nov 7 15:30:41 2017 @author: Emmanuel """ file = open("Test.txt","r") print(file.read()) file.seek(0) #allows you to specify a starting point; 0 = the beginning print(file.read()) #****Lab 7-1 dicRow = {} tblData = [] ID = 1 def LoadData(): file = open("Test...
560d32113c7eaa5824ebe0bb43b23dd7fc8815e8
AdityaBelani/Learning-Python
/28.06.2018/1. Single Level Inheritance.py
1,275
4.34375
4
#Simple Inheritance class Employee(object): def __init__ (self,EmpNo,EmpName,EmpDesign,EmpContact): self.EmpNo=EmpNo self.EmpName=EmpName self.EmpDesign=EmpDesign self.EmpContact=EmpContact def show(self): print('Employee No.: ',self.EmpNo) print('Employee Name: ...
faf4fe2d1ae4c75e736f601f473e674491fb6109
sandeepkumar8713/pythonapps
/14_trie/07_multi_search.py
2,656
4
4
# CTCI : Q17_17_Multi_Search # Question : Given a string band an array of smaller strings T, design a method to search b for # each small string in T. # # Example: # T = {"is", "ppi", "hi", "sis", "i", "ssippi"} # b = "mississippi" # # Question Type : Generic # Used : Insert the words of the array in trie. # Now...
f364919831db75bb6900dfec45d3f335dea847b8
kwanhong66/TodayILearned
/algorithms/python_algorithm_interview/linear_data_structure/array_pair_sum.py
1,137
3.96875
4
from decorators import timer from typing import List nums_one = [1, 4, 3, 2] nums_two = [6, 2, 6, 5, 1, 2] # solution 1 @timer def get_array_pair_sum(nums: List[int]) -> int: maximized_sum = 0 pair = [] nums.sort() for n in nums: pair.append(n) if len(pair) == 2: # list is sorted; j...
39d47df1a89bc83631383672a18a950dd1c3a53f
akashk97/Akash-kumar
/first.py
448
3.8125
4
'''l = [3,1,6,5,2] print("before sorting",format(l)) l.sort() print("after sorting",format(l))''' def getsum(a,b): return(a+b) def getdiff(a,b): if isinstance(a,(int,float)): return a-b else: print("pass either int or float") def getvalues(a, pi=3.141, c=None): if c is not None: print(c) return a+pi+c re...
fe037b032252f9de70944bac85c5a24cfec6c9cd
WonyJeong/algorithm-study
/wndnjs9878/recursive/bj-2447.py
694
3.640625
4
# 2447 import sys input = sys.stdin.readline ''' ********* * ** ** * ********* *** *** * * * * *** *** ********* * ** ** * ********* ''' def star(pattern): star = [] for i in range(3*len(pattern)): if i // len(pattern) == 1: star.append(pattern[i%len(pattern)]+""+len(pattern)+patter...
103074ddf15076fad43f909ade79e25344c85197
GaryDoooo/emoji_game
/bank.py
5,339
3.53125
4
import term_io import os from account_manage import account, load_account import pickle class bank_acc: def __init__(self,name="RECEIVER",amount=0): self.name=name self.amount=amount def save(self): pickle.dump(self, open("vending_accounts/" + sel...
94d9193a284802436208775ba4c528db0580ef80
sebastiancalleu/holbertonschool-higher_level_programming
/0x0F-python-object_relational_mapping/10-model_state_my_get.py
781
3.515625
4
#!/usr/bin/python3 ''' Select data from states table and return the first row the print the state id of that first element the element to search is given by the user. ''' import sys from model_state import Base, State from sqlalchemy import (create_engine) from sqlalchemy.orm import Session if __name__ == "__main__"...
f5c25261fbc775a546f07482b1c649fe15237dbb
E-A-N/pointless_scripts
/python/fakeTernary.py
307
4.21875
4
def ternary(condition,truthValue = True,falseValue = False): if condition: result = truthValue else: result = falseValue return result num = 5 numIsNine = ternary(num == 9) print(numIsNine) num = 9 numIsNine = ternary(num == 9, "Yep, num is 9!!", "Nope! :(") print(numIsNine)
6e1b79711f6b6b075c640100b500b1910b654fcc
albertopha/ds-algo
/LC/101/101.py
719
3.921875
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def isSymmetric(self, root: TreeNode) -> bool: return self.getInorder(root, root) def getInorder(self, leftRoot: TreeNode, rightRoot:...
54cf0a2fb866dbc1a18df9c3a0268129e18e0783
nekapoor7/Python-and-Django
/PythonNEW/Str/StringReverse4.py
568
3.890625
4
"""Write a Python function to reverses a string if it's length is a multiple of 4. """ def reverse4(s): if len(s) % 4 == 0: ns = s[::-1] return ns else: return s print(reverse4(input())) '''def reverse4(seq): if len(seq) == 4: typeseq = type(seq) ...
b5d9207d29054f7af46bc96a78a50dcedbacfa1c
Cyberproof/codemate
/codemate/utils.py
530
4.09375
4
import re def remove_indentation(content: str) -> str: """ Removes indentation from a given string that contains multiple lines. It removes spaces before new lines by the first line spaces at the beginning. Args: content(str): The sting that we want to clean from the indentation. Returns...
bbcdbdb3ff80a16e6f617cb7d502d39cb01ff345
jacquerie/leetcode
/leetcode/1352_product_of_the_last_k_numbers.py
760
3.8125
4
# -*- coding: utf-8 -*- class ProductOfNumbers: def __init__(self): self.prefix_products = [1] def add(self, num: int) -> None: if num == 0: self.prefix_products = [1] else: self.prefix_products.append(self.prefix_products[-1] * num) def getProduct(self, k...
dd42385a18b8792c62742ef243ca0087f8a80c32
rg16/GreenFilmSegmentation
/fileManager.py
2,405
3.640625
4
import os import string import argparse import cv2 # Function : parseArgs # -------------------- # This function prepares the input to be processed. The input should be an image or a directory # with images. If the directory contains other files that are not images, they are ignored. # But any .tif file in the direc...
6a75da5293845e1607da79923aa582cd2d6e5248
gy19ynk/Hello-World
/model.py
4,256
3.578125
4
"""Agent Based Model @Author: Naomi Yankho Kalebe Run in Spyder The model is run using the agents and environment that are called and initialised in the agentframework.Graphical User Interface (GUI)is used to run model.A window pops up when model is run. Use the option "Run model" on the menu bar to cre...
9a3d084224c945253e7cc539e4a07819c227f428
BJWiley233/Practical-Computer-Concepts-Files
/Database_Project/create_mysql_db.py
1,786
3.65625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Oct 26 06:34:43 2020 @author: coyote """ import mysql.connector from mysql.connector import errorcode def connect(user, password, host): cnx = mysql.connector.connect(user=user, password=password, ...
34ed86c302a8f9de4d916b69272da47badb9c9e7
ZhouDavid/cmsc25400-machine-learning
/project5/neural_net.py
4,411
3.578125
4
#!/usr/bin/env python3 import math import numpy as np def sigmoid(x): '''The sigmoid transfer function''' return 1 / (1 + np.exp(-x)) def d_sigmoid(x): '''The derivative of the sigmoid function with respect to x''' return sigmoid(x) * (1 - sigmoid(x)) def softmax(yprobs): '''Calculate normalized softmax p...
e8bb36d6cf2306722efe9d1e31f78c3618bcb28c
airings/LearningPython
/src/TrigPythonTraining/trig-2016-aug-23/plsentence.py
427
3.953125
4
#!/usr/bin/env python # get a sentence from the user # and translate each word # and then print the resulting translation # on a single line # (all lowercase letters, no punctuation) sentence = raw_input("Enter a sentence: ").strip() output = [ ] for word in sentence.split(): if word[0] in 'aeiou': outp...
0b1b9fb42e407a086823c6bcc471f2f852f66b84
qbittech/MicroPython-micro-bit_Study_Buddy
/sb_template.py
8,507
3.671875
4
import gc import time from microbit import display, Image, pin_logo, button_a, button_b from music import play, POWER_UP from speech import say # Generic talking educational database generic_ted = { 'your name': 'My name is Mr. George.', 'food': 'I like pizza.', } # Gene...
c69353009182b1b160edea5c08c494e7e1711261
Pastor59/python
/lessons/if_elif.py
214
3.953125
4
age = int(input('Enter you age:')) if age < 10: print("you are young, strange one") elif age < 40: print('the fire in you is strong, strange one') else: print('you are wise beyond doub, strange one')
11316d7f1bee91e4871e07a600a7f1d3e3792a00
nalex28/TrabajoConstruccionSoftware
/circulo.py
251
3.984375
4
from math import pi def area_circulo(r): if type(r) not in [int, float]: raise TypeError ("El radio debe ser un número real no negativo") if r < 0: raise ValueError("El radio no puede ser negativo.") return pi*(r**2)
3ea2fb02dc752da2c1dca41499e358414f83350e
mehmettaha/Practice
/Character input.py
123
3.875
4
name = input('your name please\n') age = int(input("your age?\n")) print("you'll be 100 in " + str(100-age) + " years")
ea0b99fcf64f0820b466deecd6acf56f38851658
0n1udra/Learning
/Python/Python_Problems/Rosalind-master/Algorithmic_021_SQ.py
2,068
4.03125
4
#!/usr/bin/env python ''' A solution to a ROSALIND problem from the Algorithmic Heights problem area. Algorithmic Heights focuses on teaching algorithms and data structures commonly used in computer science. Problem Title: Square in a Graph Rosalind ID: SQ Algorithmic Heights #: 021 URL: http://rosalind.info/problems/...
b45e537ff48afa479d363a82ddc692b190d9e383
etsvetanov/Algorithms
/leetcode/add_singly_linked_lists.py
1,226
3.703125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: cur1 = l1 cur2 = l2 head = ListNode(None, None) cu...
813669d39080feba92d46f9067e327d5fbc3b4f0
tychonievich/cs1110s2017
/markdown/files/001/2017-03-13-for_intro.py
191
3.734375
4
sentence = 'This is a longer piece of text' words = sentence.split() ''' word = words[0] do_stuff(word) word = words[1] do_stuff(word) ...''' for word in words: print(word) print(words)
926b2b7a2ca2a11eeb86516f5878054d65dd7332
udayt-7/Python-Assignments
/Assignment_2_Lists_Dictionaries/lists/a2p9.py
240
4.15625
4
#to remove duplicates in list a = int(input("enter the range of list 1: ")) l1 = [] for ch in range(a): a2 = int(input("enter the list 1: ")) l1.append(a2) s1 = set(l1) l1 = list(s1) print("List after removing duplicates", l1)
0f697453eb2aae5e98b3290ba042a455ac0bfc56
Yurof/WheeledRobotSimulations
/fastsim/controllers/follow_wall.py
4,384
3.875
4
from .forward import ForwardController class FollowWallController: """ The agent follows a wall while maintaining a distance specified by the user. If no wall is seen, it will search for one using the forward controller """ def __init__(self, env, verbose=False): self.env = env ...
6112a801e3b8f55e38c2104390a43b0532de551a
wesenu/Python-3
/09.Dictionaries/recordUniqueNames.py
193
3.53125
4
n = int(input()) s = set() ans = [] for i in range(n): name = input() if name in s: continue else: s.add(name) ans.append(name) for i in ans: print(i)
d3ce291b641fa28452a7baf995830d3d402582f9
Nels2/randompass
/Rpass.py
690
3.734375
4
# .Sypnosis: this is a random password generator. saves to a text file after the passwords are generated. import random char = 'abcdefghijklmnopqrstuv1234567890ABCDEFGHIJKLMNOPQRSTUV!@#$%^&*' number = input('Number of passwords to create: ') number = int(number) length = input('Password length: ') length = int(length)...
089d8f2cf7180e9d3ebb4a17400431068c9fc57f
schoef/fun
/python/IPD/strategy/Agent.py
2,511
3.875
4
''' Base class of an Agent playing the iterated prisoners dilemma ''' import abc import random class Agent: __metaclass__ = abc.ABCMeta def probabilistic_bahaviour( self, state ): ''' If one of the properties is defined, act accordingly ''' # give a random answer in 'probability_rando...
102626853b538cd44de098fa7c17b4080522da9c
alexCM93/brazo-repartidor
/part.py
11,678
3.5625
4
from constants import * import random pygame.init() # class Part, controls part object movement, position and size class Part(object): def __init__(self, name): self.name = name self.menu_pos = [125, 498] self.init_pos = [155, -70] self.init_speed = [0, 2] self.current_po...
43fe0528217175a1741aa141abc5652145ea18fb
duarte28nm/SR1
/MMC/cliente.py
2,229
3.609375
4
# client.py import socket from tkinter import * def enviar(): # criar um objeto de soquete s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # obter o nome da máquina local host = socket.gethostname() port = 9999 # conexão com o nome do host na porta s.connect((host, port)) print...
33001d396e0234a4e834d766925bf1f3f77508a3
kerzol81/Bash-and-Python-scripts
/fish
1,481
3.8125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- def fishes(): print '[1] - Csuka - Esox Lucius' print '[2] - Balin - Aspius Aspius' print '[3] - Sügér - Perca' print '[4] - Fogassüllő - Sander Lucioperca' print '[5] - Kősüllő - Sander Volgensis' print '[6] - Garda - Pelecus Cultratus' p...
f4f139b27a0261dcef3c5fd42e581aa07a81218f
apage-pi/pi-projects
/copyfile.py
892
3.953125
4
# Python program to explain shutil.copyfile() method #This is a note: create the file test.txt in the source file in repl and if on RPi, modify the user, create the folders, and create test.txt # importing shutil module import shutil # Source path source = "/home/runner/source/test.txt" # Destination path destinati...
d60538e1d659f1fdc32975a983a556f12e4458b7
eric496/leetcode.py
/tree/105.construct_binary_tree_from_preorder_and_inorder_traversal.py
2,047
3.921875
4
""" Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. For example, given preorder = [3,9,20,15,7] inorder = [9,3,15,20,7] Return the following binary tree: 3 / \ 9 20 / \ 15 7 """ # Definition for a binary tr...
5d4b180ce8204cb614ca62093e6614ec1ab75cba
levirre/Python-Projects
/tictactoe.py
2,888
3.90625
4
#board = { # 'HIGH_L':'','HIGH_M':'','HIGH_R':'', # 'MID_L':'','MID_M':'','MID_R':'', # 'LOW_L':'','LOW_M':'','LOW_R':'' #} moves_left = [0,1,2,3,4,5,6,7,8,9] board = { 7:'',8:'',9:'', 4:'',5:'',6:'', 1:'',2:'',3:'' } winning_set = [ {1,2,3},{4,5,6},{7,8,9},{1,5,9},{1,4,7},{2,5,8},{3,6,9},{3,5,7}...
3eb3d2c61b3d002528ae926e20b64029e95345cc
xmaimiao/qianchengdai
/test1/test3.py
294
3.734375
4
r=1 n=0 while r<4: sex=input("\nPlease input your sex(m/f):") age=int(input("Please input your age:")) if sex=='m': if age >=10 and age <= 12: print("Congratulations on joining the team!") n+=1 r+=1 print("Number of eligible persons is "+ str(n))
09eb609f4f525af21e5096110b3baf76c2862d1c
irromano/SleepSure
/Code/MachineLearning/src/StatML/kMeans.py
803
3.515625
4
from sklearn.cluster import KMeans from sklearn.model_selection import train_test_split from sklearn.pipeline import Pipeline import numpy as np class kMeans: def __init__(self): print("Running kmeans Network") def runModel(self, df): clustering=KMeans(init="random", n_clusters=2, random_state=8...
6c4d683d3a298cfed45f085c73078ee1a49311e3
szabgab/slides
/python/examples/functions/mysum.py
138
3.703125
4
def mysum(*numbers): print(numbers) print(type(numbers)) total = 0 for s in numbers: total += s return total
2adea4fa8496e4e3ce261e853427b2a9337ebbbe
fabiolima-dev/21
/21.py
1,926
3.984375
4
def header(text = "", size = 108, spaces = 6): new_size = size - len(text) - spaces print_spaces = int(spaces / 2) * " " half_size = int((new_size) / 2) if text == "": print("\n" + "$" * size + "\n") elif new_size % 2 == 0: print("\n" + "$" * half_size + f"{print_spaces}{text}{print_...
7b7ba391b2d185e0abadc91f9d07f560b044e845
devilfishcn/lang
/decoratorcode.py
1,458
3.640625
4
# -*- coding: utf-8 -*- # def bread(func): # def wrapper(): # print "</''''''\>" # func() # print "</______\>" # return wrapper # @bread # def sandwich(food="--ham--"): # print food # sandwich() #下面为简单的装饰器函数 from time import ctime # def deco(func):#函数对象 # def decorator(*args,...
01a507b194d65b4c31db2c5edbe0f833c117becf
niryarden/sweetcase
/tests/test_basic.py
2,223
3.546875
4
import unittest from sweetcase import switch, case, default class TestBasic(unittest.TestCase): def test_basic_use(self): num = 2 res = switch(num, [ case(1, lambda: "one"), case(2, lambda: "two"), case(3, lambd...
c14f3e8a6cf87a52c223ca05042d180930cadcb8
roni-kemp/python_programming_curricula
/CS1/0380_standard_game_loop/investigation.py
2,972
4.1875
4
''' For 70 points, complete the following investigation and answer the questions below. Pygame is a wonderful resource for creating simple computer games. The following is my version of the standard template for games. The formatting looks roughly like this: setup main loop receive inputs update draw timing dela...
9d57823d32ebeb494b6fb1f77f8ed9bc1ae896c0
ErfanDipto/Python_Projects
/Pong Game/scoreboard.py
1,130
3.953125
4
from turtle import Turtle ALIGNMENT = "center" FONT = "courier" SIZE = 80 class ScoreBoard(Turtle): def __init__(self): super().__init__() # Screen().bgcolor("black") self.penup() self.hideturtle() self.color("white") self.player1_score = 0 self.player2_sco...
393ba8ee92585e8cfe3b944e887fd60bb2071690
ThiagoCComelli/POO
/Python/POO I/Exercicios 24/Leilao.py
1,512
3.640625
4
# -*- coding: utf-8 -*- class Leilao(): __maiorValor = 0 __nomeMaiorvalor = 'Ninguem' __qtde = 0 __tot = 0 __estado = 0 __valores = [] def __init__(self,obj,minimo): self.__obj = obj self.__minimo = minimo def lance(self,nome,lance): if self.__estado == 1 and lan...
739cf57897a245a50d3fcabb0ae91810b9b04bb7
Khushal-ag/Python_Programs
/loops/prime_upto_n.py
253
3.75
4
import math n = int(input("Enter a number = ")) print("Prime no. -> ",end="") for k in range(1,n+1): f =0 for i in range(2,int(math.sqrt(k))+1): if k%i == 0: f = 1 break if f==0: print(k,end=" ")
032cfc91efeb3abdd3d389d3a46e8e34d77ff82f
riders994/DataCleaningPython
/DataCleaner.py
3,397
3.65625
4
import pandas as pd import numpy as np import scipy.stats as stats from sklearn import cross_validation as cv from sklearn.preprocessing import StandardScaler class DataCleaner(object): """ Data Cleaning Class object. As of version 1.0, takes in a dictionary of fields, and operations to perform on fields, an...
873f36e983725441d93a865c5fb81290661ea181
Monjoie11/cs400
/pythonchain/asssignments/assignment6.py
1,069
3.59375
4
import pickle import json repeat = True choice = '' def load_history(): with open('blockchain.txt', mode='rb') as f: global file_content file_content = pickle.loads(f.read()) return file_content prose = load_history() while repeat: print('want to write stuff?: 1') print('want to...
b964ff20fbe90a06cace11a0bd822ab5434d862c
AusCommsteam/Algorithm-and-Data-Structures-and-Coding-Challenges
/Challenges/largestNumberSubsequence.py
1,980
3.5625
4
""" Given a positive integer represented as a string of length N, and an integer K (0 <= K <= N), find the largest subsequence of length K in the string. Input: "3141592", K == 4 Output: "4592" """ """ Use the num from the N-K element, start from that position, I go backwards and find the maximum number in that rang...
18584d741a2a123a59a46f6944643e7397b6f6ec
baomanedu/Python-Basic-Courses
/课程源码/06-函数.py
722
3.578125
4
#function def print_msg(x:"这是一个数字"=0,y:"这是第二个数字"=0): """ This is a function ! print hello world! """ print("hello world!") print("x + y = {0} ".format(x+y)) print(dir(print_msg)) print(print_msg.__doc__) print_msg(1,3) print(print_msg.__annotations__) #args def print_mes(*test,**kw)...
5b78791556e7b9b420e9a1fa61f9f6bc1b6414ef
yc2768/PythonLearn
/.idea/day2.py
1,279
4.1875
4
#coding=utf-8 #单行注释 #print("hello") #多行注释 ''' print("hello") print("hello") print("hello") print("hello") ''' """ print("hello") print("hello") print("hello") """ ''' applePrice=3.6 #苹果的价格 weight=3 #苹果的重量 monney=applePrice*weight print(monney) ''' ''' height=input("请入你的身高:") print("身高:%d"%height) ''' ''' print("...
16d335e0c64d156c1796d45ba0835ac7c823cad6
junbyungchan/python
/lec03_function/function03.py
1,430
4.15625
4
""" 함수 정의: def 함수이름(파라미터: 타입, 파라미터2: 타입, ...) -> 리턴타입: 함수 기능(body) """ def subtract(x: int,y: int) -> int: return x - y result = subtract(5,3) print(result) # 파이썬은 함수를 호출할 때 # 함수 파라미터 타입과 리턴 타입을 검사하지 않음! result = subtract(1.1, 0.9) print(result) def my_sum(numbers: list) -> float: """ 숫자(int,float...
129cd3e612d60a7eb37baff1672df88494a8605b
barbosa-henrique/Python
/aula09-3.py
275
3.921875
4
#Divisão de string frase = 'Curso em Video Python' frase = frase.split() #Divide um string em uma lista, onde cada elemente é dividido pelo caracter ' ' espaço print(frase) frase = '-'.join(frase) #junta uma lista com base no caracter informado antes do join print(frase)
a6ac9e6a1bfd0751c8c6be6b82c5943ca5926360
ntduong/Algorithms
/utils/max_sub_array.py
1,589
3.546875
4
""" Finding the sub-array containing contiguous elements that have which has largest sum.""" import sys def slow(a): """ O(n^2) solution.""" n = len(a) b = [0] for i in xrange(n): b.append(b[i]+a[i]) # Now, b is array of cumulative sums of array a # b[i] := a[0]+..+a[i-1] = sum of the f...
26e130519761fe0b488ee08a2f09a83fc1609110
youkaimx/programmingintro
/source/intersemestral_202007/ifs_multiplos.py
785
4.21875
4
# Leer del teclado dos numeros enteros o asignarlos a dos variables # Desplegar en la pantalla si cada número es impar o par # y si el primero es múltiplo de el segundo # Por ejemplo, si tengo números 6 y 9 # el programa desplegaría # 6 es par # 9 es impar # 6 no es multiplo de 9 primer_numero = 70 segundo_num...
16bba2ce2b61972e64dd2b26dd094c69c6cc7b38
Darshnadas/100_python_ques
/DAY9/day9.29.py
550
4.375
4
""" Define a function that can accept two strings as input and print the string with maximum length in console. If two strings have the same length, then the function should print all strings line by line. """ def length(l1,l2): if len(l1) > len(l2): print("The maximum length is of this string: ",l1) ...
f141da4b1e0e08fb081c9319fec3c3398b86a7f3
hanrick2000/algorithm-6
/07 - Hash & Heap/E128hashFunction.py
354
3.515625
4
class Solution: """ @param key: A string you should hash @param HASH_SIZE: An integer @return: An integer """ def hashCode(self, key, HASH_SIZE): # write your code here magicNumber, result = 33, 0 for char in key: result = (result * magicNumber + ord(char)) %...
325f089498f75abb7bd7180b67c79faf0be882fb
sun-yifeng/python-primer
/ch11-object-class/BindDemo.py
729
3.859375
4
# !/usr/bin/env python # -*- coding:utf-8 -*- # @Time : 2018/11/9 11:10 AM # @Author: sunyf # @File : BindDemo.py """方法必须有实例才能被调用,这种限制就是绑定!""" class A: def printA(self): print("python严格要求:方法必须有实例才能被调用,这种限制就是绑定!") a = A() a.printA() """ """ class B: def setX(self, x, y): self.x = x s...
2254521d387261ce74219d4249e31ee17145efab
marioviti/Stats
/montecarlo/mcmc.py
671
3.78125
4
import random import numpy as np def uniform(a,b): if a>b: t = b b = a a = b return (random.random())*np.abs(a-b) + a def pi_monteCarlo(N): """ rejection sampling method to calculate Pi """ in_pi = 0 random.seed() x = np.zeros((N,)) y = np.zeros((N,)) fo...
043109a4ab1e34aef38d325ade4e2a1462be89a0
AmitabhPathak/Project_Euler
/problem2.py
490
3.734375
4
'''Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued term0s. '''...
ac3af5f24e7504b125cb59501d7acf720b2fff27
mkvk/Topos
/wiki_webscraping.py
6,113
3.921875
4
#!/usr/bin/env python3 """ This Python code is used to scrape the wiki website of most populous cities and add extra information from each other wiki webpages of most populous cities. Requisites : This project requires python 3 environment with "requests" "BeautifulSoup4" and "pandas" libraries pre-installed. If not...
68435be95d769e029853b2f74d217a894b9240e1
Satily/leetcode_python_solution
/solutions/solution460.py
3,090
3.546875
4
class DoubleLinkListNode: def __init__(self, value, previous=None, next=None): self.value = value self.previous = previous self.next = next class DoubleLinkList: def __init__(self): self.head = DoubleLinkListNode(None) self.tail = DoubleLinkListNode(None) self.h...
eac64562f6598ce6cc52cd676394e448b6b60ca0
AozzyA/homeCode
/LetterIf.py
2,488
3.875
4
import upperCaseLetters import turtle #name = input('what is your name ').lower() window = turtle.Screen() tur = turtle.Turtle() tur.penup() tur.goto(-330, 0) #tur.goto(-645, 0) tur.pendown() def blah(): print("do nothing") def clearS(): tur.clear() blah() while True: name = window.textinput("Name"...
4ec7b9e5070134633cb7118f2db91b0174834470
steelpwner/Ejercicios-Python-Exercism
/sum-of-multiples/sum_of_multiples.py
345
3.65625
4
def sum_of_multiples(limit, multiples): if (0 in multiples and len(multiples) == 1): return 0 elif (0 in multiples): multiples.remove(0) def filtro(n): for i in multiples: if (n % i == 0): return True return False return sum(filter(filtro, [x ...
f86b747102d3e557c71f4df17c5ff76b43789bcd
Avery123123/LeetCode
/dataStructure/queue/decode_string.py
1,099
3.671875
4
class Stack(object): def __init__(self): self.data =[] def isEmpty(self): return self.data == [] def push(self,newElem): self.data.append(newElem) def pop(self): if self.isEmpty(): raise Exception("Your Stack is Empty!") else: return se...
19175d790a8f1abc0b52b01d93b1a57bb986f010
yixin-zhu/SquareMaze-the-python-game
/game1.py
2,084
3.546875
4
import random myMap = [[0] * 10 for i in range(10)] target = [[0] * 10 for i in range(10)] width = 3 height = 3 directions = {1: "w", 2: "a", 3: "s", 4: "z"} def victory(): flag = True for i in range(height): for j in range(width): if myMap[i][j] != target[i][j]: flag = Fal...
e54d12aeb1d518eb026553010135aa642e4515bf
jgerrish/cookiecutter-pygame
/{{cookiecutter.project_module}}/{{cookiecutter.project_module}}/animation.py
990
3.921875
4
import pygame # define colors BLACK = (0, 0, 0) GREEN = (0, 255, 0) class Rectangle(pygame.sprite.Sprite): """ Rectangle is a simple sprite """ def __init__(self, screen, width, height): pygame.sprite.Sprite.__init__(self) self.image = pygame.Surface((50, 50)) self.image.fill(G...
8cfde804d50557f8aeac9fc6cbd5c1b1fd280387
spjmurray/AoC2017
/python/13.2.py
741
3.65625
4
#!/usr/bin/python # -*- coding: utf-8 -*- # PROBLEM # # http://adventofcode.com/2017/day/13 import itertools # The scanner will be in position zero at time (depth * 2) - 2). If we are # there then we have been caught def caught(time, depth): return time % ((depth * 2) - 2) == 0 def main(): # Map of firew...
2a70a0aa3798155ee341eb42ad6a8bd05163c384
fresh34/pajton
/wstepList.py
341
3.5
4
#listy owca = [d] owca2 = [5,4,2,54,4,3,54, 'napis', True, False] #wybieranie elementów owca2 [1] #drugi element print ( owca2 [2:5] ) #wyciągnie liste print ( type (owca2[2:5]) ) #wyświetli typ danego elementu # łączenie list [1,2,3] + [4,5,6] #dodawanie elementu do listy owca.append(7) ...
b7e68be582d16e8e45e5fad18a5a1fb6c0b3e3df
zhazhazhazhi/likou
/57.py
999
3.609375
4
# -*- coding: utf-8 -*- """ Created on Tue Nov 12 21:39:03 2019 @author: vip """ class Solution(object): def insert(self, intervals, newInterval): intervals.append(newInterval) intervals.sort() flag=[[intervals[0][0],intervals[0][1]]] for i in range (1,len(intervals)): ...