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
47de9e81d4e95399dc6113ca3522b8f968f8e44d
wangyunge/algorithmpractice
/eet/86_Binary_Search_Tree_Iterator.py
1,280
3.90625
4
''' Design an iterator over a binary search tree with the following rules: Elements are visited in ascending order (i.e. an in-order traversal) next() and hasNext() queries run in O(1) time in average. Have you met this question in a real interview? Yes Example For the following binary search tree, in-order traversal ...
e1e3e1744e5e347e72bfcedaa53c873c09ad25f4
wangyunge/algorithmpractice
/int/120_Word_Ladder.py
1,302
3.796875
4
''' Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: Only one letter can be changed at a time Each intermediate word must exist in the dictionary Notice Return 0 if there is no such transformation sequence. All words have the same le...
7f5784b154c1472c0df8058521a96fa1233f257f
wangyunge/algorithmpractice
/eet/301_Remove_Invalid_Parentheses.py
536
4.03125
4
""" Given a string s that contains parentheses and letters, remove the minimum number of invalid parentheses to make the input string valid. Return all the possible results. You may return the answer in any order. Example 1: Input: s = "()())()" Output: ["(())()","()()()"] Example 2: Input: s = "(a)())()" Output...
3bd025a7c52e92aedca526c54a1beeb5895a0a3e
wangyunge/algorithmpractice
/eet/Reverse_Linked_List_II.py
2,241
4.09375
4
''' Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. Note: Given m, n satisfy the following condition: 1 ≤ m ≤ n ≤ length of list. Subscribe to see which companies asked this question Show Tags Show Simi...
9438d60a669a59fd1aa3f1d0d43ee3dc3c67f072
wangyunge/algorithmpractice
/eet/Add_and_Search_Word.py
2,265
4.03125
4
''' Design a data structure that supports the following two operations: void addWord(word) bool search(word) search(word) can search a literal word or a regular expression string containing only letters a-z or .. A . means it can represent any one letter. For example: addWord("bad") addWord("dad") addWord("mad") sea...
3f35390e3175f4c4d33e169a5078781b12ad839d
wangyunge/algorithmpractice
/cn/450.py
1,530
3.953125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution(object): def deleteNode(self, root, key): """ :type root: TreeNode :type key:...
ae968f7561fab037f39dba5e47eb745058a1ba24
UchihaSean/ReinforcementLearningForDialogue
/bleu.py
1,534
3.703125
4
# -*- coding: UTF-8 -*- import csv import numpy as np def evaluation_bleu(eval_sentence, base_sentence, n_gram=2): """ BLEU evaluation with n-gram """ def generate_n_gram_set(sentence, n): """ Generate word set based on n gram """ n_gram_set = set() for i in ran...
133a87b450bcdb2cf9374d11cba74108cca68358
seanws2/Using-search-to-operate-robot-arm
/mp2-code/template/search.py
2,311
3.796875
4
# search.py # --------------- # Licensing Information: You are free to use or extend this projects for # educational purposes provided that (1) you do not distribute or publish # solutions, (2) you retain this notice, and (3) you provide clear # attribution to the University of Illinois at Urbana-Champaign # # Created...
45dd8e0c59db48f7f557a9d084454d9fe00da97e
egill12/machine_learning
/dataset/document/generate_trend.py
1,306
3.640625
4
''' Author: Ed Gill This is a process to return a randomly generated series of numbers. change alpha from -0.2 to 0.2 to move from mean reversion to strong trend. ''' import numpy as np import pandas as pd from create_model_features import trends_features def generate_trend(n_samples, alpha, sigma): ''' :retu...
168300928e12bcc8b469a010346a5632e2e98041
JDOsborne1/Advent-of-code
/Day2/Puzzle1.py
1,354
3.796875
4
# -*- coding: utf-8 -*- """ Created on Sun Dec 2 11:05:09 2018 @author: Joe """ # Puzzle 1 ## Get the checksum ## Data import #%% dictonary link for individual letter alphanum = {'a':1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6, 'g':7, ...
6988fe01eceba6c5f8bdba8dee341cdf6022f4b7
iuliaL/dna_sequencing
/De_Bruijn_Graph.py
799
3.84375
4
def buildDeBruijnGraph(string, k): """ Return a list holding, for each k-mer, its left (k-1)-mer and its right (k-1)-mer in a pair """ edges = [] nodes = set() for i in range(len(string) - k + 1): curr_kmer = string[i:i+k] left = curr_kmer[:-1] right = curr_kmer[1:] ...
8552f778aaf03e105a5d42e2e5421ec3acd522cd
cSquaerd/ccDiceSumming
/ccDiceSumming.py
7,375
3.796875
4
# Imports import numpy as np import matplotlib.pyplot as plot # Recursively calculates how many ways to roll a value from a list of dice def ways(value : int, diceCount : int, dice : list) -> int: if value < 1 or diceCount < 1: return 0 elif diceCount == 1: return int(value <= dice[0]) else: return sum( way...
7f262c239659a7bc67048b7d88ad9890d6592260
9aa9/tabling
/tabling.py
730
3.5625
4
''' $ Email : huav2002@gmail.com' $ Fb : 99xx99' $ PageFB : aa1bb2 ''' def TABLING(lines): num = len(max(lines)) nums = [0 for i in range(num)] for line in lines: for a in range(len(line)): if len(line[a]) > nums[a]:nums[a] = len(line[a]) for a in range(len(lines)): lines[a]...
4022746f6eea714070df77e4d463a166801f3566
alexanderankin/CSV-SQL-Import-Scripts
/create_counts_table.py
1,473
3.625
4
#!/usr/bin/python3 """ This will produce a table definition from the length count matrix """ from sqlalchemy.dialects import mysql from sqlalchemy.schema import CreateTable from sqlalchemy import Table, Column, String, MetaData import fileinput import sys import csv def main(): table_name = 'import' if len(s...
87ef927974942deb7d3140c57200e281ceaa389e
manh100004104234761/otodochoi
/findpath.py
7,576
3.703125
4
from math import sqrt def getPossibleX(points): set_x = set() for point in points: set_x.add(point[0]) return set_x def getPossibleY(points): set_y = set() for point in points: set_y.add(point[1]) return set_y def findStartingAngle(start_point, next_point): if start_point[0]...
c0e2797affe5d5bfde8219c5ef6ee717af281169
tasver/python_course
/lab5_1.py
125
4.0625
4
#! /usr/bin/python3 # -*- coding: utf-8 -*- import sys print("Enter your number: ") num = int(input()) print(not(num&num-1))
f70962dff39951264b72468373fadb78663ea583
tasver/python_course
/lab9_4.py
1,905
4.0625
4
#! /usr/bin/python3 # -*- coding: utf-8 -*- def input_number() -> int: """This function returns input number""" number = input('Enter your number: ') return number def input_rome_number() -> str: """This function returns input rome number""" number = input('Enter your rome number: ') return n...
ba2b9d296a98edfb414c89aba262142b031014ea
tasver/python_course
/lab7_4.py
782
4.375
4
#! /usr/bin/python3 # -*- coding: utf-8 -*- def input_str() -> str: """ This function make input of string data""" input_string = str(input('Enter your string: ')) return input_string def string_crypt(string: str) -> str: """ This function make crypt string""" result_string = str() string = string.lower() for ...
c79e8895e05e1640469fb9d4ea21fbbf11f01262
tasver/python_course
/lab8_1.py
747
3.59375
4
#! /usr/bin/python3 # -*- coding: utf-8 -*- def input_number() -> list: """ This function make input of your data""" number_step = [] number_step.append(input('Enter soldiers number: ')) number_step.append(input('Enter step killing: ')) return number_step def killing_soldiers(number_step:list) -> int: number, s...
611f5ff5305ad4db517bb39313296f77acd0b773
tasver/python_course
/lab17_tests.py
430
3.75
4
#! /usr/bin/python3 # -*- coding: utf-8 -*- import unittest import math def formula(a:float, b:float)-> float: x = (math.sqrt(a*b))/(math.e**a * b) + a * math.e**(2*a/b) return x def output(x:float) -> str: print(x) class tests(unittest.TestCase): def test_equal_first(self): self.assertEqual(formula(0,1),0.0)...
e18e81c8986c383ac6d6cec86017d3bf948af5b3
tasver/python_course
/lab6_1.py
719
4.21875
4
#! /usr/bin/python3 # -*- coding: utf-8 -*- import math def input_par() -> list: """ This function make input of data""" a, b, c = map(float, input('Enter 3 numbers: ').split()) return [a, b, c] def check_triangle(a:list) -> bool: """ This function check exists triangle""" if (((a[0] + a[1]) > a[2]) and ((a[0] +...
d90d53e6c36ea8baebc8c65e476e7d930a9d2851
JonNData/Graphs
/objectives/graph-intro/lect_example.py
2,052
4.09375
4
class Queue: def __init__(self, ls=[]): self.size = 0 self.storage = [] def __len__(self): if self.size <= 0: return 0 else: return self.size def enqueue(self, value): self.size +=1 return self.storage.append(value) def deque...
3a5ee700dce71d3f72eb95a8d7b5900e309270ec
ahmetYilmaz88/Introduction-to-Computer-Science-with-Python
/ahmet_yilmaz_hw6_python4_5.py
731
4.125
4
## My name: Ahmet Yilmaz ##Course number and course section: IS 115 - 1001 - 1003 ##Date of completion: 2 hours ##The question is about converting the pseudocode given by instructor to the Python code. ##set the required values count=1 activity= "RESTING" flag="false" ##how many activities numact= int(input(" Enter ...
e7aeb456f723ea10f99d185e096b159e3d3de090
BigPieMuchineLearning/python_study_source_code2
/exercise_5_4.py
285
3.78125
4
mult_3=list(set(range(0,1000,3))) mult_4=list(set(range(0,1000,4))) sum=int(len(mult_3))+int(len(mult_4)) print(sum) weekday={'mon','tues','wen','thurs','fri'} weekend={'sat','sun'} n=input() def is_working_day(n): rest= n in weekend print(rest) is_working_day(n)
2eba63c46d8a4f74c5e11d165eb4f8c488dcf174
BigPieMuchineLearning/python_study_source_code2
/exercise_3_3.py
1,072
3.875
4
def print_absolute(): """절댓값을 알려주는 함수""" #독스트링 import math print('정수를 입력하세요') number = int(input()) abnumber=abs(number) print(number,'의 절댓값:',abnumber) print_absolute() help(print_absolute) def print_plus(number1,number2): """두 수를 전달받아 그 합계를 화면에 출력하는 함수""" print("두 수의 합계:",...
71cc0002a3bbdfe951d3ab035f6f3f5e17654c11
jithendra2002/LAB-15-12-2020
/L7-LinkedList_deleting_element.py
1,425
3.953125
4
class Node: def __init__(self, value): self.data = value self.next = None class LinkedList: def __init__(self): self.head = None def inputs(self,value): if self.head is None: new_node = Node(value) self.head = new_node ...
af123d78f63c5ed279e54545959ebdfa55d7d16d
ZuchniakK/PITE-Sensor-Eval
/code/Classifier.py
4,247
3.6875
4
import numpy as np import random import math from sklearn.neighbors import KNeighborsClassifier from sklearn import cross_validation class KNN(): def __init__(self,fakedatapath, sensordatapath, n_sensor_samples=None, n_fake_samples=None): """ Read the data from real sensors and simulated fake ...
0c95d6b6ebcda72fcecc1f734faf7d409936713a
Lianyihwei/RobbiLian
/Lcc/pythonrace/PYA801.py
116
3.921875
4
# TODO word = list(input()) for index,value in enumerate(word): print(f"Index of \'{value}\': {index}")
17f8483a8cec72840bc28122cfb872776e196a83
Lianyihwei/RobbiLian
/Lcc/pythonrace/PYA408.py
197
3.65625
4
# TODO evc = 0 odc = 0 for i in range(10): num = eval(input()) if num %2 == 0: evc += 1 else: odc += 1 print("Even numbers:",evc) print("Odd numbers:",odc)
ebd80b7a1750ed164559c89537b5ac64fbf01bd5
Lianyihwei/RobbiLian
/Lcc/pythonrace/PYA710.py
249
3.609375
4
#TODO from tabnanny import check dict = {} while True: key = input("Key: ") if key == "end": break value = input("Value: ") dict[key] = value search_key = input("Search key: ") print(search_key in dict.keys())
8d07696850cc5f7371069a98351c51266b77da6b
lintangsucirochmana03/bigdata
/minggu-02/praktik/src/DefiningFunction.py
913
4.3125
4
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> def fib(n): # write Fibonacci series up to n """Print a Fibonacci series up to n.""" a, b = 0, 1 while a < n: print(a, end=' ') a, b = b, a+b >>...
3e8b85dcf36442098a6cf0e1d28afb80b7abaf95
dhivya2nandha/players
/11.py
97
3.6875
4
end=['saturday','sunday'] inp=input() if(inp not in end): print("no") else: print("yes")
d760e08b472dab01b6dae64d20f84fd1ab8547ee
jmswu/learn_python
/english_dict/main.py
177
3.8125
4
from dictionary import Dictionary # make a dictionary dictionary = Dictionary() # user input user_input = input("Please enter word:") print(dictionary.translate(user_input))
d79f3a1c11d9f1afcdcb233fc0653fc70479f3c3
RoCorral/LAB_3_A
/LAB_3_A_ProcessTrees.py
7,419
3.734375
4
""" @author Rocorral ID: 80416750 Instructor: David Aguirre TA: Saha, Manoj Pravakar Assignment:Lab 3-A - AVL,RBT, word Embeddings Last Modification: 11/4/2018 Program Purpose: The purpose of this program is to practice and note the difference in computation times of insertion and retrieval between AVL Trees and Red Bl...
fa28503d8d9926d7445464844aff6e2fdd27f5a8
daibogh/lilya
/example1.py
412
3.90625
4
a = input("введите имя и фамилию через пробел: ") a = a.split(" ") print(len(a)) print(type(a))# type(a) выводит тип переменной a print(a[0]) print(a[1]) print(a[-1])# a[-1] = последний элемент a # a[0] = a[0][0].upper() + a[0][1:] # a[1] = a[1][0].upper() + a[1][1:] # print("привет, ", end= "") # print(" ".join(a), e...
7bf949a518e62547a7c76501df89cb7a28681e48
phipag/opencv-face-detection-python
/main.py
875
3.765625
4
import cv2 import argparse def main(image_path): # Load image and turn into grayscale img = cv2.imread(image_path) gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # Use the Haar Cascade classifier to detect faces face_cascade = cv2.CascadeClassifier("haarcascade_frontalface_alt.xml") faces = fac...
8dc0d965aebeaa2cbb464984a3b58cc314c8aa42
SamirSatpute/newPython
/study/study/8.py
186
3.625
4
''' Created on 29-Dec-2017 @author: samir ''' from platform import python_version print(python_version()) s2,s1 = input("Enter name").split() print("hello world") print(s1) print(s2)
8250f313bf841cebe7ae8d36dba27b3b1675502c
thoan741/lek
/Lek/mcnuggets.py
1,337
3.703125
4
d = 0 #värdet som efterfrågas n = 1 #värdet som testas counter = 0 #räknare s = 0 #variabel som enbart används för att kolla om det finns någon lösning a = 0 b = 0 c = 0 while counter < 6: #kör tills dess att vi hittar 6 tal på följd kan lösas s = 0 ...
5ed41522f413213440b7ffc675c9ffd3e4ad778c
thoan741/lek
/Laborationer/Laboration_7/calcQueue.py
1,378
3.796875
4
# -*- coding: utf-8 -*- class calcQueue: """ Här definieras en klass. I instanser av denna klass kommer värden sparas i en lista. """ def __init__(self): """ Det här är en konstruktor, och denna kommer att skapa en instans av klassen calcQueue när man t.ex. skriver x = calcQ...
e63d25776063ee323384fb7af74dcfbea5a4774c
thoan741/lek
/Laborationer/Laboration_6_copy/laboration_6_uppgift_3.py
1,073
3.734375
4
TryckString = input("Mata in trycket: ") Sort = input("Mata in sorten: ") NyaSort = input("Vad vill du omvandla till?: ") omvandlingsLista = ["mbar", float(1013), "torr", float(760), "pascal", float(101325), "atm",float(1)] def flerStegsOmvandlare(tryck, sort, newsort, ls): def NextUnit(tryck,sort,aUnit): ...
652990fdc99924c1810dddc60be12a8d81709a6e
ashwani8958/Python
/PyQT and SQLite/M3 - Basics of Programming in Python/program/module/friends.py
379
4.125
4
def food(f, num): """Takes total and no. of people as argument""" tip = 0.1*f #calculates tip f = f + tip #add tip to total return f/num #return the per person value def movie(m, num): """Take total and no. of the people as arguments""" return m/num #returns the per persons value print("The na...
18cfb77c6446b34575ea92d962e26fa5e461c7f0
ashwani8958/Python
/PyQT and SQLite/M3 - Basics of Programming in Python/program/function/5_global_vs_local_variable.py
441
3.78125
4
age = 7 def a(): print("Global varible 'age': ", globals()['age']) #now modifying the GLOBAL varible 'age' INSIDE the function. globals()['age']=27 print("Global variable 'age' modified INSIDE the function: ", globals()['age']) #now creating a LOCAL variable, 'age' INSIDE the function. age = ...
9691a4a5ae601d1584ff81a6b27139bdd19e2ca1
ashwani8958/Python
/PyQT and SQLite/M5 - Connecting to SQLite Database/assignment/assignment/main.py
509
4.03125
4
from add_record import * from search_record import * while True: print("Menu for the database\n1) Add New Record\n2) Search a existing record\n3) Exit") choice = int(input("Enter your choice : ")) if 1 == choice: print("Adding New Record to Database") new_record() elif 2 == choice: ...
12911df610c449a02f52622633078e729afc8313
ashwani8958/Python
/Image Processing/Computer_Vision_A_Z/Face Recognition/3_FaceRecognitionInImages.py
1,317
3.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun May 24 15:14:22 2020 @author: ashwani """ # https://realpython.com/face-recognition-with-python/ import cv2 # Loading the cascades face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') eye_cascade = cv2.CascadeClassifier('haarca...
0e9eca5ed6993b1e3a2c4bb9c3ca245b6dd5c5e3
ashwani8958/Python
/PyQT and SQLite/M5 - Connecting to SQLite Database/assignment/some try/original_search_record.py
2,784
3.984375
4
import sqlite3 import re def search_record(): book_list = list() #Connect to existing database MyLibrary = sqlite3.connect('Library.db') #create a cursor object curslibrary = MyLibrary.cursor() while True: #Loop to check for valid Title while True: title = inp...
eda8e23a26733d5cfd1f4712cb9bf1f53294e585
ayhanbasmisirli/wdi_april_2019
/11-working-with-libraries/instructor/todo.py
543
4.0625
4
# let user specify due date for item # datetime.date class # display how much time is left until it's due # today() looks useful # e.g. _____ due in _____ days import arrow import datetime class ToDo: """ Represents an item on a to-do list """ def __init__(self, description, due_date): self.description = d...
5912bcec4dd22442c46ac13ea361eb54e44d20d5
ayhanbasmisirli/wdi_april_2019
/11-working-with-libraries/instructor/main.py
412
3.59375
4
from todo import ToDo, datetime, Arrow from arrow.arrow import Arrow print('When is this item due?') due_year = 2019 due_month = 5 due_day = 25 due_date = Arrow(due_year, due_month, due_day) todo = ToDo('buy groceries', due_date) print(todo) past_due = Arrow(2019, 5, 12) todo2 = ToDo('dishes', past_due) print(todo2...
8d33c9452fb32c5da941d4c0761f59c7f3eaa065
SURBHI17/python_daily
/src/quest_9.py
236
3.640625
4
#PF-Prac-9 def generate_dict(number): #start writing your code here new_dict={} i=1 while(i<=number): new_dict.update({i:i*i}) i+=1 return new_dict number=20 print(generate_dict(number))
95e0619eeb977cefe6214f8c50017397ec35af3b
SURBHI17/python_daily
/prog fund/src/assignment40.py
383
4.25
4
#PF-Assgn-40 def is_palindrome(word): word=word.upper() if len(word)<=1: return True else: if word[0]==word[-1]: return is_palindrome(word[1:-1]) else: return False result=is_palindrome("MadAMa") if(result): print("The given word is a Palin...
b4c480356866bb7bfebd5fc540f7cf134ef439b3
SURBHI17/python_daily
/src/quest_12.py
510
3.671875
4
#PF-Prac-12 def generate_sentences(subjects,verbs,objects): #start writing your code here sentence_list=[] sentence="" for el in subjects: for el_2 in verbs: for el_3 in objects: sentence+=el+" "+el_2+" "+el_3 sentence_list.append(sentence) ...
afdd7db2d0487b2cc2af9a6c33bcdc5c61512109
SURBHI17/python_daily
/prog fund/src/day4_class_assign.py
338
4.1875
4
def duplicate(value): dup="" for element in value: if element in dup: #if element not in value: continue # dup+=element else: # dup+=element #return dup return dup value1="popeye" print(...
40d7c2448928e437701a688d0bc3d991ba89c808
SURBHI17/python_daily
/prog fund/src/assignment21.py
789
3.78125
4
#PF-Tryout def generate_next_date(day,month,year): #Start writing your code here if(day<=29): if(month==2): if(day==28)and((year%4==0 and year%100!=0) or year%400==0): day+=1 else: day=1 month+=1 else: ...
a893a3be9c8715a178c57d1a9c2b6ecb8874ec33
SURBHI17/python_daily
/prog fund/src/exercise22.py
663
3.890625
4
#PF-Exer-22 def generate_ticket(airline,source,destination,no_of_passengers): ticket_number_list=[] count=101 #while(no_of_passengers>0): for i in range(0,no_of_passengers): ticket_number_list.append(airline+":"+source[:3:]+":"+destination[:3:]+":"+str(count)) count=count+1 ...
1105eaac5a28e722be234a440276647401a03b08
SURBHI17/python_daily
/src/quest_16.py
325
3.546875
4
#PF-Prac-16 def rotate_list(input_list,n): #start writing your code here output_list=input_list[:len(input_list)-n] rotate=input_list[len(input_list)-n:] output_list=rotate+output_list return output_list input_list= [1,2,3,4,5,6] output_list=rotate_list(input_list,4) print(output_...
8ef915f51cf5615969b047dd61e05f4054b44f10
lssergey/projecteuler
/skovorodkin/007_10001st_prime.py
577
3.78125
4
from itertools import count, islice from math import sqrt def nth(iterable, n): return next(islice(iterable, n, None)) def prime_generator(): primes = [2] def is_prime(n): for prime in primes: if prime > sqrt(n): break if n % prime == 0: ...
cdcab6d17e29620c08c0853e7b667c18e15ad1f5
mylessbennett/reinforcing_exercises_feb20
/exercise1.py
247
4.125
4
def sum_odd_num(numbers): sum_odd = 0 for num in numbers: if num % 2 != 0: sum_odd += num return sum_odd numbers = [] for num in range(1, 21): numbers.append(num) sum_odd = sum_odd_num(numbers) print(sum_odd)
d71bb614afb0a7c248734c9ce444623ef1b29686
psambalkar/Design-2
/hashset.py
1,724
3.859375
4
/ Time Complexity : O(1) // Space Complexity :O(N) // Did this code successfully run on Leetcode :Yes // Any problem you faced while coding this :No class MyHashSet(object): def __init__(self): """ Initialize your data structure here. """ self.primaryArray = [None]* 1000 ...
de41ac8aac2c33527569eb9cdcce2b0c316d6083
Mauriciods07/practica09
/p09.py
4,764
4.28125
4
#Código de la práctica 09 para comenzar el aprendizaje en Python x = 10 #variable de tipo entero cadena = "Hola Mundo" #varible de tipo cadena print(cadena, x) x = "Hola mundo!" type(x) x = y = z = 10 print(x,y,z) #Cuando una variable tiene un valor constante, por convención, el nombre se escribe...
a76c4a577bc6afdfbd0afe19478cf7eefbd0abe5
shailendrajain2892/ga-learner-dsmp-repo
/MakingYourFirstPrediction/code.py
1,614
3.5
4
# -------------- import pandas as pd import numpy as np from sklearn.cross_validation import train_test_split # code starts here df = pd.read_csv(path) df.head() # all the dependent columns X = df.iloc[:, :-1] y = df.iloc[:, -1] # split the columns into test and training data X_train, X_test, y_train, y_test = train_...
2d4105bc0b4902b24d1eab5560521a2d0c3560ae
kedro-org/kedro-viz
/tools/github_actions/extract_release_notes.py
1,069
3.5625
4
import sys def extract_section(filename, heading): with open(filename, "r") as file: lines = file.readlines() start_line, end_line = None, None for i, line in enumerate(lines): if line.startswith("# "): current_heading = line.strip("#").replace(":", "").strip() if...
5b3a302fa6960a1765a5f839d3520ca27ec24735
SergioCaler0/my_first_proyect
/main.py
2,893
3.921875
4
# Juego de adivina el número. import random def generate_random_number(): # creo la funcion que me va a dar un numero aleatorio random_number = random.randint(1, 100) # generamos un numero aleatorio del 1 al 100 y lo meto dentro de una variable return random_number ...
9868e5d6dfcc89302b2da8700b5c105f9d88149e
joshrz/joshrz.github.io
/story.py
7,619
4.25
4
import time print("This story takes place in the abandoned town of Astroworld") time.sleep(3) print('\n') print ("In Astroworld there are many cruel and uninmaginable crimes that have taken place") time.sleep(3) print('\n') print("Over the years there has been a report that over 250 crimes of missing teenagers th...
114dd9807e3e7a111c6e1f97e331a7a98e6e074a
KanuckEO/Number-guessing-game-in-Python
/main.py
1,491
4.28125
4
#number_guessing_game #Kanuck Shah #importing libraries import random from time import sleep #asking the highest and lowest index they can guess low = int(input("Enter lowest number to guess - ")) high = int(input("Enter highest number to guess - ")) #array first = ["first", "second", "third", "fourth", "fifth"] #va...
2d8603a4d21955787543691bbeca2bb8858ecb85
Caaddss/livros
/backend.py
2,283
3.609375
4
import sqlite3 import sqlite3 as sql def iniitDB(): database = "minhabiblioteca.db" conn = sqlite3.connect(database) cur = conn.cursor() cur.execute("""CREATE TABLE livros(id INTEGER PRIMARY KEY, titulo TEXT, subtitulo TEXT, editora TEXT, autor1 TEXT, autor2 TEXT, autor3 TEXT, cidade TEXT, ano TEXT, ed...
6c4d38f9bf65685d9bbae420787da7cd31cc45e2
Bouananhich/Ebec-Paris-Saclay
/user_interface/package/API/queries.py
1,949
3.5625
4
"""Queries used with API.""" def query_city( rad: float, latitude: float, longitude: float, ) -> str: """Create an overpass query to find the nearest city from the point. :param rad: Initial search radius. :param latitude: Latitude of the point. :param longitude: Longitude of ...
49a3ed95a43897bf688cb2de2eb1ee3de114f148
inambioinfo/Genomic-Scripts
/assignment6/Polk.py
4,268
3.71875
4
#!/usr/bin/env python3 """ Script that takes in amino acid sequence as input and outputs all possible DNA sequences that could encode this AA. Usage: python3 Polk.py <peptide sequence(s)> <melting temperature> """ # Importing necessary modules import sys # Initializing a list for the number of arguments inputed arg_l...
56f1e0d155213301cb7281889c529b5a3d29e9b0
DineshkumarAgrawal4/walk-through-the-subdirs
/countline.py
525
3.640625
4
import subprocess import os import sys #This is a very simple program to count the line of some files with suffix def countlines(directory,suffix): print('lines'+' '+'dir') for (thisdir,subsdir,thisfile) in os.walk(directory): for file in thisfile: if file.endswith(suffix): f...
9e776f2abda1037063a92933b4df16a421ea3392
vedaditya/Some-Common-problems
/mancunian and colored tree.py
775
3.65625
4
# -*- coding: utf-8 -*- """ Created on Wed May 13 15:11:03 2020 @author: aryavedaditya question link:- https://www.hackerearth.com/practice/data-structures/trees/binary-and-nary-trees/practice-problems/algorithm/mancunian-and-colored-tree/ """ from collections import defaultdict from sys import stdin n,c=map(int,st...
9407f6a1dacfc2dca38e6b25ec31495357d8ba3b
blankxz/LCOF
/Python语言测试/单例模式2.py
624
3.609375
4
# encoding:utf-8 __author__ = 'Fioman' __time__ = '2019/3/6 13:36' import threading class Singleton(object): _instance_lock = threading.Lock() def __init__(self, *args, **kwargs): pass def __new__(cls, *args, **kwargs): if not hasattr(cls, '_instance'): with Singleton._instan...
9e3cafdfe5db8541e85c8480f18df920bf743b7b
blankxz/LCOF
/密码锁(3602017秋招真题)/hello.py
280
3.734375
4
data = [] while 1: a = input() data.append(list(a)) if len(data) == 3: temp = data.copy() for i in range(3): data[i] = data[2-i][::-1] if temp == data: print('YES') else: print('NO') data = []
2529dedc764fcca0e923232f9dc8f56cc154ae93
blankxz/LCOF
/Python语言测试/生产消费_多进程.py
593
3.5625
4
from multiprocessing import Process, Queue import time, random def producer(queue): for i in range(10000): tem = random.randint(1,1000) queue.put(tem) print("生产了:"+str(tem)) # time.sleep(1) def consumer(queue): while True: time.sleep(5) tem = queue.get() ...
d15700d5e54ef4902dac5a4fdeab8419b868866a
blankxz/LCOF
/对称的二叉树/hello.py
637
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: if not root: return True return self.dfs(root.left,root.right)...
101aaa5c240aca840d1b5db161dfcec53b82c57b
blankxz/LCOF
/Python语言测试/sort_.py
795
3.78125
4
def bubble(arr): for i in range(len(arr)): for j in range(len(arr)-1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j] return arr print(bubble([3,6,8,1,2,10,5])) def select(arr): for i in range(len(arr)): min_ind = i for j in range(i+1,len(arr)...
3954ffe60b7440baa5fe64c372da8d8339c2e077
blankxz/LCOF
/重建二叉树/hello.py
703
3.734375
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 buildTree(self, preorder, inorder) -> TreeNode: if len(preorder)>0: root = TreeNode(preorder[0]) ind = inorder....
f1fa5083c061636adff9631207520c81e5681a81
paulogpafilho/machine-learning
/maker-fair-2017/resize_image.py
2,553
3.8125
4
"""Resizes all images from a source_dir to a target_dir. This program reads all images from a folder, --source_dir, resize them based on the --img_width and --img_height arguments, and save them to --target_dir. The --source_dir argument sets the folder where the images to be resized are located. The --target_dir ar...
26dc089d77ad91233b9a0d57df9cd2c47ba4f413
mohansn/dsa_assignment
/1_fib.py
257
3.875
4
#!/usr/bin/python def fib(n): """ Returns the the first 'n' Fibonacci numbers """ fibs=[] for i in range(n): if (i == 0 or i == 1): fibs.append(i) else: fibs.append(fibs[i-1]+fibs[i-2]); return fibs
9bab6ff99aa72e668524b63523c2106181049f6f
IamBiasky/pythonProject1
/SelfPractice/function_exponent.py
316
4.34375
4
# Write a function called exponent(base, exp) # that returns an int value of base raises to the power of exp def exponent(base, exp): exp_int = base ** exp return exp_int base = int(input("Please enter a base integer: ")) exp = int(input("Please enter an exponent integer: ")) print(exponent(base, exp))
ed1d712104934ccec97205a06a3daede7352dc29
IamBiasky/pythonProject1
/SelfPractice/phoneBook.py
402
4
4
def user_phonebook(user_name=None, user_age=None, user_no=None): for counter in range(3): user_name = input(str("Please enter your Name: ")) user_age = int(input("Please enter your Age: ")) user_no = int(input("Please enter your Phone Number: ")) contact = {"Name": user_name, "Age":...
7b113d95aa328c3fbe74be66f35c03508947d1b9
IamBiasky/pythonProject1
/ChapterThree/Arithmetic_Smallest_Largest_Remake.py
543
4.0625
4
number1 = int(input("Enter first integer: ")) number2 = int(input("Enter second integer: ")) number3 = int(input("Enter third integer: ")) number4 = int(input("Enter fourth integer: ")) smallest_int = min(number1, number2, number3, number4) largest_int = max(number1, number2, number3, number4) sum_int = smallest_int ...
04fb4ac9117370c5fffe9abbe435fdc1c165e0b0
BSBandme/Decaf-Compiler
/hw1/Number2.py
5,515
3.578125
4
#program submit import sys import string #mode = "test" # test mode input from file mode = "submit" # submit mode keyboard input commands = "" vari = [] value = [] result = "" def labelCheck(label,colon = False): #check label name validness #label the string to check; colon if the label end with colon ...
4cbd2d5b040711aaa6bf3c0e599d04682d177cdc
Radmaster5000/shadowrun
/shadowrun.py
7,180
3.53125
4
import time from missionText import missionText import random def roll(modifier): result = random.randint(1,6) + modifier print(result) return result # Creating the Intro screen def intro(key): # repeats until player presses 1, 2, or 3 while (key != 1 or key != 2 or key != 3): print(""" #### # # #### ##...
9f0c9a33209211c9f37bf474cdc2762f60dbf9d6
soumya62/GitCommands
/Vowel.py
166
4.1875
4
VOWELS=("a","e","i","o","u") msg=input("Enter ur msg:") new_msg="" for letter in msg: if letter not in VOWELS: new_msg+=letter print(new_msg)
2d4cf0b46c47fad8a5cc20cdf98ebf9ab379a151
sooryaprakash31/ProgrammingBasics
/OOPS/Exception_Handling/exception_handling.py
1,347
4.125
4
''' Exception Handling: - This helps to avoid the program crash due to a segment of code in the program - Exception handling allows to manage the segments of program which may lead to errors in runtime and avoiding the program crash by handling the errors in runtime. try - represents a block of code t...
8997e1b48a911acfdf53c74f7d1eb17fb294308d
sooryaprakash31/ProgrammingBasics
/Data-Structures/Linked_List/Circular/circular.py
4,266
4.3125
4
''' Circular Linked List: - A linear data structure in which the elements are not stored in contiguous memory locations. - The last node will point to the head or first node thus forming a circular list Representation: |--> data|next--> data|next--> data|next --| |--------------------------------...
79dda99fe42354f17d03eb33a1aab1ee9ebe61ab
sooryaprakash31/ProgrammingBasics
/Algorithms/Sorting/Quick/quick.py
2,027
4.25
4
''' Quick Sort: - Picks a pivot element (can be the first/last/random element) from the array and places it in the sorted position such that the elements before the pivot are lesser and elements after pivot are greater. - Repeats this until all the elements are placed in the right position - Divide and conquer strateg...
98648e9554675226787aeb68463d480b46827e7b
sooryaprakash31/ProgrammingBasics
/Algorithms/Searching/Linear/linear.py
389
3.734375
4
''' Linear Search: - Compares every element with the key and returns the index if the check is successful - Simplest searchin algorithm ''' arr=list(map(int,input("Enter array ").split())) key = int(input("Enter key ")) for i in range(len(arr)): if arr[i] == key: print("Found at {} position".format(i...
2d6f7f9ab17c96341ab645c3716579de46cc6d73
valdirsjr/learning.data
/python/jogo_nim.py
2,468
3.9375
4
def computador_escolhe_jogada(n,m): y = 0 i = 1 if n <= m: y = n else: while i <= m: if (n - i) % (m + 1) == 0: y = i i = i + 1 if y == 0: y = m if y == 1: print("O computador tirou uma peça.") else...
3188506e24c4ef4122a8c1dd30601950757f3c9c
sebastian-mutz/integrate
/course/source/exercises/E201/bme280_ssd1306_control_script.py
5,341
3.515625
4
""" author: daniel boateng (dannboateng@gmail.com) This script basically controls the measurement from BME280 sensor, store in an excel sheet (with defined columns for date, time, temperature, humidity and pressure. Not that other parmaters like dewpoint temperature can be calculated from these parameters) and also dis...
fb60a0538163955276551a694a4ae667f60023ea
melissabuist/PythonPrograms
/Python/Lab 4/lab4.py
2,944
3.890625
4
#********************************************************************** # Lab 4: <Files> # # Description: # <This program open a file and outputs data based on the file> # # # Author: <Melissa Buist, melissa.buist@mytwu.ca> # Date: <October 26, 2018> # # Input: <a data file> # Output: <average opening, av...
a6a8d6d43bd5de7b51c8bd3b0018d6c53a1652a6
BekzhanKassenov/olymp
/informatics.mccme.ru/Python/Chapter 3/C/C.py
90
3.609375
4
n = int(input()) if (n > 0): print(1) elif (n < 0): print(-1) else: print(0)
cb047338515789dcab16172208ccf171a1239f6b
GrisWoldDiablo/Data-Structure-and-Algorithm
/Python/Tree/Tree/TheTree.py
12,327
3.78125
4
""" Author: Alexandre Lepage Date: February 2020 """ from abc import ABC, abstractmethod #region TheNode class TheNode(ABC): """ Custom abstract Tree Node class """ def __init__(self,k): """ Constructor of the Class Initialize left, right and parent node as None Initial...
8c37b00a3c1d1ef62f15d3849165df8dec44a430
abhishekanand10/dataStructurePy3
/mislPy/mergeSort.py
878
3.796875
4
def mergesort(a): if len(a) == 1: return else: # tmp = [] mid = len(a) // 2 ll = a[:mid] rr = a[mid:] mergesort(ll) mergesort(rr) merge(a, ll, rr) return a def merge(a, leftlist, rightlist): ln = len(leftlist) rn = len(rightlist)...
372ecd89fd5286c2106a7d4bff590768b29121e1
bhaveshpandey29/python_3
/bill_generation.py
937
3.8125
4
while True: count_per = int(input("Please enter the number of persons : ")) total_val = [] for i in range(1,count_per +1): print("\nEnter the details of the person",i,"below:") person_starter = int(input("\nPlease enter the value of breakfast : ")) person_meal = int(input("Please ent...
155926fcbca6ae4641a76ef9498b91604f176db9
deepaksharmak92/Assignment---Tic-Tac-Toe
/TCGame_Env1.py
4,694
3.734375
4
from gym import spaces import numpy as np import random from itertools import groupby from itertools import product class TicTacToe(): def __init__(self): """initialise the board""" # initialise state as an array self.state = [np.nan for _ in range(9)] # initialises the board p...
43e64a75f4f81b31ec821ea2c4d80abfc99eb39f
SSzymkowiak/CDV_PS
/pętle.py
1,021
3.71875
4
#while licznik = 0 while (licznik < 3): licznik = licznik + 1 print("CDV") print(licznik) ############################ licznik = 0 while (licznik < 3): licznik += 1 print(licznik, end="") else: print("Koniec pętli") ############################## ########## FOR lista = ["Jan","Anna","Paweł"] ...
89f931044d2ea43a228a802a1ea214d5745c3d4c
Phantom-Eve/Python
/python/demo7/demo7_4.py
1,194
3.5
4
#!/usr/bin/evn python # -*_ coding: utf-8 -*- import functools # 装饰器Decorator print u"\n===================# 在代码运行期间动态增加功能的方式,称之为“装饰器” ===================" def log(text): def decorator(func): @functools.wraps(func) def wrapper(*args, **kw): print '%s %s():' % (text, func.__name__) ...
bda6af37cae4aba2f72394089a4353b4a8012d20
Phantom-Eve/Python
/python/demo7/demo7_1.py
2,035
3.75
4
#!/usr/bin/evn python # -*_ coding: utf-8 -*- # map/reduce接收两个参数:1.函数,2.序列 L = [1, 2, 3, 4, 5, 6, 7, 8, 9] print u"\n===================# map将传入的函数依次作用到序列的每个元素 ===================" print u"使用map把数字list转化为字符串:", map(str, L) print u"\n===================# reduce把一个函数作用在一个序列上 ===================" # 集合求和 def add(x, y): ...
aef025a22d78acf9b7ec392e11c0b2cb2f0339f5
manjoong/python_study
/out/test/python_study/queue.py
944
3.59375
4
# num = int(input()) # command = [" " for _ in range(0, num)] # for i in range(0, num): # command[i] = input() num = 1 command = ["back"] arr = [] def push(x): arr.append(x) def pop(): if len(arr) == 0: print(-1) else: print(arr[0]) del arr[0] def size(): print(len(ar...
d7253e332951b7f394a63562ff08ee304dc79b82
manjoong/python_study
/programmers_find_sosu.py
1,165
3.625
4
import itertools def prime(n): if n == 1 or n ==0: return False else: if n == 2: return True else: for i in range(2, n//2+1): if n%i ==0: return False return True def solution(numbers): answer = 0 a...
8d0231814f7b143b468ccda9ee71d62040a7a1f0
lwd19861127/Leetcode
/Leetcode/Linked List Cycle(141).{python3}/LinkedListCycle.py
691
3.921875
4
# Linked List Cycle # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def hasCycle(self, head: ListNode) -> bool: fast = slow = head while fast and fast.next: slow = slow.next fast ...