blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
10d17f8b1bf944bfed21a4152ec4b63f4e388d97
jmrp81/Python
/diccionarios.py
456
4.28125
4
print("Diccionarios --> relacionan clave con valor") print("Ejemplo dic = {\"Nombre\":\"Alberto\",\"Apellido\":\"Rodriguez\",\"Victorias\":[2001,2002,2003]}") dic = {"Nombre":"Alberto","Apellido":"Rodriguez","Victorias":[2001,2002,2003]} print("x = dic[\"Nombre\"]","\n","print(x)") x = dic["Nombre"] print(x) print("x =...
a23e1b657d06ae3fd82a80b64a196901ac053af8
Chrisu892/Simple-Library-System
/main.py
4,130
3.953125
4
# Import required modules from classes.BookList import BookList from classes.UserList import UserList from classes.Loans import Loans import sys # Define the Library interface class class Library: def __init__(self): """Library class constructor.""" self.book_list = BookList() self.user_list = UserLi...
72d5d25341fecca80849230e83d36b26b4afc81b
rufi91/sw800-Coursework
/ML-6/ex1.py
1,785
4.03125
4
""" Develop an ML model for predicting the digits in the digits image dataset in sklearn using SVM . Plot some sample input images together with its class information. Also plot some predicted outputs together with its actual images. [hint: To plot the images using plt.imshow use the actual dimension of the images in t...
041eb1ecaad4d9fcc7a3a834dbfcbfcddb3b607a
Lcoderfit/Introduction-to-algotithms
/PythonLeetcode/greedy/easy/1221. 分割平衡字符串.py
1,067
3.59375
4
""" 方法1: 贪心法 (while版) 时间复杂度:O(n) 空间复杂度:O(1) 方法2: 贪心法 (for版) 时间复杂度:O(n) 空间复杂度:O(1) case1: RLRRLLRLRL r: 4 case2: RLLLLRRRLR r: 3 case3: LLLLRRRR r: 1 """ import sys from typing import List class Solution: @staticmethod def balanced_string_split(s: str) -> int: ans, i = 0, 0 balance = 0 ...
2e30f18bba5161fc3bb8ddb9531bf799a376245f
yychuyu/LeetCode
/problems/0215_Kth_Largest_Element_in_an_Array/leetcode215.py
977
3.609375
4
# !/usr/bin/env python3 # -*- coding:utf-8 -*- class Solution: def findKthLargest(self, nums, k): # 64ms(快排) """ :type nums: List[int] :type k: int :rtype: int """ return self.find(nums, k-1, 0, len(nums)-1) def find(self, nums, k, left, right): l = lef...
48f7a08b3703cf9e5cb992f5e59d423523f01abe
KevinMichaelCamp/Python-HardWay
/Algorithms/Chapter3_Arrays/13_Remove_Negatives.py
312
3.890625
4
# Create a function that accepts an array, removes the negative values, and returns the same array. def removeNegatives(arr): i = 0 while i < len(arr): if arr[i] < 0: del arr[i] i -= 1 i += 1 return arr # Test Cases print(removeNegatives([1,2,-3,4,-5,6]))
f3b31d3420e93561e1831d68e72eecec07ccdcb1
realpython/materials
/python-class/employee.py
1,021
3.953125
4
from datetime import datetime class Employee: company = "Example, Inc." def __init__(self, name, birth_date): self.name = name self.birth_date = birth_date @property def birth_date(self): return self._birth_date @birth_date.setter def birth_date(self, value): ...
79a1efb3294bb9d6df8a42865d34d58952a1f6e8
leeo1116/PyCharm
/Algorithms/LintCode/059_3sum_closest.py
1,107
4.03125
4
class Solution(object): def three_sum_closest(self, numbers, target): """ If find minimum absolute difference between three sum and target by Brute-Force, time complexity will be O(n^3) If first sort numbers, e.g. quick sort whose time complexity is O(n), and then use two pointers to denote ...
f17ae0d0027f83e81829521e5d127ff1dbd08c0c
leizhen10000/learnPython
/python_improve/sorted_maopao.py
2,673
3.546875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ # @Time : 2019/11/8 06:51 # @Author : Lei Zhen # @Contract: leizhen8080@gmail.com # @File : sorted_maopao.py # @Software: PyCharm # code is far away from bugs with the god animal protecting I love animals. They taste delicious. ┏┓ ┏┓ ...
f2b5d7605e3d3df61967cc7c5258e40bd817d5f9
Jhy1993/Data-Structure
/5.1 Searching/5.1.2Binary Search.py
517
3.78125
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 08 21:37:03 2016 @author: Jhy1993 """ def binarySearch(array, target): low = 0 high = len(array) - 1 while low < high: mid = (low + high) // 2 print array[mid] if target == array[mid]: return True elif target < array...
6a9deed914d18e29cd7c580aa4f65c4992c572b5
guiconti/workout
/leetcode/566.reshapeMatrix/566.reshapeMatrix.py
1,593
4.21875
4
# 566. Reshape the Matrix # Easy # 666 # 94 # Add to List # Share # In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data. # You're given a matrix represented by a two-dimensional array, and two positive integers r and ...
aabe6a329872831e87298ac75c0e4425dd423890
nebulx29/LearnPython
/language_basics/random_list_entry.py
291
3.53125
4
# test01 import random def lentry(i, liste1, liste2): x1 = random.randint(0, len(liste1)-1) x2 = random.randint(0, len(liste2)-1) print(str(i) + ": " + liste1[x1] + str(liste2[x2])) liste1 = ["a", "b", "d", "f"] liste2 = [4, 3, 8, 6] for i in range(0,9): lentry(i, liste1, liste2)
fa546d1a74cd2e193a9902ff794adc6d265a9ca2
dinnguyen1495/QuizGame
/quiz_database.py
1,356
3.6875
4
""" quiz_database.py Questions and answers for a quiz game """ import requests import html class QuizDatabase: """ Class for Quiz """ def __init__(self, amount: int, qtype="boolean", difficulty="any", category=0): self.params = { 'amount': amount, 'type': qtype ...
b8f3ceaa6dcdb0179ff690b6a80c2dd8ba942115
bingzhong-project/leetcode
/algorithms/pyramid-transition-matrix/src/Solution.py
655
3.53125
4
import collections class Solution: def pyramidTransition(self, bottom: str, allowed: list) -> bool: def func(cur, above, data): if len(cur) == 2 and len(above) == 1: return True if len(above) == len(cur) - 1: return func(above, "", data) ...
3c0afae5e82e487392cfd2d2b3d00b359070a0e2
pavancd/algorithms
/Permutations/Permutations.py
1,103
3.875
4
# #O(n!*n*n) | O(n*n!) # def getPermutations(array): # permutations = [] # permutationHelper(array, [], permutations) # return permutations # def permutationHelper(array, currentPermution, permutations): # if not len(array) and len(currentPermution): # permutations.append(currentPermution) ...
5bc26fb471d921462bc8535954718ae3a80f9bcf
walidA1/programmingnew
/Pe9_1/Sets.py
440
3.65625
4
bruin = {"Boxtel", "Best", "Beukenlaan", "Eindhoven", "Helmond 't Hout", "Helmond", "Helmond Brouwhuis", "Deurne"} groen = {"Boxtel", "Best", "Beukenlaan", "Eindhoven", "Geldrop", "Heeze", "Weert"} print("de treinen rijden allebei langs de volgende stations: {}".format(bruin.intersection(groen))) print("de groene trei...
23a34fe58213ecee597cfd2eebf5c0ad34f3587e
fxw97/NCRE2python
/第2套/简单应用题/2-45.demo.py
606
3.703125
4
# 计算输入的平均年龄和女性的人数 fo = open("PY202.txt","w") data = input("请输入一组人员的姓名、性别、年龄:") # 姓名 年龄 性别 women_num = 0 age_amount = 0 person_num = 0 while data: name, sex, age = data.split(' ') # 注意分隔字符串并赋值要在循环内部 if sex == '女': women_num += 1 age_amount += int(age) person_num += 1 data = input("请输入一组人员的姓...
e742ebec5d1e3ce5b72f93ee332ecd73f5ca7647
zachary-trozenski/dat129_ccac
/In-class/Week_4/in_class.py
2,736
3.5
4
# -*- coding: utf-8 -*- """ Created on Wed Feb 19 18:57:59 2020 @author: zachary.trozenski """ # pull in the json & csv module into the script import json import csv from pprint import pprint # open the file gitinfo.json and using the load() method, assign the json # file to the variable gitkeywords with open('gitin...
d9cd48bdbfcc094e775e3c9c6992f9749fd8b89b
petervdonovan/socscrapecontent
/SocScrapeContent/HtmlProc.py
1,933
3.734375
4
import bs4 class HtmlProc: ''' Class used for namespacing static methods. These methods are needed to represent HTML elements in BeautifulSoup soup as plain text for people unfamiliar with HTML. ''' @staticmethod def ulProc(soup): ''' Get an ul as a series of bullet points m...
dc6e01d4b3bd0f5de9664d02d7d276904e727825
casiojapi/python-para-industriales
/listas/lista_avg.py
387
3.671875
4
#Lista con promedio def prog(): l=[] cant=int(input("Ingrese la cantidad de valores:")) suma=0 for i in range(0,cant): a=int(input("Ingrese valor de la lista:")) l.append(a) suma=suma + l[i] prom=suma/(cant) print("El promedio es:",round(prom,2)) #Round es ...
6c21d6f6d51f0ca7f4455adb5a071462cc0b54d4
aryanxk02/HackerRank-Solutions
/Problem Solving/Two Strings.py
244
3.65625
4
t = int(input()) for _ in range(t): s1 = input() s2 = input() flag = 0 for letter in s1: if letter in s2: print('YES') flag = 1 break if flag == 0: print('NO')
48b16a73d6474312ed6dcc65111ec2ffb712bcb8
shyamsaravanan/nexwave
/funcs_7.py
351
3.703125
4
#VARIABLE KEYWORD ONLY ARGUMENTS def add(a,b=10,*c,d,e,**f): print('Extra keyword only args= ',f) r=a+b+sum(c)+d+e+sum(f.values()) return r r1=add(10,d=20,e=30) print('r1= ',r1) print('-'*40) r2=add(10,20,30,40,50,d=60,e=70,x=80,y=90) print('r2= ',r2) D={'d':50,'e':60,'x':70} res3=add(10,20,30,40...
6d704e489ef8dd5b08df9221cc22b3437b533607
arushibohra/0703_0135
/arma and arima/arma.py
5,078
3.5
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Sat Oct 19 08:33:19 2019 @author: arushibohra """ import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) data =pd.read_csv("all_stocks_5yr.csv") data.head() data.tail() #I just picked the first stock da...
9ef390ece12305ba28d282a7a32854fac03e613f
mrslwiseman/python
/temp.py
82
3.703125
4
f = input("fahrenheit: ") c = 5 / 9 * (int(f) - 32) print("celcius: {}".format(c))
b129e38d7c3b0ab93816c6c8482a0e10d2d45ddc
gxmls/Python_NOI
/NOI1-4-05.py
393
3.796875
4
''' 描述 输入两个整数,比较它们的大小。 输入 一行,包含两个整数x和y,中间用单个空格隔开。 0 <= x < 2^32, -2^31 <= y < 2^31。 输出 一个字符。 若x > y,输出 > ; 若x = y,输出 = ; 若x < y,输出 < ; ''' x,y=map(int,input().split()) if x>y: print(">") elif x==y: print("=") else: print("<")
5d026f6f082f732ee63e215cfd63eaaa88282acd
dtbinh/6854
/kleinberg.py
4,888
3.796875
4
# kleinberg algorithm # on the k-secretary problem # input: N, number of candidates, k, number of candidate to select # W: the list of N-values for each candidate, in the order of arrival. # output: list of k candidates selected by the algorithm import math import numpy # the optimal algorithm for k = 1 # o...
0ff87e495fbb7aaeca8c679d690bd91bf30bad1b
badalmainali/Discount
/discount calc.py
132
3.578125
4
A=int(input("Enter Amount:")) D=int(input("Enter Discount percnt:")) Disc=(D/100*A) Amnt=(A-Disc) print("Total Amount is ",Amnt)
b1b9bf08309d4ebfffaf61a1c3096166fdbc88a2
PaulOfili/patrick-s_code
/text_threat.py
753
3.921875
4
sentence = 'xaxax' sentence = sentence.lower() score = 0 def check_palindrome(segment): reversed = segment[::-1] return reversed == segment # for begin in range(len(sentence)-2): # for stop in range(3, len(sentence)+1): # end = begin + stop # if end > len(sentence): # continu...
7be18265ff35426af1a49caf005f4143559dcf1c
PrashantMhrzn/100-days-of-code-1
/100daysofpython/practice_unittest/cuboid_volume.py
202
3.71875
4
def cuboid_volume(l): if type(l) not in [int, float]: raise TypeError() return l*l*l # length = [2, 1.1, -2.5, 2j, 'two'] # for i in length: # print("Result: ", cuboid_volume(i))
e20cd09fdcc94f3a0e1e90860ae51e19f43be50c
smallgreycreatures/kth-programming1labs
/Lab4/lab4-a3.py
412
3.984375
4
from math import sqrt def calculate_mean_value_with_loop(number_list): total = 0 for number in number_list: total += number return total/len(number_list) def standard_deviation(number_list): mean_value = calculate_mean_value_with_loop(number_list) sum2 = 0 for i in number_list: sum2 +=(i-mean_value)**2 re...
e1d4b4c88a22a652177ab3a3d688fb1723a09ccf
mingtao13595/NaturalLanguageProcessing
/NaturalLanguageProcessing/ex19.py
1,293
3.515625
4
# coding: UTF-8 #!/usr/bin/env python f = open('./file/hightemp.txt', 'r') # ファイルデータの配列 fileList = {} # 県だけ抜き出した配列 prefList = [] record_num = 0 for line in f: lineList = line[:-1].split('\t') fileList[record_num] = { "id" :record_num, "pref" :lineList[0], "area" :lineList[1], "te...
4200f6f2f7c0a513ff7a8f1f0f1cb165d5305b37
laharikaneelam/Python_exercises
/squares.py
103
3.71875
4
def square(x): return x*x for k in range(10): print(f"the square of {k} is {square(k)}")
8fd8dcab7f35affa6f1fc04eaffc7e3d4d4f4235
vhdinh/Python-ScoreGrades
/ScoreGrades.py
535
4
4
print "score and grades" for i in range(1,11): score = input("enter your score:") if score <= 59: print "score: %s; You failed :( " % score elif score > 59 and score < 70: print "score: %s; Your grade is D" % score elif score > 69 and score < 80: print "score: %s; Your grade is C" %...
a68c18e5c41eb3581d4824d886d40b80308e387b
llCUriel/TheoryOfComputation
/[TC 01] Basic Concepts Of Python Programming/prUno.py
433
4.0625
4
Sigma = ["E", "S", "C", "O", "M", "/", "$", "X"] miCadena = input("Introduce una cadena de texto: ") cnt = 1 for caracter in miCadena: if (caracter not in Sigma): cnt = 0 if (cnt == 0): print ("La cadena '" + miCadena + "' no se encuentra en el alfabeto") else: print ("La cadena '" ...
e1edb5b14e017a0b478c3df3aac0f7100c21d243
Shehaab/CodeSignal
/IsLucky.py
469
3.890625
4
def isLucky(n): """ Returns True for an even number whose first half's sum equal to its second half.""" # List of digits of the number n. numList = [int(d) for d in str(n)] # Extract first half sum, and second half sum using list slicing. FSum = sum(numList[0:int((len(numList)/2))])...
3f657ccebd42272c331fe384112a7978bd977de1
HsiangHung/Code-Challenges
/leetcode_solution/binary search/#744.Find_Smallest_Letter_Greater_Than_Target.py
1,278
3.640625
4
# [#744] Find Smallest Letter Greater Than Target # # Google # class Solution(object): def nextGreatestLetter(self, letters, target): """ :type letters: List[str] :type target: str :rtype: str """ self.ch = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, ...
dad4d50fb6999cbe3f177289ebea275ee0ce3919
mathi1811/snakegame
/snake2.py
770
3.578125
4
from turtle import* from random import randrange from freegames import square,vector food=vector(0,0) snake=[vector(10,0)] aim=vector(0,-10) def change(x,y): aim.x=x aim.y=y def inside(head): return -200<head.x<190 and -200<head.y<190 def move(): head=snake[-1].copy() head.move(aim) if not ...
3644e20e5feea3f9a519b8093e198263288256f7
urein/Leecode_python
/Ag007_reverse_integer.py
774
4.21875
4
""" Given a 32-bit signed integer, reverse digits of an integer. Note: Assume we are dealing with an environment that could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows. Example 1:...
77d1e7c44796dc177e545bd0a01c3dbc62a048de
brunodantascg/listaExercicioPythonBR
/2estruturaDeDecisao/10_bomDia.py
333
3.90625
4
# frase de bom dia turno = str(input("Informe Turno: ")) turno = turno.upper() if(turno == 'M'): print("M-matutino") print("Bom dia!") elif(turno == 'V'): print("V-vespertino") print("Bom Tarde!") elif(turno == 'N'): print("N=noturno") print("Boa Noite!") else: print("{} valor inválido".fo...
fbfcf75ab1d9352ec60dd3ed91b959f7d0f2e6db
Davidpd1/Python
/CS101-Ch3-Ex1.py
227
3.546875
4
# David Powis-Dow CS 101:Python # 2016-10-30 v0.1 # Chapter 3 : Exercise 1 - Recursion for f in range(1000): printsentence = "I enjoy Python's turtles!" print(printsentence)
7ea95ad01564bc9eecfc0a62636191dfb815ac99
dankernel/AlgorithmTest
/acmicpc/test/round/test.py
180
3.546875
4
def _round(a): if int(a) % 2 == 0: return round(a) + 1 else: return round(a) print(_round(2.5)) print(_round(3.5)) print(_round(4.5)) print(_round(5.5))
8d0fe9f9ed8076fa4dd7c84c22ffb1c18246c099
s1f101902208/logmeal
/func.py
3,742
3.546875
4
import datetime import meal import deal_json import material_class import json def register_meal(): print("食事記録を登録しましょう。") date = datetime.date.today().strftime("%y/%m/%d") while True: sort = int(input("1.朝食 2.昼食 3.夕食 4.間食 5.戻る")) if 1 <= sort <= 4: break elif sort == 5:...
7e4f56a3fc7c2108fab22b72d336acd2a3986dfb
stanfeldman/samples
/python/common.py
281
3.953125
4
d1 = { "a": 55, "b1": 77, "c1": { "x": 55, "c2": 11 } } d2 = { "a": 56, "b2": 88, "c1": { "c2": 22 } } def merge(d1, d2): for k1,v1 in d1.iteritems(): if not k1 in d2: d2[k1] = v1 elif isinstance(v1, dict): merge(v1, d2[k1]) return d2 print merge(d1,d2)
9d4eb34827c171bae4698b30028f07b7ff71a939
ankitrjsingh/Caesar-cipher
/caesarcipher.py
956
4.28125
4
"""code for encoding and decoding using caesar cipher technique. The code works for the alphabets.""" choice=input("enter your choice:encrypt=0 or decrypt=1\n") if choice=="0": text=input("enter the text\n") text=text.lower() key=int(input("enter the key between 1-26\n")) if key > 26 or key < 1: ...
6b69f6186d28af82079b88717dd511bf094ca0c1
MAPLE-Robot-Subgoaling/IPT
/data/HW5/hw5_050.py
405
4.15625
4
def main(): width=int(input("Please enter the width of the box: ")) height=int(input("Please enter the height of the box: ")) outline=input("Please enter a symbol for the box outline: ") fill=input("Please enter a symbol for the box fill: ") print() print(outline*width) for i in range(height...
706e18df4d5244d5c14f65cb34168a0b08059d9e
deeptivenugopal/Python_Projects
/edabit/ones_threes_nines.py
500
3.953125
4
''' Ones, Threes and Nines (Version #1) Given an int, figure out how many ones, threes and nines you could fit into the number. You must create a class. You will make variables (self.ones, self.threes, self.nines) to do this. https://edabit.com/challenge/X6xZ2EaqqQbGF7Bwv ''' class ones_threes_nines: def ...
fc894fa5241653ac70e829640c131a0304ed8f10
newverygood/Jtyoui
/jtyoui/data/methods.py
1,781
3.609375
4
#!/usr/bin/python3.7 # -*- coding: utf-8 -*- # @Time : 2019/6/1 22:34 # @Email : jtyoui@qq.com # @Software: PyCharm import random import string _special = "#$%&@" # 随机选择字母: def random_char(number=1): ls = random.choices(string.ascii_letters, k=number) return ''.join(ls) # 随机选择小写字母: def random_lower_cha...
c066e04c3c0c2d9f00727a9ee66e039ab104886d
023Sparrow/Projects
/Numbers/next_prime.py
498
3.890625
4
'''**下一个素数** - 让程序查找素数,直到用户选择停止请求下一个素数。''' #!/usr/bin/python # -*- coding: utf-8 -*- def odd_numbers():#生成一个无限序列,由3开始的奇数 i = 1 while True: i = i + 2 yield i def ismuti(n): return lambda x: x % n > 0 def prime(): yield 2 it = odd_numbers() while True: n = n...
d190e039c1fd358cfe15b05259b91c159c068c21
knight-byte/Codewars
/beta/Merge Intervals/Merge Intervals.py
501
3.515625
4
def merge_intervals(intervals): intervals.sort() res = [] start, end = intervals[0][0], intervals[0][1] for i, interval in enumerate(intervals[1:]): s, e = interval[0], interval[1] if s > end: res.append((start, end)) start, end = s, e else: e...
c56fe44f13bd5c8e65930f70587d92a582cf354a
ObinnaObeleagu/Udacity
/Data Wrangling with MongoDB/Lesson3/dbpediaAudit.py
959
3.90625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import csv import math def skip_lines(input_file, n): for i in range(n): input_file.next() def is_number(v): try: ret = float(v) except: ret = None return ret def ensure_float(v): if is_number(v): return float(v) def ...
60309c3255b6514896d3989c48f29745e002e2f8
vpdeepak/PirpleAssignments
/InputAndOutput/main.py
2,004
4.1875
4
""" This is the solution for the Homework #8: Input and Output (I/O) """ import os print("Assignment on Input and Output (I/O)") def WriteToFile(fileName, option): content = input("Please enter the text to be put to the file " + fileName + " : ") with open(fileName, option) as inputFile: inputFile.w...
9549e65b90fa8f417ba8d4a7fadc4b1aafdbf566
Keith-Njagi/Design_Patterns
/composite_design.py
1,146
3.859375
4
class User(object): def __init__(self, fullname, id_no, phone, amount): self.fullname = fullname self.id_no = id_no self.phone = phone self.amount = amount def showDetails(self): # print("\t", end ="") print(self.fullname, '\n', self.id_no, '\n', self.phone, '\n', self.amount) class AccountType(object)...
cb6547ad110d226797482056dba2d7c5790b2980
yanglt7/programTest
/53.py
1,547
3.703125
4
''' 请实现一个函数用来判断字符串是否表示数值(包括整数和小数)。 例如,字符串"+100","5e2","-123","3.1416"和"-1E-16"都表示数值。 但是"12e","1a3.14","1.2.3","+-5"和"12e+4.3"都不是。 ''' ''' 定义两个标志位,分别表示E或者e是否出现过,以及小数点.是否出现过。 1. 以e(或E)为分隔,获得两个子字符串;e之前的字符串小数点只能出现一次; e之后的字符串不允许出现小数点; 2. 符号位+或-只可能出现在两个子字符串的首位; 3. e(或E)、小数点.不能出现在末尾 ''' # -*- coding:utf-8 -*- class Solu...
3a483b18a07178cf6210046c03598c1bf6c4201d
Vaishnavmatte/Project1.O
/PROJECT 1.O.py
641
3.8125
4
#!/usr/bin/env python # coding: utf-8 # In[27]: #STUDENT DETAIL PROJECT# name=str(input('enter student name')) clas=int(input('enter the standard')) division=str(input('enter the division')) Rollno=int(input('enter the roll no')) Subject1=str(input('enter the subject1')) mark1=int(input('enter the marks of subject1'...
db35b485bbb9bd30e965027456a23fbce8651846
5-pankajkr/greyatom-python-for-data-science
/pankaj-spy-game/code.py
2,299
3.5625
4
# -------------- ##File path for the file file_path def read_file(path): file=open(path, 'r') sentence=file.readlines()[0] file.close() return sentence sample_message = read_file(file_path) print(sample_message) #Code starts here # -------------- #Code starts here message_1= read_fil...
57e79be2f2f6568d5695231abbbf3d506f4c5e7b
nileshgulve/file-operations
/delete-dirc-recursively.py
748
4.21875
4
#!/usr/bin/python3 # You able to delete directory recursively, only when this are empty. import os def main(): print(os.path.exists('/root/python/file-operation/wf4/one/two/three')) print(os.path.isdir('/root/python/file-operation/wf4/one/two/three')) # print(os.removedirs('/root/python/file-operation/wf4/one/two/th...
7719466b769b4e0bcdb0ba5ca11f97ca20f9cbe8
ITISFoundation/osparc-simcore
/services/web/server/src/simcore_service_webserver/security/_utils.py
1,285
3.546875
4
""" Permissions - Describe actions on resources using normalized labels. These are later used to determine whether a given user is allowed or not to execute it. - Labels convention: dot-separated labels denoting a hierarchical resource name and an action e.g. project.template.read => resource='template...
770846c0ec9d122ab804d7662f4ed3671ef5e11a
KseniyaTonko/BSUIR-PYTHON-2020
/Solutions/Task2/853502_Катя_Жевняк/tasks/ExternalSort/ExternalSort.py
2,592
3.9375
4
import tempfile def Sort(source_file_name: str): try: with open(source_file_name, 'r') as input_file: print("Start sorting...") Simple_Merge_Sort(input_file) except IOError: print("Wrong file name") def Simple_Merge_Sort(input_file): amount_of_nums = 0 with op...
9f0c0c2c6e45c6833ddd67747c3feb420455070f
pmheintz/Python3
/conditionals.py
378
4.28125
4
x = 2 y = 20 if x == 1: print("X is equal to 1") elif x == 2: print("X is equal to 2") elif x == 3: print("X is equal to 3") else: print("X is NOT a number from 1-3!") """ if x == y: print("This print statement should not be run") else: print("X is NOT equal to Y!") if y > x: print("Y is greater than X!") els...
d9d581852ac1014126e1c0041038d38de974765f
mcr229/AutoCorrect
/wordTree.py
4,532
3.6875
4
import levenshtein """ wordTree data structure is a tree whose node values are string words. The edges connecting the nodes is the levenshtein distance between the words, and there are no duplicate words in the tree. Capital letter do not change/affect the words so a word such as "AUTO" is equivalent to "auto." The poi...
d0268cfbb39e2f0270d7e85f6d3279ae57c1c58f
rbirkaur23/second_largest_element
/secondlargestelement.py
82
3.625
4
list1=[10,20,4,45,99] list1.sort() print("Second largest element is: ",list1[-2])
28d6c49d7dbc3c3b2b7c222383987a03deee4ab7
sivareddykostam/Python_practices
/python/numbers.py
528
4.3125
4
#//-------------------------------------------------------------------------------------------- #// Python Numbers Method #//-------------------------------------------------------------------------------------------- #Addition ''' a = 2 b = 3 print(a+b) ''' #Subraction ''' a = 6 b = 4 print(a-b) ''' #Multiplication...
83c030e899978bd5a66f7b7b66c66285f3962d12
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_199/2778.py
482
3.5
4
def solve(): s, k = input().split() k = int(k) s = list(s) cnt = 0 for i in range(len(s)): if s[i] == '-': cnt += 1 if i + k > len(s): return 'IMPOSSIBLE' for j in range(i, i + k): if s[j] == '-': s[j] = ...
b94dd6150706fdfa23626b07fd883f42259d84a3
TonyBoy22/gittest
/Python/scopes/function_scope.py
610
3.765625
4
# Vérifier si on doit passer les fonctions en argument # main, a et b sont dans le même scope global, mais pas appelées dans les mêmes scope def function_a(x1: int, x2: int): # Some stuff return x1+x2 def function_b(x1: int, x2: int): # Called in main, needs function_a # Passes arguments to function ...
430ade80eaebe6e622883f2703507cf959de83c7
ZhemingX/leetcode-python
/src/list-dict/display-table-of-food-orders-in-a-restaurant.py
872
3.59375
4
from typing import List class Solution: def displayTable(self, orders: List[List[str]]) -> List[List[str]]: import copy table_dict, food_dict = dict(), dict() # create food dict for order in orders: if order[2] not in food_dict.keys(): food_dict[order[2]...
7bf5bc7b776e69037bb05bd014b5e674d24874bb
yijunhhhe/code
/CS1026a/randon=m.py
747
3.796875
4
def combineWord(first, second, eachLine): if first in eachLine: index = eachLine.index(first) eachLine.remove(second) eachLine[index] = first + " " + second popFile = open("pop3.txt", "r") cityDic = {} for i in range(1,6): cityDic[i] = list() for eachLine in popFile: eachLine = eac...
5e258c5f5a61a53ca7a2bab6a932347b142b5c1d
HenryKJ/Python
/Python Portfolio.py
1,463
3.609375
4
class TextFrequency(): def __init__(self, file_name): self.file_name = file_name self.text = [] self.getText() def getText(self): file = open(self.file_name, 'r') self.text = file.read() file.close() def letterFreq(self): t = self.text.replace('\n', ' ...
925ef01de3e18c361384289022f0f6f33f00480d
Rafael-Inacio/CursoPython
/Curso de Python Youtube/Aula07-While/Exemplo01.py
198
3.765625
4
x = 0 # coluna y = 0 # linha while x <= 10: y = 0 while y <= 5: print('Coluna {} e linha {}.'.format(x, y)) y += 1 x += 1 print('\nAcabou.') """ teste git pessoal """
3f204dd70932794ca578ecc0a5fd9f87f2a2df90
eduabi/ReadingNotes
/python/python基础/01数据类型.py
251
3.890625
4
#01:数字类型 numType = 2020 print(type(numType)) #输出:<class 'int'> print(isinstance(numType,int))#输出:True #02:字符串类型 strType = '2020' print(type(strType)) #输出:<class 'str'> print(isinstance(strType,str))#输出:True
2c59846008bb514955834aa1f79c869779e0034f
robert920nelson/portfolio
/GE2/Q7-ranelso7.py
338
4.28125
4
# -*- coding: utf-8 -*- """ Created on Sun Sep 20 12:14:45 2020 @author: rob """ from datetime import datetime dt = datetime(2017, 8, 26, 14, 51, 33) print('dt variable is:', dt) # place your code below this line ### dt2 = dt.strftime('%m/%d/%Y') ### place your code above this line ### print('d...
9b7359f7e993dc186c1386538b89af6deaacb111
guojingyu/nn_dna_to_protein
/utils.py
507
3.5
4
""" Utility functions Author Jingyu Guo """ import datetime def today(): """ :return: a string representing today """ return datetime.datetime.now().strftime("%Y-%m-%d") def clock_now(): """ :return: return a formatted string as current time of the day """ return datetime.datetime.no...
3f6cfdbc4eaa1f85fbeac72e60dce722773ce0a9
antho1810/CursoPython
/Tareas/ActividadFor.py
175
3.671875
4
def main(): V1 = int(input("Ingrese el primer valor: ")) V2 = int(input("Ingrese el segundo valor: ")) for i in range(V1, V2): if i % 2 != 0: print(i) main()
7c56af1e7aaee3bed0d48ef3f86372006c3b8e31
liuyuzhou/python3.7sourcecode
/chapter16/radiobutton_exp.py
291
3.625
4
from tkinter import * root = Tk() v = IntVar() v.set(1) for i in range(3): Radiobutton(root, variable = v, indicatoron = 0, text = 'python & tkinter', value = i ).pack() root.mainloop()
c4d7269b3bfabe4be5d6b26e3faa11fcb53d89de
Galmachar/Python3ScriptingLearing
/Reverse_File_Script/reverse-file.py
863
3.78125
4
#!/usr/bin/env python import argparse import sys # build the parser parser = argparse.ArgumentParser(description='Reads a file in reverse') parser.add_argument('filename', help='file to read') parser.add_argument('--limit', '-l', type=int, help='number of lines to read') parser.add_argument('--version', '-v', action='...
d0d18e5ff92d14318b007977804e09535c3ffd95
mehmetalperenkurt/pyexercises
/inheritance-1/inheritance_super.py
847
3.546875
4
class hayvanlarAlemi: def __init__(self): self.evcil=True self.memeli=True def memeliMi(self): if self.memeli: print("Memeli hayvan") else: print("Memeli bir hayvan değil") def evcilMi(self): if self.evcil: print("Evcil h...
a81743ac6e33cf9d26cdec0679f3e0f27b488f31
BhavaSuryaVamsiSrireddy/guvi
/wordpuzzle.py
1,031
3.75
4
import random sc=0 def puzzle(l,sc): le1=len(l)-1 i1=random.randint(0,le1) k=list(l[i1]) le2=len(k)-1 ri=[] for i in range(2): rig=random.randint(0,le2) if rig not in ri: ri.append(rig) for i in range(len(k)): if i in ri: k[i]='*' print(''....
972e14604b4c9caf838176260da632f8bb21ac02
AndrianovaVarvara/algorithms_and_data_structures
/TASK/Хирьянов 18 лекция pygame/мячик прыгает.py
1,367
3.625
4
import pygame width = 900 height = 300 FPS = 60 x = 50 y = 250 speed = 5 BLACK = (0, 0, 0) WHITE = (255, 255, 255) pygame.init() screen = pygame.display.set_mode((width, height), pygame.RESIZABLE) clock = pygame.time.Clock() isJump = False jumpCount = 10 while True: for event in pygame.event.get(): # чтобы можно...
c9ba13486e7269e30fd07b50499cd375b2e47211
132-cabdelmalek/Programming11
/side to side.py
558
3.75
4
import turtle screen = turtle.Screen() screen.setup(500,500) screen.tracer(0) # tell screen to not show automatically don = turtle.Turtle() don.speed(0) don.width(3) don.hideturtle() # hide donatello, we only want to see the drawing def draw_square() : for side in range(4) : ...
6cc0f1204ec5c1497e11d83684f97801348c55ee
jichunwei/MyGitHub-1
/PythonTest/Python_100/P26.py
293
3.890625
4
#coding:utf-8 ''' 题目:利用递归方法求5! ''' def func(N): if N == 1: return 1 else: return N * func(N-1) if __name__ == "__main__": N = int(raw_input("Please enter an num: ")) res = func(N) print "res is : %r" %res
5978f46ec6aa02bdc73aaa7e03e4f670f28ccf93
18101003rakin/Mini-Mario
/gameloop.py
3,170
3.5
4
def game_loop(): while True: global dragon dragon = Dragon() #call class flames = Flames() mario = Mario() add_new_flame_counter = 0 #intial value of counter global SCORE SCORE = 0 global HIGH_SCORE flames_list = [] while True: ...
396b9b3031a8ca84a0251edb9950065362e5d696
richistron/PythonCabal
/clase_02/tools.py
2,853
3.984375
4
'''Herramientas para PythonCabal Rutinas para todo el grupo ''' class Robot: "Un robot con nombre, posición y dirección." def __init__( self, nombre, posicion = (0,0), direccion = 'N', distancia = 1 ): "Constructor" self.nombre = nombre self.x, self.y = posicion self.direccion...
f492752a9fd9edf8b818d96199c78b40f9693906
ChrisDelf/Matrix_Spiral_Copy
/matrix_spiral_improved.py
1,797
3.765625
4
def spiral_2(inputMatrix): copy_array = [] column_num = len(inputMatrix[0]) row_num = len(inputMatrix) top_row = 0 btm_row = row_num - 1 left_column = 0 right_column = column_num - 1 count = 0 y = 1 z = 1 # every time we go across to the end of the row we have to subtract the amount columns by ...
a66d2c3df1167a1fb9afa1443db15ba753728fa8
marisalvarani/FaculdadeADS
/Lógica de programação/8).py
136
3.5625
4
a1 = float(input()) a2 = float(input()) a3 = float(input()) a4 = float(input()) m =(a1+a2+a3+a4)/4 print("A media das alturas eh:",m)
cb7b472256852636ffc435d966ffb47f67f7a1c1
fahripradinatia/labspy05
/labspy05.py
4,179
3.546875
4
nomor = 0 data = {} while (True): pilihan = input("[(L)ihat, (T)ambah, (U)bah, (H)apus, (C)ari, (K)eluar]:") if pilihan == 't': while (True): nama = input("Nama: ") nim = int(input("Nim: ")) tugas = int(input("Nilai Tugas: ")) uts = int(input("N...
2289d416320f3de2afc8672f077b3674d58709e9
vipul-royal/a10
/4.py
390
4.09375
4
def LastNlines(fname, N): #Python program to read last n lines of a file with open(fname) as file: for line in (file.readlines() [-N:]): print(line, end ='') if __name__=='__main__': fname='Test.txt' N=int(input("Enter the No.Of last lines to be read:")) try: ...
26bfac82b7439e46c09bcb8b7639a796a0a0d248
vlovell24/Python-Projects
/Program8.py
1,722
4.28125
4
# This program takes a user input of a sentence, and capitalizes the first letter of each # sentence, while leaving any other capitalized letters in their natural state. # -------------------------------------------------------------------------- # Variable Name Data Type Purpose # ------------------...
b88c9ce4bb86d63f9cfce1bb6671f7a692484622
jero98772/diy_graphic_linear_regresion
/diy_linear_regression.py
355
4.0625
4
import matplotlib.pyplot as plt import numpy as np size = int(input("size of X:\n")) X=np.random.randint(low = 0, high = size, size = size) w =eval(input("W slope of line:\n"))#1 b =eval(input("B intercept of line:\n"))#0 y = [] for x in X: y.append(w*x+b) print(y) print(X) plt.plot(X,y ,linewidth=2.0,color="b") plt...
bf9c1bc4f3a78a845b9053203d62768f01a74c4c
yemao616/summer18
/Google/Word Break.py
834
4
4
# Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. # For example, given # s = "myinterviewtrainer", # dict = ["trainer", "my", "interview"]. # Return 1 ( corresponding to true ) because "myinterviewtrainer" can be segment...
1c2570f17a60800a4ed9c67d1385257f6a72ab0d
yi-guo/coding-interview
/leetcode/python/054-spiralMatrix.py
1,545
4.03125
4
#!/usr/bin/python # Given a matrix of m x n elements (m rows and n columns), return all elements of the matrix in spiral order. # For example, given the following matrix: # [[ 1, 2, 3 ], # [ 4, 5, 6 ], # [ 7, 8, 9 ]] # You should return [1, 2, 3, 6, 9, 8, 7, 4, 5]. # Get the spiral order layer by layer start...
7485334038aefebea885c1f0f72eb98f6cca39e1
slauney/Portfolio
/Python/Labs/Lab06/Program02.py
593
4.09375
4
########################################### # Desc: rewrote for loop (for i in range (1,10)) # # Author: zach ########################################### def main(): # Main function for execution of program code. # Make sure you tab once for every line. s = 0 # Input #for loop that i am rewrit...
889b8602144b3303daa84353a6e012c61caee940
katharinameislitzer/smartninjacourse
/Class3_Python3/example_01201_files_read_write.py
1,109
4.34375
4
text = "This is a new text now\n" filename = "foo.txt" # apart from reading a file you can also # store data in it. This can be done by # adding a parameter in the open() function. # verschiedene modii: # a : append -> will append at the end # w : write -> will overwrite (clears the file), wenns file schon gibt, wird...
8908e317257494651ef89867efe323a8b4ce9b84
spike688023/10-Real-World-Application
/Implement-6-Small-APP/5.witch-hunter.py
4,661
3.546875
4
import random import time class Witch: def __init__(self, name, level): self.name = name self.level = level def __repr__(self): return '{} (lv{})'.format(self.name, self.level) def witchcraft_attack(self): return random.randint(1, 10) * self.level class FireWitch(Witch): ...
5642f6c11be6c920ebdcd3206e34d5d8a7a43986
jessicaice/LPTHW
/ex3.py
1,317
4.625
5
# This prints the what I am going to count print "I will now count my chickens:" # This print that I will count hens and my calculation print "Hens", 25 + 30 / 6 #This prints that I will count roosters and my calculation print "Roosters", 100 - 25 * 3 % 4 #This prints that I am now going to count some eggs print "Now I...
c90539c2df208af2641d69a2005f75c916897d89
stephenroche/COMP2041---Software-Construction
/assignment 1/test01.py
241
3.5625
4
#!/usr/bin/python3 # put your test script here # Test for loops & nested functions arr = [2, '3', "4", r'5'] # Trailing whitespace --------> for i in sorted(range(len(arr))): print(arr[i]) # No following dedented line closing loop
d7979590b21dfdf4ad1cbb014168aae2e2daf69d
karan919/Algorthims
/Knight_Tour_using_BackTracking.py
1,017
3.609375
4
def isSafe(n,x,y,board): if x>=0 and y>=0 and x<n and y<n and board[x][y]==-1: return True return False def printSolution(n, board): for i in range(n): temp=[] for j in range(n): temp.append(board[i][j]) print(temp) def solveKT(n): board = [ [-1]*n for i in ...
5b60336a34261911b2dab5ec74e0580cc5b28c5d
luismichu/Python
/ejPractica/comprension3.py
76
3.765625
4
cuadrado = [n**2 if n%2==0 else n**3 for n in range(int(input('Numero: ')))]
d92dc67b2121a405a1237017f45eb86f28e236fe
YaKalmar0/PyCh
/1(2)/Zavd1(2)_Yakovyna_01_04_2019.py
1,012
3.703125
4
class Book: def __init__(self, a, n, y ,g, com): self.author = a self.name = n self.year = y self.genre = g self.response = com.comment def __repr__(self): return 'Book: %s, %s, %d, %s' % (self.author, self.name, self.year, self.genre) def __eq__(sel...
7e21bfd6c5c38fde15835cf03c65aceb693b06d1
felixriese/susi
/susi/SOMUtils.py
3,492
3.75
4
"""SOMUtils functions.""" from typing import Sequence, Tuple import numpy as np from sklearn.utils.multiclass import check_classification_targets from sklearn.utils.validation import check_array, check_X_y def decreasing_rate( a_1: float, a_2: float, *, iteration_max: int, iteration: int, mode: str ) -> float: ...
0645828aeef88a707368521bfa676dc325a7ab05
hike-training-institute/core-python
/projects/atm_with_excel_as_database/script_mode/atm_practice_task_skeleton.py
4,440
3.890625
4
""" This script is a Skeleton for replicating ATM machine Basic Functionalites Completing this script shall give a Strong Understanding of Python Programming """ from openpyxl import load_workbook user_options = {0 : 'exit', 1 : 'check_balance', 2 : 'withdraw_amount', ...
62471f2613e9fa6f5cc5c978ed07c6a22d149836
riverszxc/riverplum
/pkm/lbld/653.两数之和-iv-输入二叉搜索树.py
1,985
3.640625
4
# # @lc app=leetcode.cn id=653 lang=python3 # # [653] 两数之和 IV - 输入二叉搜索树 # # https://leetcode.cn/problems/two-sum-iv-input-is-a-bst/description/ # # algorithms # Easy (63.35%) # Likes: 424 # Dislikes: 0 # Total Accepted: 98.9K # Total Submissions: 156.2K # Testcase Example: '[5,3,6,2,4,null,7]\n9' # # 给定一个二叉搜索树 r...