blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
8c2194aff0316a985b622da8d38414c9b5d58c7f
kawa-kokosowa/pygame-anisprite
/pygame_anisprite/anisprite.py
13,129
3.5
4
"""Painless animated sprites which are pygame.sprite.Sprite objects. Animated sprites are loaded from GIF, but there will be other ways very soon! When using an AnimatedSprite you must remember to update it every main loop iteration with timedelta: >>> AnimatedSprite.from_gif('example.gif') # doctest: +SKIP >>> ...
51d89acafdd9cac787a525f620612f6c4ed66514
olgakirova/lab_python
/lesson5/less 5.1.py
384
3.671875
4
import random s = ["самовар","весна", "лето"] a = random.randint(0, len(s)-1) b = random.randint(0, len(s[a]) - 1) print (s[a][0:b] + "?" + s[a][b+1: ]) x = input ("Введите букву: ") def check (x): if x == s[a][b]: return "Победа" else: return "Увы! Попробуйте в другой раз!" print (che...
de31c828ae2e94f1f1379220f66d2c56cc9624db
ChanakaUOMIT/python
/OOP/multipleFunctions.py
495
3.671875
4
class DoMath: def addition(self, x, y): return x+y def subtraction(self, x, y): return x - y def multiplication(self, x, y): return x*y # first object first_object = DoMath() print(first_object.addition(5, 6)) print(first_object.subtraction(7, 8)) print(first_object.multiplicati...
93ddf92432f0f07ab8fc27d3d5af685d26335560
conniechen19870216/WorkNotes
/Ubuntu4Me/codes/python/cir1.py
172
3.515625
4
#!/usr/bin/python from time import sleep for i in range(20): print i sleep(1) else: print 'ending' """ if i == 2: pass if i == 3: exit() if i == 6: break """
1164e1096a23db08a358914a552b34a7f0f8ed76
ncmatson/oncall
/oc.py
4,195
3.671875
4
import datetime, re, random from collections import OrderedDict # takes a properly formated string and returns a date object # (m)m/(d)d/yyyy def string_to_date(input_date_string): input_date_list = re.split('-|/| ', input_date_string) return datetime.date(int(input_date_list[0]), int(input_date_list[1]), in...
7e73f881b2a082f8fa480c41162798c1caba3297
oscarjundt/proj_en_python
/graphe.py
364
3.828125
4
from turtle import* while True: color("blue") a=input() if(a=="avancer"): forward(100) if(a=="tourner a gauche"): left(90) if(a=="tourner a droite"): left(-90) if(a=="reculer"): ...
733255ddfecc6724989918aa94f5ca1ffe58fabf
Juandipal/Algoritmos-y-Programacion-C3S1
/Taller-estructuras-selectivas/Ejercicio_8.py
294
3.71875
4
""" Entradas num 1--->int--->P num 2--->int--->Q Salidas: condicion 1--->str--->c1 condicion 2--->str-->c2 """ P=int(input("P: ")) Q=int(input("Q: ")) c=(P**3+Q**4-2*P**2) if(c>680): print("P y Q satisfacen la expresión "+str(c)) else: print("P y Q no Satisfacen la expresión "+str(c))
7b582f41c26fad9b3975e55acda094a9dc5d52bc
Nkhinatolla/PoP
/Lection-4/dictionary.py
839
4
4
thisdict = { "brand": "Ford", "model": "Mustang", "year": "1992 2000", 1: 4 } print(thisdict) x = thisdict[1] print(x) for x in thisdict: print(x, end = " ") #printing keys: brand model year print() for x in thisdict: print(thisdict[x], end = " ") #printing value: Dict = {"Albert":"March 14, 1...
fc9d3da41f6d473bbf807c6c70e5d47a9277367f
Manoj431/Python
/Arrays/Solution_4.1.py
254
3.875
4
import array number_array = array.array( 'i' , [10,20,3,54] ) # Array with integer values.. sum=0 for i in range(len(number_array)): sum = sum + number_array[i] print(f"After adding the integer values of array, the value is : {sum} ")
1e0ebd442999490a60487d53e901b201a58ec43c
leon890820/python-numbertower
/python3/examples/ch3/bitmap6.py
456
3.71875
4
# 數字 6 的點矩陣縱橫方向為 5x4 r , c = 5 , 4 while True : n = int( input("> ") ) # 大縱向 for s in range(r) : # 縱向重複次數 for i in range(n) : # 大橫向 for t in range(c) : # 橫向重複次數 for j in range(n) : # 數字 6 的點陣滿足條件: if ( ( s%2==0 ) or t==0 or ( s==3 and t==3 ) ) : print( "6" , end="" ) e...
bf11fa22c4258b81a8a97c714a97305910518a37
IamConstantine/LeetCodeFiddle
/python/NumberOfIslands.py
1,598
3.75
4
from typing import List # https://leetcode.com/problems/number-of-islands # Medium # T = O(MN) # S = O(MN) # can be also solved using Union Find def numIslands(grid: List[List[str]]) -> int: total = 0 rows = len(grid) columns = len(grid[0]) total_area = sum(1 for x in range(rows) for y in range(col...
8861465452d42be69d59707020ebe10f4471d7ce
sevdaghalarova/fonksiyon
/lambda_ifadeleri.py
335
3.875
4
# lambda ifadeleri bazi fonksyonlari tek satirde yazmamizi sagliyor def topla(a,b,c): return a+b+c # lambda ile yazma sekli toplama=lambda a,b,c:a+b+c print(toplama(1,2,3)) def ciftmi(a): if a%2==0: return True else: return False print(ciftmi(5)) #lambda ile yazarsak cift=lambda x:x%2==0 ...
1d2842276091218b64c46b9f470a33c53ef206e4
i-fernandez/Project-Euler
/Problem_053/problem_53.py
353
3.515625
4
""" How many, not necessarily distinct, values of (n|r) for 1≤ n ≤100, are greater than one-million? """ from math import factorial def n_on_r(n, r): return int(factorial(n) / (factorial(r)*factorial(n-r))) count = 0 for n in range(10,101): for r in range(1,n): if n_on_r(n, r) > 1000000: ...
5a5fedde7a11317343f6ddf496d69c4a0bdf5b36
kaz1m1r/sudokuSolver
/Solver.py
4,099
3.875
4
from Grid import Sudokugrid from termcolor import colored class Sudokusolver: def __init__(self, sudoku: Sudokugrid): """ AI class that can be used to solve a sudoku :param sudoku: Sudokugrid """ self.sudoku: Sudokugrid = sudoku def solveSudoku(self) -> None: ...
dee8c62676cfdd7e9cfce45c0250dce47522fd7c
FidelNava2002/Actividades-de-python
/Ejercicios-01/Datos_compuestos-03.py
366
4.0625
4
"""3.- Escribir un programa que pregunte al usuario los números ganadores de la lotería primitiva, los almacene en una lista y los muestre por pantalla ordenados de menor a mayor.""" loteria= [] suma=0 Valor=0 for i in range(5): suma+=1 print("Ingresa el numero ",suma,": ") valor= int(input()) loteria.a...
eef1315c0a3d42b48014d017b57d2bde6613b541
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/rna-transcription/44fbf2ab8de3452d9aac850ff8943028.py
237
3.5
4
#!/usr/bin/env python def to_rna(sequence): key = {"G":"C", "C":"G", "T":"A", "A":"U", } translation = "" for i in range(len(sequence)): translation += key[sequence[i]] return translation
3061f0f8a34e5fb4257b9e47b8e835bfd15f6d23
igelritter/learning-python
/ex17-lphw.py
707
3.5
4
from sys import argv from os.path import exists script,from_file,to_file=argv print "Copying from %r to %r" %(from_file,to_file) #we could do these two on one line too, how? #indata=input.read(open(from_file)) input=open(from_file) indata=input.read() print "The input file is %d bytes long" %len(indata) print "Does the...
decd485d2c02ed4db7a109d90bc3d3e541751648
alexeykomov/hacker-rank
/diagonal-difference/task.py
927
3.578125
4
#!/bin/python import math import os import random import re import sys # Complete the diagonalDifference function below. def diagonal_difference(arr): left_to_right_diag_sum = 0 right_to_left_diag_sum = 0 for row_index in range(0, len(arr)): for col_index in range(0, len(arr[0])): if ...
afeceb328560ddc7f47fad3365a5ee2723324963
hkkhuang/interpy-zh
/code/3.x/03_generators.py
530
3.671875
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # Script Name : 03_generators.py # Author : huangkeke # Time : 2018/6/2 11:39 # Contact : hkkhuang@163.com # Description : 迭代器和生成器 def fibon(n): a = b = 1 for i in range(n): yield a a, b = b, a + b def fibonacci...
b5289897be531d0f799bc794a881366102c9fda6
shubhigupta991/Data-Structures-and-Algorithms
/Python/Practice/Find Twins.py
690
3.5
4
''' Suppose you have two pets and you love both of them very much. You go to a pet store to buy different articles for your pets. But you ask salesman that you will buy only those articles which are actually in pair. In this store, articles are referred as integers. So you have to tell total no. of articles you will bu...
14216ed03021208c8da8713d87a4bce3f452bc7f
thespatializer/pythonScripts
/experiments/huffman_tree_codec.py
5,520
3.796875
4
# -*- coding: utf-8 -*- """ © 2016 TheSpatializer https://github.com/thespatializer @author: TheSpatializer """ """ 1\ Détermination des occurences des caractères """ def countChar(chn): count = {} for car in chn: if car in count: count[car] += 1 else: count[car] = 1 ...
fe0ffe1d1f6f3a34dfde45c14ef83b5013979f8b
catboost/catboost
/contrib/python/scipy/py3/scipy/interpolate/_pade.py
1,798
3.625
4
from numpy import zeros, asarray, eye, poly1d, hstack, r_ from scipy import linalg __all__ = ["pade"] def pade(an, m, n=None): """ Return Pade approximation to a polynomial as the ratio of two polynomials. Parameters ---------- an : (N,) array_like Taylor series coefficients. m : int ...
1c9c639697457932e0db555a47536697c42bb2a4
Light1928/python-test
/python/pythontest3.py
1,762
4
4
class Shopping_test: # 定数を定義 apple_price = int(200) # コンストラクタ(初期化メソッド) def __init__(self, username): self.username = username def shopping(self, money, count): total_price = Shopping_test.apple_price * count # print(self.username + 'が購入' + '購入するりんごの個数は' + str(count) + '個です\...
ea459176af4baa092bca448ed52e2f80b4e8498e
sanshitsharma/pySamples
/bit_magic/multiply_with_three_point_five.py
210
4.03125
4
#!/usr/bin/env python def multiply_3point5(num): #return (num << 2) - (num >> 1) return (num<<1) + num + (num>>1) if __name__ == "__main__": num = 5 print num, "x 3.5 =", multiply_3point5(num)
3149a03e421a32bbf4be80b1d1568f6e7860a57b
shikha1997/Interview-Preparation-codes
/Day6/flattenll.py
495
3.53125
4
class Node: def __init__(self,data): self.data=data self.right=None self.down=None def merge(a,b): if(a is None): return b if(b is None): return a if(a.data<b.data): temp=a temp.down=merge(a.down,b) else: temp=b temp.down=merg...
63bae52a3b636767458cd18b0f8e05e4b64b2b8e
G-development/Python
/Python exercises/programmareInPython/sommatrice-moltiplicatore inarrestabili.py
376
3.71875
4
def sommatriceInarrestabile(lista): risultato = 0 for numero in lista: risultato += numero print ("Il numero della somma è: " + str(risultato)) def moltiplicatriceInarrestabile(lista): risultato = 1 for numero in lista: if numero != 0: risultato *= numero print ("Il...
b398d233a883dc9227f0f4d6b4692c347d3e49c3
estecche/python_course
/dictionaries.py
979
4.71875
5
""" This is an example about dictionaries. """ book = { "title" : "From the Earth to the Moon", "author" : { "first_name": "Jules", "last_name": "Verne" }, "pages" : 240 } author_name = book["author"] print(author_name["first_name"] + " " + author_name["last_name"]) # we can also add so...
8a15f46bf0277403119191d3e0c5ef9a3597788b
zhengbr11/COMS-4705
/(hw2)cky_parser/cky.py
7,842
3.59375
4
""" COMS W4705 - Natural Language Processing - Fall 2020 Homework 2 - Parsing with Context Free Grammars Daniel Bauer """ import math import sys from collections import defaultdict import itertools from grammar import Pcfg ### Use the following two functions to check the format of your data structures in part 3 ###...
1e91f9bc3dc77e4c4ae2266a156bf33edc217283
pgamboa/curso-paython-pgamboa
/Tarea_1/ejercicio_5.py
723
4.3125
4
# La siguiente matriz (o lista con listas anidadas) debe cumplir una condición, # y es que en cada fila el cuarto elemento siempre debe ser el resultado de sumar los tres primeros. # ¿Eres capaz de modificar las sumas incorrectas utilizando la técnica del slicing? ''' Ayuda: La función llamada sum(lista) devuelve una ...
96d65d96446c8133c889dbc11790bf0ff015b09b
meghanabhat29/Simply-py
/writelisttoafile.py
191
3.6875
4
list1=["Songs","Music","Notes","Tunes"] with open("example.txt","w") as myfile: for c in list1: myfile.write("%s " %c) file_content=open("example.txt") print(file_content.read())
0a9196bdc64bdcf3f1b5a9c6876149e507959a01
lilaboc/leetcode
/445.py
2,091
3.859375
4
# https://leetcode.com/problems/remove-linked-list-elements/ from typing import Optional # Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def __repr__(self): r = [] a = self while True: ...
c807296e8f6410bd742022ea069f3267aff7ff2a
radulescupetru/Machine_Learning
/linear_regression.py
1,226
3.546875
4
import pandas as pd from sklearn import linear_model dataset = pd.read_csv('salary.csv') print("Rows:",dataset.shape[0],"Columns:",dataset.shape[1]) #separating out independent variable X=dataset.iloc[:,:-1].values Y=dataset.iloc[:,1].values #print(X,"\n\n",Y) #splitting dataset into training and test set from sklea...
26df6bdd67138ee262d5325ba8d23928d7dad9af
Ankur-singh/sem7
/AI/minMax/gameBoard.py
515
3.84375
4
### human = "X" ### ai = "O" class board(object): def __init__(self): self.board = [["O","_","_"], ["_","X","_"], ["_","_","_"]] def vacant(self): vacantCell = [] for i in xrange(3): for j in xrange(3): if self.boa...
4c0ea623902a67aeee65da0159b55a638f22542f
zhangsong1417/xx
/Python_script/51zxw/unittest/test_Math2.py
1,019
3.640625
4
from calculator import Math import unittest class Test_add(unittest.TestCase): def setUp(self): print("Test_add start") def test_add(self): j = Math(5, 10) self.assertEqual(j.add(), 15) def test_add1(self): j = Math(5, 10) self.assertNotEqual(j.add(), 15) def...
38e1ca65648e10476157807470ca78961fc3c31a
MrAlekzAedrix/MetodosNumericos
/Sum.py
176
4.0625
4
def Sum() : n1=int(input('Please enter a number: ')) n2=int(input('Please enter another number: ')) print("The addition of both number is:" , n1+n2) Sum()
94a691dcf293fc4e3b0233719a2a9ff005464460
hechty/datastructure
/2.3.4.py
234
3.5
4
#! /usr/bin/env python3 # code showing dynamic binding class B: def f(self): self.g() def g(self): print('B.g called') class C(B): def g(self): print('C.g called.') x = B() y = C() x.f() y.f()
368c83b1b1cad3f8efc3edb0261300adedd01eea
Rudedaisy/CMSC-201
/Labs/lab11/lab11.py
791
3.6875
4
# File: lab11.py # Written By: Edward Hanson # Date: 11/17/15 # Section: 18 # E-mail: ehanson1@umbc.edu # Description: Translates english words into the "Ong" language. def main(): word = str(input("Please enter a word to translate into Ong: ")) myWord = ong(word) myWord.translateO...
d8a439410c34c955c91e3e6247521553296ba3a0
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/226/users/4139/codes/1674_1107.py
1,949
3.6875
4
a = int(input("dia de hoje:")) b = int(input("numero de dias apos hoje:")) #c = int(input("numero:")) x = "Hoje eh " y = " e o dia futuro eh " c = (a+b)%7 if(a==0): a = "domingo" if(c==0): c = "domingo" elif(c==1): c = "segunda" elif(c==2): c = "terca" elif(c==3): c = "quarta" elif(c==4): c = "quinta...
2ac244c2ae5c8ea63e4d28d2b05db3c9a98ccadb
Hyeongmin-Kim/algorithm-test
/greedy/s5_1439.py
614
3.546875
4
sentence = input() num_zero = 0 num_one = 0 check = False while check != True: idx = 0 if sentence[0] == '0': while sentence[idx] != '1': idx += 1 if idx == len(sentence): idx -= 1 check = True break num_zero += 1 ...
628416dd33501eb78697ba53ffff8f32b73ec904
zhangyunf/python-
/类/类方法.py
370
3.84375
4
#-*- coding:utf-8 -*- #!Author:YunFei Zhang class Dog(object): n = 333 def __init__(self, name): self.name = name @classmethod def eat(cls, food): print("%s is eating %s" % (cls.n, food))#无法访问实例变量self.name,但是如果变成类变量n的话就可以了。 def talk(self): print() d = Dog("zhangsan") d.eat("...
b2e374189a12ae0f9fad35704b1e5e19287b1473
pabloTSDAW/Programacion-Python
/Trimestre1/Ejercicio13b.py
707
4.25
4
""" Contar los multiplos de dos y cuantos de esos multiplos de dos son multiplos de tres """ cont = 0 suma = 0 multi2 = 0 multi23 = 0 num = int(input("Introduce un numero: ")) while num != 0: cont = cont + 1 suma = suma + num num_calc = num calc2 = num_calc % 2 calc3 = num_calc % 3 if c...
355b40a94c15ce75504149ed45c7696079e60b1e
aravind4799/DS_and_Algorithms
/math/prime_factorization.py
817
4
4
#prime factorization using seive() #find smallest prime factor(spf) for everynumber using seive() #and recursively divide the number with this SPF and add to prime list import math def smallest_prime_factor(limit): spf=[0]*(limit+1) spf[1]=1 #smallest prime factor for every even number is 2 for j in ra...
97b52c37018ce29a66cdc699116f3f1437c124d2
NeedNamePLS/IDF_And_Stuff
/Python_Tryathalon/PythonExercise6/Car_Class.py
772
3.953125
4
#Pet Class class Car(object): def __init__(self, year_model, make): self.__year_model = year_model self.__make = make self.__speed = 0 def get_speed(self): return self.__speed def accelerate(self): self.__speed += 5 return self.__speed d...
6824c6219adac3458c8a86131ffe586a9dc2fb85
ender8848/the_fluent_python
/chapter_1/demo_1_1.py
1,361
3.953125
4
from collections import namedtuple ''' 示例 1-1 一摞有序的纸牌 ''' Card = namedtuple('Card', ['rank', 'suit']) class FrenchDeck: ranks = [str(n) for n in range(2, 11)] + list('JQKA') suits = 'spades diamonds clubs hearts'.split() def __init__(self): self._cards = [Card(rank, suit) for suit in self.suits for rank in sel...
b698b5ae15fca1f632873094c121f39f6364edcd
twairball/draw-labels
/draw_labels/points.py
2,266
3.578125
4
import cv2 import math import numpy as np def sort_left(points): """sort list of points by x-axis Ref: - https://stackoverflow.com/questions/2706605/sorting-a-2d-numpy-array-by-multiple-axes """ a = np.asarray(points) ind = np.lexsort((a[:,1], a[:,0])) return a[ind] def get_midpoint(e...
fcd06d66dcaf3364c7764fd9efb00dff70bdf3a6
mohsen081/Homework
/3.py
183
3.65625
4
# -*- coding: utf-8 -*- """ Created on Fri Aug 9 21:41:01 2019 @author: OFOK """ a=[1,1,2,3,5,8,13,21,34,55,89] for aa in a : if aa > 5: break print(aa)
22c47e8f2eddf17132886bd4b3598bbf4d914809
HyunsuLee/TIL
/Jumptopython/mod1.py
185
3.65625
4
def sum(a, b): return a + b def safe_sum(a,b): if type(a) != type(b): print("더 할 수 있는 것이 아닙니다.") return else: return sum(a,b)
5d398d884972f984b4a17819397a3c5d491da292
PototskaIryna/dbis
/km52/Pototska_Iryna/csv_import.py
1,359
3.5
4
import csv import cx_Oracle connection = cx_Oracle.connect("SYSTEM", "12345", "localhost:1521/xe") filename = "student_1.csv" with open(filename, newline='') as file: reader = csv.reader(file) name = next(reader)[1] group = next(reader)[1] country = next(reader)[1] email = n...
b428366a66e56e6293144e07de339a2067f96646
DayGitH/Python-Challenges
/DailyProgrammer/DP20150923B.py
4,975
3.78125
4
""" [2015-09-23] Challenge #233 [Intermediate] Game of Text Life https://www.reddit.com/r/dailyprogrammer/comments/3m2vvk/20150923_challenge_233_intermediate_game_of_text/ #Description John Conway's [Game of Life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life) is a classic game among computer programmers and ...
85275f3bc58262af7db378da316fe67f06b37f52
rameshm78/Python
/unique-list.py
135
3.546875
4
names = ["Michele", "Robin", "Sara", "Michele"] names = set(names) #names = list(names) print(names) input ("Press Enter key to exit")
5941f747e6d6a7178cb0dfdca847de6f81981956
gerardogtn/matescomputacionales
/matescomputacionales/project04/derivation.py
1,320
3.859375
4
from collections import OrderedDict class Derivation: """A class that stores derivations of a string in a cfg""" def __init__(self, entries=[]): self.__data = [] self.__current = 0 self.addAll(entries) def add(self, string, variablePosition): self.__data.append((string, va...
9bef89fcf6ebf663f6bf141e49856d645baa05d3
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_84/360.py
1,330
3.71875
4
#!/usr/bin/env python import sys def attempt(moz): for y in range(len(moz)): for x in range(len(moz[0])): if moz[y][x] == '#': result = place_red(x, y, moz) if result is False: return False else: moz =...
986ce856fcd20396b1dab5c4990f1030365aad4a
MiConnell/Katas
/codewars/Codewars_Multiples.py
488
4.03125
4
# https://www.codewars.com/kata/514b92a657cdc65150000006/train/python """ If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Finish the solution so that it returns the sum of all the multiples of 3 or 5 below the number passed in. Note: If...
c7bc0b0cde4f07f9ad88462bcf1ab2a868f4b818
Dhivyabarathi3/codekata-set2
/prime.py
267
4.03125
4
n = int(input("enter a no")) if n == 1: print("prime no") if n > 1: for i in range(2,n): if (n % i) == 0: print("is not a prime number") break else: print("is a prime number") else: print("is not a prime number")
99828336c3589ac5960f193999ef11649167f048
Haozhuo/practice
/python/array/q169.py
981
4.0625
4
""" Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority element always exist in the array. Credits: Special thanks to @ts for adding this problem and creating all test cases. "...
aa757926c7509dfd8bc81a7f1503777e09fa944b
judealfred/AWS-Nginx-Container
/src/count.py
429
3.546875
4
from bs4 import BeautifulSoup import urllib2 import re from collections import Counter page = urllib2.urlopen("http://localhost") soup = BeautifulSoup(page, features="html.parser") text = soup.get_text() lst = re.findall(r'\w+',text) count = Counter(str(x) for x in lst) result = count.most_common(1)[0] word = result[0...
6e2e8d501b7200cc3a8437ee8a3cabaafd7fae21
xzjh/OJ_LeetCode
/merge-k-sorted-lists.py
1,056
3.9375
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # @param a list of ListNode # @return a ListNode def mergeKLists(self, lists): def sort_list(list_a, list_b): if not list_a: return list_b elif not list_b: return list_a ...
1fb213b262e2f5f10a55713e9f86d396636151d4
scomonty/python
/upper_lower.py
85
3.578125
4
def sillycase(x): return x[:5].lower() + x[:-5].upper() print sillycase(treehouse)
e692253472aa2ea794aab99b92e5d947360a8351
deepakkadarivel/python-data-structures-and-algorithms
/001_APlusB/a_plus_b.py
325
3.796875
4
# Uses python3 # coding=utf-8 import sys tokens = input() tokens = tokens.split() try: a = int(tokens[0]) b = int(tokens[1]) except ValueError: print('Enter valid numbers') sys.exit(0) if 0 <= a <= 9 and 0 <= b <= 9: print(a + b) else: print('Numbers not satisfying constraints: 0 ≤ a,b ≤ 9')...
973267a8677c698274a02ebc8803dabfb1c3a1cc
johnnyterp11/cst236_lab1
/cst236_lab7/cst236_lab4/source/job_story_end.py
4,809
3.59375
4
import time from decimal import Decimal, getcontext from datetime import datetime import math getcontext().prec = 5 def check_n_pi(number): """ func that return the pi digit :param number: :return: """ digit = Decimal(0) k = 0 while k < number: digit += (Decimal(-1) ** k / (10...
77364e7d34d1a21236cac0d6d0b1aa2f8acfa005
LWS-CSDN/python
/2021/工作需要/正在进行-python面向对象编程/48.面向对象-补充-只读属性-方案1/main.py
147
3.53125
4
""" """ class Person: def __init__(self): self.__age=18 def getAge(self): return self.__age p1=Person() print(p1.getAge())
c2954c7c63ddae1b9e49c5581a4e9a47db39e996
bilal-700/Multi-threaded-Web-Crawler
/fileManipulation.py
1,644
3.6875
4
# function for file manipulations import os #OS module in Python provides functions for interacting with the operating system. # writing contents into a new file def write_file(path, data): f = open(path, 'w') f.write(data) f.close() # appending contents at the end of the file def append_to_file...
f89750c3c561c3f46c2ed173c443a7688347fa5b
Sridha2412/GUTS2017
/sridha_test.py
5,199
3.515625
4
import os import sys import random import time import multiprocessing import pygame as pg SCREEN_SIZE = (500, 400) class App(object): """ This is the main class for our application. It manages our event and game loops. """ def __init__(self): """ Get a reference to the screen (crea...
aadc3462883817f0aff47944e6ef7f4464e38668
sanjay1711/100-days-of-code
/1.7. Input print:Two timestamps.py
296
4
4
# Read an integer: # a = int(input()) # Print a value: # print(a) hour1 = int(input()) minute1 = int(input()) seconds1 = int(input()) hour2 = int(input()) minute2 = int(input()) seconds2 = int(input()) result = (hour1*3600+minute1*60+seconds1)-(hour2*3600+minute2*60+seconds2) print(result);
6bb698db981a3e6a44a1e311d410c10233afc0e8
kcmao/leetcode_exercise
/CodingInterviewChinese2-master_python/CodingInterviewChinese2-master/43_1到n整数中1出现的次数.py
1,310
3.890625
4
def given_digits_get_1_num(n): """ 例如,n为3,返回1~999中有多少个1 @param n: n位数 """ assert isinstance(n, int) if n <= 0: return 0 if n == 1: return 1 f_n_minus_1 = 1 for i in range(2, n + 1): f_n = 10 * f_n_minus_1 + 10 ** (i - 1) f_n_minus_1 = f_n return...
08eb33d4e78defc9152d630c97d5467e28d8c2cd
ysn-77/code-snippets
/coding_problems/spiral.py
346
3.546875
4
import numpy as np from math import sqrt def spiral(N): assert N%2 == 1 A = np.zeros(shape=(N,N), dtype=int) x = (N//2)*(1j+1) a = 1 d = -1j for n in range(1, N**2+1): A[int(x.imag), int(x.real)] = n if n == a: a += round(sqrt(a)) d *= 1j x += d return A [print(spiral(2...
8e0d3a43611ef2c9fc7a86d5a5eeca1d4dd6c21c
daniel-reich/turbo-robot
/mwicBKcq3gTGhsGsW_14.py
1,036
4.09375
4
""" What does the word **LFAND** represent? It represents the word **Finland** , because F is _in_ LAND! Create a function which replicates this to create brand new original word riddles! For the purposes of this challenge, take the string of letters _before the word "in"_ , and insert it into the **2nd letter posi...
746d28bc82bfa49d6d068c6771a1d34a53cfd84b
iampython-team/Python_Aug2020
/String_operations2.py
1,138
4
4
sport='baseball' # string --> basetall #sport[4]='t' #TypeError: 'str' object does not support item assignment print(sport) # immutable object sport='basetall' print(sport) #immutable dataypes - int, float, complex, string # String interpolation - String formmating # 4 ways - %, format, sys.format() , f-string...
0dd9ee24c0c0fd66f567f37066d1e022e9577b14
gbaweja/consultadd_assignments
/assignment1/A1-1.py
1,111
4.40625
4
# Govinda Baweja # Assignment 1 # Date: 04-26-2019 # Raw Input x = raw_input("Please Enter a Number and not a string\n") print ("The value of x is: "),x print ("The data type is: "),type(x) #Raw Input with type conversion to integer y = int(raw_input("\nPlease Enter a Number\n")) print ("The value of y i...
6497afb8c69dfc3a78fd80a1e8e6904acb901730
p1x31/ctci-python
/leetcode/merge_k_sorted_lists_23.py
1,194
3.875
4
# Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def mergeKLists(self, lists: List[Optional[ListNode]]) -> Optional[ListNode]: if not lists or len(lists) == 0: return None while...
cd2c0fcbc0f2bb9e09a0c9252187f67583173f68
greenfox-zerda-lasers/t2botond
/week-03/day-2/sort.py
291
4.15625
4
def bubble_sort(list): ready=False while ready == False: ready=True for i in range(len(list)-1): if list[i] < list[i+1]: list[i], list[i+1] = list[i+1], list[i] ready=False return list print(bubble_sort([3,9,4,5,2,1]))
b27d4eaff62be0b9758eed1b6c8785b70d33cd39
a5eeM/PCC
/Ch 10/ex_polling_poll.py
246
3.609375
4
filename = "polling.txt" print("\nEnter 'quit' to Quit") while True: answer = input("Why do you like programming? ") if answer == "quit": break else: with open(filename, "a") as f: f.write(answer + "\n")
7bcbe2cc0f8ac9c2037ea371e88c1766875a7f41
margaretphillips/leetcode_stubs
/valid_mountain.py
750
4.09375
4
#given an array of integers return true if certain conditions are met #1) length of array is at least 3 #2) the array should have an increasing sequence followed by a decreasing sequence #3) ie....[1,2,3,3,2,1] def validmountain(arr): n = True n = len(arr) >= 3 if n: mid = arr[max(arr)] a1 ...
74081762d891d2bfd3e83612a8902abc3de52e32
gitAnonymous1488/PySysScripts
/HW1.py
899
3.703125
4
# What about negatives # what about empty lists def cum_sum(l: list): return [sum(l[0:i + 1]) for i in range(len(l))] # Testing for the 1st Function print(cum_sum([])) print(cum_sum([1])) print(cum_sum([-1,1])) print(cum_sum([1,2,3,4])) def l_str_sort(l: list): return sorted(l, key=lambda x: len(x)) # Testing...
ef9878fe3eb90ab3e3c8781e706b6de504a97fbe
turanmehdiyeva/Hangman
/Hangman.py
786
3.65625
4
def Hangman(): x = np.random.choice(wordslist,1) print(x[0]) g = '-'*len(x[0]) s = '' lst = [] lst[:0] = x[0] arr1 = np.array(lst) for i in range(10): print(f'Welcome, you have to guess a word of {len(x[0])} {g.upper()} letters\nYou have {10-i} lives') a = input('Enter a ...
72cf5a6f92808319184bd89141faab344528f5e8
Otumian-empire/Core-py-course-files
/Untitled Folder/greetings.py
811
3.609375
4
def greetings(name): print("Hello", name) # greetings("Adom") def add_two(param): param += 2 print(param) # add_two(23) def loop_to(stop): for i in range(stop): #[0,1,2,3,4] print("I am a loop", i) # loop_to(5) def paint(item, color): print("The " + item + " is " + color) # paint("Ca...
330be13f6ce41dfa090a3de3b2511c8ee0e6abe6
PrateekJain999/Python-Codes
/4 PRATICAL2.py
186
3.65625
4
def Cloning(L1): L2 = [] L2.extend(L1) return L2 # Driver Code L1 = [4, 8, 2, 10, 15, 18] L2 = Cloning(L1) print("Original List:", L1) print("After Cloning:", L2)
2e83eddd2f36578d68fe63cdcbdb20687f69ea04
shashikanthgk/D
/DFS/practice.py
205
3.96875
4
def factorial(x): if(x==1): return 1 return x*factorial(x-1) def factorial2(x): result = 1 for i in range(1,x+1): result = result*i return result print(factorial(5))
fd0dcc2e3465edaa6ef4c78cd0490b48c1c3f7f2
Aneesawan34/Assignments
/exersice 6-3.py
260
3.828125
4
programming_words={'insert': ' for insert any word in list', 'ln': ' for new line','variable' : ' for to assign in any value'} # print("insert " + programming_words['insert']) for list in programming_words: print(list +":" + "\n" + programming_words[list])
3ed89b3392c83ed61bf7fde3bef1b037db3a37b7
Kartavya-verma/Python-Projects
/GFG/nth_natural_number.py
208
3.6875
4
def natural(n): res = 0 temp = 1 while n > 0: res = res + temp*(n%2) n = n//2 temp = temp * 10 print(res,n,temp) return res n = int(input()) print(natural(n))
2a64adef06da790e5c15c146867d504999bce1bf
soumya-678/Bike-Rental-Count-Prediction-Model
/model_2.py
8,499
3.625
4
# Supressing the warning messages import warnings warnings.filterwarnings('ignore') # Reading the dataset import pandas as pd import numpy as np BikeRentalData=pd.read_csv('hour.csv', encoding='latin') print('Shape before deleting duplicate values:', BikeRentalData.shape) # Removing duplicate rows if a...
7109fb7aef41012844daf8de8e5aaab1e9fe2627
maybeee18/HackerRank
/30 Days of Code/Loops.py
320
3.5
4
""" Created on Mon Mar 19 12:06:58 2018 @author: Nodar.Okroshiashvili """ n = int(input().strip()) x = [print("{} x {} = {}".format(n, i, n*i)) for i in range(1, 11)] #%% # Second Solution n = int(input().strip()) for i in range(1,11): print("{} x {} = {}".format(n, i, (n*i)))
bd788d03502bada324ae6d1e01a4c832a2ac4d42
AnirjitHomRoy/Roy1998
/nlp.py
2,061
3.5
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd #Importing dataset dataset= pd.read_csv('Restaurant_Reviews.tsv', delimiter = '\t', quoting = 3) #tab separated values # quoting specifies which symbol to ignore # dataset[column][index of the row] #Cleaning the texts import re impo...
1880f799eb27830a3bc492be70a5c12c277a3e34
operation-lakshya/BackToPython
/MyOldCode-2008/JavaBat(now codingbat)/Strings1/lastChars.py
313
3.71875
4
a=raw_input("\nEnter a string\t") b=raw_input("\nEnter a string\t") if (len(a)==0 and len(b)==0): print "\nOut put is: @@" elif (len(a)==0): print "\nOutput is: @"+b[len(b)-1] elif (len(b)==0): print "\nOutput is: "+a[0]+"@" else: print "\nOutput is: "+a[0]+b[len(b)-1] raw_input("\nPress enter to finish")
fa196bad482d4b2c5b754045f3bab554b250e1b2
hellflame/leetcode
/290.word_pattern.py
421
3.53125
4
# coding=utf8 # https://leetcode.com/problems/word-pattern/description/ # Easy class Solution(object): def wordPattern(self, pattern, str): """ :type pattern: str :type str: str :rtype: bool """ if not len(str.split(" ")) == len(pattern): return False ...
c6c811c24068fd92d82c190e42aa1d47fb2c3851
anlzou/python-test
/python-course/P90_10_19/P90_6.py
505
3.796875
4
import math #<0 def fun_1(): print("函数无解") #=0 def fun_2(a,b): x1 = -b/2*a print("有一个解:",x1) #>0 def fun_3(a,b,c): x1 = (-b+math.sqrt(b**2-4*a*c))/2*a x2 = (-b-math.sqrt(b**2-4*a*c))/2*a print("有两个解:%d,%d"%(x1,x2)) def fun(a,b,c): p = b**2-4*a*c if p < 0: fun_1() elif p ...
d62b463aa6a343af04deaa82256d72010e4e2d68
ancabilloni/algorithms_practice
/karger_minimum_cut/minCut.py
3,702
3.65625
4
""" Given the file contains the adjacency list representation of an undirected graph. There are 200 vertices labeled 1 to 200. For each row, the first column is the vertex label, and rest of the entries are the adjacent vertices. Task: Code and run the randomized contraction algorithm to compute the min cut for the gr...
561a77f5f5e484fa1fb7c13dd83d42194ef5948e
Mohit-Gaur/PythonCodes
/shipping.py
1,084
3.78125
4
def ship_cost_ground(weight): if weight <= 2: price_per_round = 1.50 elif weight <= 6: price_per_round = 3.00 elif weight <= 10: price_per_round = 4.00 else: price_per_round = 4.75 return 20 + (price_per_round * weight) print(ship_cost_ground(8.4)) ship_prem_ground = 125.00 def ship_cost_dr...
694c359fe4d6d254fc878c19ecd28445f040697c
praneethpeddi/Python-Assignments
/san_foundry/count_lower_case.py
268
3.90625
4
def lower_case_count(str_): count = 0 for i in str_: if i.islower(): count += 1 return count def main(): str_ = 'sanSFoundry' count_lower = lower_case_count(str_) print(count_lower) if __name__ == '__main__': main()
f53fcb9e11f8853ed7380b2e393b5f8d613bfa6c
liusongdu/FrankKanesTamingBigDatawithApacheSparkandPython
/spark-linear-regression.py
3,498
3.6875
4
# coding=utf-8 from __future__ import print_function from pyspark.ml.regression import LinearRegression from pyspark.sql import SparkSession from pyspark.ml.linalg import Vectors if __name__ == "__main__": # Create a SparkSession (Note, the config section is only for Windows!) # The config section is not nec...
53fa6587d37e3525b6b4c454f20685fa81cc2c47
muranava/KiwiPyCon-NLP-tutorial
/basics/02_frequent_words.py
901
3.96875
4
__author__ = 'a_medelyan' # Goal: Find out how to compute most frequent words using NLTK # See: http://www.nltk.org/book/ch02.html from nltk.corpus import movie_reviews from nltk.probability import FreqDist words = movie_reviews.words('pos/cv000_29590.txt') words_by_frequency = FreqDist(words) print 'Most frequent ...
9c8b361c6070102de81225e3cbf840e1fa05157f
myharvestlife/advent_of_code_2020
/day2/part2.py
708
3.796875
4
import re file1 = open('input1.txt', 'r') lines = file1.readlines() allData = [] pattern = re.compile(r"^(\d+)-(\d+) ([a-z]{1}): ([a-z]+)$") num_words = 0 for line in lines: result = pattern.match(line) start = int(result.group(1)) end = int(result.group(2)) letter = result.group(3) word = result.group(4...
65fc88a820ddf306290d91904e24005caf929acb
AFCgooner29/Coding-Ninjas-Competetive-Programming-code
/Language1 + Time Assignment/unique_element.py
940
4.03125
4
""" Find the Unique Element Send Feedback Given an integer array of size 2N + 1. In this given array, N numbers are present twice and one number is present only once in the array. You need to find and return that number which is unique in the array. Note : Given array will always contain odd number of elements. In...
8ed4f2a55504636f9fee38c6d1750c726f854837
Gabrielganchev/week2final
/whilelloops/1_to_n_by_22.py
81
3.6875
4
a=int(input()) b=0 while b<=a: b+=1 if b%2==1: print(b)
6281d1a52a53a5752379fb3eeec8824bac5f99ef
delroy2826/Programs_MasterBranch
/Inter.py
512
3.921875
4
user_input= input("Enter two numbers seprated by comma:") user_input_split=user_input.split(",") number1 =user_input_split[0] number2=user_input_split[1] if int(number1)>int(number2): for i in range(int(number1)): val = str(i)[::-1] if int(number1) == i + int(val): print("Got it", i, in...
bb159bfeb97b653e0e845af9bafe630f72c2b4f0
Fiffy-dot/spirograph
/spirograph.py
444
3.6875
4
import turtle as t from turtle import Screen import random turtle = t.Turtle() t.colormode(255) def random_color(): r = random.randint(0, 255) g = random.randint(0, 255) b = random.randint(0, 255) color = (r, g, b) return color for circle in range(72): turtle.speed(0) ...
15867c15128c17576b96eddfc6b8ea5349e8947b
Matteomnd/TPrecursivite
/EXERCICE6_Partie1.py
358
3.734375
4
import turtle def drawCurve(turtle, I): if I==0: turtle.forward(I) else : drawCurve(turtle,I/4) turtle.left(60) drawCurve(turtle,I/4) turtle.right(120) drawCurve(turtle,I/4) turtle.left(60) drawCurve(turtle,I/4) turtle.setup(800,400) drawCurve(tu...
addce5c4bb1c0acef1839e97243a8500b795c40b
henriquevital00/machine-learning
/polynomial_regression/main.py
1,027
3.578125
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd from sklearn.linear_model import LinearRegression from sklearn.preprocessing import PolynomialFeatures dataset = pd.read_csv('./Position_Salaries.csv') X = dataset.iloc[:, 1:-1].values Y = dataset.iloc[:, -1].values lin_regressor = LinearRegressio...
117953614e0f1e59c857845ff4933d297878cbf0
Intel76/pythonProject3
/program1-Hanna Magan.py
617
3.96875
4
# Team member: Hanna Magan # Course: CS151, Dr.Rajeev # Date: 22 September 2021 # Programing Assignment 1 # import math # Program Inputs: ask user for dimensions (length,width and height) room_length = input("Enter room_length") room_width = input("Enter room_width") room_height = input("Enter room_height") # Program O...
b7033441068502c570f0f3af32afa243e9f0086d
ChenLaiHong/pythonBase
/test/homework/4.12-用选择法排序十个数.py
2,122
4
4
""" 【问题描述】 用选择法对10个整数进行从小到大的排序。 这里采用的选择法的思路是进行9轮比较和交换: (1)遍历10个数,选出最小的数,该数和10个数中首位置的数进行交换; (2)遍历末尾的9个数,选出最小的数,该数和末尾9个数中首位置的数的进行交换; (3)遍历末尾的8个数,选出最小的数,交换至末尾8个数中首位置,......,依次类推,直至排序完成。 【输入形式】 输入十个整数 【输出形式】 输出9行。 前8行是9轮比较和交换后的整数序列。 第9行是排序后的十个整数。 数之间用空格隔开。 【样例输入】 4 5 3 6 7 2 1 8 10 9 【样例输出】 1 5 3 6 7 2 4 8 10 9 1 2 3 6 7 ...