blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
15907ec54447fe7a6b182b7262d035d9e5ca1953
Divya5504/A-security-system-with-python-is-made-here-for-deep-understanding-of-python-code-and-how-it-works.
/DIVYA.py
852
4.03125
4
known_users=["Saurabh","Saurya","shikha","Sumit","Garima","Mayank","Smith","Emma"] print(len(known_users)) while True: print("Hi! My name is DIVYA ") name=input("what is your name : ").strip().capitalize() if name in known_users: print("Hello {} welcome to the security system".format(name)) ...
804e38d39837df14fc85f1c8f357304dc6938f7a
sebutz/pythinks
/chapo8.py
2,446
4.28125
4
# strings someString = "abcdef" letter1 = someString[0] print(letter1) print(len(someString)) ll = someString[-1]; print(ll) # -1 or len() - 1 ll = someString[len(someString) -1];print(ll) ll = someString[-2]; print(ll) # traversal with for loop for letter in someString: print(letter) for letter in someStri...
0bb4e0473a56032c234453d697be6457e9f1485e
MertUzeken/codes
/Python Codes/Homework12_2_1.py
899
3.765625
4
def texteses(s): sentence = s.split() dict = {'be':'b','because':'cuz','see':'c','the':'da','okay':'ok'} index = 0 for word in sentence: index +=1 for element in dict: if element == word: sentence[index-1] = dict[element] newstring = ' '.join(sentence) ...
3a76d1ea10d0807b0e4a3f1f5a1567a3e08bc69a
nazaninsbr/Algorithms-DataStructure
/Linear-Search/search1.py
352
3.90625
4
if __name__ == '__main__': #reading the content of the array li = [] N = int(input()) for i in range(N): li.append(int(input())) #asking what the user is looking for in the array print("What number are you looking for?") X = int(input()) for j in range(len(li)): if(li[j]==X): print(str(X)+" is the "+st...
014473af770b27166079c7fa3c32ca9380824e77
LARC-CMU-SMU/dph19-glycemic-impact
/skip_thoughts/.ipynb_checkpoints/vocab-checkpoint.py
2,270
3.5625
4
""" This code has been taken and modified from https://github.com/ryankiros/skip-thoughts Constructing and loading dictionaries """ import pickle as pkl from collections import OrderedDict import argparse def build_dictionary(text): """ Build a dictionary text: list of sentences (pre-tokenized) """ ...
b49af0273cac7d97b1620d818643046aa3f4aa8c
BriGuy520/LearnPythonTheHardWay
/ex15.py
1,152
4.28125
4
# sys - This module provides access to some variables used or maintained by the interpreter and to functions # that interact strongly with the interpreter. It is always available. # argv allows you to take in a list of arguments into your python script # import argv from sys module from sys import argv # declare va...
adf13d6c2b3d891117dc3360aab353405b1c73a5
Reiich/Raquel_Curso
/POO_Python_HERENCIAS/herencia4.py
2,088
3.9375
4
''' Funcion super() y Funcion isinstance() ''' ''' Herencia SImple y múltiple creo la clase que no hereda de ninguna otra, uqe es VELelectrico() y otra de BicicletaElectrica de esta manera, la BicicletaElectrica OBTENDRÁ HERENCIA MULTIPLE ES DECIR, obtiene valores de vehiculo y también de VELelectri...
3fc756337d8dce9e09310f6d18d02bb7d263d805
azizij4/tuto
/2.loops&conditions/loops.py
391
3.953125
4
#let start with for loop #let create a list my_chain = ['azizi','jumanne','yusuph','Mramba','Hulila','mwishwaa'] #now let loop our list for chain in my_chain: if chain == 'jumanne': print('jumanne is your father') continue elif chain == "hey": print("hey") break print(chain) #now lets look about while l...
bfa75778e9c027f9642bc2304589670838305a8e
aisaacroth/Code-Eval
/String-Mask/Python/test_string_mask.py
1,545
3.59375
4
#!/usr/bin/env python3 ''' Test suite for the String mask program. Author: Alexander Roth Date: 2016-01-15 ''' from string_mask import encode_string, read_file import unittest class TestStringMask(unittest.TestCase): def setUp(self): self.filename = 'test.txt' self.test_hello = ['hello', '110...
767c9799b6b4a1fd90590d906f0279ce3ffa07e6
manhar336/manohar_learning_python_kesav
/Datatypes/list/List_Method_insert.py
519
4.03125
4
#/usr/bin/python acoollist = ["superman","spiderman","man",10,20] onemorelist = [10,20,30,40,50] print("printing list information",acoollist,type(acoollist),id(acoollist),list(enumerate(acoollist))) acoollist.insert(4,"hero") print("") print("printing list after appending element",acoollist,type(acoollist),id(acoollis...
e8e851f387ecd1b4fb22fc882d19890c1103ca3e
Flynnon/leetcode
/src/leetcode_100/81_search_in_rotated_sorted_array_2.py
1,575
3.890625
4
# 假设按照升序排序的数组在预先未知的某个点上进行了旋转。 # # ( 例如,数组 [0,0,1,2,2,5,6] 可能变为 [2,5,6,0,0,1,2] )。 # # 编写一个函数来判断给定的目标值是否存在于数组中。若存在返回 true,否则返回 false。 # # 示例 # # 输入: nums = [2,5,6,0,0,1,2], target = 0 # 输出: true # # 输入: nums = [2,5,6,0,0,1,2], target = 3 # 输出: false # 进阶: # # 这是 搜索旋转排序数组 的延伸题目,本题中的 nums 可能包含重复元素。 class Solution: ...
308925ef1cea4d9b11f5ad0391c3c0e24043e25c
rosharma09/PythonBasics
/whileLoop2.py
321
4.3125
4
#While loop sample example name = '' while name != 'Rohan Sharma': print('please enter your name') name = input() print('Thank you') password = '' print('Please enter the password') password = input() while password == 'Password': print('Please enter the password') password = input() print('Thank ...
b810dd134696c939c3a79010fe68612252a7563a
eragnew/dojodojo
/day1/cointosses.py
370
3.703125
4
import random print 'Starting the program...' heads, tails = 0, 0 for i in range(5000): toss = round(random.random()) if toss == 1: result = 'head' heads += 1 else: result = 'tail' tails += 1 print 'Attempt #%d: Throwing a coin... It\'s a %s! Got %d head(s) so far and %d tail(s) so far' % (i, result, hea...
fef6d25706b9a48d35dc97399dcdccd9b00c1a5a
shubham-ricky/Python-Programming---Beginners
/Gravitational Force.py
2,082
4.5625
5
""" Gravitational force can be measured by how every particle attracts every other particle in the universe with a force that is directly proportional to the product of their masses and inversely proportional to the square of the distance between their centres. The formula for the gravitational force is given as: ...
76ec551f44229ef91fcefc00f457c261632d63a9
daniela-mejia/Python-Net-idf19-
/GUI Programming python/button2.py
936
4.0625
4
#This program demostrates a Button widget import tkinter from tkinter import messagebox class MyGUI: def __init__(self): #create the main window widget self.main_window = tkinter.Tk() #create a Button widget. The text 'Click Me! do something when button clicked ...
79d7829c09ffc8dd3c78fab8166829567043e44b
mziauddin/Bibtex-File-Comparison-and-Update
/Bibtex-File-Comparison-and-Update/controller.py
4,564
3.5
4
#!/usr/bin/env python from . import model import pymongo from bibtexparser import * from tkinter import * class Controller(): """ This class is used as an interface between the model and the view """ def __init__(self,v): """initialize view instance and compare the given files""" self.view ...
30be6e5a51b494d57cb11d9b5adffa888e9a08c5
bryan-lima/python-cursoemvideo
/mundo-03/ex077.py
514
4.28125
4
# Crie um programa que tenha uma tupla com várias palavras (não usar acentos) # Depois disso, você deve mostrar, para cada palavra, quais são as suas vogais tupleOfWords = ('aprender', 'programar', 'linguagem', 'python', 'curso', 'gratis', 'estudar', 'praticar', 'trabalhar', 'mercado', 'programador', '...
338aaaeb9cf7bc12f8bf0b8ed1a5f66b421d193b
tarcisio-neto/PythonHBSIS
/Exercicios Python/Exercicio 16.py
416
4.03125
4
# - Ler dois valores (considere que não serão lidos valores iguais) e escrever o maior deles. print ('Digite valor 01: ') valor_01 = int(input()) print ('Digite valor 02: ') valor_02 = int(input()) if valor_02 == valor_01: print ('valores iguais') else: if valor_01 > valor_02: print('valor 01 é maio...
3fa7f516dc863bae19c2cb63784b3403c6221801
Do-code-ing/ChanSuShin_Algorithm
/자료구조/02_Singly_Linked_List.py
5,838
4
4
# [한방향 연결 리스트 구현하기] class Node: # 노드 정의 def __init__(self, key=None, value=None): self.key = key self.value = value self.next = None def __str__(self): return str(self.key) class SinglyLinkedList: # 한방향 연결 리스트 정의 def __init__(self): self.head = None ...
09c487114968148d7ee3159805be5e69290484b7
zergioz/pythonVisual
/scatterplot_sizes.py
521
3.640625
4
""" Scatterplot with continuous hues and sizes ========================================== _thumb: .45, .45 """ import seaborn as sns import matplotlib.pyplot as plt sns.set() # Load the example planets dataset #planets = sns.load_dataset("planets") titanic = sns.load_dataset("titanic") #cmap = sns.cubehelix_palet...
2df6c2662f1959daaa73190b6229f57d920c776d
xsank/cabbird
/leetcode/excel_sheet_column_title.py
387
3.671875
4
def convertToTitle(num): res = [] while num: t = num % 26 if not t: t = 26 num -= 1 res.insert(0, chr(t + 64)) num /= 26 return ''.join(res) if __name__ == "__main__": print(convertToTitle(1)) print(convertToTitle(26)) print(convertToTitl...
752e662c4bb749cbe2fa6b75b3308652cc7f8912
suinautant/learnCode
/python/old/p158.py
1,889
3.59375
4
######################################################## for i in range(6): if(i == 3): continue print(i) ######################################################## # for i in range(1, 10): # # print("i is %d" % i) # for j in range(1, 10): # if j == 3: # break # print(...
c15c0c3d569855464c3930c1b1e1e147923fceb8
vishalpmittal/practice-fun
/funNLearn/src/main/java/dsAlgo/leetcode/P9xx/P914_XOfAKindInADeckOfCards.py
1,881
3.90625
4
""" Tag: array, math In a deck of cards, each card has an integer written on it. Return true if and only if you can choose X >= 2 such that it is possible to split the entire deck into 1 or more groups of cards, where: Each group has exactly X cards. All the cards in each group have the same i...
5fd6a8639531f3de7c12a97010df7366ae283928
TonaGonzalez/CSE111
/07TA_RandomNumber.py
817
3.6875
4
import random def main(): randnums = [16.2, 75.1, 52.3] print(randnums) append_random_numbers(randnums) print(randnums) append_random_numbers(randnums,5) print(randnums) randomwords = [] append_random_words(randomwords,3) print(randomwords) def a...
e9641f8b87de752a4f0e1640b701301dcf5f7f6e
waer24/Python-abc
/files/forIn_1108.py
548
3.921875
4
#_*_ coding: utf-8 _* #1:改写1+2+3....+100 # res = 0 # for i in range(1,101): # res += i # print(res) #:2:输入一个值,输出以这个值为公比,1为首项的等比数列前10项 # print("please enter a number:") # num = int(input()) #2 # a = 1 # i = 0 # res = 1 # print(1) # for i in range(1,10): # res *= num # i += 1 # print(res) #2的优化方案 ...
d16db753051d8381264411a3eff5d6a265fd25d1
rodrigocruz13/holbertonschool-machine_learning
/pipeline/0x02-databases/33-schools_by_topic.py
517
3.8125
4
#!/usr/bin/env python3 """ Module used to """ def schools_by_topic(mongo_collection, topic): """[changes all topics of a school document based on the name] Args: mongo_collection ([db]): [mongo collection object] topics ([list of strings]): [list of topics approached in the school] Retur...
89b0ee3c7b9dc566d21b80a0abadf32f5b7665ab
qmnguyenw/python_py4e
/geeksforgeeks/python/expert/3_3.py
1,507
4.40625
4
Display Snowfall using arcade library in Python In this article, we are going to display snowfall using the _arcade_ Python Package. The _Arcade_ library is a modern Python Module used widely for developing 2D video games with compelling graphics and sound. It is an object- oriented library and can be install...
325886e4196fdca01b9c2b72ab5f36477b978a0a
csYuryV/geekbrains_PyBasic
/03_Lesson/PrakticalTask/05 Exercise.py
1,682
3.90625
4
""" Python Basic Lesson 03, Exercise 05 Программа запрашивает у пользователя строку чисел, разделенных пробелом. При нажатии Enter должна выводиться сумма чисел. Пользователь может продолжить ввод чисел, разделенных пробелом и снова нажать Enter. Сумма вновь введенных чисел будет добавляться к уже подсчитанной сумме. ...
989832375c2a5b4adf3f6bc55f4e9e8e5e30b887
pkrucz00/ASD
/Gotowce/wszelkie mozliwe sortowania/QS-linked-list.py
2,004
3.828125
4
class Node: def __init__(self): self.val = None self.next = None class LinkedList: def __init__(self): self.head=None def printList(self): temp = self.head while temp: print(temp.val) temp=temp.next def push(self,val): newNo...
7bf3f58d0dd2cb9688ae24218c294a404838e933
Hernandezjose2000/PARCIAL_FINAL_ALGORITMOS_1
/107411 - Hernandez, Jose - E1.py
6,729
3.875
4
import csv def menu() ->int: opciones = ["Procesar archivos","Agregar o eliminar un gasto al archivo gasto.csv", "Cantidad de dinero recaudado","Top 3 productos mas comprados", "Reporte de porcentaje por de cada gasto sobre el total", "Incidencia en porcentaje de cada articulo"] ...
18936d3553f5683ba48362fc7595270698d5a4c5
janbohinec/gen-i
/AdventOfCode/2019/Day10/day10.py
2,466
3.59375
4
# -*- coding: utf-8 -*- """ Created on Fri Nov 30 20:42:22 2018 @author: Jan """ import numpy as np import pandas as pd import time import datetime as dt from collections import defaultdict import math ## Advent of Code 2019 day = 10 year = 2019 def day_str(day): """ Return string from integer day. """ retu...
8f18f7ebd6ee0075d1a6df09f017aab6ff5bf26f
BDSchoeler/Euler
/Euler37.py
1,106
3.671875
4
import math def binarySearch(alist, item): first = 0 last = len(alist)-1 found = False while first<=last and not found: midpoint = (first + last)//2 if alist[midpoint] == item: found = True else: if item < alist[midpoint]: last = midpoint-1...
a6b3e23202c78fab87f8de7ece3cddd16f350c7d
supertypeai/Python-syntax-docs
/Tutorial_postgresql_timescaledb/docker_version/sample/test1.py
621
3.53125
4
from psycopg2 import connect table_name = "some_table" # declare connection instance conn = connect( dbname = "savtrik", user = "savtrik", host = "172.18.0.2", password = "2345678910Aa" ) # declare a cursor object from the connection cursor = conn.cursor() # execute an SQL statement using the psycop...
6b4a8102ae1fd9667323fbde5b1c33199ef401da
Amithabh/Python4Informatics
/Course_2_Python_to_Access Web Data/chapter12/Ex_12.2.py
856
4.09375
4
# Exercise 2: Change your socket program so that it counts the number of characters # it has received and stops displaying any text after it has shown 3000 characters. # The program should retrieve the entire document and count the total number of # characters and display the count of the number of characters at the en...
f2f41b147b9565d33eacc043b518d983d4522850
zlatnizmaj/mylpthw27
/ex33extra.py
501
4.21875
4
# function def add_numbers(maxList): i = 0 numbers = [] while i < maxList: print "At the top i is %d" % i numbers.append(i) i += 2 print "Numbers now: ", numbers print "At the bottom i is %d\n" % i return numbers def print_numbers(numbers): print "The list o...
9a18d0f9dea34a64dd23b6ae752611307643bde8
YuanG1944/COMP9021_19T3_ALL
/9021 Python/review/prefinal/exercise_5.py
1,631
4
4
# You might find the ord() function useful. def longest_leftmost_sequence_of_consecutive_letters(word): ''' You can assume that "word" is a string of nothing but lowercase letters. >>> longest_leftmost_sequence_of_consecutive_letters('') '' >>> longest_leftmost_sequence_of_consecutive_lett...
8c419a00a113caeff4cd9d58956b681e5f73ac37
Kenn3Th/Physics_at_UiO
/INF1100/Assigments/Chapter_4/ball_qa.py
1,118
4.09375
4
print ''' Only insert numbers ''' def y(v0, t): g = 9.81 #gravity on earth Fy = v0*t - 0.5*g*t**2 #formula return Fy def test_y(): #test if the function is working computed = y(2, 1) expected = -2.905 tol = 1e-10 success = (computed - expected) < tol msg = 'something is...
172efc4a37982ce91eb6a569bdfe3d0c08ba4289
DaHuO/Supergraph
/codes/CodeJamCrawler/16_0_3_neat/16_0_3_hatze_coins.py
2,317
3.703125
4
import sys import numpy # this method is from http://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n (thanks a lot!) def primesfrom2to(n): """ Input n>=6, Returns a array of primes, 2 <= p < n """ sieve = numpy.ones(n/3 + (n%6==2), dtype=numpy.bool) for i in xrange(1,int(n**0.5)/...
8b9468fb13c5f97571d8ff4fb58729e0121f0c7f
indraoli429/Programming-In-python
/operators/AlgebaricExpression1.py
115
3.859375
4
x=int(input("Enter number")) y=int(input("Enter number")) z=(x**3+3*x**2*y+3*x*y**2+y**3) print("The answer is",z)
a871063cf68983b29bd9444ad568e0206d9ab27b
csagar131/Competitive-python
/Hackrrank/appendAndDelete.py
1,629
3.53125
4
#!/bin/python3 import math import os import random import re import sys # Complete the appendAndDelete function below. def appendAndDelete(s, t, k): x = s y = t t = list(t) s = list(s) count = 0 if s==t: l = len(t) rem = k-l for i in range(0,rem): if len(t)...
da347d1d987142494c048c89f06f17d72be09c88
lweiser/tkinter_projects
/old/lights_out_old.py
894
3.640625
4
"""Testing making square buttons in tkinter.""" import tkinter as tk def button_grid(window, image, b_per_side=5, b_width=60): """Make a grid of square buttons (b_per_side*b_per_side) for console tk. Return a b_per_side*b_per_side list of buttons. """ buttons = {(i*j, make_button(window, image, b_wid...
371f83f375c41dfec5dfbd152e5e7adbb11f75c3
AIS05/covid-symptoms
/covid-symptoms.py
1,290
3.984375
4
# Aaron Stacey - https://github.com/AIS05 from math import ceil # Dictionary key: "symptom" : "weight" symptoms = { "COUGH" : 2, "FEVER" : 2, "FATIGUE" : 1, "SORE THROAT" : 2, "HEADACHES" : 1, "RUNNY NOSE" : 1, "SHORTNESS OF BREATH" : 3, "BODY ACHES" : 1, "LOSS OF TASTE...
9e7ae4faee72db433bf8d8474287cfc7cf8f76fa
YukunQu/learn-python-the-hard-way
/pra.py
771
4.125
4
'''def isPrime(n): i = 2 while i < n // 2 + 1: if n % i == 0: return False i += 1 return True ''' from math import sqrt def isprime(n): # 判断是否为素数 if n < 2: return False for i in range(2, int(sqrt(n)) + 1): if n % i == 0: re...
bb9504966e39ec320b47987f8508044b4ea166e3
Katherine916/suye
/five/conditional_tests.py
259
4
4
animal1 = "cats" animal2 = "dogs" if animal1 == animal2: print("这两种动物一样") else: print("这是两种不同的动物") if "cataa" in animal1: print("猫咪属于动物") if "cataa" not in animal1: print("猫咪不属于动物")
ff9e2660e0d23ffd78f685cd4396b95e1122d7a5
b-r-oleary/random_algebra
/code/stirlings_approximation.py
1,325
3.78125
4
""" here are a few methods that facilitate factorial calculations when n is large enough such that factorials are no longer practical to calculate """ import numpy as np from scipy import special @np.vectorize def log_factorial(n, threshold=25): "stirlings approximation to log(factorial(n)) when n > threshold" ...
3ea410c45ac240f6025c5ef1f3e656e0d3baaa8b
alex93skr/Euler_Project
/019.py
2,444
4.1875
4
# !/usr/bin/python3 # -*- coding: utf-8 -*- print(f'----------------------19--') day_name = ['Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота', 'Воскресенье'] # 1 января 1900 года - понедельник. # В апреле, июне, сентябре и ноябре 30 дней. # В феврале 28 дней, в високосный год - 29. # В остальных м...
ec594ea5a41f4aff164649440f4a792ffcbad9d3
yogeshunavane/pythontest
/examples/singleton.py
1,621
3.53125
4
# Singleton/SingletonPattern.py class OnlyOne: class __OnlyOne: def __init__(self, arg): self.val = arg def __str__(self): return repr(self) + self.val instance = None def __init__(self, arg): if not OnlyOne.instance: OnlyOne.instance = OnlyOne.__...
358c3c92e23dccc4328bb9d33417c4b0fa6fb0a3
AndreLovo/Python
/aula014.py
320
3.984375
4
#LAÇOS DE REPETIÇÃO - WHILE - Enquanto (Não sei o limite para terminar) e sem padrão - # Estrutura de repetição de teste lógico - FLAG é o valor que quando digitado o sistema pára. '''for c in range(1,10): print(c) print('FIM')''' c=1 while c<10: print(c) c+=1 print('FIM')
39ff784b193dde022d63097b051fa1f3926fbb17
ydPro-G/Python_file
/python/5_if/5.3/try/5-3.py
171
3.578125
4
alien_color = ['green','yellow','red'] if 'green' in alien_color: print("Give you five points!") if 'green' not in alien_color: print("Give you five points!")
5081046482a46b6d9d6930b466be1464f54b7438
jzqioipst/pre-education
/quiz/quiz5_3_quick_sort.py
679
3.65625
4
""" 퀵정렬 """ def swap(lst, li, ri): lst[li], lst[ri] = lst[ri], lst[li] def partition(lst, start, end): big = start for i in range(start, end): if lst[i] < lst[end]: swap(lst, big, i) big += 1 swap(lst, big, end) return big def quick_sort(lst, start=0, end=None...
018e3a501710e71373150ca6e05a1c98f2d77664
nashfleet/codefights
/arcade/python/lists/printList.py
264
4.25
4
""" Now you need to implement a function that will display a list in the console. Implement a function that, given a list lst, will return it as a string as follows: "This is your list: lst". """ def printList(lst): return "This is your list: " + str(lst)
3a303d127b8df7509c942bb4a6d066b56ef0471a
ambrosy-eric/100-days-python
/day-34/utils/quiz.py
1,326
3.640625
4
import html class Question: def __init__(self, text, answer): self.text = text self.answer = answer class Quiz: def __init__(self, question_list): self.question_number = 0 self.question_list = question_list self.question = None self.score = 0 def still_...
d5886483a162b4e57621e17ecefabb9d67808057
scb-am/Fractals
/checkio/gil_example.py
417
3.78125
4
# current file show main difference in time between python2 and 3, single process and several from threading import Thread import time def count(n): while n > 0: n -= 1 COUNT = 50000000 # t1 = Thread(target=count, args=(COUNT//2,)) # t2 = Thread(target=count, args=(COUNT//2,)) start = time.time() # ...
79903d6710611cb6f28f853d4e87adc6291ffc24
Delin2/mindstorm
/mindstorms.py
595
4.03125
4
import turtle def draw_square(turtle): for i in range(0,4): turtle.forward(100) turtle.right(90) def draw_art(): window = turtle.Screen() #make square with turtle named bob bob = turtle.Turtle() bob.shape("turtle") bob.color("green") bob.speed(30) #make circle out of ...
70b7268510b35e032c2a7a39e7f70ba9bf0fdf52
garvitburad/Basic-Python-Programs
/Classes, objects,functions.py
232
3.5
4
class Printer(object): @staticmethod def show(): print "you are using the function of the class" var = "u just used a variable present in the class" new_obj = Printer() new_obj.show() print new_obj.var
d7201a7af292a2cf117a1657999747cba13c7b13
leelasd/Scripts
/mad.py
672
3.546875
4
# Author: Samuel Genheden samuel.genheden@gmail.com """ Program that prints the MAD of the first and second column from standard input. The data on standard input should contain nothing but numbers in rows and columns. """ import sys import numpy as np from sgenlib import parsing if __name__ == '__main__': dom...
1d2fe244feebd155f98f98062e8b467b443b5a8d
deathweaselx86/thingsandbits
/leetcode/expression_list.py
2,109
3.671875
4
#!/usr/bin/env python3 # -*- coding: utf-8; mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vim: fileencoding=utf-8 tabstop=4 expandtab shiftwidth=4 # ughhhh import sys operators = ')(*/+-' NUMBERS = [str(i) for i in range(10)] OPERATORS = {operators[i]:i for i in range(len(operators))} class Node: ...
58246ec214c6920fcf4b1d5681012a229cdaf9ad
Am3l1a/FortuneTeller
/FortuneGame.py
2,073
4.15625
4
Numbers = [1,2,3,4,5,6,7,8] ColorsEven = ["Purple", "Pink", "Blue", "Rainbow"] ColorsOdd = ["Green","Yellow","Orange","Red"] Fortunes = ["Remember what we say to the God of Death. 'Not Today.'", "Play the lottery today! (The $1 scratcher, you're not feeling that lucky).", "Age is just a number, so is being ric...
0b2299353fd3183f1a3d7fdb4c03366d6044be9e
ElenaAn12/GBLearning
/Вебинар_Основы/lesson3/Alexey_Krapivnitskiy/less3_3.py
300
4.1875
4
def my_func(a, b, c): """ This function returns the sum of the largest two arguments :param a: int :param b: int :param c: int :return: a+c or a+b or b+c """ num_as_list = sorted([a, b, c]) return sum(num_as_list[1:]) result = my_func(15, 28, -31) print(result)
06dfdf50ef332e4ea36d5ba56a793f89af1e1a52
MrHamdulay/csc3-capstone
/examples/data/Assignment_9/tlssoh001/question2.py
1,406
3.765625
4
'''Sohail Tulsi TLSSOH001 14/05/2014 Programme to reformat a text file so that all lines are at a given length''' #get user input infile=input("Enter the input filename:\n") outfile=input("Enter the output filename:\n") width=eval(input("Enter the line width:\n")) #read file contents f=ope...
37382d22f1a70c2f25c05762c2f689f2cd0cf8df
trqminh/cp-code
/python/dijkstra/sendingmail.py
1,307
3.5
4
#https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1927 import queue class node_in_graph: vertice = 0 distance = 0 def __init__(self, weight, vertice): self.vertice = vertice self.distance = weight def __lt__(a, b): return...
78512a35c9c923eef7de9546d9eb95b53be8b8f2
MysticalGuest/Advanced-Python
/CourseReview/add.py
801
4
4
class MyClass: def __init__(self, height, weight): self.height = height self.weight = weight # 两个对象的长相加,宽不变.返回一个新的类 def __add__(self, others): return MyClass(self.height + others.height, self.weight + others.weight) # 两个对象的宽相减,长不变.返回一个新的类 def __sub__(self, others): ...
3eb3ed8ce19fb1aa4673abbca50f141f8bd84d32
Tokyo113/leetcode_python
/code_27_findfirstIntersectNode.py
6,912
3.515625
4
#coding:utf-8 ''' @Time: 2019/10/23 16:45 @author: Tokyo @file: code_27_findfirstIntersectNode.py @desc: 两个单链表相交的一系列问题 【题目】给定两个可能有环也可能无环的单链表,头节点head1和head2。请实 现一个函数,如果两个链表相交,请返回相交的 第一个节点。如果不相交,返 回null 【要求】如果两个链表长度之和为N,时间复杂度请达到O(N),额外空间复杂度 请达到O(1)。 ''' class Node(object): def __init__(self, num): self.ele...
bd1db7bde57939b8807cd21f5f7fd76a93221c4b
worace/python_the_hard_way
/ex25.py
810
4.1875
4
def break_words(stuff): """This function will break up words for us.""" return stuff.split(" ") def sort_words(words): return sorted(words) def print_first_word(words): w = words.pop(0) print w def print_last_word(words): w = words.pop(-1) print w def sort_sentence(sentence): words =...
86147d2189127e77c23a65e9ee7686466b042b7d
katherinejay/nomacaroons
/homework3/HW3.py
67
3.765625
4
word = input() for i in range(1, len(word) + 1): print(word[0:i])
0ceee21d92f12875a04886852eba30d78c6f9712
FearlH/pypytest
/python_work/two/sort_some.py
546
3.890625
4
L=[2,4,1,3,1,7,8,5,6,9,1,2,3,4,5,6,8,7,1] L.sort()#永久排序 print(L) L.sort(reverse=True) print(L) P=sorted(L)#L并不变 P.reverse()#倒着来 num=len(P)#长度 place=["beijing","new york","lendon","amsterdam"] print(place) sort_place=sorted(place)#这样的都不改变原始值 print(sort_place) print(place) print(sorted(place,reverse=True)) place.reverse...
28733797d0615cdfdbe98fbe0bb0ae4a9321b757
alexander-matz/adventofcode-2018
/day2-code.py
1,018
3.875
4
#!/usr/bin/env python # part 1 # twos = 0 # threes = 0 # for line in open("day2-input"): # counts = {} # for letter in line: # if letter in counts: counts[letter] += 1 # else: counts[letter] = 1 # two = 0 # three = 0 # for letter in counts: # if counts[letter] == 2: two = 1...
5f45af5889df6a36b7190fe4f777c1c3c403aeec
andysitu/algo-problems
/leetcode/300/217_contains_duplicates.py
234
3.515625
4
class Solution: def containsDuplicate(self, nums: List[int]) -> bool: ns = set() for i in range(len(nums)): if nums[i] in ns: return True ns.add(nums[i]) return False
cbb84daf926476d51d110058bd8bbbcd948fd61e
raymond234/redi
/lesson_6_oop/l611_property.py
1,661
3.859375
4
class Student: def __init__(self, name, birthday, courses): # public attributes self.full_name = name self.first_name = name.split(' ')[0] self.courses = courses # protected attributes self._grades = dict([(course, 0.0) for course in courses]) # birthday is n...
f1cdd9bcc863bebf90eb54bd539eee63a9a050bf
harshrecb/Python-Assignment-5
/A.5.3.py
140
3.59375
4
p=int(input("enter principal")) r=int(input("enter rate")) t=int(input("enter time")) si=(p*r*t)/100 print("simple interest is",si) input()
2b52e8a436b07b228b80805899b3d83d3df2e9e8
ma291265298/helloword
/1553.py
307
3.578125
4
class Cylinder: def __init__(self, radius, height): self.radius = radius self.height = height def getVolume(self): return 3.14 * self.radius ** 2 * self.height r, h = [int(x) for x in input().split()] cylinder = Cylinder(r, h) print('{:.2f}'.format(cylinder.getVolume()))
c8d1ff96f913f4fbfca384be60068949364ba9ac
mateusrmoreira/Curso-EM-Video
/desafios/desafio41.py
493
4.03125
4
""" 25/03/2020 jan Mesu A confederação nacional de natação precisa de um programa para selecionar a categoria de um atleta Até 9 mirim Até 14 ele é Infantil Até 19 anos ele é Junior Até 25 anos ele é Sênior Até acima de 25 ele é master """ from datetime import datetime nascimento = int(input('Qual é seu ano de nascim...
7f91bcee2874bb6006aafe1c377235779267944c
Swathi-16-oss/python-
/queue1.py
197
3.5625
4
from collections import deque que=deque() que.append('D') que.append('s') que.append('w') que.append('a') que.append('t') que.append('h') que.append('i') print(que) print(que.popleft()) print(que)
97819f805b59d5cc75f5a02942858ea3a67231a1
leejy001/Algorithm
/Python/Practice/programmers_008.py
141
3.96875
4
def solution(n): answer = '' while n > 0: answer += str(int(n % 3)) n = int(n / 3) return int(answer, 3)
541771e109ccfd5e3d1110e939c5f0e4c6bef250
rafaelri/coding-challenge-solutions
/python/kardane-sum/kardane.py
394
3.9375
4
from typing import List def largest_sum(ints: List[int]) -> int: if not ints: return 0 lg = ints[0] curr = lg for i in range(1, len(ints)): added = curr + ints[i] if added > curr: curr = added if curr > lg: lg = curr else: ...
05d0e44fdd986bf0057bb61b329ff3c923fd8c24
laughtLOOL/grok-learning-answers
/introduction to programming 2 (python)/5/X marks the trail.py
809
3.59375
4
size = int(input('Grid size: ')) grid = [] a = '' location = [0 , 0] b = 0 # make grid for i in range(size): row = [] for j in range(size): row.append('.') grid.append(row) direction = 'a' # print inital position grid[0][0] = 'x' for i in range(size): for j in range(size): a = a + gr...
f433671c636851626cf46359f66304136d7d6ece
pradeepdevloper1/Python_Tutorial_AI
/32tuple.py
1,522
4.1875
4
# tuple is similar to list its element cannoyt be changed once created #empty tuple t=() print(t) t2=(1,2,3) print(t2) print('----Nested Tuple----') t3=(1,(1,2,3),['pradeep','kumar','yadav']) print(t3) print('----only parenthesis is not enough----') t4=(1) print(type(t4)) print('----, is Required ----') t4=(1,)...
552e61ac9180f0402a0bfbe1fa40600818eab54e
Manoo-hao/project
/at_content2.py
678
3.875
4
from __future__ import division def get_at_content(dna): '''takes the content of a file that was stored in a variable called 'dna'. counts the length of the string of characters of 'dna'. counts the occurrence of the letter A in dna, ignoring the case, and storing it in the variable 'a_count'. does the same with the le...
e929e9c1098c89eb059369f0712461f404737567
ehizman/Python_Projects
/test/chapter_three_tests/test_miles_per_gallon.py
577
3.53125
4
import unittest from chapterThree.miles_per_gallon import average_miles_per_gallon class MyTestCase(unittest.TestCase): def test_something(self): self.assertEqual(True, True) def test_returns_average_miles_per_gallon(self): average: float = average_miles_per_gallon(12.8, 287) self.a...
511337741fe07efb39f9c137c85eb3722c9baee5
Tayuba/Deep-Learning
/ANN.py
1,454
3.578125
4
import numpy as np import tensorflow as tf from tensorflow import keras import pandas as pd import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split # Load data sets (x_train, y_train), (x_test,y_test) = tf.keras.datasets.cifar10.load_data() # Image Class im_classes = ["airplane", "automob...
612c929fbe55fa9dada8be6ba6d6061ac4fa4faf
hildar/python-algorithms
/Lesson_2/task_6.py
1,186
4.125
4
# Задача № 5 # Напишите программу, доказывающую или проверяющую, что # для множества натуральных чисел выполняется равенство: 1+2+...+n = n(n+1)/2, # где n - любое натуральное число. def func_check(n): i, a, b = 0, 0, 0 b = n * (n + 1) / 2 while i != n: a = a + (n - i) i += 1 if a =...
645d51e3c972d8169a18fda833edf07600dbe8ff
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/point-mutations/31579554cf62450395848c27ce07cb7b.py
155
3.609375
4
class DNA: def __init__(self, dna): self.dna = dna def hamming_distance(self, s): return sum(a != b for a, b in zip(self.dna, s))
acc9cc3d831a900187166b9fe5a4907040103108
Signewton/Python
/Dictionary Excercise.py
762
3.90625
4
counts = dict() #create dictionary to store emails bigcount = None #setting counts equal to none to deterine biggest bigword = None name = raw_input("Enter file:") if len(name) < 1 : name = "mbox-short.txt" #opening file handle = open(name) for line in handle: line = line.strip() if not line.startswith('From ')...
089ae0817fd751511c247c7a27d3fd79c12a94f8
vignesh0710/DS-and-Algorithms
/Binary Search/recursive_search.py
450
3.78125
4
def recur_bin_search(arr,start,end,numb): if start> end: return -1 else: mid = int((start+end)/2) if numb == arr[mid]: return ("Number found", mid) elif numb < arr[mid]: return recur_bin_search(arr, start,mid-1,numb) else: return r...
41bd8906e3fed308f45fb4587e432e57c2d05556
musyma/Pyth_lesson
/lesson1.py
2,067
3.8125
4
#???????1 long_phrase='????????? ????? ???? ?? ?????? ?????????, ???? ?? ?? ?????????' short_phrase='640?? ?????? ??????? ??? ????? ?????. ???? ????? (?? ???????)' if len(long_phrase)>len(short_phrase): print(True) else: print(False) #???????2 a=input('??????? ????? ? ?????? ') b=round(int(a)/(2**20),2) print('???...
19042318e1b30208fc52c45878281274fbdf56ab
SamiaAitAyadGoncalves/codewars-1
/Python/6kyu/Find the unique number.py
748
3.859375
4
# https://www.codewars.com/kata/585d7d5adb20cf33cb000235 # # There is an array with some numbers. All numbers are equal # except for one. Try to find it! # # findUniq([ 1, 1, 1, 2, 1, 1 ]) === 2 # findUniq([ 0, 0, 0.55, 0, 0 ]) === 0.55 # # It’s guaranteed that array contains more than 3 numbers. # # The tests contain ...
6bbaddd430d463f4ab2200031b6409cbb289fd15
thinkSharp/Interviews
/minimumSwap.py
5,147
3.59375
4
def minimumSwaps(arr): def heapify_max(a): array_len = i = len(a) - 1 def swap(parent, c1, c2): if a[parent] < a[c1] or a[parent] < a[c2]: if a[c1] > a[c2]: a[parent], a[c1] = a[c1], a[parent] check_children(c1) els...
84b644c1a2542a0fbb22e8e4a721f48bca144220
DaHuO/Supergraph
/codes/CodeJamCrawler/16_0_3/EtonCeb/jamcoin.py
4,006
3.640625
4
__author__ = 'benoitcotte' # import sys import math import random # Run with the following commands: # for printing into terminal: python store_credit.py < A-small-practice.in # for printing into output file: python store_credit.py < A-small-practice.in > A-small-practice.out # for debugging uncomment following line w...
282c7a4b5e9110e9a4db64f406fb22bbf05f9c47
rashedrahat/wee-py-proj
/pickNearn.py
4,440
3.59375
4
# a program that will print the earning value based on user's picking things. import random Ark1 = ["room1", "room2"] Ark2 = ["room1", "room2"] Ark1_room1 = ["apple", "banana", "mango", "orange", "pineapple", "jackfruit", "coconut", "olive"] Ark1_room2 = ["mobile", "computer", "pc", "smartwatch", "watch", "clo...
fb7570c3d906a52ec542c429ff12d32e46bb7b14
Abhiforcs/mypythonworkspace
/file2dict.py
156
3.640625
4
fhand = open(input('Enter file name: ')) lines = fhand.read() lines = lines.split() dty = dict() for word in lines: dty[word] = len(word) print(dty)
2b6e50372f45990e89a33a9b52a4315cc2abe202
robbrooks1991/Coding-Challenges
/16 . Using python with MySQL part three/Insert-update-driver/main.py
1,393
3.5625
4
from database.mysql import MySQLDatabase from settings import db_config """ Retrieve the settings from the `db_config` dictionary to connect to our database so we can instantiate our MySQLDatabase object """ db = MySQLDatabase( db_config.get( 'db_name' ), db_config.get( 'user' ), ...
c90eb666e4d73a84f148bc331bc6a9c0e5bebce4
DikranHachikyan/python-programming-20200323
/ex23.py
260
3.734375
4
# 1. декларация def addNumbers(first_number, second_number): result = first_number + second_number return result if __name__ == '__main__': # 2. извикване a, b = 5, 6 suma = addNumbers(a, b) print(f'{a}+{b}={suma}')
b9fcbe64fdc45c6e2b5b604a40b558f668ad3b2f
norogoth/baseballgame
/help_with_dict.py
836
3.5625
4
def display_information(): print("information for one player (keys and valus0") print(players["yelich"]) print("all the players") for player in players: print(player) print("all the data without the player names") for player_data in players.values(): print(player_data) p...
70d959fa5f6f46528ac3299453bc740ddffdd677
jkelly37/Jack-kelly-portfolio
/CSCI-University of Minnesota Work/UMN-1133/Labs/selectionSort.py
638
3.625
4
def main(): intstring = input("enter list of integers with spaces inbetween:").replace(" ","") intList = [0] * len(intstring) p = 0 while p<len(intstring): intList[p] = int(intstring[p]) p = p+1 for i in range(len(intstring)): min = i for j in range(i+1, len(intL...
d292b7ee5f1325d4323cd4146770737e7aa4485f
daheige/python3
/2017/03/bic_list.py
779
3.96875
4
#!/usr/bin/env python3 #-*- coding:utf8 -*- bic = ['fe', 'tcan', 'readline'] print(bic) print(bic[0]) print("第一个元素是", bic[0]) # 遍历列表 for item in bic: print("this value is " + item.title()) print("think you!") for i in range(1, 5): print(i) # 创建数字列表 num_list = list(range(1, 4)) print(num_list) num2 = lis...
a67d18ca8cdfa73a42bd9b01f611963e58946773
zhanybekovich/Python-Learning
/dawson/ch04/no_vowels.py
317
4.09375
4
message = input("Введите текст: ") new_message = "" VOWELS = "aeiouаеёиоуыэюя" print() for letter in message: if letter.lower() not in VOWELS: new_message += letter print("Вот ваш текст с изъятыми гласными буквами:", new_message)
2ed858e18a855977b8ebebd013aa4b56a9c7bc25
UkrainianEngineer/programming_education
/volodymyr_shkliar/find_the_cheapest_book.py
563
4.25
4
""" Find the cheapest book. """ books = [ { 'name': 'Lord of the rings', 'price': 700 }, { 'name': 'Harry Potter', 'price': 1300 }, { 'name': 'Fluent Python', 'price': 650 } ] def min_price(data: list) -> str: cheapest_book = min(data, key=...
6a21969a11cd7bfc9f2d254d4a0f757748a630ab
sarthakjain07/OOPS_Python
/instanceVSclass_Variables.py
809
3.953125
4
class Student: # class variables grade=1 no_of_students=0 #constructor def __init__(self,name,roll,gender): # instance variables self.name=name self.roll=roll self.gender=gender self.grade=7 Student.no_of_students+=1 def newGrade(self): s...
894c298150d80d215b9d3608a72d4d6f4ff0709f
bookc618/python3tutorial
/pre-chp7/guessnum.py
487
3.78125
4
#!/usr/bin/python3 ## ## import random secrectNum = random.randint(1,20) print("猜猜我是多少?") for guessTaken in range(1,6): print("请输入:") getInput = int(input()) if getInput < secrectNum: print("小了!") elif getInput > secrectNum: print("大了") else: break if getInput == secrectNum: print("恭喜你!你在第 "+str(guessT...
96e07b1d8759969665284583e9ef2c91d00ac2f9
maki216syou/study_python2
/pyramid.py
167
3.671875
4
#coding:utf-8 dansu = int(input('段数を入力してください : ')) for i in range(dansu): print(' ' * (dansu - 1 - i), end='') print('*' * (i * 2 + 1))