blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
7dc315634ef2beda7b03551c4727d249d437ffbe
CarlosPimentel10/py-Projects
/exercise2.py
655
4.34375
4
# FIND THE NUMBER OF OCCURRENCES OF LETTERS IN THE FOLLOWING STRING # use a dictionary # from pprint import pprint -> this module is used to print data in a more readable way sentence = 'This is a common interview question' char_frequency = {} for char in sentence: if char in char_frequency: char_frequency[...
8b83fb55fe6a169eedaff02f253c391d3c2e0f88
Miracle-bo/Work
/19.06/work-等腰三角.py
225
3.90625
4
# 单循环 for a in range(1,9): c = 2*a-1 d = '* '*c f = ' '*(8-a) print(f'{f}{d}') # 嵌套循环 for x in range(1,9): y = 2*x-1 for z in range(1,9-x): print(' ',end='') print('* '*y)
b38f053fc0eb34382f55171633479273bd53dea5
RahatIbnRafiq/leetcodeProblems
/Linked List Problems/725. Split Linked List in Parts.py
862
3.578125
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def getSize(self,root): p1 = root length = 0 while p1: length +=1 p1 = p1.next return le...
7c52d759c6ed4d19c3952d013f70bfca5ecff6e8
alexandraback/datacollection
/solutions_5753053697277952_0/Python/easyrider/run.py
1,288
3.515625
4
#!/usr/bin/python3 import numpy nr_of_tasks = int(input()) def p_name(ind): return chr(ind + ord('A')) def find_index_of_max_value(_list): max_value = 0 counter = -1 for item in _list: counter = counter + 1 if item > max_value: max_value = item + 0 pos = counte...
88bd6e35a06da2c04376be4178b1b96967723b93
4RG0S/2020-Fall-Jookgorithm
/김송이/[2020.10]/[2020.10.02]10825.py
624
3.625
4
import re def main(): n = int(input()) p=re.compile('(\D+)(\s)(\d+)(\s)(\d+)(\s)(\d+)') student_list = [] regular_list=[] for i in range(n): student_list.append(input()) #for student in student_list: # s_list=p.findall(student) # regular_list.extend(s_list) #print(r...
d241d4cd2d50e000980c26b5811918a871781e03
wseungjin/codingTest
/kakaoEnterprise/chihoon/1.py
508
3.734375
4
def solution(x,spaces): sortedArray = [] for index,value in enumerate(spaces): sortedArray.append((value,index)) sortedArray.sort() minValues = [] for start in range(len(spaces) - x + 1): for value in sortedArray: if start <= value[1] and value[1] < start + x: ...
fdaee5881dbe4a1afd7a017f23ecba697fe02405
clhernandez/projecteuler
/ex5_2.py
773
4.03125
4
import sys, time #2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. #What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? def smallMultiple(num, size): for x in xrange(1,size): if(num%x!=0): re...
f235c39b3819518b10d216212e40fb16507b1474
joshseymour/python-challenge
/PyPoll.py
2,311
3.84375
4
#import libraries import os import csv #set file path csvpath = os.path.join("Resources", "election_data.csv") #create counters votes = 0 winning = 0 #create list without headers data = [] #create list of candidates candidates = [] #create dictionaries of candidate votes & percentage of votes candida...
8339adf8196b966a16bcd04e614589c2edc898e9
Styfjion/code
/ex_quicksort.py
1,102
3.90625
4
def quicksort(array): if len(array) >= 2: mid = array[len(array)//2] array.remove(mid) right,left = [],[] for unit in array: if unit>=mid: right.append(unit) else: left.append(unit) return quicksort(left)+[mid]+quicksort...
b604f6dca715c61940b77714f03053fd0c275bf4
ahmedfadhil/Binary-tree-insertion
/bst_remove_node.py
1,357
3.875
4
def remove_node(self, value, parent): if value < self.value and self.left_child: return self.left_child.remove_node(self, value) elif value < self.value: return False elif value > self.value and self.right_child: return self.right_child.remove_node(self, value) elif value > self....
5c5410f692aa23555eff353a04a4eaa1f38b13b4
MagicTrucy/Python
/liste_adjacence_vers_tableau_adjacence.py
632
3.578125
4
# Donnée : l la liste d'adjacence l = [[1,3],[0,2],[1],[0]] # Initialisation # N : nombre de pages N = 4 # A : tableau d'adjacence A = [[False for x in range(N)] for y in range(N)] # Début du traitement # index_page : l'index en cours dans la liste for index_page in range(len(l)): # index_lien : l'index en cours...
c557a0847300970310bd8c3963b3dfc9acece269
wzlwit/jac_spark
/lecture2/task3.py
2,175
3.703125
4
# Task 3: Skeleton of an ML program: Transformer, Estimator, Parameters # Objective: Understand the building block of any ML application with the example of predicting the role of an IT professional is developer by looking at his experience and annual salary #Read data # df = spark.read.csv("/home/s_kante/spark/data/...
19045f74871fb0fd8f5edb4153e1c76db75c1a28
111110100/my-leetcode-codewars-hackerrank-submissions
/leetcode/countMatches.py
757
3.65625
4
class Solution: def countMatches(self, items: list, ruleKey: str, ruleValue: str) -> int: map = { 'type': 0, 'color': 1, 'name': 2, } return sum([1 for item in items if item[map[ruleKey]] == ruleValue]) class Solution2: def countMatches(self, items: l...
9af700efd4dc47f354bc1ca2805a6ac9caf416db
NhungTu/learninglab
/pandas/pandas_info_gain.py
1,233
4.03125
4
""" Classification is a way to 'bin' observations in order to better understand particular attributes. Optimally, observations in the same 'bin' or subset of the original have a lot in common; and different subsets have little in common. One measure of this is the 'information gain', or reduction of entropy (randomn...
a1fe405ceeb9858642b94d19349d4f9b6e2a3a8c
dawchenlee/dawchengit
/Leetcode/day13对称二叉树.py
2,277
3.9375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jul 23 17:43:40 2019 题目:对称二叉树 给定一个二叉树,检查它是否是镜像对称的。 例如,二叉树 [1,2,2,3,4,4,3] 是对称的。 1 / \ 2 2 / \ / \ 3 4 4 3 但是下面这个 [1,2,2,null,3,null,3] 则不是镜像对称的: 1 / \ 2 2 \ \ 3 3 @author: dawchen """ # Definition for a binary tree...
26960f12f803d7d5e57687917b6c9d1da6f1b50d
Eymric/pythonCours
/rh.py
502
3.546875
4
class DateNaissance: def __init__(self, jour, mois, annee): self.jour = jour self.mois = mois self.annee = annee def ToString(self): return print(self.jour,'/',self.mois,'/',self.annee) class Personne: def __init__(self, nom, prenom): self.nom = nom self.pre...
18ae5ca84072ae2474f15985d193c7ba6f7334a9
habibanalytics/Python_Exercises
/Programs/SumOfDigits.py
141
3.671875
4
num = input("Enter a number: ") lenth=len(num) index=0 sm=0 while index < lenth: n=int(num[index]) sm=sm+n index+=1 print(sm)
10fbbb4cb6f14a4007e2686f09d0e99a67f51b50
alexandraback/datacollection
/solutions_1484496_0/Python/Staer/sums.py
980
3.71875
4
def find_combos(initial_set): from itertools import combinations for size in xrange(1,num_elements): for combo1 in combinations(initial_set, size): for size2 in xrange(1, num_elements): for combo2 in combinations(initial_set, size2): if combo1 != combo2 and sum(combo1)==sum(combo2): ...
f6eab9f3837741bf991e6d38eba212316851294f
ravigaur06/PythonProject
/duck_typing_EAFP/eafp.py
462
3.828125
4
person={"name":"karthi","Age":7,"Grade":"second grade"} try: print ("I am {name}.I am {Age} years old.I am studying in {Grade}".format(**person)) except KeyError as e: print ("Missing Key{}".format(e)) l1=[1,2,3,4,5] try: print (l1[6]) except IndexError as e: print (e) import os my_file="/tmp...
608718374408fa9124e69f6c8b0c9d34d71bc28c
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/226/users/4160/codes/1593_1804.py
360
4.125
4
# Coordenadas de A (xa, ya): xa = float(input(" Digite a coordenada xa: ")) ya = float(input(" Digite a coordenada ya: ")) # Coordenadas de B (xb, yb): xb = float(input(" Digite a coordenada xb: ")) yb = float(input(" Digite a coordenada yb: ")) # Distancia entre A e B (d): from math import sqrt d = sqrt ((xb - xa)**...
b306deb502be381e12e648b4dc4d05e68d528859
anitazhaochen/nowcoder
/线性表/反转链表.py
710
4.03125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # -*- coding:utf-8 -*- class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # 返回ListNode def ReverseList(self, pHead): if pHead is None or pHead.next is None: return pHead p1 = pHead ...
b228341b94fe1aec3846dbd8f639907aa84c4777
akshansh2000/project-euler
/py/4.py
308
3.734375
4
def is_palindrome(num): if str(num) == str(num)[::-1]: return 1 return 0 maximum = 0 for outer in range(999, 99, -1): for inner in range(999, 99, -1): if is_palindrome(outer * inner): maximum = outer * inner if outer * inner > maximum else maximum print(maximum)
99d7f7e7d2c95b1f34c52f483d53ef1dbee17f0b
rishinkaku/Software-University---Software-Engineering
/Python Fundamentals/Final_Exam_Prep/05. Easter Bake.py
525
3.890625
4
import math easter_bread = int(input()) sugar_count = 0 flower_count = 0 flower_max = 0 sugar_max = 0 for i in range(1, easter_bread+1): sugar = int(input()) sugar_count += sugar flower = int(input()) flower_count += flower if sugar > sugar_max: sugar_max = sugar if flower > flower_max: ...
3e5af17bad1c236cf8cbb568a03713ab2ea38e6b
makwana-jaydip/Mini-Projects
/Card Remember/Remember_Card_Game.py
4,790
3.96875
4
#Card Remember Game #0 To 9 Number Card available in hide format when you press the card is turn on and show the card number. #first step is press any card #next step is press different card if card number is matches then it doesn't turns off if doesn't match then after pressing the third card first two card is tur...
656a9789028288aa1989770a7d60b23a75a65d02
bresslem/ppi
/Serie_5/linear_solvers.py
3,415
3.5
4
""" Author: Bressler_Marisa, Jeschke_Anne Date: 2020_01_03 Solves the given linear equation system Ax = b via forward and backward substitution given the LU-decomposition with full pivoting pr * A * pc = l * u and with CG method. """ #pylint: disable=invalid-name, dangerous-default-value, import-error, unused-import ...
55ff891db63d3c457107ccaf8cbd864dd880959b
bthakr1/Faster_Pandas
/Candies.py
436
3.96875
4
candies = [2,3,5,1,3] extraCandies = 3 def kidsWithCandies(candies,extraCandies): maxCandies = max(candies) result = [] for i in range(len(candies)): if candies[i] + extraCandies >= maxCandies: result.append(True) else: result.append(False) return result def i...
aa386b27b7777e49086cd40a1b33a85d342ec31d
AttilaAV/szkriptnyelvek
/harmadik_o/palindrom_it.py
240
4.125
4
#!/usr/bin/env python3 def palindrome(s): return s == s[::-1] def main(): s = input("Enter a string: ") ans = palindrome(s.lower()) if ans: print("Palindrome") else: print("Not Palindrome") if __name__ == "__main__": main()
51eea69b91543915042008fb9e9123fc336f916b
BretFarley129/Hospital
/hospital.py
1,257
3.8125
4
class Patient(object): def __init__(self, idNum, name, allergies): self.id = idNum self.name = name self.allergies = allergies self.bed = 0 def display(self): print "" print self.id print self.name print self.allergies print self.bed ...
e3af53856bf058051588397292d4271088cba855
francosorbello/Python-Can
/palabras.py
3,346
3.65625
4
from algo1 import * from libreriafinal import * def imprimir(L): node=L.head while node!=None: imprimirLIST(node.value) node=node.nextNode def comparoyordeno(pal1,pal2,bigL): if pal1.value>pal2.value: aux=bigL.value bigL.value=bigL.nextNode.value bigL.nextNode.value...
1648e7e52f67235fb8c029418a31be2f723d7319
JungAh12/BOJ
/4344.py
570
3.5625
4
import sys if __name__ == '__main__': T = sys.stdin.readline().rstrip() for _ in range(int(T)): score = sys.stdin.readline().rstrip() score = score.split(' ') student = int(score[0]) score_sum = 0 for i in range(1, len(score)): score_sum+=int(score[i...
15c9b126f5dcfcd6f772c531704fd4c6b9a583fa
artembigdata/lesson_2_home_work
/task_4.py
122
3.671875
4
string = input("введите слова - ").split() for i, word in enumerate(string, 1): print(f'{i} {word[:10]}')
a911d1fc62ed31100370d9ef0699dddd45f4d67b
RutyRibeiro/CursoEmVideo-Python
/Exercícios/utilidadesCeV/dado.py
495
3.890625
4
def substituir(num): if num.find(',') != -1: num=num.replace(',','.') return num def teste (num): try: float(num) except ValueError: return False return True def leiafloat(num): while True: num=substituir(num) testando=teste(num) if testando==T...
8bcca92158608be10dd77ba81f6e81457e878cd1
Devalekhaa/deva
/play27.py
119
3.890625
4
d=input() e='' for i in d: if i.isupper(): e+=i.lower() if i.islower(): e+=i.upper() print(e)
f44ea1477741a6e3eaca0cdd436a590127cc8e9a
manbalboy/python-another-level
/python-basic-syntax/Chapter08/04.오버라이딩 클래스 변수.py
912
3.75
4
# 생성자 # : 인스턴스를 만들 때 호출되는 메서드 import random class Monster: max_num = 1000 def __init__(self, name, health, attack): self.name = name self.health = health self.attack = attack Monster.max_num -= 1 def move(self): print("이동하기") class Wolf(Monster): pass clas...
12e22b18b2369d092d4bc4b9cd4cc9873820d61a
gunupati/Programs
/Event_Driven_Using_Tkinter/ex1.py
269
3.578125
4
from tkinter import * from tkinter import messagebox top=Tk() top.geometry("100x100") def helloCallBack(event): msg=messagebox.showinfo('Hello Python','Hello World') B=Button(top,text='Hello') B.bind('<Button-1>',helloCallBack) B.place(x=40,y=40) top.mainloop()
7347c543c572f1a3abbfc31a12e478e86c7197e0
abhilshit/bloxorz
/app/position.py
764
3.578125
4
# Copyright (c) 2020. Abhilshit Soni import json class Position: """ A position object depicting position on terrain map. """ def __init__(self, x, y): """ Initialize position based on column (x) row(y) :param x: :param y: """ self.x = x self.y...
1b97790207e2a53718591095ca03160fab8ea45f
HussainAther/computerscience
/puzzles/wordtransform.py
2,033
4.0625
4
import numpy as np import enchant d = enchant.Dict("en_US") """ In 1879, Lewis Carroll proposed the following puzzle to the readers of Vanity Fair: transform one English word into another by going through a series of intermediate English words, where each word in the sequence differs from the next by only one substi...
c290ec53ccc04672d490d9ed6ded1e5ba3135be4
hmonika/A
/remove_item.py
917
3.6875
4
def remove_one(list_input): print list_input count = 0 while len(list_input) != count: if len(list_input) > (count + 2) and list_input[count]+1 == list_input[count+1] and len(list_input) > (count + 2) and list_input[count+2] == list_input[count] + 2 : list_input.po...
00c22e87a8315daf2cd3cea64e8c98c03f5cdafb
darshancool25/IIIT_Codes
/SY Lab Codes/SEM 3/SEM 3 Python/Assignment 4/A4_2.py
123
3.9375
4
num = int(input("Enter a number : ")) mylist = [i for i in input().split(' ')] print([i for i in mylist if (len(i)>num)])
85c6e9b791e8915c02eb79205bdc6b964ac41305
AbiFranklin/Cellular-Automata
/src/conways.py
5,377
3.703125
4
import pygame, random import pygameMenu import sys from patterns import blinker # Define some colors and other constants BLUE = (66, 87, 245) WHITE = (255, 255, 255) PINK = (242, 172, 241) GRAY = (228, 230, 235) DGRAY = (192, 192, 192) WIN_SIZE = 500 CELL_SIZE = 20 # This sets the margin between each cell MARGIN =...
4bdc9f2fc05777672453d6f16eea9141803c610d
Moandh81/python-self-training
/tuple/7.py
265
4.34375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- #Write a Python program to get the 4th element and 4th element from last of a tuple. mytuple = ("dog", "cat", "cow", "fox", "hen", "cock", "duck" ,"bull", "sheep") print(mytuple[3]) print(mytuple[len(mytuple) -4])
4c974dd9b5d91ae44e790161750adf8ac54ed8c9
TMJUSTNOW/python-for-everybody-1
/coursera_py4e/programming_foundations_with_python/rename_files.py
579
3.96875
4
import os def rename_files (): #1 get file names from a folder file_list = os.listdir('/Users/JF/Documents/1PROFESSION/PYTHON/Python_WD/prank') print (file_list) saved_path = os.getcwd() print ("Current Working Directory is " +saved_path) os.chdir('/Users/JF/Documents/1PROFESSION/PYTHON/Python_WD/prank') #2 for ...
8ec5effda08a122b015a7303c6e9fd84005779ee
rdimaggio/kata
/multi_split/multi_split.py
707
3.875
4
def multi_split(string_to_split, list_of_delimiters): string_to_split = [string_to_split] for each in list_of_delimiters: output = [] for item in string_to_split: result = 0 while result >= 0: old_result = result result = item[result:].fi...
3126c9169436f37d8b9ccf6def73f3e14867c597
Kiet2910/ipsip-project
/Python Practice(11-2018)/Sets.py
2,165
4.25
4
##Symmetric Difference #Given 2 sets of integers, M and N, print their symmetric difference in ascending order. The term symmetric difference indicates those values that exist in either M or N but do not exist in both. a,b = [set(input().split()) for _ in range(4)][1::2] print(*sorted(a^b, key=int), sep='\n') ##S...
84aef766d85ef4f9f6e9f1d6e7417d5de46ea214
tiagorodriguessimoes/LinguaNatural-Authorship-mp2
/normalizermstopwords.py
1,092
3.59375
4
#!/usr/bin/python # -*- coding: utf-8-*- # Grupo 29 # Joao Pinheiro 73302 # Tiago Simoes 73100 import re import sys import string from nltk.corpus import stopwords def main(): file_path = sys.argv[1] list_strings = [] with open(file_path, 'r') as file: content = file.readlines() for line in content: line_n...
3609f25932c6022f36d9a1948c8f12b151c23e83
Jamshid93/TaskBook
/While/w6.py
104
3.671875
4
N=int(input("N=")) if N%2==0: L=2 else: L=1 F=1 while N>=L: F=F*N N=N-2 print(float(F))
641fdd99cef6c038a3ad52ae152baec611038863
HexxGamerDraenor/Ex6-Task
/Desktop/Projects/ex6.py
1,136
4.1875
4
name = input("Name: ") age = int(input("Age: ")) height = int(input("Height(cm): ")) weight = int(input("Weight(kg): ")) eyeCol = input("Eye Colour: ") hairCol = input("Hair Colour: ") if(age < 10): print ("Go get your parent please and ask them to not let you on the computer, silly x") elif(age > 10 or...
4b299235a7e6fdd7d24d1e3c6c3b666e4e5545f5
philippbechhaus/uda-ipnd-s2
/fill-in-the-blanks.py
9,146
3.5
4
# fill-in-the-blanks # by Philipp quiz_blanks = ["___1___", "___2___","___3___","___4___"] #blank codes in sample texts quiz1_answers = ["theory","GPS","navigation","Earth"] #answers for paragraph_1 quiz2_answers = ["satellite","speed","atomic","nanosecond"] #answers for paragraph_2 quiz3_answers = ["Differential...
e69d72586bcf1be38abd9ed129bb1831d0eb7093
tcrowell4/adventofcode
/2020/day22_part1.py
1,377
3.640625
4
#!/usr/bin/python # day19_part1.py """ """ import sys import pprint import re import numpy as np def play_cards(p1, p2): num_cards = len(p1) + len(p2) print("Number of cards : {}".format(num_cards)) # if both players have cards then continue playing while len(p1) and len(p2): # draw card ...
a227a685196521b97549d56b57a7a0546e68f90a
Hyun-JaeUng/TIL
/PythonExam/Day8/collectionmgrTest2.py
661
3.578125
4
yoil = ["월", "화", "수", "목","금", "토", "일"] food = ["갈비탕", "순대국", "칼국수", "삼겹살"] menu = zip(yoil, food) print(menu, type(menu)) #type이 , zip 객체임 for y, f in menu: print("%s요일 메뉴 : %s" % (y, f)) print("*"*20) menu = zip(yoil, food) d2 = dict(menu) # 딕셔너리로 for y, f in d2.items(): print("%s요일 메뉴 : %s" % (y, f)) prin...
63c533373e7dea736862a053c97378161b398fac
JasonCh17/Tomato
/week2/分割等和子集.py
1,169
3.625
4
class Solution: def canPartition(self, nums): """ :type nums: List[int] :rtype: bool """ if sum(nums) %2 ==1:#若和的一半不是偶数,则返回False return False elif len(nums)==2 and nums[0]==nums[1]: #排除[1,1]的情况 return True else: ''' ...
f48e09d0ae8dd35d466777e29ca84bca454f9a31
nirgalili/us-states-quiz
/scoreboard.py
761
3.6875
4
from turtle import Turtle STATES_NUMBER = 50 FONT = ("Courier", 54, "normal") class Scoreboard(Turtle): def __init__(self): super().__init__() self.hideturtle() self.penup() self.color("black") self.goto(0, 280) self.score = 0 def write_new_score(self): ...
deff55698a008e59cd467bd1a13e358e22ec81d0
qmnguyenw/python_py4e
/geeksforgeeks/python/expert/2_19.py
2,957
4.4375
4
Pandas Groupby and Computing Median The Pandas in Python is known as the most popular and powerful tool for performing data analysis. It because of the beauty of Pandas functionality and the ability to work on sets and subsets of the large dataset. So in this article, we are going to study how pandas Group By...
94fd6ca69f412302be7505f9a1d032e8e5a66027
suprviserpy632157/zdy
/ZDY/Jan_all/pythonbase/January0112/text0112/day0112_test1.py
567
3.859375
4
# 1.编写函数fun,其功能是计算并返回下列多项式的和 # sn=1+1/1!+1/2!+1/3!+…+1/n! # 建议用数学模块中的math.factorical(x)函数 # 求当n=20时,sn的值 # def fun(n): # from math import factorial as fac # s=0 # if n==0: # return 1 # else: # return 1/n*1/fac(n-1) # print("he=",sum(map(fun,range(0,21)))) # return sum([1/fac(x) for x...
6129e3089871169ad3dfbe17d78342b17551959d
llewyn-jh/data_structure-algorithm
/py_is_palindrome.py
2,155
4.0625
4
"""Check the Palindrome""" import re import time import collections def is_palindrome_match(string: str) -> bool: """Use the match method of regular expression and slicing""" string = string.lower() string = [char.lower() for char in string if re.match('[a-zA-Z]|[0-9]', char)] return string[::-1] == s...
2e7e44cd2b3e8b1ee4321d0e4ee547f6fd489874
sonukrishna/Anandh_python
/chapter_2/q28_enumearate.py
201
4.15625
4
''' the function prints the index and value of the given list ''' def enum(lst): return [(x,lst[y])for x in range(len(lst))for y in range(len(lst))if x==y] aa=list('abrakadabra!') print enum(aa)
d92012c1caca20071c53db233806f68aa624a680
kkkyan/leetcode
/problem-string-easy/58.最后一个单词的长度.py
1,122
3.609375
4
# # @lc app=leetcode.cn id=58 lang=python3 # # [58] 最后一个单词的长度 # # https://leetcode-cn.com/problems/length-of-last-word/description/ # # algorithms # Easy (30.84%) # Likes: 130 # Dislikes: 0 # Total Accepted: 39.1K # Total Submissions: 126.7K # Testcase Example: '"Hello World"' # # 给定一个仅包含大小写字母和空格 ' ' 的字符串,返回其最后一...
26ec638ed1cd5c3cc65dd69956407d9653219468
gabriellaec/desoft-analise-exercicios
/backup/user_139/ch22_2020_03_04_11_28_13_775698.py
102
3.671875
4
a = int(input('Quantos cigaros por dia?') b = int(input('Há quantos anos?') p = (a * 10) * b print(p)
5c20adbd5d94763cc4d374562375d7c11cf71d43
edu-athensoft/cdes1201dataanalysis
/session01/statistics/std.py
686
4.15625
4
import math numstr = input("to find standard deviation, input a set of numbers separated by space: ") try: numlist = numstr.split() num = list(map(float, numlist)) # conv to int mean = math.fsum(num[:]) / len(num) diff = [] i = 0 while i < len(num): square = (mean - num[i]) ** 2 ...
70d5f90cb777e2f8e6f3ea024f90d622e2df404e
althafuddin/python
/Python_Teaching/introduction/test_cities.py
705
3.96875
4
import unittest from city_functions import get_city_name class TestCityNames(unittest.TestCase): """Test the format given city name and country name""" def test_city_country(self): """Test the fucntion to work with 'hyderabad india'?""" formatted_name = get_city_name('hyderabad', 'india') ...
862dd49905db491d5086140514ef7251f7a03031
pp2095/BE-Project
/create_dict.py
1,882
3.515625
4
import csv, json from collections import OrderedDict def make_json(f1,f2): #csvfile=open("maria_results1.csv","r") csvfile=open(f1,"r") #print "OPENED CLUSTER RESULTS" csvreader = csv.reader(csvfile, delimiter=',') emos=['joy','optimism','admiration','acceptance','fear','apprehension','amazement','surprise'...
e1dff830aafb8f6d14e7e94bc45fbb17011a1b97
lucascoelho33/ifpi-ads-algoritmos2020
/VETORES - ALONGAMENTO/alongamento.py
2,353
3.9375
4
def main(): numero = int(input('Quantos números? ')) vetor = gerar_vetor(numero, -1) print(vetor) for pos in range(len(vetor)): vetor[pos] = int(input('Num: ')) print(vetor) qtd_pares = contar_pares(vetor) qtd_impares = contar_impares(vetor) qtd_positivo = contar_p...
58a7b172b7f719eca24e0f98780dc5056daa0a3e
foureyes/csci-ua.0479-spring2021-001
/assignments/hw03/grade.py
1,073
4.5
4
""" grade.py ===== Translate a numeric grade to a letter grade. 1. Ask the user for a numeric grade. 2. Use the table below to calculate the corresponding letter: 90-100 - A 80-89 - B 70-79 - C 60-69 - D 0-59 - F 3. Print out both the number and letter grade. 4. If the value is not numeric, all...
371c1cae2d4f48126b87feb8f4396bc80790eab2
ctucker02/CircuitPython
/Servo_cap_touch.py
951
3.609375
4
import time import board import touchio import pulseio #necessary libraries from adafruit_motor import Servo pwm = pulseio.PWMOut(board.A2, duty_cycle= 2 ** 15, frequency=50) #how long the pulses are and how many there are my_servo = Servo.Servo(pwm) #defining servo touch_A0 = touchio.TouchIn(board.A0) #...
59fe125c05f6a8ee110d4a94f0dfd77fc202ef37
yongwang07/leetcode_python
/vertical_order.py
1,903
3.515625
4
from collections import defaultdict, Counter from binary_tree import Node from operator import itemgetter def vertical_order(root): m = defaultdict(list) def helper(node, level): if node is None: return m[level].append(node.value) helper(node.left, level - 1) helpe...
7ad7a58844d9e95fc4225b2f6bf5c6867a3dd0fd
schakkirala/workspace
/Guttag3.1.py
154
3.71875
4
i = int(raw_input('Enter an int: ')) root = 2 for pwr in range(0,abs(6)+1): print root, ' ', pwr if (root**pwr == abs(i)): print root, '::: ', pwr
9fcfba3bb243cd4d2cc4aeef3aef33f1684793e2
Florisbruinsma/GoGame
/GoGame.py
14,352
3.78125
4
import numpy as np import random class ObservationSpace: def __init__(self, boardSize=5): self.shape = (boardSize*boardSize,) class ActionSpace: def __init__(self, boardSize=5): self.n = boardSize*boardSize class GoGame: def __init__(self, boardSize=5, maxTurns=30): """ i...
887aae9683e0db9948b9ef8f22ae99108945d1fa
KongChan1988/51CTO-Treasure
/Python_Study/第一模块学习/Day1/New_dir/Login.py
339
3.890625
4
# -*- coding:utf-8 -*- # Author:D.Greay username = 'alex' password = '123' _username = input('请输入用户名: ') _password = input('请输入密码: ') if _username == username and _password == password: print('Welcome user.txt {name} Login '.format(name = username.title())) else: print('Please enter the correct username')
bc4d041ac984cceda4e15068d454fd647a3e57cd
kunal27071999/KunalAgrawal_week_1
/Week_1_basic/Week_1_basic_Q16.py
172
4.1875
4
"""WAP to print swap two numbers without using the third variable""" a = 1 b = 2 print("Before swap :", a, b) a = a + b b = a - b a = a - b print("After swap :", a, b)
991059d068e28baa2f8988e46d0fe8e54806a95e
ValeriaLco/Python-Class
/Ejercicios/Strings/crossing_words.py
367
3.578125
4
import math def cruzando_palabras(palabra1, palabra2): mitad1 = math.ceil(len(palabra1) / 2) mitad2 = math.ceil(len(palabra2) / 2) string1 = palabra1[:mitad1] + palabra2[mitad2:] string2 = palabra1[mitad1:] + palabra2[:mitad2] print(string1) print(string2) string1 = input() string...
36abf24931c9784fe910ad50af7ef4fe373be471
b3ngmann/python-pastime
/ps10/ps10.py
14,689
3.71875
4
# 6.00x Problem Set 10 # Graph optimization # Finding shortest paths through MIT buildings # import string, time # This imports everything from `graph.py` as if it was defined in this file! from graph import * # # Problem 2: Building up the Campus Map # # Before you write any code, write a couple of sentences here ...
4f121996bac99b8754401b74274d490f64628b6c
ksks2012/BD_simulater
/main_window.py
4,508
3.578125
4
import tkinter as tk class Window(object): def __init__(self): self.window_handle = tk.Tk() self.window_handle.title('BD Simulater') self.window_handle.geometry('200x100') # return super(Window, self).__init__() def create_label(self): self.var = tk.StringVar() # tex...
7cc38a04961f68721a9a3dd9f8ec5e68e491c22c
x0rk/python-projects
/String_length.py
183
4.21875
4
def str_len(): str1 = input("Enter a string: ") #str1 = "kavinash" result = str1.index(str1[-1]) + 1 return result print("Length of the string is ",str_len())
61c48ca181da06b26a51d93b9197065a431a27be
Shadjistefanov/python-fundamentals
/Courses_practice.py
107
3.609375
4
n = int(input()) courses = [] for i in range(n): text = input() courses.append(text) print(courses)
dd553c33a30664bd55b71ea21d38d44e22955bfd
junyoung-o/PS-Python
/by date/2021.05.14/124나라의 숫자.py
643
3.671875
4
question = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"] answer = [1, 2, 4, 11, 12, 14, 21, 22, 24, 41] num = ["1", "2", "4"] def get_result(n): if(n <= 3): return num[n - 1] q, r = di...
e0547bcc6c094e3f72ac3a4efe31e9c43c650b33
Aasthaengg/IBMdataset
/Python_codes/p03634/s286729663.py
1,037
3.5
4
import sys def input(): return sys.stdin.readline().rstrip() def ii(): return int(input()) def mi(): return map(int, input().split()) def li(): return list(mi()) from collections import deque from heapq import heappop, heappush def main(): def dijkstra(k): def push(v, x): if dist[v] <...
1ddff1ecd5dae626a82d5887b4d33df6e2a162c5
YuliangZHENG6/hackerrank
/CrackingTheCodingInterview/dataStructure/Trees_IsThisBinarySearchTree.py
508
3.890625
4
# python 3 """ Node is defined as class node: def __init__(self, data): self.data = data self.left = None self.right = None """ ##### METHOD 1 def checkBST(root): return checkInorder(root, [-1]) def checkInorder(root, prev): result = True if root.left: result &= c...
95f49937a7334ab61b02d22c7218cfedff3f76d8
jpch89/picpython
/pp_009_多线程执行的不确定性.py
671
3.71875
4
from threading import Thread, current_thread import time def do_sth(): for i in range(5): print('%s: %d' % (current_thread().getName(), i)) time.sleep(2) if __name__ == '__main__': for i in range(3): Thread(target=do_sth).start() do_sth() """ Thread-1: 0 Thread-2: 0 Thread-3: 0 ...
9aed21372b8d00dfafa048142c134581f6f20ea3
malaybiswal/python
/leetcode/containsDuplicate1.py
292
3.734375
4
#https://leetcode.com/problems/contains-duplicate/ def containsDuplicate(nums): """ :type nums: List[int] :rtype: bool """ l1=len(nums) l2=len(set(nums)) if(l1!=l2): return True else: return False arr=[1,2,3,4,6,2] print(containsDuplicate(arr))
f06375983a352943b6ad34eafeb9ffa85f9bb32d
marisalvarani/FaculdadeADS
/Listas/6).py
701
4
4
n = int(input("Digite a quantidade de nomes:" )) lst_nomes = [] while n<3 or n>10: n = int(input("Digite a quantidade de nomes entre 4 e 9:" )) for x in range(1,n): nome = str(input("Digite o nome:" )) lst_nomes.append(nome) print("Nomes digitados:", lst_nomes) lst_nomes.insert(3, "Teste") print("Lista...
9c1dfbb72b3608a79f7e74859e48f8e8c1623370
Srynetix/libnx-gol
/tools/font.py
2,150
3.96875
4
""" Hex font data generator. From an input string, generate an 32-bit hex code to use for font rendering. Example, for a font size of 5 x 6 pixels (0 for a white pixel and 1 for a black pixel) ..o.. => 00100 .ooo. => 01110 ..o.. => 00100 ..o.. => 00100 .ooo. => 01110 ..o.. => 00100 => Input string: "001...
d2e38630ab4ff120f1f7d39cb1776fddc5789c24
akalikhan/flask_course
/Lecture8/table.py
331
3.6875
4
import sqlite3 conn = sqlite3.connect('data.db') cur = conn.cursor() create_items = 'CREATE TABLE IF NOT EXISTS items (name TEXT, price REAL)' cur.execute(create_items) create_users = 'CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, username TEXT, password TEXT)' cur.execute(create_users) conn.commit() c...
25b032fe2e2307604b243b068d33d6d0ac10176e
Skywonder/Connect4-Python
/I32CFSP.py
2,220
3.59375
4
# ANPING HE (17685951) KUAN-PING CHANG(71018021) import socket def get_host()->str: '''prompts the user for host address, and check for validity''' while True: result = input('Please enter the host name or address: ').strip() if result == '': print('Error! Invalid host name or addr...
2c41ddf8d0f5e6d1da6e57d60dd7b9f1793051f9
Vivekyadv/450-DSA
/3. String/4. Count and Say problem.py
714
3.8125
4
# Given a number n, return the nth pattern # pattern is defined as # N = 4 # countAndSay(1) = "1" # countAndSay(2) = say "1" = one 1 = "11" # countAndSay(3) = say "11" = two 1's = "21" # countAndSay(4) = say "21" = one 2 + one 1 = "12" + "11" = "1211" def countAndSay(n): if n == 1: return '1' if n =...
434f99afbd5ab32cc089dd3abad8d4e6f9b8d57a
baghirov/python-slides
/Lecture7/lecture-examples/lecture7-2.py
377
3.765625
4
a = float(input("Performance of CPUA:")) b = float(input("Performance of CPUA:")) performance_rate = a/b print(f'I have been living here for {years} years') faculties = ["Case", "Ce", "Cs", "Ssch", "Med"] index = int( input(f'These are the faculties {faculties} which index do you want to use?')) faculties[index...
164afc1b17243ef5e8ec91e8c2687d6d097d1bb7
Ellana42/OnePyce2
/terrain.py
10,764
3.640625
4
from random import randrange, random, seed, choices, shuffle from math import sin, cos, pi, fabs, sqrt import copy from pygame import Rect, Color class Terrain: @classmethod def get_terrains(cls): terrains = { "S": ("Sea", "Water"), "E": ("Pond", "Water"), "M": ("M...
3b998067e8888d297fea25efcd0676d2fa0feaaa
krishna-rawat-hp/PythonProgramming
/codes/list14.py
200
4.15625
4
# Python list common element in two list lst1 = [1,2,3,4,5] lst2 = [4,5,6,7,8] # Example-1 cele = [] for i in lst1: for j in lst2: if i == j: cele.append(i) print("Common Element is: ",cele)
4f2f175bf9c2315b0fd9fb7ea4acf4b895d35ecb
ch0r1es-1n-ch0rge/starting_out_with_Python
/Chapter 5 - Programming Exercises/CH: 5 - Kinetic Energy.py
1,326
4.4375
4
# In physics, an object that is in motion is said to have kinetic energy. The following formula can be used to determine # a moving object's kinetic energy: # KE = 1/2mv^2 # The variables in the formula ae as follows: KE is the kinetic energy, m is the object's mass in kilograms, a...
98ed3b42a67f5fa0060a5f7db93fa47b07f4da8c
3wh1te/Leecode
/code/searchMatrix.py
2,358
3.53125
4
class Solution: def searchMatrix(self, matrix, target): def search(matrix,row,col,target): if row < 0 or col >= len(matrix[0]): return False if matrix[row][col] == target: return True elif matrix[row][col] < target: return s...
7d6d949479b831b2c60b7c87cc0a34458fceb4b5
DREAMS-lab/SES230-Coding-for-Exploration
/Labs/linear-regression.py
608
3.515625
4
import numpy as np import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression x = 30*np.random.random((20,1)) slope = 0.5 intercept = 1.0 noise_vec = np.random.normal(size=x.shape) y_without_noise = slope * x + intercept y = y_without_noise + noise_vec model = LinearRegression() model.fit(x,y...
ce88aef91451479eec95a2430951b741789958a4
nivi2021python/luminarpython
/functions/subfunction3.py
121
3.828125
4
#subtraction with arguments and return type def sub(no1,no2): diff=no1-no2 print(diff) data=sub(8,5) print(data)
c0d5c34707901f4db3b99f00229a595d2276cc91
mehulchopradev/kate-elizabeth-alon-python
/play_tuples.py
638
4.21875
4
# create a tuple of details of a book in library b1 = ('Prog in C', 900, 4500) print(type(b1)) # create an empty tuple b2 = () print(type(b2)) # create a tuple that has only one element b3 = ('Prog in Java',) # leave a trailing comma print(type(b3)) # a tuple is also like a sequence of elements # position of the ele...
a9a9271bfad563ad4f474867c6c06f04d43a72a6
vcancy/python-algorithm
/leetcode/Algorithms/Array/88.py
817
4.03125
4
__author__ = "vcancy" # /usr/bin/python # -*-coding:utf-8-*- """ 分析: 题目中要求将nums2插入nums1中,最后存在nums1中 最后新的nums1的大小为m+n-1 倒序nums1和nums2,判断最后一位,越大的数放在新nums1的最后 """ class Solution: def merge(self, nums1, m, nums2, n): """ :type nums1: List[int] :type m: int :type nums2: List[int] ...
f7de23137952b2a1f77816f470f794e7d00ddd3c
Bosh-Kuo/Udemy-Bootcamp-of-Data-Science-with-Python
/Section5_Pandas_Essential/Ex5_9.py
274
3.859375
4
import pandas as pd s = pd.Series([1, 2, 3, 4, 5, 6], index = ['a', 'b', 'c', 'd', 'e', 'f']) print(f'First element: {s[0]}') print(f'Third element: {s[2]}') print(f'First three elements: \n{s[:3]}') print(f'Last three elements: \n{s[-3:]}') print(f'Last element: {s[-1]}')
d00fe7f4128eac3bc95b1f81a3fb3032c5c06b8f
johannbzh/Cracking-The-Coding-Interview-Python-Solutions
/stacks_and_queues/MyQueue.py
321
3.5625
4
class MyQueue(object): def __init__(self): self.enq = [] self.deq = [] def push(self, x): self.enq.append(x) def popleft(self): if not self.deq : while self.enq : self.deq.append(self.enq.pop()) return self.deq.pop() if self.deq else None...
6dbab9f1c75e22a6f8bc1c602008d3364219d273
fomitim37/PEP8_class
/main.py
986
3.953125
4
"""class file""" def summ(a_num, b_num): """summ function""" return a_num + b_num class Human(): """Human class""" def __init__(self, name, height, weight): """__init__ function""" self.name = name self.height = height self.weight = weight def is_weight_normal(...
21b2e08dab5d6a4637dcf02c506a410698a81c1f
vinayakgaur/Algorithm-Problems
/Jewels_and_Stones.py
689
3.96875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Jan 10 11:55:34 2021 @author: VGaur """ # You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to know how many of the ...
aef0d92d1f0355e5f1ca6fcbfb16c32136b1b7f3
sherms77/Python-challenges
/HackerRank/Python if-Else/tests/rule2-test.py
362
3.859375
4
# Rule 2: if n is even and in the inlcusive range of 2 to 5 print Not Weird # n = int(input('Enter num:')) def rule2(n): if n%2 and n in range(2,6): print('Not Weird') else: print('Weird') rule2(2) # out[2]: Not Weird rule2(3) # out[3]: Weird rule2(4) # out[4]: Not Weird rule2(5) # ...
aa7b2481c3591abf0aa1ddedd30a23d01359ab39
Mils18/Lab
/class_TollSyste_3.py
6,963
3.734375
4
class Vehicle: def __init__(self,cPriceM,bPriceM,tPriceM,cPriceP,bPriceP,tPriceP): self.cPriceM = cPriceM self.bPriceM = bPriceM self.tPriceM = tPriceM self.cPriceP = cPriceP self.bPriceP = bPriceP self.tPriceP = tPriceP def getcPriceM(self): ...
b7c77fbd738a031da2a9eba9f8138848d101c831
jiangyihong/PythonTutorials
/chapter10/exercise10_6.py
409
3.96875
4
first_number_str = input("Please input first number:") try: first_number = int(first_number_str) except ValueError as e: print("You input wrong number!") first_number = 0 second_number_str = input("Please input second number:") try: second_number = int(second_number_str) except ValueError as e: sec...