blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2fd6bf337c2a5e22e4c8a9ecd158eb55545bd999
Devn913/Rock_Paper_Scissors
/RPS.py
3,091
4.34375
4
import random print('welcome to the Rock Paper Scissors!') print('This game is created by Dev Nirwal') print('Choose how you wanna play: ') print(' Single player or Multiplayer player') game_mode = input(' Type Single / Multi : ').lower() print('Lets get started') print('You will have 3 choice...
e8541ee9b7ff18af145566d977f5ba7cafc09cb9
Aparecida-Silva/Exercicio-pos-greve
/Questão8.py
741
3.890625
4
#Variaveis ListaB = "" verificador = 1 #Lista A só de enfeite ListaA = [] #Progama while(verificador == 1): #Pedir nome do usuario nome=str(input("Digite o nome:")) # Adicionando o nome na lista A(ListaA) ListaA.append(nome) #COntador de palavras no nome palavras = len(nome.split()) #Organiz...
0994fdb75642e6ecd5402c1ca62260802090dfca
dlondonmedina/intro-to-programming-python-code
/exercises/4-1/objects/main.py
1,376
4.1875
4
# "module" refers to code that is imported # copy the phone class into a file called phone.py # create 2 different objects # charge up both their batteries # notice that if you use the battery on one of them its doesn't affect the # current_battery on the other other want # Change the owner name - notice that defining ...
21fcc097433be88eef53f08037aef57674fa6d88
Goular/PythonModule
/05廖雪峰Python教程/05.函数式编程/02map.py
100
3.546875
4
def f(x): return x * x r = map(f, [1, 2, 3, 4, 5, 6, 7, 8, 9]) result = list(r) print(result)
c5e99a6e4e0c0f1aa9e930e3315aacaca682c0cb
igarnett6/CS-1114
/1114 labs/lab9/lab9q3.py
124
4.0625
4
n = int(input("Enter a number n: ")) lst = [] for i in range(1, n+1): add = 2**i lst.append(add) print("List: ",lst)
f36c681465c3a13b8a727b8976e4524ff175fd51
ranamahmud/python-data-structures-subeen
/binary_tree_pre_order.py
236
3.5
4
from binary_tree import * def pre_order(node): print(node) if node.left: pre_order(node.left) if node.right: pre_order(node.right) if __name__ == "__main__": root = create_tree() pre_order(root)
0c6865629b6b390c99dcffbf1b9e25b7b528abd0
NRL-Plasma-Physics-Division/turbopy-training-public
/T03/T03-0/coffeeshop.py
1,974
4.34375
4
class beverage: """ A class representing a basic drink Parameters ---------- drink : str Type of base drink size : str Size of drink Attributes ---------- drink : str Type of base drink size : str Size of drink cost : float Price of d...
b1ff43b893e687f7b9b65ceae41b6598192cfc54
pawloxx/CodeWars
/is_perfect_square.py
271
4.03125
4
""" is_square (-1) # => false is_square 0 # => true is_square 3 # => false is_square 4 # => true is_square 25 # => true is_square 26 # => false """ from math import sqrt def is_square(n): return int(n) > -1 and sqrt(n) % 1 == 0 print(is_square(1905835656))
8f5bd9e5630a29812d64241464ba6a148a7915d3
nga-27/SecuritiesAnalysisTools
/libs/tools/math_functions.py
11,845
3.5625
4
""" math functions """ from typing import Tuple, Union import pandas as pd import numpy as np from scipy.stats import linregress def lower_low(data: Union[list, pd.DataFrame], start_val: float, start_ind: int) -> list: """Lower Low Looks for a bounce (rise) then lower low Arguments: data {list...
bf3bbd762d7f12b3e1bf4abe8f455a424662256d
JAYARAJ2014/python
/exceptions2.py
395
3.53125
4
from pprint import pprint try: file = open("app.py") pprint(file.readlines()) age = int(input("Age")) xfactor = 10/age except (ValueError, ZeroDivisionError): print("You didn't enter a valid age") else: print("THere was no errors") finally: file.close() #finally block closes the open file p...
d4857a8303781e1a67dcffc52093ee6f7e77750b
TimmontCd/Proyecto-Peliculas-
/Python Proyecto/Menu.py
3,946
4.125
4
def menu(): opc = 0 Peliculas = {'Tortugas_Ninja':' B'} while opc != 6: print("*" * 10) print(" MENU ") print("*" * 10) print("[1] SUBIR PELICULA") print("[2] MODIFICAR PELICULA") print("[3] ELIMINAR PELICULA") prin...
961e6b9b635d11045e8468720ded0f871a2d696b
deyim/python_prac
/mentor_week12.py
1,056
3.609375
4
def searchList(L, x): for i in range(len(L)): if(x == L[i]): return i return -1 def main(): fp_r = open("DataIn_02.txt", "r") fp_w = open("Out_02.txt", "w") for r in fp_r: key = int(r) values = fp_r.readline() i = searchList(values, key) if i != -1: fp_w.write("Key %d is at %d in " % (key, i)) ...
bb8e9eb19f83e3e4408af6cb5adfa02a74d9cb78
suntong/lang
/lang/Python/StringTemplate.py
816
3.875
4
#!/usr/bin/python3 from string import Template #open the file filein = open( 'StringTemplate.tmpl' ) #read it src = Template( filein.read() ) #document data title = "This is the title" subtitle = "And this is the subtitle" list = ['first', 'second', 'third'] d={ 'title':title, 'subtitle':subtitle, 'list':'\n'.join(lis...
02f7d845e5f6f16a26e850e3db9fd46546b54d0e
timmyjing/python-practice
/hasGivenPath.py
519
3.609375
4
# Given a binary tree t and an integer s, determine whether there is a # root to leaf path in t such that the sum of vertex values equals s. def hasPathWithGivenSum(t, s): if t == None: return s == 0 if t.value == s and not t.left and not t.right: return True left = False rig...
e0db18ec8d713e9a259f23ce5d24667b18718bc2
BarbecuePizza/Mypython
/ python基础/getset.py
702
3.625
4
# -*-coding:utf-8 -*- #!/usr/local/bin/python3 class Student(object): """docstring for Stedent""" def __init__(self, name, score): self.__name = name self.__score = score def info(self): print('学生:%s; 分数:%s' % (self.__name, self.__score)) def get_score(self): return ...
c632a8965e24be5fc8376120029ff39a9e4847b5
slfdstrctd/num_methods
/4/main.py
4,671
3.671875
4
print("Приближённое вычисление интеграла по составным квадратурным формулам\nВариант 5\n") # Вес w(x) def w(y): return 1 # Функция f(x) def f(y): global ty if ty == 1: return w(y) * 1 if ty == 2: return w(y) * 2 * y if ty == 3: return w(y) * 4 * (y ** 3) - 2 * y # Max f...
30410778f4121ca917a3f9eb3bd0b235cbca5800
Eric-Wonbin-Sang/CS110Manager
/2020F_quiz_2_pt_2_submissions/liethan/Quiz 2 Part 2.py
2,746
4.25
4
def main(): start = input("Please enter 1 for mathematical functions, or enter 2 for string operations: ") if start == "1": math = input("Please enter 1 for addition, 2 for subtraction, 3 for multiplication, or 4 for division: ") if math == "1": input1 = float(input("Please enter the...
caa0e449793138ededaac5d073d38f9574b57e18
pushker-git/LeetCodeTopInterviewQuestions
/Daily Byte/modeInBST.py
1,066
3.9375
4
Given a binary search tree, return its mode (you may assume the answer is unique). If the tree is empty, return -1. Note: the mode is the most frequently occurring value in the tree. Ex: Given the following tree... 2 / \ 1 2 return 2. Ex: Given the following tree... 7 / \ ...
8e57be00bfba1c737dda7f4407126cabd4386627
XyliaYang/Leetcode_Record
/python_version/Interview28.py
990
3.75
4
# @Time : 2020/2/25 17:59 # @Author : Xylia_Yang # @Description : class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def isSymmetric(self, root: TreeNode) -> bool: return self.Symmetric(root,root) def Symmetric(self,roo1,r...
e74ae3c5e1b5c6d1f731e035dc5bf6a15fc14c95
McRules2004/DTCassessment
/Project/question.py
1,359
4.09375
4
""" Joel McKinnon September 2021 Question Class """ # imports import random # class of question, this class will generate the question and all needed variations/answers class Question: def __init__(self, question_num): self.question_num = question_num Units = ["x", "+", "-"] # list of units ...
1ce020a7d394af9462864330c3084b365dbf2e2c
arteum33/homework_lesson_2_Part2
/Homework_Lesson_2_part_2.py
2,860
4
4
#Задачи на циклы и оператор условия------ #---------------------------------------- ''' # Задача 1 # Вывести на экран циклом пять строк из нулей, причем каждая строка должна быть пронумерована. a = 0 for i in range(5): print(i+1, a, sep='.') ''' ''' # Задача 2 # Пользователь в цикле вводит 10 цифр. Найти количес...
b88a5d2917dd549f2474cdf0e1192daaef005b7d
CodeTemplar99/learnPython
/Exceptions/handling_exceptions.py
927
4.46875
4
# to handle exceptions properly and prevent your program from crashing # put the code to be executed in a try block and # use the except block to print a friendly message for the error try: age = int(input("Age:")) # when a above throws an exception, the code below will not be executed because the control ...
0e239323c8a6473c2a9ed1ba4df2d1261ca75234
humbertoperdomo/practices
/python/PythonCrashCourse/PartI/Chapter10/favorite_number_remembered.py
444
3.765625
4
#!/usr/bin/python3 """ Favorite number remembered.""" import json file_name = 'text_files/favorite_number.json' try: with open(file_name) as f_obj: favorite_number = json.load(f_obj) except FileNotFoundError: favorite_number = input("What is your favorite number? ") with open(file_name, 'w') as f_o...
f67c558dd6c3a703ebd03819110321142cdc505c
Ashwathguru/MACHINE-LEARNING---FUNDAMENTALS
/FML_LAB/pythonex.py
19,522
4.40625
4
#add_numbers is a function that takes two numbers and adds them together. def add_numbers(x, y): return x + y add_numbers(1, 2) ------------------------------------- #add_numbers updated to take an optional 3rd parameter. #Using print allows printing of multiple expressions within a single cell. d...
778f3eae949fd05001d7497407193f20ceb50609
sumanes4u/Anaconda-Projects
/All-Classes_DotPY_Modified_Sublime/Class-2-datatypes-Sep13.py
2,562
4.1875
4
# coding: utf-8 # In[1]: x = 'Hello' # In[2]: print(x) # This print the value of the x as it gets stored # print(x) # This prints the value in a suitable format. # In[3]: num = 121 name = 'Sam' # In[5]: print('My number is:{one}, and my name is: {two}'.format(one=num,two=name)) # In[9]: print('My numb...
4dead7197da8a1086349c96fdb9894fdd331f465
Bschuster3434/Euler_Problems
/p8.py
2,638
3.671875
4
import urllib2 website = "http://projecteuler.net/problem=8" def return_greatest_product(website): source = urllib2.urlopen(website) list = source.readlines() full_list_string = ''.join(list) string_start = "<p style='font-family:courier new;font-size:10pt;text-align:center;'>" string_end = "</p>" start_loc...
cb96023ef71998d1c1073ef0d319240d750646c9
nataliewyq/GSS-homework
/0703hw1.py
494
4.1875
4
print('enter your score:') score=int(input()) if score >=0 and score<=100: print('score valid') if score>=91 and score <=100: print('your letter grade is A') if score>=81 and score<=90: print ('your letter grade is B') if score>=71 and score<=80: print('your letter grade is C') ...
e5c9db6b67aa1ab3211716a535b253b1265d09b8
lpyqyc/Python-100-Days
/Day01-15/code/Day01/hello.py
967
4.53125
5
""" 第一个Python程序 - hello, world! 向伟大的Dennis M. Ritchie先生致敬 Version: 0.1 Author: 骆昊 Date: 2018-02-26 请将该文件命名为hello.py 使用Windows的小伙伴可以在命令行提示下通过下面的命令运行该程序 python hello.py 对于使用Linux或macOS的小伙伴可以打开终端并键入下面的命令来运行程序 python3 hello.py """ print('hello, world!') # print("你好,世界!") print('你好', '世界') print('hello', 'world', sep='...
037248ddbf07dd5a0dfc13b6bcb08342fa139604
RaghavGoyal/Raghav-root
/python/code/src/DataStructures/Tree/Binary/Main.py
1,053
4.3125
4
""" Demo for Binary Search Tree """ from BinarySearchTree import BinarySearchTree if __name__ == '__main__': bst = BinarySearchTree() bst.insert(10) print(f'Root Data: {bst.root.data}') print(f'Root.left: {bst.root.left}') print(f'Root.right: {bst.root.right}') bst.insert(5) bst.insert(...
c30f5b6b642a2d45ff26bfe9f010953d891f245b
diesarrollador/CRUD-MySQL
/insertar.py
938
3.53125
4
import mysql.connector # creando la coneccion a la base de datos mydb = mysql.connector.connect( host = "localhost", user = "root", password = "", database = "clientes" ) # gestiona las operaciones de la base de datos def insertar(): try: mycursor = mydb.cursor() cedula_cliente =...
658112caa4819c814840951fbb7f2b4eb4a34535
ThaiSonNguyenTl/NguyenThaiSon-fundamental-c4e24
/session1/homework1/or_even_better.py
104
3.734375
4
from turtle import* shape("turtle") speed(0) for i in range(100): circle(100) left(9) mainloop()
c6b9c06700952a2a13cf2e320da8a6917bcba520
harshagl2002/COVID_CLI
/Country_CovidGraph.py
1,507
3.625
4
import requests import json import datetime import matplotlib.pyplot as plt from datetime import timedelta def country_graph(): url = "https://covid-193.p.rapidapi.com/history" date_string = '2020-04-01' date = datetime.datetime.strptime(date_string, '%Y-%m-%d').date() today = datetime.date.today() ...
1e9d421f4fe2bdd66f8ead4364cb636727df4967
msonderegger/PolyglotDB
/polyglotdb/io/parsers/speaker.py
1,904
3.703125
4
import os class SpeakerParser(object): def parse_path(self, path): raise (NotImplementedError) class FilenameSpeakerParser(SpeakerParser): """ Class for parsing a speaker name from a path that gets a specified number of characters from either the left of the right of the base file name. ...
a67e149c2a7d7eeca08e13b3e2ecedb32a5ba731
ashutosh1906/DistributedCyberMirror
/Dijkstra.py
7,559
3.875
4
import heapq def Dijkstra_algorithm_unweighted(source, adjacent_matrix): '''Find the shortest path to all nodes from the source node Return the output structured as dictionary where the keys are ids of the nodes and the value is the shortest distance''' # print("Neighbour Node %s"%(adjacent_matrix[sour...
7bbe66d7ec2da4e7bb5cef550a01dc1d50a0e4cc
MrHamdulay/csc3-capstone
/examples/data/Assignment_4/edwmoe001/piglatin.py
1,822
3.828125
4
VOWELS = ("a", "e", "i", "o", "u", "A", "E", "I", "O", "U") def consonant_check(a): first = a.lower() if first in ('a', 'e', 'i', 'o', 'u'): return False else: return True def conv_consonant_start(word): if len(word)>=2 and consonant_check(word[1]) == True: if len(word)>=3 and cons...
adbd48685f7a2c5366adfa59744cda9e52263f71
Rochan2001/python_stuff
/python_projects/print_matrix_spiral.py
1,254
4
4
class Spiral: def __init__(self, matrix): self.matrix = matrix def print_spiral(self, i, j, r, c): # If i or j lies outside the matrix if i >= r or j >= c: return # Print First Row for index in range(i, c): print(self.matrix[i][index], end=" ") ...
3a82a3d4a10c73c8bf67eb6e065444ae7b590397
yacinekedidi/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/5-text_indentation.py
501
4.03125
4
#!/usr/bin/python3 """module text_indentation. """ def text_indentation(text): """ function text_indentation """ if type(text) is not str: raise TypeError("text must be a string") i = 0 text = text.strip() while i < len(text): print(text[i], end="") if text[i] ==...
c1bb73c746d32812f283a5523f131415733b081b
AntonSergeqich/GeekHttps
/ls4_dz2.py
750
4.28125
4
# Представлен список чисел. Необходимо вывести элементы исходного списка, значения которых больше предыдущего элемента. # Подсказка: элементы, удовлетворяющие условию, оформить в виде списка. Для формирования списка использовать генератор. from random import randint my_list = [] for i in range(10): my_list.append...
f1ca2e1dee1086447a00fc099592d32fc2b5985e
EleazarLopezOsuna/COMPI2-PROYECTO1
/Modelos/Objeto.py
1,434
3.6875
4
class Objeto(): # Constructor de la clase objeto, funciona como multi constructor ya que se hace una verificacion # del tipo de dato que le estamos enviando; Puede ser cadena o un Objeto def __init__(self, *args): if isinstance(args[0], str): self.parametros = {} self.arregl...
6cca993ad5317df22f412fe9f660088ba6c6c641
jvano74/advent_of_code
/2020/day_11_test.py
9,284
4.3125
4
from collections import defaultdict from typing import NamedTuple class Pt(NamedTuple): x: int y: int class Puzzle: """ --- Day 11: Seating System --- Your plane lands with plenty of time to spare. The final leg of your journey is a ferry that goes directly to the tropical island where you c...
066872bc7eeb81328ad8bc545bc90731730d5302
yanolab/python-functionals
/functionals.py
2,626
3.796875
4
# -*- coding: utf-8 -*- from string import letters, digits from random import choice from itertools import islice, count, tee, takewhile, imap def randstrings(strs, limit=None): """ generate random strings by given string. """ return (choice(strs) for x in countup(stop=limit)) def randalphanumerics(l...
b77aa4d261eb4d0c618addd7e21116cff4eb93ed
mccdaq/daqhats
/examples/python/mcc118/ifttt/ifttt_log.py
3,146
3.59375
4
#!/usr/bin/env python """ MCC 118 example program Read channels 0 and 1 every 5 minutes and send an IFTTT event for logging to a Google sheets spreadsheet. This uses the IFTTT Webhooks channel for inputs. You create your own event and enter the name here for event_name (we used voltage_data for the name), then choose ...
69f1c30d5959b3c70f91e5323cfe84ab2067e5aa
umfundii/learning-robot-swarm-controllers
/source/controllers/controllers_task2.py
9,290
4.21875
4
from utils import utils class ManualController: """ Using the sensing of the robots, decide which robots are the first and the last and start sending a communication message containing a value that is incremented by each robot that received it. Each robot can receive two messages, if the count receive...
b6bc4fdad48a21a679055fa4d6a55344ccc44052
btrif/Python_dev_repo
/Algorithms/Tonelli - Shanks.py
4,293
4.03125
4
# Created by Bogdan Trif on 16-05-2018 , 5:08 PM. # https://en.wikipedia.org/wiki/Tonelli%E2%80%93Shanks_algorithm # The Tonelli–Shanks algorithm (referred to by Shanks as the RESSOL algorithm) # is used in modular arithmetic to solve for r in a congruence of the form r^2 ≡ n (mod p), # where p is a prime: that is, t...
731e233d78a85e9b2237d5ea83984571246e4ff9
KacperKubara/USAIS_Workshops
/Other/grid_search.py
1,941
3.5625
4
"""Grid Search Example based on the Random Forest Regression""" import numpy as np import pandas as pd import matplotlib.pyplot as plt # Read Data from sklearn.datasets import load_boston dataset = load_boston() #Loading Sklearn internal dataset # Choose which features to use x = dataset["data"][:, [7, 9]] # using...
34d54b4a8459a5fa6ab23943968d07a213e03415
gurramdeepika/python_programming
/PycharmProjects/no1/Fourth_Day/Fibnocci.py
357
3.515625
4
class fibnum: def __init__(self): self.f1 = 0 self.f2 = 1 def __next__(self): self.f1,self.f2,olff2 = self.f1+self.f2,self.f1,self.f2 return olff2 def __iter__(self): return self def main(): f = fibnum() for i in f: print(i) if i > 20: break ...
0baae320e7a2056a09fd1d024920a60c42078ecb
lokeshV89/pythonPrac
/numpy/1numpy.py
344
3.859375
4
import numpy as np # single dimentional array a = np.array([1,2,3]) # multi dimentional array b = np.array([(1,2,3),(4,5,6)]) print(a) print(b) # create a array of 1000 number d = np.arange(1000) print(d) print(d.itemsize) # to get a tupple having array dimensions print(a.shape) print(b.shape) # to reshap a array c =...
c2e4fefcd02e71824d17291a0d6033c72de51c25
Toma-L/NLP
/NLP.py
13,094
3.796875
4
#Natural Language Processing with Python #1.1==================== import nltk #nltk.download() #download book from nltk.book import * text1 text2 text1.concordance("monstrous") text2.concordance("affection") text1.similar("monstrous") text2.similar("monstrous") text2.common_contexts(["monstrous", "very"]) text4.di...
f0d63914bb07dc9927df4be3cd6dfc0fb181ccb3
eduardogomezvidela/Summer-Intro
/10 Lists/Excersises/23.py
493
3.921875
4
#5 char word counter list = ['no','umm', 'crazy', 4, 'banana', 'scuba', 'apple', 1, 'nope', 'bloke'] #4 5 letter words five_letters = 0 counter = 0 for word in list: counter = 0 if (type(word)) == int: #In case of ints in list x = 0 else: #...
f1633d2b7fd2fe05e157b9b4f8c62b6ea852b0b8
hayuzi/py-first
/base/function.py
6,186
4.125
4
# 函数 def funcFirst(): print('hello world') # python 函数的参数传递: # 不可变类型:类似 c++ 的值传递,如 整数、字符串、元组。如fun(a),传递的只是a的值,没有影响a对象本身。 # 比如在 fun(a)内部修改 a 的值,只是修改另一个复制的对象,不会影响 a 本身。 # 可变类型:类似 c++ 的引用传递,如 列表,字典。如 fun(la),则是将 la 真正的传过去,修改后fun外部的la也会受影响 # 关键字参数 # 关键字参数和函数调用关系紧密,函数调用使用关键字参数来确定传入的参数值。 # 使用关键字参数允许函数调用时参数的顺序与声明时不一致,因为...
ad998f0cc40ecdb4d0cc8255be9f67f0ff530beb
userddssilva/Exemplos-introducao-a-programacao
/condicional.py
137
3.890625
4
idade = float (input ( "informe uma idade: ")) if idade >= 18: print ("voce ja pode beber") else: print(" voce nao pode beber")
a504d5468361efaabf472ef887e885f4bf3d4444
Nonac/Python_practise
/Xs and Os Referee.py
1,206
3.734375
4
def checkio(game_result): a = "" for i in game_result: a = a + i if a[0] == a[1] and a[0] == a[2] and a[0] != ".":return a[0] elif a[0] == a[3] and a[0] == a[6] and a[0] != ".":return a[0] elif a[0] == a[4] and a[0] == a[8] and a[0] != ".":return a[0] elif a[1] == a[4] and a[1] == a[7] a...
7627698addfefc711f0d24b0e13a961cc932dbff
hyolin97/bigdata_web
/python/실습3.py
357
3.515625
4
pu=int(input("숫자를 입력하시오:")) if pu>10: if pu%2==0: print("%d는 10보다 큰 짝수입니다."%pu) else: print("%d는 10보다 큰 홀수입니다."%pu) else: if pu%2==0: print("%d는 10보다 작은 짝수입니다."%pu) else: print("%d는 10보다 작은 홀수입니다."%pu)
5dc708d1a573ad42ff14a73aa04eecb86a66d782
Mnoori198/week_4
/main_store/coupon_calculations.py
607
3.609375
4
def calculate_price(price, cash_coupen, percent_coupen): shipping_vp_to_ten = 5.95 shipping_ten_to_thrity = 7.95 shipping = 0 tax = 0.06 price_after_cash_coupen = price - cash_coupen price_after_percent_coupen = price_after_cash_coupen - (price_after_cash_coupen* percent_coupen) price_with_...
aafc25c9b625d5793f83033dfc5c717acfa0f1db
aidardarmesh/leetcode
/Problems/200. Number of Islands.py
1,093
3.53125
4
from typing import * class Solution: def numIslands(self, grid: List[List[str]]) -> int: ''' Strategy is to "draw" lands in water ''' if not grid: return 0 N = len(grid) M = len(grid[0]) islands = 0 for i in range(N): ...
d8566277f2f88b1b63ce4463a3c8e7adea2b9913
Alextter/lesson4-year2
/lesson4_4.py
115
3.640625
4
a = int(input("Storona")) r = int(input("RadiusK")) if r == (a/2): print("mojno") else: print("net")
cb1eafcd6285b415a2545685aef67a9f1d6a1379
conradstorz/Palindrome
/Palindrome_python2.py
2,912
4.125
4
#! /usr/bin/env python #python 2 """ A simple module for testing the isPalindrome(string) code. """ import string def isPalindrome_Jaysen(s): s = s.upper() s = s.translate( string.maketrans("", ""), string.punctuation + string.whitespace) return s == s[::-1] def isPalindrome_Storz(s): upcase...
006ef29a90b0d540f1c8bba0ef31e7c8289f5dfd
Hezel254/python_projects
/meal.py
233
3.515625
4
username='hez' password=1234 def log(): user=input('Enter name: ') pass_=int(input('Enter password: ')) if user==username and pass_==password: print('Welcome') else: print('Access Denied') log()
c13a3700c4791a9393d7f25a8b226a27f335f4f3
Sebastian-CQ/Introduction-to-Algorithm
/Data_Structure_And_Algorithm/_6_UnorderedList.py
3,536
3.8125
4
class Node: def __init__(self, initial): self.data = initial self.next = None def getData(self): return self.data def getNext(self): return self.next def setData(self, newData): self.data = newData def setNext(self, newNext): self.next = newNext ...
3f1b790ce48502e601ab104f777c1be12f5150e4
DataBranner/recurse_center_mentoring_11139
/db_setup.py
1,358
4.125
4
import sqlite3 def connect_db(): """Connects to or creates a db and returns a cursor""" conn = sqlite3.connect('word_problems.db') return conn.cursor() def make_table(c, table_name, columns): tables = c.execute('''SELECT name FROM sqlite_master WHERE type='table' AND name=?;...
b6fd4fc85a1033d0e5dc7c7f69813cd9a0672f83
writecrow/text_processing
/final_file_standardization/final_file_standardization.py
2,253
3.8125
4
#!/usr/local/bin/python3 # -*- coding: utf-8 -*- # DESCRIPTION: Given a directory with text files passed as argument # to the script, the folder directory is copied copying over # all text files. File names are cleaned (_checked and _deidentified) are # removed from file and folder names. And all lines breaks are repl...
ab95d535646c25a184601c6f11772b250a3b0d87
NastyaZotkina/STP
/lab21.py
486
4.25
4
weight,height=map(float,input().split()) def bmi(weight: float, height: float) -> float: return weight/(height/100)**2 def print_bmi(bmi: float): if(bmi<18.5): print("Underweight") elif(bmi>=18.5 and bmi<25.0): print("Normal") elif(bmi>=25.0 and bmi<30.0): print("Overwei...
1b0d899cbc067e91601f1fb9e9cf262cbb29f757
CharlesECruz/PythonCICC
/Introduction/Labs/Alone/Lab6/Lab6.py
808
4.03125
4
""" Primes, GCD, LCM """ import math def is_prime(num): """ Check if n is prime """ if num <= 1: return False for i in range(2,int(math.sqrt(num))+1): if num% i == 0: return False return True def gcd(a, b): """ GCD of a and b """ if b == 0: return a e...
d341d01aae35873c8401acf139d4faedd6d92728
shashankgaur/machine-learning
/HW1/Problem 1/problem1.py
3,099
3.671875
4
#!/usr/bin/python #author: Shashank Gaur, FEUP, UP201309443 #Course: Machine Learning HomeWork1 # Explaination pending for the whole file by Shashank Gaur #The file loads the training data, calculates the mean, convolution and then decides where to plot other data. import scipy.io #from sklearn import svm import numpy ...
8ce559a2ddbe734f5cc0ad6c1d52252e1cd08419
Svegge/GB_2021_06_py_foundations
/02_homeworks/01/task_01.py
568
4.15625
4
''' 1. Поработайте с переменными, создайте несколько, выведите на экран, запросите у пользователя несколько чисел и строк и сохраните в переменные, выведите на экран. ''' FIRST_VAR = 1 SECOND_VAR = 2 print(FIRST_VAR, SECOND_VAR) third_var = int(input('Please enter number:\n>>> ')) fourth_var = input('Please enter an...
775997871756527391fcb1a6516ab7b4a51bbe71
Eezzeldin/HackerRankChallnges
/Ceasar_Cipher/Ceasar_Cipher_test.py
1,464
3.765625
4
''' Original alphabet: abcdefghijklmnopqrstuvwxyz Alphabet rotated +3: defghijklmnopqrstuvwxyzabc ''' cipher = {} n = 3 #abcdefghijklmnopqrstuvwxyz letters = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q", "R","S","T","U","V","W","X","Y","Z"] #print (len (letters)) letters_2 = [letters ...
e13492435f33b44107bb96297764283953b0a72c
flerchy/codestyle-core
/ml_quality/datasets/shit/inverse.py
1,395
4.25
4
def slow_inverse(f, delta=1/128.): """Given a function y = f(x) that is a monotonically increasing function on non-negatve numbers, return the function x = f_1(y) that is an approximate inverse, picking the closest value to the inverse, within delta.""" def f_1(y): x = 0 while f(x) < y: ...
af321a1091219842d1f1308f2c4a2d1923024485
Samtrak/HomeWork1
/OOP/Account.py
1,141
3.578125
4
class Account: def __init__(self, id ,name, balance = 0): self.id = id self.name = name self.balance = balance def __str__(self): return "Account [" + "id=" + str(self.id)+","+"name="+self.name + "," +"balance="+ str(self.balance)+"]" def getID(self): return self.id ...
38173fd27e45fa9205aa07a66b1d4e106d93c154
RideGreg/LintCode
/Python/1465-order-of-tasks.py
1,921
3.765625
4
# Time O(nlogn) # Space O(1) # There are n different tasks, the execution time of tasks are t[], and the # probability of success are p[]. When a task is completed or all tasks fail, # the operation ends. Tasks can be performed in a different order, and it is # expected that in different order the time to stop the act...
b72ea63b66637c0e73fb9b0332d5753bf5930f83
JinshanJia/leetcode-python
/+Longest Palindromic Substring.py
1,697
3.75
4
__author__ = 'Jia' # Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, # and there exists one unique longest palindromic substring. class Solution: # @return a string def longestPalindrome_DP(self, s): #isP[i][j] means s[j:i + 1] is pali...
f5b58167a84be4e8b68c0848aad676b2fa4046ba
blam4521/ConvertTgaToPng
/Checkes_Dir/check_dir.py
705
3.609375
4
"Check the directory if it exists." # Built-in imports import os import sys import os.path import shutil def check_name(img_dir): """Check if the directory exists. Args: img_dir (str): name of the file directory. """ src_small = img_dir + ' ' #src_large = img_dir + ' ' try: ...
5776ffb7a7b0edea9c32dff12675382526741791
Taraslut/git_tarin
/lesson_19/initila.py
344
3.515625
4
def addition_action(fn): def inner(var): print("Before foo call") rez = fn(var) print("After foo call") return rez return inner @addition_action def double(x): print("In double") return x * 2 print(double("Hello")) # print(addition_action(double)("Hello")) # double = ...
c7306fae1ae63f5143fc3af8636daf1ed47fd086
jsebastianrincon/curso_python
/Fundamentos/metodos_privados.py
825
3.828125
4
# Crear metodos privados en clases class Persona: def __init__(self, nombre, primer_ape, segundo_ape): # No privado self.nombre = nombre # Protegido self._primer_ape = primer_ape # Privado self.__segundo_ape = segundo_ape def metodo_publico(self): self._...
3d7be1ce3f34a58bec65e79fa7c12520b9c33dd8
cowboybebophan/LeetCode
/Solutions/~1019. Next Greater Node In Linked List.py
548
3.53125
4
# similar to 503 and 739 class Solution: def nextLargerNodes(self, head): res, stack = [], [] # Be carefule here, do Not initialize like this: res = stack = [] # because res and stack points to the same reference and they will change together as [] changes. while...
8ffa50a65d7d5cb027ab8e3f6df94ab76e5f900a
VinceVi83/RemoteControlNAO
/NAO/MoveHeadNAO.py
4,187
3.546875
4
# coding=utf-8 __author__ = 'Vincent' from threading import Thread import time class MoveHeadNAO(Thread): """ * Gere le pilotage de la tête du NAO :param motion: Objet permettant de contrôler la tête du NAO :type motion: ALMotion """ def __init__(self, motion): Thread.__init__(self) ...
49b07b3989ea17e5760451626a54f15fc084e190
nileshnegi/hackerrank-python
/day009/ex54.py
1,054
3.765625
4
""" Piling Up! The first line contains a single integer ```T```, the number of test cases. For each test case, there are 2 lines. The first line of each test case contains ```n```, the number of cubes. The second line contains ```n``` space separated integers, denoting the sideLengths of each cube in that order. """ ...
bc789c8b12d94337d28ee6318cd2669b6ff37733
Jack7510/python_algorithm
/simple_sort.py
2,864
4.4375
4
# author: Jack Lee # samples of Python # sort algorithm with Python # Simple Sort: Bubble, Insertion # from random import randrange # # func: gen_rand_list(numbers of random ) # desc: generate random number of list with bubble sort algorithm # para: number - how many numbers of random will be generated # def gen_ran...
37357d0a3b15d068b02b6412018f6c08e2df9c95
ZouCheng321/myPythonCode
/csc1002/Assignment#4/VocabularyGUIStep1(to students).py
1,474
3.796875
4
def PressShowMeaning(): print('PressShownMeaning') def PressNextWord(): print('PressNextWord') from tkinter import * root=Tk() root.geometry('500x600+150+200') root.title('My first GUI') wordLabel0=Label(root,text='Word:',height=2) wordLabel0.grid(row=0,column=0) wordLabel1=Label(root,widt...
0877c6cb13dbc6514b981e28caf85472262a4b53
tgreenhalgh/Intro-Python
/src/day-1-toy/fileio.py
462
4.28125
4
# Use open to open file "foo.txt" for reading f = open('foo.txt', 'r') # Print all the lines in the file for line in f: print(line, end='') print("\n") # Close the file f.close() # Use open to open file "bar.txt" for writing f = open('foo.txt', "a") # Use the write() method to write three lines to the file f.write...
2643e967a4879875efd26271fa1a0e59a216e083
Ghanshyam-Coder/Positive-Number-List
/Positive number list.py
545
4.09375
4
#!/usr/bin/env python # coding: utf-8 # In[5]: #Python Program to print Positive Number in a List def positive_number(NumList): for j in range(Number): if(NumList[j] >= 0): print(NumList[j],end=' ') NumList=[] Number = int(input("Please Enter the Total Number of List Element:"))...
94bc60f74782f8910131aaaba10efdf4736e66ab
AdamZhouSE/pythonHomework
/Code/CodeRecords/2450/60837/242782.py
402
3.578125
4
def exist(nums,target): start=-1 end=-1 num=0 for i in range(len(nums)): if nums[i]==target: if num==0: start=i end=i num+=1 else: end=i res=[] res.append(start) res.append(end) return res nu...
f8a5502f2b0a3eb3e83bab07a25fc80aeed3e311
HWYWL/python-examples
/面向对象/Cat.py
431
3.578125
4
class Cat: def __init__(self, cat_name): print("创建对象,数据初始化。。。") self.name = cat_name def eat(self): print("%s 爱吃鱼" % self.name) def drink(self): print("%s 喝水" % self.name) # 对象创建 cat = Cat("Tomcat") # 对象方法调用 cat.eat() cat.drink() # 对象创建 lazy_cat = Cat("大懒猫") # 对象方法调用 l...
3b3e5828cb47f9ea88b0bca054ac982ac902df30
ninaReb/ExerciciosPy
/primeiro_desafio.py
924
4.03125
4
# ***Primeiro desafio*** # Você recebe uma lista de 300 números ordenados por ordem crescente. # Sua tarefa é achar um número aleatório informado pelo usuário da # maneira mais eficiente possível. #digitar os números do array. ex: 1,2,3,4 # def get_array(): # text = input("digite os numeros") # my_array = tex...
0ba6d2e2e7ed0f576b8855950bc095e086317dc9
ANTZ314/raspi
/python/file_R_W/write1.py
1,076
3.828125
4
# -*- coding: utf-8 -*- """ Python 2.7 (virtual env) If file doesn't exist, file is created If exists, opens existing file reads & prints contents Appends 10 new lines """ import sys def main(): exists = 0 # append after printing contents try: # Skip if file doesn't exist file = open('test.tx...
1bc2315ebf763fe1c8147a2cce7d0a8e49a3b6b2
mwsmales/project_alien_invasion
/ship.py
2,092
3.78125
4
import pygame from pygame.sprite import Sprite class Ship(Sprite): def __init__(self, ai_settings, screen): """Initialise the ship and its starting position""" super(Ship, self).__init__() self.screen = screen self.ai_settings = ai_settings # load and resize the ship image,...
ee2f727de4e49c7446a1137ef339efda5f5cba5b
Mercy1231/CMPUT-396
/rushhour.py
15,794
3.828125
4
""" CMPUT 396 Assignment 3 Created by Andrea Whittaker 1386927 And Mercy Woldmariam 1413892 --- RUSH HOUR --- The Objective: slide the red car through the exit to freedom! To Play: slide the blocking cars and trucks in their lanes (up and down, left and right) until the path is clear for the red car to es...
88ba4393b835759a46cc69b45aeaac347e564e6a
jerrylance/LeetCode
/819.Most Common Word/819.Most Common Word.py
1,336
3.625
4
# LeetCode Solution # Zeyu Liu # 2019.5.29 # 819.Most Common Word from typing import List # method 1 dic, replace(),常规 class Solution: def mostCommonWord(self, paragraph: str, banned: List[str]) -> str: count = 0 dic = {} for c in "!?',;.": paragraph = paragraph.replace...
071731d701260c2d72d7f894e7f4930c33c3f7f0
luchen-z/pdsnd_github
/bikeshare_project/project_bikeshare.py
13,570
4.4375
4
import time import pandas as pd import numpy as np CITY_DATA = { 'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv' } def get_filters(): """ Asks user to specify a city, month, and day to analyze. Returns: (str) city - name o...
b5b41b91f229aa0c23246d2585ad58da1b17a6a0
speciallan/algorithm
/leetcode/problem231/problem231.py
757
3.75
4
#!/usr/bin/env python # -*- coding:utf-8 -*- # Author:Speciallan class Solution(object): def isPowerOfTwo(self, n): """ :type n: int :rtype: bool """ if n <= 0: return False if n == 1: return True # yushu = n % 10 # #...
0bc9f19f70076857a77efe690a7f54085ac50345
mocchacino/latihan_python
/PembagianTanpaOperator.py
221
3.578125
4
# membuat fungsi pembagian tanpa menggunakan div atau '/' # menghasilkan integer def pembagian(a,b): hasil = -1 while a >= 0: a = a - b hasil += 1 print(hasil) pembagian(9,3)
f52f07b7cb868e9805bbc3d1156bcd91ea62a347
bhattaraijay05/prg
/multiple_of_any_number.py
260
3.984375
4
multiple_number=int(input("Whose multiple ")) multiple_upto=int(input("upto where ")) for multiple_upto in range(1,multiple_upto+1): multiple=multiple_number*multiple_upto print(str(multiple_number) + " * " + str(multiple_upto) + " = " + str(multiple))
a7bd81aee9907933e878b4d26868d5f6ba071f1a
Beardocracy/holberton-system_engineering-devops
/0x16-api_advanced/100-count.py
1,903
3.546875
4
#!/usr/bin/python3 ''' This module contains the count function ''' import re import requests def count_words(subreddit, word_list, hot_list=[], print_flag=0): ''' Prints the number of occurrences for a list of keywords in a subs hotlist ''' url = "https://www.reddit.com/r/{}/hot.json".format(subreddi...
5e087948839dbdbf36330e9f9491bf96960cae6c
nov3mb3r/DidierStevensSuite
/sortcanon.py
5,225
3.65625
4
#!/usr/bin/env python __description__ = 'Sort with canonicalization function' __author__ = 'Didier Stevens' __version__ = '0.0.2' __date__ = '2022/07/17' """ Source code put in public domain by Didier Stevens, no Copyright https://DidierStevens.com Use at your own risk History: 2015/07/07: start 2015/07/08: add...
343ae2be3ca6f112dec9cb1ac646c1187b5c5513
Sidney-kang/Unit5-03
/lowest_value_array.py
724
4.4375
4
# Created by : Sidney Kang # Created on : 13 Nov. 2017 # Created for : ICS3UR # Daily Assignment - Unit5-03 # This program def find_lowest_value(arrays = []): value_number_in_array = 0 for value in arrays: if value_number_in_array == 0: value_number_in_array = value else: ...
35cfc68d3bbea3b1a42b6a5d20def9d4cb98d66b
snlnrush/python-alg-and-data
/les_2_task_4.py
477
3.90625
4
""" 4. Найти сумму n элементов следующего ряда чисел: 1, -0.5, 0.25, -0.125,… Количество элементов (n) вводится с клавиатуры. """ def s_element(n, s=0, b=1): if n == 0: return s s += b n -= 1 b /= 2 return s_element(n, s, b) amount = int(input('Enter number:')) if amount == 0: print...
3d098db289ab06c07a42a429cb8ecc4da39ece42
scriptographers/CS228-Assignment-1
/src/mastermind-harness.py
2,966
3.78125
4
# !/usr/bin/python3 # sample harness; your code should play against this code without # any modification in this code. For any issues in this code # please report asap. # your code lives in this file; we will import it import mastermind # We expect the following three functions in your code # their usage will expla...
4c0c873866cc2367199759556938fb0de05b055e
shiannn/LeetCodePython
/linklist/LeetCode 78 [Subsets]OneBranch.py
1,053
3.65625
4
class Solution(object): def subsets(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ if nums is None: return [] res = [[]] self.dfs(sorted(nums), 0, [], res) return res def dfs(self, nums, index, path, res...
bd647fc6841613b0f0e733174d37a24680fe1999
azam6301732985/test
/Prediction Using Supervised ML.py
4,591
4.125
4
#!/usr/bin/env python # coding: utf-8 # # AUTHOR :- M.A.AZAM # # TASK 1 :-Prediction Using Supervised Ml GRIP @ THE SPARKS FOUNDATION # Linear Regression with Python Scikit Learn # In this section we will see how the Python Scikit-Learn library for machine learning can be used to implement regression functions. We wi...
802cf41dbad7ea163cf2ba69c3c5048936379d52
skshabeera/dictionary
/saral10.py
495
3.921875
4
# dict = {'Alex': ['subj1', 'subj2', 'subj3'], 'David': ['subj1', 'subj2']} # ctr = sum(map(len, dict.values())) # print(ctr) dict = { 'Alex': ['subj1', 'subj2', 'subj3'], 'David': ['subj1', 'subj2']} total=0 for value in dict: value_list=dict[value] count=len(value_list) total=total+count print...
d8734960bcddeeb471adc5f6142d3cd481306c01
benzheren/python-playground
/project-euler/p019.py
861
3.921875
4
''' You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twenty-nine. A leap year occurs ...