blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
f02417484423f993c2f6c66cc03fc579ef49c0e4
RobinFiveWords/merge_closest
/merge_closest/__init__.py
3,951
3.625
4
from __future__ import print_function import numpy as np import pandas as pd def merge_closest(data, lookup, data_field, lookup_field, include_cols=None, exclude_cols=None, presorted=False): """Merge column(s) into DataFrame using closest-without-going-over lookup. Th...
5ec8bf57f9cf8a7b2d2474ebc8cfdb3224bd084e
sdugaro/django
/django-tutorial/polls/converters.py
3,189
3.90625
4
""" Custom Path Converters For more complex routing table matching requirements, you can define custom path converters. A Converter is a class that: 1. has a regex as a string as an attribute (which will be compiled) 2. implements a to_python() method which converts the matched string into the type that should be ...
9bba257ce2587277ee7f02563f4a9e59c466dec4
copley/University
/Undergraduate/COMP312/Assignment1/Programs/radius.py
548
3.515625
4
import random import math N = 1000000 random.seed(123) circleRadi = [] for i in range(0, N): r = random.random(); A = math.pi * math.pow(r, 2) circleRadi.append((r, A)) sumR = 0 sumRSquare = 0 sumA = 0 for circle in circleRadi: r, a = circle sumR += r sumRSquare += math.pow(r, 2) sumA += a meanR = (1.0/N)...
062cb87caa5ff20d1bd57bb91a216b18ee75337f
copley/University
/Undergraduate/COMP312/Assignment3/Programs/01.py
394
3.953125
4
import math class Ellipse(object): """The Ellipse class""" def __init__(self, a, b): self.a = a; self.b = b; def area(self): return math.pi * self.a * self.b def eccentricity(self): return math.sqrt(1 - math.pow(self.b/self.a, 2)) if __name__ == "__main__": ellipse = Ellipse(10, 5) print "Area: " +...
a072fae93291284e06a709f1a5ae35e5810b30f0
copley/University
/Undergraduate/COMP312/Final Project Submission/Scripts and Data/arrival_departure_plot_rawData.py
5,406
3.6875
4
import numpy import math import Tkinter import tkFileDialog import matplotlib.pyplot as pl # This script generates a plot of customers in the session over time #Function ************************************************************ def split_data_into_individual_servers(services): """ Takes the full activity lest...
d7b87e6e6ce3c70447f641293d3d2c53928afc85
AlekseiKustov/GBPyHomework
/Homework_5.py
7,175
3.71875
4
#1. Создать программно файл в текстовом формате, записать в него построчно данные, вводимые пользователем. # Об окончании ввода данных свидетельствует пустая строка. with open('C:/Users/Алексей/Desktop/PyProjects/beginning/textX.txt', 'x') as file: while True: user_print = input('Введите строку:...
8a8a44214e08ca49391afa9510e00a1d7dc622d2
adarshajit/Everything-Python
/crypto_machine.py
494
3.984375
4
def crypto_machine(): keys = 'abcdefghijklmnopqrstuvwxyz !' values = keys[-1] + keys[0:-1] dict_e = dict(zip(keys,values)) dict_d = dict(zip(values,keys)) msg = input("enter your message: ") mode = input("enter e to encrypt and d to decrypt:") if mode == 'e': new_msg = ''.join([d...
b1020a0e36baa29b31dd14c9f476c80fe095ef95
rob0ak/Hang_Man_Game
/app.py
2,728
4.125
4
import random def set_up_game(word, list_of_letters, blank_list): for letter in word: list_of_letters += letter blank_list += "-" def find_letters(word_list, blank_list, guess, list_of_guesses): count = 0 # Checks the users guess to see if its within the word_list for let...
93329b0ae1294f56671df5f395fe1d85d807c1d4
cianibegood/Ising-Monte-Carlo
/isingMetropolis.py
2,852
3.59375
4
""" Metropolis simulation of the classical Ising model on a square lattice. Algorithm: 1) Create a random N x N matrix of 1 and -1 (initial configuration) 2) Select one spin (site) randomly 3) Generate random number r between 0 and 1 4) If r< \exp[-\Delta E/\beta] (Boltzmann weight) flip the spin 5) Select another sp...
5b2d471c93a42bc8d999dda75efc8cff7c8774c4
kristofferjh/search-and-sort
/binary_search.py
1,009
3.84375
4
import csv from merge_sort import merge_sort def binary_search(A, target): pivot = len(A) // 2 if len(A) == 1 and A[pivot] != target: return False if A[pivot] == target: find_city(target) return True elif A[pivot] < target: return binary_search(A[pivot:], ta...
f5bf86a676ab4cd1bcf2499205256a8d349e7d71
YoungJun-Lee1994/bioinfo-lecture-2021-07
/210708/bioinformatics_1_3.py
102
3.625
4
l = input("Enter a interger : ") i = input("Enter another : ") s = int(i) + int(l) print("Sum : ", s)
3f5696be46de50a567b8fc5f0d1992dea1b90b1b
YoungJun-Lee1994/bioinfo-lecture-2021-07
/src/210706.py
3,092
3.734375
4
#! /usr/bin/env python """ #아니 2시까지 스크립트 다 날아감..... #울어 #020 문자열 더하기 #두 개의 변수를 선언한 후 각각 Bio와 Informatics를 넣은 후 다른 변수에는 두 변수를 합친 값을 집어넣고 출력해보세요. a1 = "Bio" a2 = 'Informatics' a3 = a1 + a2 print(a3) #여기서 부터 클래스 간단히 설명 class A: def __init__(self): val = "" a1 = A() -> a1.val 출력하면 ''(아무것도 없는거) 나옴 a2 = A() -...
cf1da963fd82dbcf56899bb5fcff0374d31d5c25
YoungJun-Lee1994/bioinfo-lecture-2021-07
/210708/bioinformatics_2_5.py
139
3.828125
4
s1 = input("s1: ") s2 = input("s2: ") l1 = len(s1) l2 = len(s2) if l1 % 2 == 1 and l1 < l2: print(s1 + s2) else: print(s2 + s1)
8d1399cd8e8e12256ca1ed39f7e0c7190a7bab12
oberetey/supervised_learning
/Fit_&_predict_for_regression.py
2,014
3.84375
4
# in this script i will use the 'fertility' feature of the Gapminder dataset. # Since the goal is to predict life expectancy, the target variable here is 'life'. # The array for the target variable is set as y and the array for 'fertility' has been set as X_fertility. # A scatter plot with 'fertility' on the x-axis ...
5fa0bda9fe72d1223a4b31eac1ab0f991ad7ed71
hchamikadilshan/polygonal_area_calculator
/Polygonal_Area_Calculator.py
1,487
3.921875
4
class Rectangle: def __init__(self,width,height): self.width=width self.height=height def set_width(self,width): self.width=width def set_height(self,height): self.height=height def get_area(self): return (self.width*se...
eb9d78da79c0d9dba32aa305bd45dfdff61173bb
shwetajoshi601/automate-python-projects
/6-Strings/3.Table Printer/tablePrinter.py
713
3.796875
4
#! python3 tableData = [['apples', 'oranges', 'cherries', 'banana'], ['Alice', 'Bob', 'Carol', 'David'], ['dogs', 'cats', 'moose', 'goose']] def printTable(tableData): colWidths = [0]*len(tableData) # find the maximum length of string in each list for i in range(len(tableData)): ...
499f5134ce9a42db3fe881ba482e4ff54c6ab137
karthikbhoshle/Typing-Speed-Test
/typing test.py
4,913
3.515625
4
import tkinter from tkinter import * import random import sys ############## root=tkinter.Tk() w = '#FFFFFF' g = '#20FF0F' lg = '#778899' r = '#8B0000' global word,user,t,k,sm t=120 k=0 sm=StringVar() word=['Computer','Science','Common','School','Impossible','Selection','Random','Python','Javascript','Fun...
1da6a5904e2d696760506872ae446095ad8e8fae
PrashantMhrzn/Quiz-App
/main.py
1,169
3.671875
4
import requests def api_data(item): question = item['question'] global correct_ans correct_ans = item['correct_answer'] print(f'Question: {question}') choices = ''' *****Welcome to the Quiz***** Choose your topic: 1.General Knowlegde 2.Films 3.Computer ''' try: usr_choice = int(input(choices)) ex...
783c1547eb544e877d6f4181a7f94bd54553db94
jllaneras/aoc-2019
/aoc/day6/star12.py
1,652
3.578125
4
# https://adventofcode.com/2019/day/6#part2 from aoc.day6.star11 import parse_orbit_map, path_to_com def min_orbit_transfers_between_you_and_santa(orbit_map_str): orbit_map = parse_orbit_map(orbit_map_str) # If Santa is on your path to the Center of Mass (COM) then it's easy: # just count the number of ...
dc8984c4cfd724b87aebfb8e99142f6a312cfbfc
yachu0721/Introduction-to-data-sciencl
/Week13/IDS_20200529_3.py
290
3.703125
4
n_vowels = 0 for i in 'azcbobobegghakl': if i in["a","e","i","o","u"]: print(i) n_vowels += 1 print(n_vowels) print("===") n_vowels = 0 for i in 'azcbobobegghakl': if i in["a","e","i","o","u"]: # print(i) n_vowels += 1 print(n_vowels)
da24fc338f593c0c01c0ab3ae976dd2a6e2a4d95
yachu0721/Introduction-to-data-sciencl
/Week9/IDS_20200501_2.py
194
3.71875
4
x = int(input("請輸入起始的整數:")) y = int(input("請輸入終止的整數:")) i = x # start while i <= y: # stop # task if i % 2 == 1: print(i) i += 1 # step
7009c5236d09e5c6578274ca138febdb91879e81
yachu0721/Introduction-to-data-sciencl
/Week12/IDS_20200522_12.py
144
3.546875
4
weekdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'] for i, wd in enumerate(weekdays): print("{}:星期{}".format(wd, i+1))
e2d878bec781d972138d7e532ceee051d51c4333
yachu0721/Introduction-to-data-sciencl
/Week12/IDS_20200522_13.py
384
3.703125
4
avengers = ["The Avengers", "Avengers: Age of Ultron", "Avengers: Infinity War", "Avengers: Endgame"] for idx, movie in enumerate(avengers): print("第 {} 部上映的復仇者聯盟是:{}".format(idx+1, movie)) print("-----------------------") years = [2012, 2015, 2018, 2019] for year, movie in zip(years, avengers): print("{}...
89af6e935db8d2225dbc634f65001265d2e4c88b
eliasmg12345/IAII
/2021_06_01/perceptron multicapa para XOR.py
2,747
3.640625
4
#ejemplo perceptron multicapa para XOR import numpy as np import matplotlib.pyplot as plt from pylab import plot, ylim, xlim #funcion sigmoide y derivada def sigmoide (x): return 1 / ( 1 + np.exp(-x)) def d_sigmoide(x): return 1 / ( 2 + np.exp(-x)+np.exp(x)) def aprendizaje(): np.set_printoptions(precision=...
d4a9976f2eb7127d918cebcbedb67b96393ab21a
eliasmg12345/IAII
/2021_06_01/Problema de Clasificacion.py
574
3.578125
4
import numpy as np import pandas as pd df= pd.DataFrame({ "x1": [0.3, 0.1, 0.4, 0.5], "x2": [0.7, 0.2, 0.3, 0.8], "y1": [0,0,0,1], "y2":[0,1,1,1] }) entrada=["x1", "x2"] salida=["y1","y2"] X_train = df[entrada] y_train = df[salida] if len(salida)==1: y_train=np.ravel(y_train) from sklearn.neural_net...
a2c6561be0be7489d0ceebd46b86b2eb3812e5cd
YoungBear/LintCode
/PythonCode/lintcode/easy/MergeSortedArray.py
1,127
3.953125
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2018/2/11 9:50 # @Author : bearyang # @Site : # @File : MergeSortedArray.py # @Software: PyCharm # Lintcode 64. 合并排序数组 # http://www.lintcode.com/zh-cn/problem/merge-sorted-array/ class Solution: """ @param: A: sorted integer array A which has m ...
3ed1289d22c7893579a076f91325ab37cd1e9ce5
YoungBear/LintCode
/PythonCode/lintcode/easy/RemoveDuplicates2.py
842
3.734375
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2018/2/11 15:05 # @Author : bearyang # @Site : # @File : RemoveDuplicates2.py # @Software: PyCharm # 101. 删除排序数组中的重复数字 II # http://www.lintcode.com/zh-cn/problem/remove-duplicates-from-sorted-array-ii/ # 允许出现两次重复 class Solution: """ @param: nums...
0333ba952779bd1a9d84088517c394d1053b2441
YoungBear/LintCode
/PythonCode/leetcode/easy/JewelsInStones.py
559
3.515625
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2018/2/10 9:26 # @Author : bearyang # @Site : # @File : JewelsInStones.py # @Software: PyCharm class Solution: def numJewelsInStones(self, J, S): """ :type J: str :type S: str :rtype: int """ count = 0...
5bb0a839304e814da08bbb6552570d17aa594661
YoungBear/LintCode
/PythonCode/lintcode/easy/JohnGarden.py
692
3.734375
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2018/1/31 10:55 # @Author : bearyang # @Site : # @File : JohnGarden.py # @Software: PyCharm # 749. 约翰的后花园 # http://www.lintcode.com/zh-cn/problem/johns-backyard-garden/ class Solution: """ @param x: the wall's height @return: YES or NO "...
720a6979576ec4fd7fd2f74dc325af5fe494a2ed
Albertpython/pythonhome
/home1.py
364
3.890625
4
# Task 1 name = input("your name ") age = input("your age ") phone = input("your phone ") email = input("your email ") print("Hello My name is", name , ":", "I am", age, "years old", ":", "My phone", phone, ":", "My email", email, ":") # Task 2 print("Python is powerfull... and fast;\n\t plays well with others;\nru...
2560465ef934a25339aafb8677688dd4fb73a590
Albertpython/pythonhome
/art.py
217
3.984375
4
import datetime year = int(input('Year: ')) month = int(input('Month: ')) day = int(input('Day: ')) x = datetime.datetime.now() y = datetime.datetime(year, month, day) res = x - y print(x) print(y) print(res[day])
9b55f6b74d6a2606471c4a8c2be61f50a58759ee
Albertpython/pythonhome
/home10.py
717
3.78125
4
'''Write a Python program to check if pc number is great than 10. random(1,20) when True break.''' # import random # while True: # pc = random.randint(1,20) # print(pc) # if pc > 10: # break # else: # continue '''Chinga Chung''' import random Point_User = 0 Point_Pc = 0 while True: User = int(input("Rock - 1...
5c708d99765f36579409eca6fa9d389b0f83b16e
Albertpython/pythonhome
/home14.py
328
4.375
4
'''Write a Python program to find the length of a tuple''' # tup = ("black", "bmw", "red", "ferrary") # res = 0 # for x in tup: # res += 1 # continue # print(res) '''Write a Python program to convert a tuple to a string''' # name = ('A', 'L', 'B', 'E', 'R', 'T') # print(name[0]+name[1]+name[2]+name[3]+name[4]+nam...
b4f7de52899ff4a447a3ee2e1b85f2dcf86be13e
Albertpython/pythonhome
/qnnakan.py
3,323
4.40625
4
''' ----- 1 ----- The doctors and the scientists are found out that you can learn about your illness coronavirus from home by the following formula. If you duplicate your body temperature by Celsus with the number of pi(math) and round up to the nearest whole number and if it is...
db53054877bc9e03ad2feba2efba6c0792857c32
panovitch/code-101
/1_shapes _and_color.py
1,510
4.15625
4
""" Here we introduce the concepts of statements and basic types: strings and integers. WE talk about how a program is a list of senteses exuted from top to bottom, and that some commands can result in a change of state, and some commands are just actions to execute. We also explain what comments are :D """ # here we...
ce7a2b8c317178401d9e07ed156ad7b183ff565a
rkguptaaa/PythonProgram
/lamda_expression.py
202
3.546875
4
# square by using lamda expression my_list = [5,3,4] print(list(map(lambda item : item ** 2, my_list ))) # sorting in tuple a = [(0,2), (4,3), (9,9), (10,-1)] a.sort(key = lambda k : k[1]) print(a)
a4374c0be0730be62a69108635deefe8164e9f97
rkguptaaa/PythonProgram
/OOPS_first.py
1,113
3.875
4
####### One way #class Cat: # species = 'mammal' # def __init__(self, name, age): # self.name = name # self.age = age # # def FindEldestCat(self): # return self.age # #cat_instance = [] #cat_age = [] # #cat_instance.append(Cat('cat1', 59)) #cat_instance.append(Cat('cat2', 25)) #cat_in...
1460afd4745b97a001540bde2dce05bf6364a8c1
Ratheshprabakar/Python-Programs
/X_Pattern.py
449
3.953125
4
def input_string(): n=input("Enter the string") for i in range(len(n)): for j in range(len(n)): if i==j : print(n[i],end=' ') elif i+j==len(n)-1: print(n[i],end=' ') el...
2b4f5355db301ea1a0c2892d384a48dec3c3ecae
Ratheshprabakar/Python-Programs
/maxmin.py
260
4.15625
4
print("Enter the three numbers") a=int(input("Enter the 1st Number")) b=int(input("Enter the 2nd Number\n")) c=int(input("Enter the 3rd Number")) print("The maximum among three numbers",max(a,b,c)) print("The Minimum among three numbers",min(a,b,c))
2efe25d4a1589a8ad24e0f9307b616bd419201b0
Ratheshprabakar/Python-Programs
/palindrome.py
258
4.3125
4
#Python program to check whether the number is a palindrome or not def palindrome(a): if(a[::-1]==a): print(a,"is palindrome") else: print(a,"is not a palindrome") def main(): a=input("Enter a number") palindrome(a) if __name__=='__main__': main()
4879b0be7e47945416bfe1764495968ae896726c
Ratheshprabakar/Python-Programs
/concatenate and count the no. of characters in a string.py
318
4.3125
4
#Concatnation of two strings #To find the number of characters in the concatenated string first_string=input("Enter the 1st string") second_string=input("Enter the 2nd string") two_string=first_string+second_string print(two_string) c=0 for k in two_string: c+=1 print("No. of charcters in string is",c)
e54a34636c36321cb03605dfc39b69f1fab40f89
Ratheshprabakar/Python-Programs
/Multiplication table.py
241
4.28125
4
#To display the multiplication table x=int(input("Enter the table no. you want to get")) y=int(input("Enter the table limit of table")) print("The Multiplication table of",x,"is:") i=1 while i<=y: print(i,"*",x,"=",x*i) i+=1
1d146fbb1d175b898233b6e8085d38e9daadd9c6
VasaStulo/Pythonchik
/prostoe_chislo.py
927
3.796875
4
def is_prime(num): d = 2 if num > 1: while (num % d) != 0: d = d + 1 return (d == num) arg = int(input()) plus = arg minus = arg res = 0 res1 = 0 res2 = 0 if not is_prime(arg): while not is_prime(plus): plus = plus + 1 while not is_prime(minus): if minus == 1: ...
7cfa1c977434c386eb3738bb15c0510c2a587563
adityaapi444/beginner_game
/chocwrap.py
1,004
4.1875
4
#chocolate wrapper puzzle game # price of one chocolate=2 #you will get 1 chocolate by exchanging 3 wrapper #write a program to count how many chocolates can you eat in 'n' money # n is input value for money #ex. #input: money=20 #output: chocolate=14 wrapper remains: 2 money=int(input("ente your mone...
0e80d006f6e0ddf82fc7a2dc12adcd38fa38a0cb
Banana-zhang/Python_Doc_Learn
/biaozhunku/Module_re.py
235
3.515625
4
import re output5 = re.findall(r'\bf[a-z]*', 'which foot or hand fell fastest') print(output5) output6 = re.sub(r'(\b[a-z]+) \1', r'\1', 'cat in the the hat') print(output6) output7 = 'tea for too'.replace('too', 'two') print(output7)
c7e29aa95415b2b40e54bb023a69ee30a4cd3c4b
Supakron123/testPython
/exercism/python/pangram/pangram.py
665
4.03125
4
def is_pangram(sentence): # characters = list(sentence) # characters.sort() # isogram_characters = [] # # for character in characters: # if character.isalpha(): # pass # elif character.upper() in isogram_characters: # pass # isogram_characters.append(c...
b1e5ad2409a66b357ddde47e1954ba007278bd8a
dean985/ddos_assignment
/monitor_files/parse_hping.py
1,550
3.53125
4
from time import sleep import sys def parse(hping_output): """ This method will parse the output of hping and reformat it according to the assignment Args: hping_output (file): File containing plain text """ with open(hping_output, 'r') as f: ping_values = [] raw = f....
cc23ecea36f0ad822e62742354427e8e1a9e4495
esterwalf/python-basics
/meh.py
806
4.1875
4
>>> grade = eval(input("Enter your number grade (0-100):")) >>> if grade >= 90: print("You got an A! :)") elif grade >= 80: print("You got a B!") elif grade >= 70: ("You got a C. ") elif grade >= 60: ("You got a D... ") else: print("You got an F :(") >>> rainy = input("How's the weather? Is it raini...
681b785e3f09a24c8ab87c58aa759a588ce30e51
esterwalf/python-basics
/rosette or polygon.py
1,005
4.5625
5
>>> import turtle >>> t = turtle.Pen() >>> number = int(turtle.numinput("Number of sides or circles", "How many sides or circles in your shape?", 6)) >>> shape = turtle.textinput("which shape do you want?", "Enter 'p' for polygon or 'r' for rosette:") >>> for x in range(number): if shape == 'r': ...
08b70f33085fa926fd8191770d5eff2724c96175
elaguerta/Xiangqi
/XiangqiGame_single_module.py
5,945
3.890625
4
from Board import Board from Player import Player class XiangqiGame(): """ Creates Xiangqi Games Language note: 'side' refers to a player side of interest, and is string that may be 'red' or 'black'. 'player' is used to refer to Player objects.""" def __init__(self): self._board = Board() ...
989eeaea35c3342c9476735031a4ea1ae496c878
elaguerta/Xiangqi
/ElephantPiece.py
1,777
4.21875
4
from Piece import Piece class ElephantPiece(Piece): """Creates ElephantPieces elephant_positions is a class variable, a dictionary of initial positions keyed by player color Two ElephantPieces are created by a call to Player.__init__().""" elephant_positions = { 'red': [...
21faf843afdeb781c1c19656871aefb721200f04
nholaday/tabletennis
/tabletennis_rand.py
706
3.859375
4
#!/usr/bin/env python #Created by Nic Holaday 2018 #nholaday@gmail.com """ Takes in a csv with a column of advanced players and beginner players. Assigns each advanced player with a random beginner player for random but even teams. """ import csv import random cola, colb = [], [] with open('Table_Tennis_Teams.csv') a...
7c598da5dce2e165a434dc5bc6a8c607af1bf616
md-vanilla/hacker-rank-javascript
/my-javscript/euler/02_even_fib_numbers.py
930
3.625
4
# from math import sqrt, floor, log # from decimal import Decimal from bisect import bisect # phi = (1 + Decimal(5).sqrt()) / 2 # def reverse_fib(val): # 2 # return floor( # log(val * sqrt(5) + 1/2, phi) # ) # def floor_divide_three(val): # return val // 3 even_fibs = [ 2, 8, 34, 144, 610, 2...
6d71bef65a3e83f9fff84f36642d2ade4a3db315
Dop-dd/Iot-Platform
/ThingsKeep/models/sensor.py
1,015
3.671875
4
# store sensor data sensor_list = [] # get the ID of the last sensor def get_last_id(): if sensor_list: last_sensor = sensor_list[-1] else: return 1 return last_sensor.id + 1 # define the sensor class class Sensor: # the __init constructor methode with the parameters def __init__(se...
fef6a53d7ac9e0a73aaf7f8a6168c6b2761c2e90
rambabu519/AlgorithmsNSolutions
/Valid_paranthesis.py
1,533
4.125
4
''' 20. Valid Parentheses Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Note that an empty string is also ...
ec52adc232ad755d49953a86bb1326e511d94163
Jatin666/password-generator
/pass.py
526
3.890625
4
import random length=int(input("enter the length of password: ")) list1=[] password='' if(length<6): print("password should have atleast 6 characters") flag=False elif(length>=6): for i in range(33,119): list.append(chr(i)) flag=True while(flag): randomCharacter = random.choice(list1) ...
22e23c217d1792a124986ae73283cca71fde5c09
ACSLaboratory/pheeno_ros
/scripts/random_walk.py
2,247
3.515625
4
#!/usr/bin/env python """ Random Walk Example Code Written by: Zahi Kakish (zmk5) License: BSD 3-Clause """ import argparse import rospy from geometry_msgs.msg import Twist from pheeno_robot import PheenoRobot def get_args(): """ Get arguments from rosrun for individual deployment. """ parser = argparse.Arg...
d95b5c1a01cbc3c4dab00c596d3019b30561b110
purushottam22/Author-Profiling-in-Social-Media
/Features/stopwordCalculation.py
448
3.640625
4
import nltk #nltk.download('punkt') from nltk.corpus import stopwords from nltk.tokenize import word_tokenize ex_sent = "This is a simple sentence, showing the word filteration." stop_words = set(stopwords.words('english')) words_token = word_tokenize(ex_sent) total_words=len(words_token) filterd_sentence= [w for w in...
7dbaaa1a2da7d81b5278ea8f9170d2a8d6524342
Saini-01/calculator
/week3.py
547
3.875
4
def add(): x = input() y = input() print(int(x) + int(y)) def sub(): s = input() u = input() print(int(s) - int(u)) def multiply(): m = input() u = input() print(int(m)*int(u)) def divide(): d = input() i = input() print(int(d) / int(i)) print("choo...
2207d76f469faa0c26fdf967aee4bc7b8d253254
SuperSayianGodCode/SimulationLab
/assignment.py
761
3.71875
4
import numpy as np import matplotlib.pyplot as plt count_list = list() no_jobs = list() def Activity(start, finish, n): j=0 count = 1 for i in range(1, n): if(start[i] >= finish[j]): count = count + 1 print(start[i], finish[j]) j = i count_list.extend([count]) print(count) def Draw_...
822650af6c5e26f62e7d9ddd235df58d0810371e
swojit/python-automations
/cse.py
692
3.734375
4
#! /usr/bin/env python3 # Author: Swojit Mohapatra # To open new tabs of UWCSE websites. Just type in course numbers as arguments # Q. Why did I do this? # A. Because I want to make the world a better place by solving one FWP at a time import webbrowser, sys chrome_path = 'open -a /Applications/Google\ Chrome.app %s'...
fbd519b2609b8aff38ce6d057c30ff54082aa425
itsvivekghosh/Problem-Solving-Data-Structures
/Coins Piles/CoinsPiles.py
382
3.859375
4
def check_piles_empty_possible(a: int, b: int) -> bool: x = 2 * b - a; y = 2 * a - b if x < 0 or y < 0: return False return not (x % 3) and not (y % 3) def main(): for _ in range(int(input().strip())): a, b = map(int, input().strip().split()) print("YES" if check_piles_empty_po...
c752ad1077b802ea919d559a496ed7ed0389aba9
Eacruzr/python-code
/clase 3/cuadrado.py
207
3.703125
4
def doble_parametro(parametro:int): print(parametro*2) def cuadrado(parametro:int): print(parametro*parametro) parametro=input('digite un parametro: ') parametro=int(parametro) cuadrado(parametro)
0708f5f36361c08359be5a4a35105b3f2b5c0b4a
Eacruzr/python-code
/clase 5/indices.py
221
3.90625
4
palabra = 'Un texto de varias palabras' palabra = 5 palabra = 5.5 palabra = [] palabra = {} #print(palabra[0]) #slices print(palabra[0:5]) print(palabra[-5:]) print(palabra[::1]) print(palabra[::2]) print(palabra[::-1])
f88dc04c5279b695d8d2d2dc3fdc2f126cc7057d
Eacruzr/python-code
/clase 7/collections.py
359
3.75
4
palabra = 'Una palabra' print(palabra) lista = list(palabra) print(lista) diccionario = {'nombre': 'Eider', 'Apellido': 'Cruz'} lista = list(diccionario.keys()) lista = list(diccionario.values()) # lista = list(diccionario.items()) print(lista) tupla = tuple(lista) print(tupla) lista = list(palabra) print(dict(lista)) ...
37171a577dc1322891ec0a9d2f6f4fa7e9bc17ad
ruddfawcett/euler
/Python/Problem2.py
503
3.96875
4
''' Problem 2: Even Fibonacci numbers 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, ... Find the sum of all the multiples of 3 or 5 below 1000. @author Rudd Fawcett @date 2015-11-26 ''' ...
2edadd5ef07eb5fd75d184f087090c2380054907
myron0220/COMPSCI_2XB3
/lab7/graphs.py
5,798
3.78125
4
# @details All search methods in this module assume that node1 and node2 are different from collections import deque # Undirected graph using an adjacency list class Graph: def __init__(self, n): self.adj = {} for i in range(n): self.adj[i] = [] def are_connected(self, node1, no...
73022263b619efa46a94a695e88453caa73c6f66
myron0220/COMPSCI_2XB3
/lab5/heap.py
6,402
3.84375
4
# @@file heap.py # @author Hyosik Moon, Mingzhe Wang, Xing Li # @date Feb. 21, 2021 import math import random class Heap: length = 0 data = [] def __init__(self, L): self.data = L self.length = len(L) # select one build method: build_heap1, build_heap2, build_heap3...
0949435307ceb7282bc0750346ea85d1cb34c439
zihuilin/coding
/997Algorithm/AVLTree/BinaryTree.py
3,855
4
4
class BinaryTree: class Node: def __init__(self, data): self.data = data self.left = self.right = None def __init__(self): self.root = None def printNode(self, node): if node is self.root: print('R(' + str(node.data) + ') ', end='') else:...
defe63587762762e40aed8af7f005ecee43544f0
zihuilin/coding
/998数据结构/19大数据2班/024ListAsStack.py
809
3.859375
4
class LStack: def __init__(self): self.list = [] self.top = -1 #整数表示栈顶的位置 #入栈 def push(self, data): self.list.append(data) self.top = self.top + 1 #出栈 def pop(self): if self.top >= 0: #栈非空 self.top = self.top - 1 return self.list.pop...
fb62f95fa5e379575bf703188558e91fd2e2d2a3
zihuilin/coding
/991概率论/zhuawawa.py
365
3.515625
4
#-*- coding:utf-8 -*- import matplotlib.pyplot as plt p = 0.05 #单次抓娃娃,抓到的概率 n = 100 plist = [] labels = [] pc = 1.0 #抓不到的概率 for i in range(n-1): #循环n-1次 labels.append(str(i+1)) plist.append(p*pc) pc = pc * (1 - p) labels.append(str(n)) plist.append(pc) #pc就是(1-p)^n-1 plt.plot(labels, plist) plt.show() ...
49730610f0d2961115180491c77dddfe262a6a4d
zihuilin/coding
/998数据结构/19大数据2班/026LinkedListAsStack.py
4,275
4.1875
4
class LinkedList: class Node: def __init__(self, data): self.data = data #数据 self.next = None #next链接指向None def __init__(self): self.head = None #头部一开始指向None(为空) self.tail = None #尾部一开始指向None(为空) def add_to_head(self, new_data): new_node = self.Nod...
92b5db2a8592239280f5e93218c4d70d325e284a
zihuilin/coding
/998数据结构/19大数据2班/035GraphWeighted.py
1,143
3.625
4
class Graph: def __init__(self, vertices, matrix): self.vertices = vertices #节点list self.matrix = matrix #邻接矩阵 self.vcount = len(vertices) #节点的个数 def printMatrix(self): for u in range(self.vcount): for v in range(self.vcount): print(str(self...
6ebdcc165fefef00036057ba3f334cf6ae9c0f33
zihuilin/coding
/995Up/0002变量的声明和使用/variable.py
55
3.609375
4
a = int(input()) a = a + 1 b = a * 2 print(a) print(b)
9420188d2d74173dc3b779fe0e6e6a19244712f7
jakovlev-fedor/tms_python_fedor_jakovlev
/02_lesson/10_or_condition.py
681
4.34375
4
"""""" """ Используя or и 2 функции из > < <= >= == != """ """ ------------------------------------ 1. Создайте 3 условия которые будут истинными (True) Пример истинного условия: 7 > 2 or 8 == 3 """ print('#01---------------') print('b' > 'a' or 'one' != 'two') print(3 <= 3 or 8 < 80) print('abc' == 'abc' or ...
f6f1e65bc8d162044a6d6bf46a641f25e8b94878
cjyfff/my_utility_room
/some_algorithms/trie.py
833
3.921875
4
class TrieTree(object): def __init__(self): self.tree = {} def add(self, word): tree = self.tree for char in word: if char in tree: tree = tree[char] else: tree[char] = {} tree = tree[char] tree['exist'] ...
7458b340c27c597f36f876722a255465be5d7c2f
Darshana97/my_python
/FilterMap.py
398
4.0625
4
'''def is_even(n): return n%2==0 nums = [1,2,3,4,5,6,7,8,9,10] evens = list(filter(is_even,nums)) print(evens)''' from functools import reduce def add_all(a,b): return a+b nums = [3,2,6,8,4,6,2,9] evens = list(filter(lambda n: n%2==0,nums)) doubles = list(map(lambda n: n*2,evens)) ...
9bc4b47f7dec04f9d4c8fa24b9c04c625de19255
Darshana97/my_python
/Constructor_Inheritance.py
538
3.546875
4
class A: def __init__(self): print("in init A") def feature1(self): print("in feature 1") def feature2(self): print("in feature 2") class B: def __init__(self): super().__init__() print("in init B") def feature1(self): print("...
acc257e33a0d319150cb98576f5e1d04a972e21d
bdscloud/MachineLearningProject
/Initialisation-et-matrice-propre.py
11,889
3.5625
4
# -*- coding: utf-8 -*- """ Created on Tue Jun 21 09:04:00 2016 @author: BriceLaTeub """ import random import numpy as np import matplotlib.pyplot as plt import math as math import copy as cp import scipy.ndimage # ***** Déclaration des classes ***** class Point(): "Un point de notre plan" class P...
eeade4f2fc283a6d5f44647e5ce751de9d6d7417
PolicarpoDi/Exerc-cios-Mundo-1-Python
/ex028.py
782
3.859375
4
from random import randint from time import sleep # Importando a biblioteca time e o metodo sleep print('=' * 60) print('Vou pensar em um número de 0 a 5. Tente adivinhar........') print('=' * 60) computador = randint(0, 5) # randomizador de 0 a 5, onde faz o computador "PENSAR" jogador = int(input('Que número eu...
e55123a716edbec5ade625139d96b62cd318b927
PolicarpoDi/Exerc-cios-Mundo-1-Python
/ex011.py
214
3.765625
4
l = float(input('Digite a Largura da parede: ')) a = float(input('Digite a Altura da parede: ')) mq = l * a mt = mq/2 print('A área do ambiente é de {:.2f}MT² e para pintar vai {:.2f} litros'.format(mq, mt))
a1cee033eed8d224c8db822a3ecbf6073aea4f51
PolicarpoDi/Exerc-cios-Mundo-1-Python
/ex004.py
344
3.921875
4
n1 = input('Digite algo: ') print('o tipo primitivo desse valor é ', type(n1)) print('É um tipo letra ou numero? ',n1.isalnum()) print('É maiusculo? ',n1.isupper()) print('É uma letra? ',n1.isalpha()) print('É um decimal? ', n1.isdecimal()) print('é numerico? ', n1.isnumeric()) print('É um espaço?{}'.format(n1.i...
cf3a5a9682efe27d8b4c94f6c2de4458a33bbcdb
olacash/grade
/grade.py
585
3.890625
4
var=int(input("put in a score")) if (var >=10 and var <20): print("you faill the course") elif(var >=30 and var <40): print("you score PASS") elif(var >= 40 and var <50): print("your score is E'") elif(var >=50 and var <60): print("your score is D") elif(var >=60 and var <70): print("y...
4ede1b205fd3048ec33aabdd4ec75d244a762fe8
up1/python-social-network
/intro/04-list-dict-range.py
217
3.65625
4
# list people = ["william", "peter", "stephen", "nicolas"] print people # dictionary william = { "first_name": "William", "last_name": "Mayer", "Age": 40 } print william # range numbers = range(0, 10) print numbers
3b000b0c1b261680ec0bd7573c6c06f3ed6f9d00
awh112/bioinformatics1
/Code/DNA.py
808
3.59375
4
def CountNucleotides(input): a = input.count('A') c = input.count('C') g = input.count('G') t = input.count('T') return "a: " + str(a) + " c: " + str(c) + " g: " + str(g) + " t: " + str(t) def PatternStartIndices(text, pattern): count = 0 indexes = "" for i in range(len(text)): ...
7e4e274e60a51173e947e0febc15873e65747c47
Toadstool/LearnPython
/Lab1/z3.py
304
3.5
4
from random import randrange r = randrange(100) u = int(input("podaj liczbe od 1 do 100")) while(r!=u): if(u>r): print("za duzo") else: print("za malo") i = input("sprobuj") if(i=="q"): break u = int(i) if(r==u): print("zgadles")
bc6f15561516eba8ecf1c9cebcbce02a5e87bc26
pop-ketle/nlp100-2020
/ch1:準備運動/ans05.py
787
3.578125
4
# 05. n-gram # 与えられたシーケンス(文字列やリストなど)からn-gramを作る関数を作成せよ.この関数を用い,”I am an NLPer”という文から単語bi-gram,文字bi-gramを得よ. # *n-gramとは: 任意の文字列や文書を連続したn個の文字で分割するテキスト分割方法. def make_n_gram(s,n): n_gram = [] for i,t in enumerate(s): if i+n>len(s): break # 最後n文字以上取れなくなったらそこで終わりらしいので n_gram.append(s[i:i+n]) ret...
8f1228b9d1e8426c8fd7644f34a9ecb3d604b20c
pop-ketle/nlp100-2020
/ch1:準備運動/ans02.py
324
3.859375
4
# 02. 「パトカー」+「タクシー」=「パタトクカシーー」 # 「パトカー」+「タクシー」の文字を先頭から交互に連結して文字列「パタトクカシーー」を得よ. s1,s2 = 'パトカー','タクシー' ans = '' for t1,t2 in zip(s1,s2): ans+=t1 ans+=t2 print(ans)
4c775b35a1f0a0b9ff4484564abcdfadc8273e01
kemar1997/Python_Tutorials
/range_and_while.py
1,213
4.5
4
# creates a for loop that iterates through nine times starting with 0 # the range function is equivalent to creating a list but within the for loop only # Remember: Computers always start counting from 0 # the range function also accepts a range of numbers so the iteration doesn't necessarily, # have to start from exac...
20781199bff842884181faa97ec7af6d40b239dd
kemar1997/Python_Tutorials
/keyword_arguments.py
991
4.4375
4
# name, action, and item are keywords that hold values either strings or numbers # these keywords can have a default value which can be set in the parentheses below def dumb_sentence(name='Kemar', action='ate', item='tuna.'): print(name, action, item) dumb_sentence() # keyword arguments are taken in the function ...
f6d5770aaa2ffd2301fcb2f637489972e1f10cab
kemar1997/Python_Tutorials
/classes_and_objects.py
561
4.0625
4
""" A class is an easy way to group similar variables a.k.a "data" and functions together. If you want to access anything from a class you must first create an object. """ class Enemy: life = 3 def attack(self): print('ouch!') self.life -= 1 def checkLife(self): if self.life <= 0...
f8eb2dcf51767c956f2abb3ee1d784a44f4d5561
C-SON-TC1028-001-2113/ciclos-t4-A01254123
/assignments/25TrianguloAsteriscos/src/exercise.py
209
3.875
4
def main(): #escribe tu código abajo de esta línea altura=int(input("Enter triangle height: ")) for i in range(1,altura+1): print((altura-i)*" "+"*"*i) if __name__=='__main__': main()
6cf991b8e8e6bbfc1ec9dc6777946a5a0ce95dfa
johnnyapu15/dragnnect-server
/pythons/dragnnect.py
7,768
3.890625
4
# Connect devices using lines import math class Vector3: def __init__(self, x = 0, y = 0, z = 0): self.x = x self.y = y self.z = z def __add__(self, _vec): return Vector3(self.x + _vec.x, self.y + _vec.y, self.z + _vec.z) def __mul__(self, _vec): if (type(_vec) == flo...
3835ef1d609ddcff8f545fd8fb3df017d7584923
yuzongjian/pythonLearning
/demo.py
505
4.25
4
#!/usr/bin/env python # -*- coding:utf-8 -*- #@Time : 2018/6/25 23:41 #@Author: yuzongjian #@File : demo.py name = input("Please input your name:") # 打印输出有下面三种方法,最常用的是第一种 print("hello {0}".format(name)) print("hello" + name) print("hello %s" %name) print("1213"+"100") classmates = ['123','1123'] print(classmates.__le...
ed68409ac2fb2be7a238cfa48b2dc523b2c568be
GuilhermeKAC/Faculdade
/conversaonabase.py
783
3.8125
4
""" Conversão de qualquer base """ def conversaohexa(resto): resultado = str(resto) if resto == 10: resultado = 'a' elif resto == 11: resultado = 'b' elif resto == 12: resultado = 'c' elif resto == 13: resultado = 'd' elif resto == 14: resu...
076c7e2aa32dcc8aef746adb9c52fd64a742106d
halamsk/checkio
/checkio_solutions/O'Reilly/cipher_crossword.py
2,329
4.3125
4
#!/usr/bin/env checkio --domain=py run cipher-crossword # Everyone has tried solving a crossword puzzle at some point in their lives. We're going to mix things up by adding a cipher to the classic puzzle. A cipher crossword replaces the clues for each entry with clues for each white cell of the grid. These ...
a8e6c91b47849742a8c065f54031352aebe964fa
CameronHa03/Cameron_Ha----Major-work-
/major proj.py
21,935
3.859375
4
from tkinter import * root = Tk(className="Python window") # setting size of window root.geometry("750x500") # this sets the background for the entire program bg = PhotoImage(file="background_major.png") # image from https://amazing-anime.netlify.app/anime-art-desktop-background.html background = Label(root, image=...
70573b9422a6e9b4122522882bf71f6dc902d9a8
No-Life-King/school_stuff
/CSC 131 - Intro to CS/philip_smith.py
1,280
4.21875
4
def mult_tables_one(num): """ Prints a row of the multiplication table of the number 'num' from num*1 to num*10. """ print(num, end="\t") for x in range(1, 11): print(x*num, end='\t') print('\n') def mult_tables_two(start, end): """ Prints the rows of the multiplicatio...
ed29ec43803750f9d086d3d083004d45403ac38a
No-Life-King/school_stuff
/CSC 231 - Data Structures/Homework 3/Student.py
332
4.0625
4
class Student: """ An object that represents a student. """ def __init__(self, firstname, lastname, gpa): self.firstname = firstname self.lastname = lastname self.gpa = gpa def __str__(self): return "Name:\t" + self.firstname + " " + self.lastname + "\nGPA:\t...
e30cc7dc01ca446c987871b77f364be1cac1992c
No-Life-King/school_stuff
/CSC 131 - Intro to CS/lab2.py
1,035
4.0625
4
#displays a line of informative text print("How much will you pay in social security and medicare taxes this year?") #gets the user's annual salary and stores it as a float in the "annualSalary" variable annualSalary = float(input("Enter your annual salary (if you're not too shy): ")) #I'm sorry, I couldn't think of ...