blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
ee457d3dfcc2ebf07674340b0a22f6d2c201bbc5
cacauisadog/code-wars
/python/find-the-missing-letter.py
1,022
4.09375
4
#Find the missing letter # Write a method that takes an array of consecutive(increasing) letters as # input and that returns the missing letter in the array. # You will always get an valid array. And it will be always exactly one letter # be missing. The length of the array will always be at least 2. # The array wi...
353fc6c0aba4f62c51ba51a6e96e8141409d81b5
JaredLLewis/IPReputationProject
/scheduleddb/seed2.py
719
3.84375
4
import sqlite3 import csv conn = sqlite3.connect('_newextra.db_') c = conn.cursor() c.execute("""CREATE TABLE IF NOT EXISTS IP1 ( id INTEGER PRIMARY KEY AUTOINCREMENT, ip text, scandate text, virustotalurl text, virustotalbool text, virustotalextra text, shodanports text, abuseipdburl text, abuseipdbcats text, abusei...
8efbc6eca5fda1404cd2a3f95ddefae3d442a346
a5eeM/PCC
/Ch 06/ex_polling.py
547
4.0625
4
favorite_languages = { "jen": "python", "sarah": "c", "edward": "ruby", "phil": "python" } for name, language in favorite_languages.items(): print(name.title() + "'s favorite language is " + language.title()) people_list = ["tom", "jen", "josh", "andrew", "sarah", "carolina", "matt"] print("\...
959d83a4cf71ae6d35d2c2832dbaa5ab804377fa
neroZWX/python-funda
/2-CurrentTime.py
306
3.5625
4
import time print(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))) #%y year(00-99) or %Y year(000-999) #%m month (01-12) #%d day(0-31) #%H 24hour system or use ‘%I’ 12 hour system #%M mins (0-59) #%S sceonds (0-59) # or can use time.strftime('%c') Represents current time.
c9101bf2f404acfd41f19d3380552d81990c6cfa
Alfredhana/Leetcode-Exercise
/25 Reverse Nodes in k-Group.py
568
3.921875
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 29 00:13:07 2020 @author: USER """ class ListNode: def __init__(self, x): self.val = x self.next = None def reverse(node): pre = ListNode(0) cur = nxt = node while cur != None: nxt = cur.next cur.next = pre ...
92e65abaf2ddb4418e4a95119db5f5d8762f0f27
turgon/CLRS
/randomizedselect.py
1,013
3.671875
4
from randomizedquicksort import randomizedpartition def randomizedselect(A, p, r, i): """ Returns the ith smallest element of the subarray A[p:r+1] >>> randomizedselect([0, 1, 2, 3], 0, 3, 1) 0 >>> randomizedselect([0, 1, 2, 3], 0, 3, 2) 1 >>> randomizedselect([0, 1, 2, 3], 0, 3, 3) 2 ...
ae652c3da43f8610ce3f930731ee8fb06ee066b4
63070070/Project-PSIT
/Project_PSIT.py
6,277
3.640625
4
"""Project PSIT""" import tkinter as tk from tkinter import messagebox from tkinter import StringVar import random import os def newgame(): """New game Function""" global word global word_withspaces global number_guess global lblword global already_guess number_guess = 0 ...
1780a29d7cc7658bbe3a56d4d0d22d9c9affe745
dhirajdkv/Guvi-Codekata
/set37.py
88
3.640625
4
a = int(input()) b = int(input()) temp = a a = b b =temp print(str(a)+" "+str(b))
4b53f1347fcf53c9f842a1acbba14133dc64db20
anamarquezz/BegginerPythonEasySteps
/hello/hello/multiplication_table.py
175
3.625
4
def print_multiplication_table(table,start,end): for i in range(start,end): print(f"{table} * {i} = {table * i}") print(5) print_multiplication_table(5,1,10)
bf1c8598cbe1c9dd23e517bc865287e7cfdbb189
Sulekha-code/code_assignment
/list set dict assignment Tasks.py
3,287
4.0625
4
'''#Tasks 12/04/2020 #creation an empty list l1=[] print(l1) #create an Empty tuple l1=() print(l1) #create an Empty set l1={} print(l1) #TASK 2 # #create empty list #concatenate it with [5,6,8,9] L1=[] L1= L1+[5,6,8,9] print(L1) ##add 8,9,1,5,6,7,8 L1.append(8) print(L1) L1.append(9) pri...
a19683c72e20ca0f368962d1f20b661ff7a4eb40
someshwarthumma/6030_CSPP1
/cspp1-assignments/m5/p3/square_root_bisection.py
435
4.125
4
'''# Write a python program to find the square root of the given number''' def main(): '''This is to find the square root given number ''' num = int(input()) epsilon = 0.01 mid = num/2 low = 0 high = num while abs(mid**2-num) >= epsilon: if mid**2 < num: low = mid ...
f52bc17a45977329191ef563d56a042b8d80ecb0
subhrajyotiChakraborty/PY_Learn
/strings.py
1,206
4.03125
4
print("hello \n world") print("hello \nworld") print("hello \t world") print(len("Check length")) my_string = "Hello World" print(my_string[9]) # fwd index position print(my_string[-2]) # bwd index postion # print(my_string[2:]) # print(my_string[:5]) print("Slice String =>", my_string[2: 9]) print("Step size =>"...
5b00d9cde0e934cc3999fa23846b1bc6ae3c21c1
Teresa90/lecture_8
/assingment_2_4.py
489
4.125
4
#define input #define the input #define the relation/operations #result=num #result=result*num #15*15*15*15 #result=result*15=(15*15=225)0 #result=result*15=(225*15=3375)1 #result=result*15=(3375*15=50625)2 def main():#we define the function num=int(input("enter a whole number"))#15 exponent=int(input("enter ...
c027bf208d1d737fed45a7a9cec8b983de0dd409
minseo1214/TIL_AI
/실습/시그모이드.py
1,099
3.859375
4
%matplotlib inline import numpy as np #넘파이 사용 import matplotlib.pyplot as plt #맷플롯립 사용 def sigmoid(x): return 1/(1+np.exp(-x))#exp는 지수 e^x를 반환해줍니다 x=np.arange(-5.0,5.0,0.1) y=sigmoid(x) plt.plot(x,y,'g') plt.plot([0,0],[1.0,0.0],':')#가운데 점선 추가 plt.title('sigmoid Function') plt.show() x=np.arange(-5.0,5.0,0.1) y1=sig...
8db064eaa60918e8989627867aba6487a71279b1
Hydr10n/only_smart_people_can_read_this
/only_smart_people_can_read_this.py
2,068
4
4
#!/bin/python3 #author: hydr10n@github import sys import random def start_and_end_of_first_word(text: str) -> tuple: found_word = False start = -1 end = 0 text_len = len(text) for i in range(text_len): if text[i].isalpha(): if start == -1: start = i ...
08baa1306aa02bdd2ca1b3b95efc0e9c7c97eda8
linchuyuan/leetcode
/strStr.py
334
3.546875
4
#return a pointer to the first occurence of needle in haystack def strStr(s,t): i = 0; while i < len(s): k = 0; while k < len(t): print i, k if s[i] == t[k]: i += 1; k += 1; if k == len(t) - 1: return s[(i-len(t)+1):]; if s[i] != t[k]: break; i += 1; s = "linchuyuan" t = "chu" print...
410193a6172877342949ca96fc99bc09620a541f
Activity00/Python
/leetcode/recursion/__init__.py
269
3.5625
4
from typing import List class Solution: def generate(self, numRows: int) -> List[List[int]]: ret = [] for i in range(numRows): if i == 0 or i == numRows - 1: ret.append(1) else: ret.append()
adffdc9424e3571d559eed35fda43c2b7b7daebb
hafidaElkorchi/python_formation
/9_poly_forme.py
291
3.8125
4
import turtle walle = turtle.Turtle() x= int(input("combien de poly? ")) y=int(input("taille ")) a=int(input("combien de cote? ")) b=360/a for i in range(x): for j in range(a) : walle.forward(y) walle.left(b) y=y+30 turtle.done()
17b881ec666c7030acd066c96c8fcfbe5be2e6a3
fabiliima/Exercicios-Curso-Python
/exercicio_20.py
676
3.828125
4
altura_alunos = {} for n in range(1, 11): n = int(input('Informe o código deste aluno: ')) altura_alunos[n] = float(input(f'Informe a altura do aluno (código {n}): ')) maximo = max(altura_alunos.values()) minimo = min(altura_alunos.values()) chave_maximo = [] chave_minimo = [] for key, values in altura_aluno...
3f7221fc9d6dec06e0da6ffea16c4186761466b4
bapi24/python_crash_course
/dicts/dict_in_list.py
602
4.34375
4
# #store info about pizza # pizza = { # 'crust' : 'thick', # 'toppings' : ['mushrooms', 'extra cheese'], # } pizza = {} pizza['crust'] = input("Choose from \n a)thin b)thick ") print("Enter Toppings:") topping_list = [] while True: topping = input() if topping: topping_list.append(topping) ...
dbdcf91f5d90d2f74e46d681df53c4f37bca5132
chetan-shirsath/Meeting-Scheduler
/Meeting_Schedular/schedular.py
1,161
4.125
4
''' A team meeting schedular on the first Monday of every month. ''' from datetime import date import calendar #Take input from user start_month = int(input("Enter your first month number to start the meetings : ")) end_month = int(input("Enter your last month number to start the meetings : ")) #open the file with f...
e7b971b36618b7eeb640ad2202c42adb0d8c8ade
miaviles/Data-Structures-Algorithms-Python
/Graphs/word_ladder.py
1,350
3.59375
4
import sys sys.path.append(".\\Simple_graph_implementations") from Graph import Graph def buildGraph(wordFile): d = {} g = Graph() wfile = open(wordFile, 'r') # create buckets of words that differ by one letter for line in wfile: # ignore the \n delimeter word = line[:-1] ...
370363cfbf3a60353ca6e6bc7c5628da3be07090
Gangamagadum98/Python-Programs
/prgms/ex4.py
110
3.625
4
for i in range(0,5): print(i) break else: print("for loop is exhausted") print("came out of for loop")
1455d038bb44f770bc645f2a123b3ed6137f0816
StBowie/euler
/025_1000_digit_fib.py
196
4
4
def fibonacci_length(length): current = 0 after = 1 index = 0 while len(str(current)) < length: current,after = after,current + after index += 1 return index print fibonacci_length(1000)
ae8019a6ea7f1f592e4ae2f7a47177d93b1a49bb
Alvin2580du/alvin_py
/business/for_Order/mnistKnn.py
7,334
3.65625
4
import os import pandas as pd import math from functools import reduce import numpy as np def vector_add(v, w): """adds two vectors componentwise""" return [v_i + w_i for v_i, w_i in zip(v, w)] def vector_subtract(v, w): """subtracts two vectors componentwise""" return [v_i - w_i for v_i, w_i in zip...
777f85e1ebc9a5508943fde67f05baee2ce77b36
cheddalu/look_chuut
/challenge2.py
534
4.65625
5
'''Coding challenge part 2. Create a list of your favorite food items, the list should have minimum 5 elements. List out the 3rd element in the list. Add additional item to the current list and display the list. Insert an element named tacos at the 3rd index position of the list and print out the list elements. ''' fa...
f706d8abf077e5955f8e2e485a73888a7447582c
elenaborisova/Python-Basics
/06. Conditional Statements Advanced - Exercise/09. Volleyball.py
343
3.515625
4
import math leap_or_normal = str(input()).lower() holidays = int(input()) weekends_home = int(input()) sofia_weekends = (48 - weekends_home) * 3/4 play_sofia = sofia_weekends + 2/3 * holidays play_total = play_sofia + weekends_home if leap_or_normal == 'leap': print(math.floor(play_total * 1.15)) else: print(...
d9f794984bc35d723a1c04e87ae3bca51e23d0e6
xBDL/coursera
/specializations/data-structures-algorithms/algorithmic-toolbox/1-introduction/fibonacci_last_digit/fibonacci_last_digit.py
280
3.984375
4
# Uses python3 import sys def get_fibonacci_last_digit(n): F = list(range(n+1)) for i in range(2,n+1): F[i] = (F[i-1] + F[i-2]) % 10 return F[n] if __name__ == '__main__': input = sys.stdin.read() n = int(input) print(get_fibonacci_last_digit(n))
3c8d2eb34b449ba238917ac547eb18dbc0ed205d
JonnyKEP/python
/ex30.py
387
3.765625
4
# coding: utf-8 people = 30 cars = 40 buses = 15 if cars > people: print u'train a car' elif cars < people: print u'no train car' else: print u'we dont choose' if cars > buses: print u'too many bases' elif cars < buses: print u'go to the bus' else: print u'we dont choose again' if people >...
10c71a0c607f015b440970aa04e2b5563bcfa037
Midnight1Knight/HSE-course
/SeventhWeek/Task10.py
629
3.625
4
numOfStudents = int(input()) AllKnowLang = set() knowAllStud = set() intpt = int(input()) lst = [] for i in range(numOfStudents): if i == 0: for j in range(intpt): lang = str(input()) knowAllStud.add(lang) AllKnowLang.add(lang) continue else: intpt = i...
e78f68a18ec55c66303833b51b9e23e673708e75
jlgalache/MPC-stuff
/learning_while-if-inputs.py
554
3.9375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- question = " Do you want to print a message onscreen? Ans: " cont = 1 while cont == 1: reply = str.casefold(input(question)) if reply == 'yes' or reply == 'y': print(" Hello, cruel World!") cont = 0 elif reply == 'no' or reply == 'n': print(" Fine, suit...
c2b802cef29f5a1d9e647152f8d5c50b09d0d64d
jgross21/Programming
/Notes/Chapter9.py
2,147
4.34375
4
# Chapter 9 - FUNctions # Why use fxns: # Make code repeatable # Organize your code def hi(name): print('Hello', name) # def means define # name of fxn is hi. Follows snake_case naming rules # parentheses contain the parameters of the fxn # this is the call to the fxn hi('Mr. Lee') hi('computer') import math ...
139819a2d9568d25b00097d64da3e6f30422f842
MiluchOK/college
/F021A/assignment7/test_assignment7.py
2,662
3.765625
4
""" The file contains tests for assignment #7 project Each test is commented with the test description clearly (hopefully) showing what the test does """ import unittest from employee import Employee from manager import Manager class Assignment7Test(unittest.TestCase): def setUp(self): self.target_first_name = ...
677fae3d8e649b37fb95eb3f572fe4d282a60dee
RamChennale/Python
/pythonExamples/src/com/python/examples/HelloPython.py
4,596
3.875
4
''' Created on Jun 7, 2018 @author: ramchennale ''' print ('Hello well come to Python world'); print() #This is python comment """ Multi line commenting way in Python """ x=10; y='Ram' z=y+"Chennale"; print (x); print (y); print (z); print() #Variable declaration and case sensitive _a=10; A=20 a=30 print (_a,a,...
d7995547e27a64e8c50052a187f0602d4b95899e
mussmanwissen/toolbox
/aufgaben/2-python/1-greetings/greetings.py
405
3.75
4
# encoding: utf-8 from __future__ import (print_function, division, unicode_literals, absolute_import) names = ['World', 'Toolbox Workshop', 'Martin', 'Kevin'] # hier ergänzen for i in range(0,len(names)-1,1): print("Hello {}".format(names[i...
0dac2e021110c55b67cbd0e14899fec7277983d0
mrbraiant/LP
/atv5.py
434
4.21875
4
# *-* codin:latin1 *-* ''' textoInvertido = input('Digite o Texto para inverter a ordem das letras:') string = textoInvertido[::-1] print('O Texto digitado é %s \ne o texto invertido: %s'%(textoInvertido,string)) ''' frase = input('Digite uma Frase para ser invertida:') invertida = ' '.join(palavra[::-1] for p...
b65a2f311785782ff57cfaf4a0871bf1281a7ebb
Enfors/ref
/python-ref/annotations.py
263
4
4
#!/usr/bin/env python3.6 from typing import List def fib(n: int) -> List[int]: numbers = [] current, nxt = 0, 1 while len(numbers) < n: current, nxt = nxt, current + nxt numbers.append(current) return numbers print(fib(10))
31c0d636d0de60abb9386c1407938baeb8986e0c
meteoratlas/cohort3
/src/python/220/read_csv.py
1,426
3.59375
4
import csv from collections import defaultdict def read_file(csv_file, columns): with open(csv_file, "r") as f: result = defaultdict(dict) lines = {} reader = csv.DictReader(f) for row in reader: for col in columns: try: result[col][ro...
b80c485d4c2cdda02cf51ddd54d15ea3e5671002
Alexidis/algorithms_basics_py
/main/lesson3/task3.py
992
3.65625
4
# 3. В массиве случайных целых чисел поменять местами минимальный и максимальный элементы. import random def main(): lst = [random.randint(-20, 33) for _ in range(0, 10)] print(lst) local_max = {'idx': 0, 'value': lst[0]} local_min = {'idx': 0, 'value': lst[0]} for i, item in enumerate(lst): ...
789133f738082dbb1224805d599600acf44b061d
JavaRod/SP_Python220B_2019
/students/j_virtue/lesson04/assignment/basic_operations.py
5,865
3.53125
4
'''Basic Operations Module for customer database''' # Advanced Programming in Python -- Lesson 4 Assignment 1 # Jason Virtue # Start Date 2/17/2020 #Supress pylint warnings here # pylint: disable=unused-wildcard-import,wildcard-import,invalid-name,too-few-public-methods,wrong-import-order,singleton-comparison,too-man...
0d4327116cb8d899199845026fc923df86109d8f
JijoongHong/Algorithms
/4-4_merge_sort_submiited_buttomUp.py
1,346
3.828125
4
def merge_sort_bu(arr): size = 1 n = len(arr) while size < n: get_idx(arr, size, n) size = size * 2 return arr def get_idx(arr, size, n): lo1 = 0 while lo1 + size < n + 1: hi1 = lo1 + size - 1 lo2 = lo1 + size hi2 = lo2 + size - 1 if hi2 >= n: ...
683e51d032d4326af248dfe274c411325f99b6f7
alex-rantos/python-practice
/problems_solving/delete_nth.py
717
3.796875
4
""" Create a new list allowing up to max_e duplicates of each member """ def delete_nth(order,max_e): hs = {} ret_list = [] for elem in order: if elem in hs: if hs[elem] >= max_e: continue else: ret_list.append(elem) hs[elem] +=...
bcdb7d104ffaa1edf2b14ec8105fab81be470df0
Calprimus/PYTHONFulvio
/python-3-playlist/codecademy_lesson10bis.py
2,988
3.78125
4
# >>>> 1/14 # print (5 >> 4) # Right Shift # print (5 << 1) # Left Shift # print (8 & 5) # Bitwise AND # print (9 | 4) # Bitwise OR # print (12 ^ 42) # Bitwise XOR # print (~88) # Bitwise NOT # >>>> 2/14 # print(0b1, end = " ") # print (0b10, end = " ") # print (0b11, end = " ") # print (0b100, end = " ") # ...
0143acd2bb9d9598c1a311a0fc8a399c918f8c46
leejoonsung007/CheckIO-python
/Sendgrid/is_strssful.py
1,077
3.828125
4
import re def is_stressful(subj): subj_handling = subj.lower(); string_handling_ori = re.sub("[^A-Za-z]", '', subj) string_handling = re.sub("[^A-Za-z]", '', subj).lower() if string_handling_ori.isupper(): return True if "help" in subj_handling or "urgent" in subj_handling or "asap" in s...
2ee1b2173a9ea4400a9f1fdc129c5c87b7416333
abbyabridged/python-challenge
/PyPoll/main.py
4,178
3.875
4
# Modules import os import csv # Set path for file election_csv = os.path.join("Resources","election_data.csv") # Open the CSV file with open(election_csv,'r') as csvfile: # Split the data on commas csvreader = csv.reader(csvfile, delimiter=',') csv_header = next(csvfile) # print(f"CSV Header: {csv_h...
1be49917a8a6c1eb7c07427a576a2b6886b0a308
krishnanandk/kkprojects
/collection/set/set opeartions.py
245
3.8125
4
#operations # union # intersection # difference set1={1,2,3,4,5,6} set2={5,5,6,7,8,9,10} set3=set1.union(set2) print(set3) set4=set1.intersection(set2) print(set4) set5=set1.difference(set2) print(set5) set6=set2.difference(set1) print(set6)
bba3f6aec869d2c394462acbf0d7c010fbfb4293
WisTiCeJEnT/tar-com-pro
/day_jan.py
194
3.703125
4
day = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"] x = int(input()) y = int(input()) if 1 < y < 31: y -= x y = y%7 print(day[y]) else: print("ERROR")
e40f1896933beed3f7de53996f10c4ec0651fd90
devam6316015/all-assignments
/assign 11 threading.py
1,129
4.28125
4
print("create a threading process such that it sleeps for 5 seconds amd then prints out the message-\n") import threading from threading import Thread import time def display(): time.sleep(5) print("it was slept for 5 seconds") t1=Thread(target=display) t1.start() print("\n###############") print("thread that prin...
38c539cd3ed5d4cbdafb4a81eb72db2966fa0de2
bobobuaa/Exercise
/testTree.py
209
3.515625
4
from binarytree import tree, bst, heap, pprint my_tree = tree(height=5, balanced=False) my_bst = bst(height=5) my_heap = heap(height=3, max=True) pprint(my_tree) pprint(my_bst) pprint(my_heap)
878ff9c1796619b4b6b12f2046fff2196d428f92
zakneifian/Laboratorio_Algoritmos_1
/Laboratorios/Lab_5/Lab05Ejercicio2.py
1,371
3.796875
4
#Autor Alejandro Martinez (13-10839@usb.ve) #Ultima modificacion: 18-oct-2016 11:10 am #"Lab05Ejercicio2.py" #Defino una lista vacia secuencia = [] #En el loop itero hasta una cota grande for i in range(0, 1000000): if i == 0: #En la primera iteracion imprimo estas lineas print("\n\nEste programa va a verificar si...
14c971b1b485dd8270ff801a9a13b7dbf75ce902
Rahuly-adav/leetcode
/leetcode/KeyBoard_Row.py
606
3.828125
4
class Solution: def findWords(self, words): res=[] r1="qwertyuiopQWERTYUIOP" r2="asdfghjklASDFGHJKL" r3="zxcvbnmZXCVBNM" for i in words: a1,a2,a3=0,0,0 for j in set(i): if j in r1: a1+=1 el...
59a75f78c7a146dcf55d43be90f71abce2bcf753
varunbelgaonkar/Beginner-Python-projects
/calculator.py
3,362
4.09375
4
from tkinter import * root = Tk() root.title("Calculator") e = Entry(root, width = 50, borderwidth = 5) e.grid(row = 0, column = 0, columnspan = 4, padx = 10, pady = 20) def button_click(number): digit = e.get() e.delete(0, END) e.insert(0, str(digit) + str(number)) def button_add(): global first_...
23d30995e5cde1dab464e8668b00c29b1904e3bc
anna-schreiber/connect4
/connect4-2-player.py
2,668
3.953125
4
import numpy as np import math #import pygame import sys ROWS = 6 COLUMNS = 7 even = 0 odd = 0 def create_board(): board = np.zeros((6,7)) return board def drop_piece(board, row, col, piece): board[row][col] = piece def is_valid_location(board, col): return board[5][col] == 0 # Check to see if the c...
805353e7dbce9f8a2606a9a6c896ca97481e860c
frezey/Wikimedia
/wikimedia.py
375
3.609375
4
import wikipedia def search_articles(query, language): wikipedia.set_lang(language) articles = wikipedia.search(query) result = { article: wikipedia.summary(article, sentences=1) for article in articles } for i in range(0, len(result)-1): print "[{}] {}".format(i + 1, result.keys()[i]) print "{}\n".for...
0e1d915d34ec785dcfb374cb8f59a86491ee6972
vanzuijlen/Projet_1_NSI
/fenetre.py
470
3.578125
4
from rectangle import rectangle import turtle def fenetre(x,y): ''' Paramètres : x est l'abcisse du centre de la fenêtre y est l'ordonnée du sol du niveau de la fenetre ''' turtle.pensize(1) turtle.fillcolor('#eef') turtle.begin_fill() rectangle(x,y+20,30,30) ...
eaae560531e5630c98d8f90b65d9c84d98920674
winkitee/coding-interview-problems
/1-10/3_longestPalindrome.py
1,823
3.984375
4
""" This problem was recently asked by Twitter. """ """ A palindrome is a sequence of characters that reads the same backwards and forwards. Given a string, s, find the longest palindromic substring in s. """ """ Example: Input: "banana" Output: "anana" Input: "million" Output: "illi" """ class Solution: def lon...
7f479d3615c240075459f90b477d1f1b8c1783f1
EchoZen/How-to-Automate-The-Boring-Stuff
/4.3 Re dot_star_caret_dollar.py
1,638
4.25
4
# ^ means the string must start with the pattern # $ means string must end with the pattern # . is anything except new lines \not # pass re.DOTALL as second argument to re.compile() to make the dot match new lines as well # pass re.I as second argument to re.compile to make matching case insensitive import re beg...
3a0289e0896d6ac2e192167bb21a8d738daa52c2
1050669722/LeetCode-Answers
/Python/problem0143_test02.py
2,265
3.921875
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None # class Solution: # def reorderList(self, head: ListNode) -> None: # """ # Do not return anything, modify head in-place instead. # """ # low, fast = head, h...
21e8dfeeda38fbe2a727cead3dd11011d3a4ab3c
sangkeerthana70/Python-playground
/typeConversion/ExpicitDataTypeConversion.py
420
4.25
4
# Explicit conversion also known as type casting is when data type conversion takes place because # you clearly defined it in your program. You basically force an expression to be of a specific type. # Integer and Float Conversions # To convert integer to float, use the float() function in Python. a_int = 3 b_int = 2...
4a1dcf53b73495daa4244a19a2704bb5ebd8f26b
rrr5458/Python-Project
/rps.py
2,549
3.984375
4
import random def rps_game(): user_wins = 0 computer_wins = 0 print("Welcome to Rock Paper Scissors Tug of War. Eliminate all computer's Os on the board to win. You both start with one icon.") board = ["X", "*", "*", "*", "*", "O"] print(board) user_icon_count = board.count("X") computer_i...
709ae0583b82afefcb45d14f5f1079e6032c763a
ManushApyan/python_lessons
/clas_car12.py
274
3.984375
4
class Vehicle: def __init__(self, name, color, cost): self.name = name self.color = color self.cost = cost car1 = Vehicle("Fer", "Red", "60000$") car2 = Vehicle("Jump", "Blue", "10000$") print(car1.name, car1.color, car1.cost) print(car2.name, car2.color, car2.cost)
50a61836d6082c98de2804944a5fe548a2d3178e
takukawasaki/threading_socket_inPython
/simple_client.py
1,331
3.75
4
#!/usr/local/bin/python3 import socket import sys import argparse host = 'localhost' def echo_client(port): # Create a TCP/IP socket s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) # Connect the socket to the server server_address = (host,port) print("Connecting to server %s port: %s" % ser...
62036d9dd6e562dc57b9af25dcfe21c2cdd75e51
Lee-3-8/CodingTest-Study
/level4/징검다리/희재.py
697
3.625
4
def solution(dist, rocks, n): rocks = sorted(rocks) + [dist] def validate(limit): removed, start = 0, 0 for r in rocks: if r - start > limit: start = r else: removed += 1 return removed > n def search(left, right): mid...
00e3a0718eeb34143ef17f5b3156b423f4d0f04c
jinrunheng/base-of-python
/python-basic-grammer/python-basic/02-python-variables-and-string/elec_charge.py
344
3.828125
4
charge = 0.0 elec = input("请输入您本月的用电量:") elec = float(elec) if elec >= 1 and elec <= 240: charge = elec * 0.4883 elif elec > 241 and elec <= 400 : charge = 240 * 0.4883 + (elec - 240) * 0.5383 else: charge = 240 * 0.4883 + 160 * 0.5383 + (elec - 400) * 0.7883 print("您本月的电费为:" + str(charge))
39b9acd926a41f8a75f085131a00d9bcd9bd50da
TinatinObgaidze/python-homeworks
/turtle/ku3.py
175
3.8125
4
import turtle turtle.shape("turtle") for i in range(0, 6): turtle.forward(80) turtle.left(90) turtle.forward(80) turtle.right(30) turtle.exitonclick()
f9357c17d56258cb4e6de9020f4b68cddb6ee6f2
TheBrokenRail/IDTech
/Story.py
1,438
4.0625
4
bob = "person" print("Bob is a " + bob) bobLocation = "grocery store" print("Bob is at the " + bobLocation + " and he has bought a cat and a lot of bacon!") bobLocation = "Home" print("Bob has gone " + bobLocation) catAttitude = "scared" print("The cat is " + catAttitude) print("What do you want Bob to do with his new ...
82fff576c2449d44a75284329014bd106f18d381
Greeninguy/LEDController
/LEDController.py
694
3.890625
4
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) ledPin = 31 GPIO.setup(ledPin, GPIO.OUT) def turnOn(): print("Turning on light.") GPIO.output(ledPin, GPIO.HIGH) def turnOff(): print("Turning off light.") GPIO.output(ledPin, GPIO.LOW) while True: print("Which Operation?...
e70a015b2886a159a8cc12159c264e36ff1621d5
prakashmenasagi/Learning
/Vowels.py
144
3.90625
4
s=input('enter the string : ') count=0 for i in s: if i in 'aeiouAEIOU': count+=1 print('we have',count,'no of vowels in string',s)
83200521b7d80160ae7f98f7c21b9827184312da
AishwarGovil/Technocolabs-Internship-Projects
/Deployment of Week 1 Task using Streamlit/ml-webapp.py
3,987
3.640625
4
# Import all the required libraries import numpy as np import pickle import streamlit as st import pandas as pd # main function def main(): st.write(""" # Credit Card Default Prediction This app predicts whether the customer's account will default or not based on some features. """) # Side...
d51cd1035f8e80a024e8f1b59e33357e6c27b6cb
Drabblesaur/PythonPrograms
/CIS_40_ProgramAssignments/P8.5.py
2,721
3.921875
4
# P8.5 Johnny To # Grade Logger gradeList = {} def addStudent(): nameStu = input("Enter name:") grade = input("Enter grade:") gradeList[nameStu] = grade return "added" def removeStudent(): exitTrigger = True while exitTrigger: nameStu = input("Enter name:") if nameStu...
49f60d26cc8551787e5dd2253b931768b59767ea
swapniljoshi22/Python-basic-projects
/calculator.py
770
3.828125
4
class cal: def __init__(self,x,y): self.x=x self.y=y def add(self): return self.x+self.y def sub(self): return self.x-self.y def mul(self): return self.x*self.y def div(self): return self.x/self.y x=int(input("Enter ...
528a4039bee2f146a8b2c832b90fb6f5e47eb507
cybelewang/leetcode-python
/code582KillProcess.py
1,689
3.734375
4
""" 582 Kill Process Given n processes, each process has a unique PID (process id) and its PPID (parent process id). Each process only has one parent process, but may have one or more children processes. This is just like a tree structure. Only one process has PPID that is 0, which means this process has no pare...
f85752a07287f46825b83f2ed5d28642c67482b2
goodwin64/pyLabs-2013-14
/2 семестр/2 лаба - Хеш Таблицы/04вар_Донченко.py
860
3.65625
4
# Задание 4: # Дан текст. Выведите слово, которое в этом тексте встречается чаще всего. Text = '''Один, два три 4 три три чаще 4 4 два: 4 Питон Питон успокоение, чаще аллегория тропики чаще Питон - Питон чаще Питон''' print(Text, '\n') D = {} # слово -> частота List_of_words = Text.split() # список слов текста Max ...
eeebe851e44e74d60025dfc9c332a0a3c1de0545
ChandraSiva11/sony-presamplecode
/tasks/final_tasks/file_handling/11.capitalize.py
224
4.21875
4
# Python Program to Read a File and Capitalize the First Letter of Every Word in the File def main(): with open('text_doc.txt', 'r') as fread: for line in fread: print(line.title()) if __name__ == '__main__': main()
9e27866bcaa29a694add6e58a0d7ff86a6e89408
HearyShen/leetcode-cn
/problems/edit-distance/solution.py
1,874
3.578125
4
import time class Solution: def minDistance(self, word1: str, word2: str) -> int: """referenced from leetcode's official DP solution.""" n = len(word1) m = len(word2) # if word1 or word2 is empty, the distance is m+n if n * m == 0: return n + m # DP ma...
ca91a541f3d55e4c98595efc7f8ecd0326d417da
Shanshan-IC/lintcode_python
/array/161_rotate_image.py
342
3.765625
4
class Solution: """ @param matrix: a lists of integers @return: nothing """ def rotate(self, matrix): n = len(matrix) for i in xrange(n): for j in xrange(i+1, n): matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j] for i in xrange(n): ...
7b2b0722e23cde1bfcbb7f1589c85a3c5696ed05
christabelmukama/Challenge-3-day-1
/Chall D.O.B.py
327
4.375
4
#2018 is required to get the age this_year=int (2018) your_input=int(input("please enter your birth year")) this_is=int(this_year - your_input) #The condition being satisfied if this_is < 18: print("this is a minor") elif this_is > 18 and this_is < 36: print("this is a youth") else: print("this is an ...
b55e61323919c198fc59cb18a1bfbe2e3ded0a64
shubhamnag14/Python-Documents
/Standard Library/queue/Docs/06_Queue_objects.py
193
3.53125
4
import queue q = queue.Queue(10) for i in range(10): q.put(i) print(f"The size of the queue is - {q.qsize()}") print(f"Check if Empty - {q.empty()}") print(f"Check if Full - {q.full()}")
a56d32aab4d2b48509b24503d7ffff4d1ef67a29
ShrutiDhiman/python
/shruti/test.py
336
3.765625
4
###question 1 for i in range(2000,3200): if i%7==0 and i%5!=0: print(i,end=",") print() question 2 def fact(x): if x==0 or x==1: return 1 result = x*fact(x-1) return result y = int(input()) z = fact(y) print(z) dict = {} n = int(input()) for i in range (1,n): ...
5f993bbd994f136645b776d76f3967dd241f6919
RLHoneysett/CompModArgon
/Particle3D.py
3,173
4.40625
4
""" CMod Ex2: Particle3D, a class to describe 3D particles. Class to describe 3D particles. Properties: - name(string) - label of particle - position(NumPy array) - position as 3D coord (x1, x2, x3) - velocity(NumPy array) - velocity vector (v1, v2, v3) - mass(float) - particle mass. In reduc...
a03b8dce51369fb728574dae9e4b4a2dbc82b6f3
WendyBu/CNA_analysis
/scripts/project_info.py
897
3.5
4
import pandas as pd import sys df_all = pd.read_table("all_bioportal_list.txt", sep="\t", index_col=0) df = df_all[df_all["CNA"]>0] def group_project(keylist): for key in keylist: project_list = df[df.iloc[:,0].str.lower().str.contains(key)] project_size = project_list.shape[0] patients_n...
254ff00ec63c02c39a5255fb2b9e1e4721d1506c
mjguidry/cfb_balanced_schedule
/compute_distance_matrix.py
2,558
3.59375
4
# -*- coding: utf-8 -*- """ Created on Tue Dec 5 21:17:28 2017 @author: mike """ import pickle from math import radians, cos, sin, asin, sqrt f=open('football_dict.pkl','rb') g=open('games_dict.pkl','rb') h=open('geo_dict.pkl','rb') j=open('name_map.pkl','rb') football_dict=pickle.load(f) games_dict=pickle.load(g)...
754be51946108f0e5537eece898d14ef088a4878
simranjmodi/cracking-the-coding-interview-in-python
/chapter-10/exercise-10.6.py
599
3.640625
4
""" 10.6 Sort Big File Imagine you have a 20 GB file with one string per line. Explain how you would sort the file. """ """ Solution Since the size limit is 20 GB, we don't want to bring all the data into memory and only bring part of the data instead. We'll divide the file into chunks, which are x megabytes each,...
1b131dd610f46aa7ce42506ae9aa94057ef22247
gongyangyu/pythonprojects
/pylearnadvance/thread/threadshare_g_varible.py
698
3.546875
4
import threading import time total=0 def test1(number): global total for i in range(number): mutex.acquire() total+=1 mutex.release() print("-------g_num ---test1 %s" % str(total)) def test2(number): global total for i in range(number): mutex.acquire() to...
8fcaf7c7aa5a19b779b7d26d9d3c35b6a77daca4
esme/algorithms
/python/sequential_search.py
344
3.84375
4
def sequentialSearch(alist, item): position = 0 while (position < len(alist)): if alist[position] == item: return position position += 1 return -1 print(sequentialSearch([], 4)) # => -1 print(sequentialSearch([3, 4, 8], 4)) # => 1 print(sequentialSearch([3, 4, 8], 8)) # => 2 print(sequentialSearch...
e07b328b02a76c8cc243bcf7002b07cf96f8b8fc
infractus/my_code
/RPG Dice Roller/rpg_dice_roller.py
2,336
4.4375
4
#Dice roller import random roll = True #this allows to loop to play again while roll: def choose_sides(): #this allows player to choose which sided die to roll print('Hello!') while True: sides=(input('How many sides are the dice you would you like to roll?' )) if sides.isd...
3a5b88346662ba37585067ac2fab16f7b697a85d
wonkwonlee/likelion-k-digital-training-AI
/Data-Structure-and-Algorithm/practice/12a_swapElements.py
1,122
3.921875
4
""" Swap Elements Given two arrays A, B with length of N, swap maximum values of array A with minimum values of array B at most K times operations. Return the maximum sum of elements in the array A. Example N = 5, K = 3 A = [1,2,5,4,3] B = [5,5,6,6,5] >> 26 (A = [6,6,5,4,5] after swap operations) # Swap Operation """...
eb818a54bcb2fb8ee49f86bbc98f6287592fe314
AlexLi88/AEQ
/pOne.py
569
3.59375
4
class POne(object): def findPeakAndValley(self, arr): arr_len = len(arr) # Since you can always build a castle at the start of the array, set ans to 1 at beginning ans = 1 prev = arr[0] for i in range(1, len(arr) - 1): if arr[i] == arr[i + 1] and arr[i] != arr[i-1]: prev = arr[i - 1] continue e...
102d7996e5b1d6e2388482f8d73e8286ebbdd2d1
faheemalit/pythonprogs
/randomsort.py
588
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Aug 29 19:59:14 2019 @author: faheem """ import random n=int(input("number of elements")) i=1 a=[] acopy=[] for k in range(n): temp=int(input()) a.append(temp) for m in a: acopy.append(m) b=[] for l in a: b.append(l) sortd=0 t=0 while(so...
386428c4078d5a75a9fb3a1c9a3e73e25fafe0fb
PuffyShoggoth/Competitive
/CCC/CCC '11 S1 - English or French.py
246
3.515625
4
Cthulhu=int(input()) E=0 F=0 for i in range(0, Cthulhu): s=str(input()) T=s.count('T')+s.count('t') S=s.count('S')+s.count('s') if T>S: E=E+1 elif S>T: F=F+1 if E>F: print('English') if F>E: print('French') if E==F: print('French')
ed779e39a40bf4bee572ba96a9159feea8d01480
Rajeevv8/pythonprograms
/Series print/series6.py
69
3.5625
4
'''3 8 10 15 17 22 24''' a=3 b=int(input("Enter number of terms:"))
1b965900f1a27f47393e2ef3e4f3949dc17fb496
vignesh1398-vz/python
/turtle-race/playground.py
600
3.65625
4
from turtle import Turtle, Screen turtle = Turtle() screen = Screen() turtle.shape("turtle") def move_forward(): turtle.forward(10) def move_backward(): turtle.backward(10) def turn_right(): turtle.right(10) def turn_left(): turtle.left(10) def clear(): turtle.clear() turtle.penup() tur...
39744c9616f03414582b937dcc1d3ed6ed6de605
idimon4uk/Pieces-Analysis-python-branch-
/graphData.py
2,025
3.65625
4
import math class Point: x = 0 y = 0 def __init__(self, x, y): self.x = x self.y = y class Graph: def __init__(self): self.dataGraph = [] def export(self, x, y): if(len(x) != len(y)): print("Uncorrect data (len of x != len of y") return ...
07c5e80a71f1ca0107f3f5accc273e488f2ffc8e
Cristofer6010/trafic_drive_age
/trafic_drive_age.py
247
3.96875
4
print ("Enter your age :") b = int(input()) if b==18: print ("We can't decide come in our company we test you physicaly") elif b<18: print ("You can't drive") elif b<=100: print ("You can drive") elif b>100: print ("Invalid age")
a5fd63a00f8f32e15b715c1739e5e3fbbf565a81
daccordeon/summerSHG
/netgpibdata/netgpibdata.py
2,833
3.5
4
#! /usr/bin/env python # Yoichi Aso Sep 22 2008 import re import sys import math import optparse import netgpib # Usage text usage = """usage: %prog [options] This command will retrieve data from a network connected GPIB device. The downloaded data will be saved to FILENAME.dat and the measurement parameters will b...
1e16f0fce7e0bd8c5bbb0a8a964d2710ea7b4e70
anderssv49/python-course-gbg
/dict_lookup.py
1,787
3.5
4
import sys def mkDict(lines,src,tgt): dict = {} for line in lines: fields = line.split(';') if len(fields) >= 2: for word in fields[src].split(','): sword = word.strip() dict[sword] = dict.get(sword,[]) for trans in fields[tgt].split('...
eb93400f1a31c815ba5e1e9a78a6d13bf09a26dc
nandansn/pythonlab
/problems/patternproblems/pattern38.py
364
3.765625
4
maxRows = int(input('Enter max rows:')) charCount = 1 startChar = 'A' asciiCodeStartChar = ord(startChar) spaceCount = (maxRows - 1) * 2 for i in range(asciiCodeStartChar, (asciiCodeStartChar + maxRows * 2), 2): print('{}{}{}'.format(' '*int(spaceCount/2),chr(i)*charCount,' '*int(spaceCount/2))) sp...
ceb81f33c6b6406e98b87f94a598c705538d2830
tpopenfoose/OptionSuite
/optionPrimitives/nakedPutTest.py
1,460
3.5625
4
import unittest import nakedPut class TestNakedPutStrategy(unittest.TestCase): def setUp(self): """Create naked put object and perform tests. Params for creating object: underlyingTicker -- stock ticker symbol strikePrice - strike price of the PUT option longOrS...
8b4d1c430c778a1608539cc94eeda84e43858b71
PauloKeller/Grade-Projects
/Pythonmancer/Lista 3/Exercicio n º 4 .py
141
4.15625
4
n = int(input("Digite um valor: ")) a = 1 b = 1 c = 0 while c < n-2: a,b = b,a+b c += 1 print("O numero Fibonacci é:%d" %b)
d7a595e3b86a111866a03383b68065115c852570
eaniyom/python-challenge-solutions
/Aniyom Ebenezer/phase 1/python 2 basis/Day_21_Challenge_Solution/Question 2 Solution.py
240
3.984375
4
""" Write a Python program that accepts six numbers as input and sort them in descending order. """ list1 = list(map(int, input("Input six digits(followed by a space after each number): ").split())) list1.sort() list1.reverse() print(list1)