blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a8374ca098190309a7fef570a6b3d5206e9b4578
Emanoel580/ifpi-ads-algoritmos2020
/lista condicionais 2b/fabio_2b_12_inteiro_decima.py
230
3.90625
4
def main(): num = float(input('numero: ')) definir(num) def definir(valor1): if valor1 // 1 == valor1: print(f' o numero {valor1} é inteiro') else: print(f'o numero {valor1} e decimal') main()
597286aa205bbfa6139a31b9b8cc168ff93c7e50
eltechno/python_course
/Random.head-or-tails.py
334
3.640625
4
import numpy as np np.random.seed(123) outcomes= [] for x in range(10): coin = np.random.randint(0,2) if coin == 0: outcomes.append("heads") else: outcomes.append("tails") print(outcomes) tails = [0] for x in range(10): coin = np.random.randint(0,2) tails.append(tails[x] + coin...
e11d7e9688a8130e42db1c4507c1605fed79f7dc
Arbazkhan4712/Python-Quarantine-Projects
/Snake_Game/Previous .py files/gamePrototype.py
4,217
3.90625
4
################################################################################ # THis is the first prototype of the snake game i'll be creating. # This has controls and displays the user score. # after the game is over we can either continue to play or exit the window #################################################...
88735f093c67f0aa7da4129ac3957519acd2cc8e
richik500/MiniProjectPython
/functions/disCusRec.py
452
3.5625
4
def display_customer_record(): print("\n\n List Of Available Customer Records\n\n") print("BOOKING ID---GUEST NAME---GUEST MOBILE NUMBER---GUEST ROOM NUMBER---GUEST CHECKIN DETAILS---GUEST CHECKOUT DETAILS---RENT---TOTAL BILL\n") file = open("Record/customer.txt", "r") while True: content = file...
13e89cfbbb8962d6945471e9e27531b5843c8e5e
mturja-vf-ic-bd/AD-Longitudinal-Smoothing
/utils/L2_distance.py
1,232
3.921875
4
import numpy as np def L2_distance(X, Y): """ Computes pairwise distance between each vector of the two lists. The vectors has to be of same length. Eq. || X_i - Y_j || ^ 2 = || X_i || ^ 2 + || Y_j || ^ 2 - 2* transpose(X_i) * Y_j :param X: List of vectors :param Y: List of vectors :return D: ...
467331a745a196a2578d6b88e3241ced8fca5fca
MrZhangzhg/nsd2019
/nsd1907/py01/day01/hi.py
1,039
3.9375
4
# print("Hello World!") # # if 3 > 0: # print('yes') # print('ok') # # s = 'Hello World!' + \ # 'Hello tedu' # # a = 3; b = 4 # c = 5 # d = 6 # 打印一行字符串 # print('Hello World!') # 字符串可以使用+进行拼接,拼接后再打印 # print('Hello' + 'World') # print打印多项时,用逗号分开各项,默认各项间使用空格作为分隔符 # print('Hao', 123) # 也可以通过sep指定分隔符 # print...
46d90a6ec75f65717bffcb81c92224414b86df5a
isabella0428/Leetcode
/python/58.py
496
3.765625
4
class Solution: def lengthOfLastWord(self, s): """ :type s: str :rtype: int """ if not s: return 0 count = 0 end = len(s) - 1 while s[end] == ' ' and end > -1: end -= 1 for i in range(end, -1, -1): if s[i] !=...
5937eae7abd332a22ed8429af5a4c403b075b58a
panditdandgule/DataScience
/NLP/Python Natural Language Processing/Regexp.py
1,385
3.890625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Feb 13 08:47:07 2019 @author: pandit """ import re def searchvsmatch(): line=" I love animals." matchobj=re.match(r'animals',line,re.M | re.I) if matchobj: print("match",matchobj.group()) else: print("No match!!") ...
c76ac4accf99699d35ec365168d95f22373056fa
green-fox-academy/kitta11
/datascience/practice/randomizer.py
163
3.734375
4
import random print(random.random()) print(random.randint(0, 5)) mylist = 'This is my list where I will pick a random word'.split() print(random.choice(mylist))
3fcde3ef467d83e792e275cd2bfaf6373f57fbc7
cobed95/gwanak-ps
/hacker-rank/asia-pacific-4/hanme/p3.py
2,508
3.671875
4
#!/bin/python3 import math import os import random import re import sys # # Complete the 'getMinEffort' function below. # # The function is expected to return an INTEGER. # The function accepts 2D_INTEGER_ARRAY C as parameter. # def getMinEffort(C): # Write your code here n = len(C) m = len(C[0]) effo...
84122822c8db191b7fe0d512279dac4271c411df
superpigBB/Happy-Coding
/Algorithm/degree.py
1,499
3.59375
4
## Solution 1 def degreeOfArray(arr): # # Write your code here. # if arr is None or len(arr) == 0: return -1 dict = {} for index in range(len(arr)): num = arr[index] if num not in dict: dict[num] = {} dict[num]['cnt'] = 0 dict[num]['in...
ab5e82cc9f731676c51cfc6a1da23efaed42e23c
nakshc/jhbhj-
/untitled0.py
320
3.515625
4
name="naksh" print(type(name)) blah=10 print(type(blah)) yo_man_this_is_a_list=["yo","bros","whassup","do","you","play","football"] print(yo_man_this_is_a_list) print(type(yo_man_this_is_a_list)) from tkinter import * root=Tk() root.title("C145") root.geometry("300x300") root.mainloop();
5d74b3e5e66377ec430adc4273cfeb1228905d2a
Drako01/Python
/tripledeunnumero.py
176
3.96875
4
## El Triple de un numero ## Autor: Alejandro Di Stefano ## Fecha 21/08/2021 uno=0 print ("Ingrese un Número cualquiera: ") uno=float(input()) print ("El Triple del Número es: ", (uno*3))
019bce8c814a537c99655de48d6e073f9708a448
Pruebas2DAMK/PruebasSGE
/py/P706JSD.py
311
3.5625
4
''' Joel Sempere Durá- Ejercicio 6 ''' contrasenya="contraseña" while True: compruebaContrasenya=input("Introduce la contraseña:\n") if compruebaContrasenya == contrasenya: print("!Correcto!\nBienvenido de nuevo") exit(0) else: print("Contraseña incorrecta, intentelo de nuevo")
71bc939935c064114f66270940a00d3d94ba92bd
litianhe/webApp3
/www/test_yield.py
760
3.765625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def accumulate(): # 子生成器,将传进的非None值累加,传进的值若为None,则返回累加结果 tally = 0 while 1: next = yield if next is None: return tally tally += next def gather_tallies(tallies): # 外部生成器,将累加操作任务委托给子生成器 while 1: tally = yield f...
47dfffc749626926e4a03394a3e51c554d1adb65
ckt371461/python
/basic/0.py
237
3.71875
4
x = 23 y = 0 print() try: print(x/y) except ZeroDivisionError as e: print('Not allowed to division by zero') print() else: print('Something else went wrong') finally: print('This is cleanup code') print()
298d0464320fa80db5677c17c2c7807a0004df4d
ankit2100/DataStructures_Python
/Tree.py
4,640
3.8125
4
class Node: def __init__(self,data): self.data = data self.left = None self.right = None class Tree: def Insert(self,node,data): if node == None : return Node(data) if node.data < data : node.right = self.Insert(node.right,data) ...
c3f8d45c494ae9e1f45927caca5d6acf4160ba02
mayupatel/Python-Code
/mpate131_fastaAndGC.py
5,729
3.65625
4
NAME: MAYURI PATEL, EMAIL: mpate131@uncc.edu #importing the module random. import random # this function takes header as parameter. #Function reports a) Gene name b) GeneID c) ProteinID def header_file(fastaHeader): ' #1. Parse the header string for gene name. geneName = fastaHeader.strip().split(" ...
4d0088dd83114a0d2680727e20643c56730137a5
igres9014/gym_chess2
/alphazero/move_encoding/knightmoves.py
2,022
3.515625
4
# -*- coding: utf-8 -*- """Helper module to encode/decode knight moves.""" import chess import numpy as np from gym_chess.alphazero.move_encoding import utils from typing import Optional #: Number of possible knight moves _NUM_TYPES: int = 8 #: Starting point of knight moves in last dimension of 8 x 8 x 73 action ...
8f5e49d9f9b286edb6fcbcb2ab890fa0dff970f8
SilentWraith101/course-work
/lesson-06/how-to-write-a-function.py
409
4.53125
5
a = 23 b = -23 # It will check if the absolute value of both a and b are equal def absolute_value(n): if n < 0: n = -n return n # return n if n > 0 else -n # Checking if the absolute value of a is equal to b if absolute_value(a) == absolute_value(b): print('The absolute values of', a, 'and',...
815e195913016f8f8a9e3b10adcfea706480e6bd
PyeongGang-Kim/TIL
/SW_Expert_Arcademy/Programming_Beginner/2-46.py
482
3.625
4
class Student: def __init__(self,name): Student.name=name def nnn(self): print("이름: "+ Student.name) class GraduateStudent(Student): def __init__(self, name, major): GraduateStudent.name=name GraduateStudent.major=major def nnn(self): print("이름: "+ Gradua...
022b2c9a7861826394aab835c173cf450e9fdf08
ywadud/Uni_Multi_Poly_Regression
/univariate_linear_regression.py
1,626
4.15625
4
# Import packages import numpy as np import matplotlib.pyplot as plt import pandas as pd # For better console printing np.set_printoptions(threshold = np.nan) # Import dataset dataset = pd.read_csv('Salary_Data.csv') X = dataset.iloc[:, :-1].values # If you use [:, 0], X will become a vector and not a matri...
046eaeef68ab16e9d776d8f12dd0c69de286a058
MRiach/Scientific_Computation
/Coursework_1/p12.py
4,908
3.5625
4
def codonToAA(codon): #TAA,TAG, and TGA are superfluous to requirement as they represent the end of the string and only end #up slowing down the function. """Return amino acid corresponding to input codon. Assumes valid codon has been provided as input "_" is returned for valid codons that do not co...
138ee9b11909576f51d2dfafb5e358126c7fb0ea
idobleicher/pythonexamples
/examples/basic-concepts/type_conversion_2.py
433
4.0625
4
# initializing string s = "10010" # binary 18 # printing string converting to int base 2 c = int(s, 2) print("After converting to integer base 2 : ", end="this is end\n") print(c) # printing string converting to float e = float(s) print("After converting to float : ", end="") print(e) # output: # After converting to...
29fa40334a80dd902540ab6b62255144db4e2df6
soyal/python-cookbook-note
/chapter1/1-8.py
488
4.0625
4
# 字典的运算 ## 求字典中value最大的key demo1 = { 'a': 123, 'b': 12, 'c': 443, 'd': 32 } # zip可以将两个可遍历对象合并成一个可迭代对象 minItemR = min(zip(demo1.values(), demo1.keys())) print('min key: ', minItemR[1]) maxItemR = max(zip(demo1.values(), demo1.keys())) print('max key: ', maxItemR[1]) ## 也可以用sorted sortedDemo1 = sorted(demo1, ke...
18868fd3a7536733f87765a2fa4650eb026af755
hua-gege/test02
/Scripts/test02.py
173
3.578125
4
# flag=None # if flag: # print("成立!") # else: # print("不成立") dict={"name":"张三"} if dict.get("age"): print("成立") else: print("不成立")
b274d42b093cb73aef6b57ebad903979e60b3923
csy-uestc-eng/algorithm_python_implementation
/KthLargestElementInAnArray215.py
1,642
3.921875
4
# -*- coding: utf-8 -*- """ using min heap to find k largest element. """ class MinHeap(object): def build_min_heap(self, elements, length=None): if not length: length = len(elements) elements.insert(0, 0) for i in range(length/2, 0, -1): self.min_heapify(elements, ...
2531ec29de49e2153ab40e36eda54bae3260e3ba
projectinnovatenewark/csx
/Students/Semester2/lessons/students/3_classes_and_beyond/24_recursion/24_recursion.py
1,189
4.5625
5
""" Example recursion functions. reference: https://realpython.com/python-thinking-recursively/ """ # the first example we will review is recursively executing a factorial. # Factorial multiplies every number by the number before it until it hits 1 # i.e. 5! would equal 5 x 4 x 3 x 2 # or 3! would equal 3 x 2 # recur...
091725ca8beb5986eb4b591cfb2b3b1bc60ce81f
AndyWKLiu/Program-Assignments
/loopcounter.py
243
4.03125
4
for x in range(0, 20): value = int(input("Enter a number between 1 and 10 inclusive")) if(value > 0 and value < 11): Calculate = value * 3 print(Calculate) #a) value and Calculate #b) 3 #c) line 3 #d) line 1 and line 4
c151b02793114dcfb8a4474932154a40e97323f4
paisap/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/3-say_my_name.py
622
3.671875
4
#!/usr/bin/python3 """Example Google style docstrings. This module demonstrates documentation as specified by the `Google Python Style Guide`_. Docstrings may extend over multiple lines. Sections are created """ def say_my_name(first_name, last_name=""): """Example of add on the say_my_name method. ...
af0bcf91d689a19efe96b2d6c7cac054233db9a2
mengw3/goodreadDashboard
/elements/webscraper_author.py
7,926
3.515625
4
""" do web scraper for an author page """ import requests from bs4 import BeautifulSoup import numpy as geek class WebScraperAuthor: """ do web scraper for an author page """ def __init__(self): """ initial all variables """ self.name = "" self.author_url = "" ...
7ffb10c6f8a6f719c45339e053123ff445e7a3cc
crazyj7/python
/math/rcos.py
455
3.515625
4
import matplotlib.pyplot as plt import math import numpy as np ''' r = cos (t) ''' t = np.arange(0, math.pi*2, 0.01) r = np.cos(t) print(t) print(r) ## change to x, y x = r * np.cos(t) y = r * np.sin(t) ''' r2=1-cos(t) ''' r2 = 1-np.cos(t) x2 = r2 * np.cos(t) y2 = r2 * np.sin(t) plt.figure() plt.title('graph') p...
23dce8af70fdff548ee13fb7c034e88654fd8a67
RajatOberoi/Assignment-2
/Q-6.py
98
4.1875
4
#area of a circle pi=3.14 x=int(input("enter radius of circle")) print("area =",x*x*pi)
8b2b8fa7e30806494a3690a2a8aba836b4877fb4
GokoshiJr/algoritmos2-py
/src/modular/anexar.py
343
3.90625
4
# 9. Anexar un dígito a un número dado por adelante. Ej.: Si N = 123 y Dig = 7 → N = 7123 def anexar(base, anexo): temp = base digito = contador = 0 while (temp > 0): contador += 1 temp //= 10 digito = (anexo * pow(10,contador)) + base print(digito) a...
5edb9e8b58d2183d1ba00883b8c3859f6dcccb12
luisespriella9/CTCI-Python
/Arrays and Strings/main.py
6,862
3.734375
4
def check(result, actualResult): #this is to check whether the answer is correct to the result we are expecting if result == actualResult: print("Correct") else: print("Issue Found") # Problem 1.1 def isUnique(string): chars = [False] * 128 for char in string: charNumber = ...
3792e802f66ceaa4de32591973aba9647e4276ad
elazafran/ejercicios-python
/Ficheros/ejercicio1.py
1,088
4.34375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' 1.Crea una función que pida el nombre de un fichero y su atributo( “añadir”) el fichero contendrá los 10 primeros números , también se creara una función para leer fichero realizar un menú con las siguientes opciones 1.Crear fichero 2.Leer fichero 3.salir ''' ...
9133c857d03cd83bc6a56b4707986021ffac90f5
l19nguye/Udacity_DE_DataWarehouse
/create_tables.py
1,857
3.84375
4
import configparser import psycopg2 from sql_queries import create_table_queries, drop_table_queries def drop_tables(cur, conn): """ This function in order to drop existing tables. The list drop_table_queries is imported from sql_queries module. Input: cursor and connection to database. ...
5ec4a97be6949e7ce39b933b934911324c403398
bcollins5/mis3640
/session_11.py
1,801
3.765625
4
#Exercise 4 #Problem 1 '''Write a function that reads the words in words.txt and stores them as keys in a dictionary. It doesn’t matter what the values are. Then you can use the in operator as a fast way to check whether a string is in the dictionary.''' # list = [word.txt] # import os # os.chdir("C:/Users/bcoll...
a81bc2c74284bf29c73329f5e14568810dfab821
Hewuxin/ubuntu_project
/Project_py/shujujiegou/数据结构/sort/shell_sort.py
910
4
4
def shell_sort(nums): """ 时间复杂度 O(n**1.3) 最差时间复杂度O(n**2) 稳定性 不稳定 会改变相同元素间的相对顺序 :param nums: :return: """ n = len(nums) gap = n // 2 while gap >= 1: # 缩短步长 for i in range(gap, n): # 遍历当前子序列的所有元素 j = i while j > 0: # 每一个子序列执行插入排序 ...
befb673f7a07a5f5ae12fca75888b1811339aed4
yanray/leetcode
/problems/0234Palindrome_Linked_List/0234Palindrome_Linked_List2.py
1,838
4.15625
4
""" Reverse Linked List Version: 1.1 Author: Yanrui date: 5/29/2020 """ # Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class SingleLinkedList: def __init__(self): "constructor to initiate this object" ...
4451c5641a03b0020683612002fe0684bb070c61
alliejones/adventcode
/ex01_2.py
358
3.53125
4
floor = 0 basement_pos = None with open('ex01-input.txt') as file: pos = 0 for line in file: for ch in line: if ch == '(': floor += 1 elif ch == ')': floor -= 1 pos += 1 if floor < 0 and not basement_pos: b...
57c5f1f0fd28705dad8d7e50eefbb09fd34a50ab
Aarohi-masq/100Days
/TipCalculator.py
388
3.9375
4
print("Enter the cost of meal: ") cost_of_meal = input() tax = 0.5 print(f"tax percentage: {tax}%") tip = 2 print(f"tip percentage: {tip}%") dollars_meal = float(cost_of_meal.replace("$","")) print(dollars_meal) dollars_meal = dollars_meal + (dollars_meal * tax/100) total = dollars_meal + (dollars_meal*tip/100...
975ca209cf420af7e312d8ec1e6151ba93ed4056
rinoa25/moneydoesgrowontrees
/main.py
17,591
4.125
4
## Project: Money Does Grow On Trees ## ## Authors: Aranya Sutharsan, Rinoa Malapaya Noshin Rahman, Carol Altimas ## import time # Imports a module to add a pause from morning import * # User Responses yes = ["Y", "y", "yes"] no = ["N", "n", "no"] answer_A = ["A", "a"] answer_B = ["B", "b"] answer_C = ["C", "c"] # ...
5afaacb06fb0b9800c9da1dd841d574a66a5dc0f
Factotum8/coursera_independent_works_dive_into_python
/1_week_3_independent_work.py
207
3.609375
4
import sys from math import sqrt a = int(sys.argv[1]) b = int(sys.argv[2]) c = int(sys.argv[3]) print(int((-b + sqrt(b ** 2 - 4 * a * c)) / (2 * a))) print(int((-b - sqrt(b ** 2 - 4 * a * c)) / (2 * a)))
953aef889c69cbe33a2c0b7471fc33b08b82bc8e
lidebao513/Python
/untitled2/day6/loginjson.py
1,785
3.65625
4
#! /usr/bin/env python #-*-coding:utf-8-*- ''' 1 模拟登录 2 模拟登录成功显示登录成功后的账号 3 模拟注册 ''' import json def regetist(username,password): ''' 实现注册功能 username:注册系统账号 password:注册系统密码 :return: ''' temp = username+'|'+password json.dump(temp,open('login','w')) def login(username,password): '...
97a89a2afc6397a544d149d2714576edc9aefd28
Jousha/GW2-Inventory-Prices
/Scripts/helpers.py
5,497
3.6875
4
import json import math import requests def get_bank_inventory(api_token): ''' Input: api_token - String of the api key of a valid account with inventory viewing rights Returns a list object containing the bank inventory associated with the api key ''' inventory_api = f'https://api.guildwa...
f9946a69d8b3299e7041aec89adda414e13e375d
freesoul84/python_codes
/other_python_codes/immediate_smaller_ele.py
327
3.71875
4
test=int(input()) for _ in range(test): number=int(input()) array=list(map(int,input().split())) for i in range(number-1): if array[i]>array[i+1]: array[i]=array[i+1] else: array[i]=-1 array[-1]=-1 for i in range(number): print(array[i],end=" ") p...
3facec5fb825ba51bdb047258cf5e08b55f803c6
saiyesaswym/Algorithms-DataStructures-using-Python
/Leetcode/Array/MaximumAveragePassRatio.py
1,377
3.546875
4
""" Brute force Approach Find max change in pass ratio for every student Time complexity: O(n*m) - n->classes m->extraStudents Space complexity: O(1) """ def maxAverageRatio(self, classes: List[List[int]], extraStudents: int) -> float: while extraStudents>0: max_percent=0 idx=-1 for i,c in e...
5a43ef0ab704ba6f767e04583f587f2d0ecccca4
nervig/Starting_Out_With_Python
/Chapter_2_programming_tasks/task_2.py
214
3.953125
4
#!/usr/bin/python # asks user enter volume of sales planned_volume_of_sales =int(input('Please, enter the planned volume of sales: ')) # calculating of profit profit = planned_volume_of_sales * 0.23 print(profit)
ba62418b6ef564416c4c733d32f6287b1e0f6845
MattWise/ProbabilityProject
/Probability.py
3,195
3.640625
4
from __future__ import division,print_function from random import random from Functions import * from types import * """ P is a dictionary of frozenset, dictionary pairs. The former is the sample space or a subset of it. The latter is a dictionary of frozenset, float pairs. The former is a simple event...
b6d78cbe02aba2e7a20a9e3142d4300ad8942e1b
green-fox-academy/bertokpeter
/week-03/day-01/reversed_lines.py
248
4.25
4
# Create a method that decrypts reversed-lines.txt reversed_file = "week-03/day-01/reversed_lines.txt" def reverse(file_name): with open(file_name, "r") as f1: for line in f1: print(line[::-1], end='') reverse(reversed_file)
83d01bd20e4af9f74b77a755041a892e472ddbc4
danielrs975/simulacion
/Problema I Version II/main.py
12,616
3.75
4
from random import random, expovariate, uniform from math import sqrt from scipy import stats from collections import deque # Funciones para calculo de probabilidades def probabilidad_binomial(prob): numero_aleatorio = random() if numero_aleatorio <= prob: return True return False # CLASES PARA L...
fb30edb7663816ce608dac5f75ac06bbd31ceb8b
MondaleFelix/CS2
/stochastic.py
396
3.96875
4
# import word_frequency import random fishy = {"one": 1, "two" : 1, "red": 1, "blue" : 1, "fish": 4} def get_random_word(dictionary): words = sum(dictionary.values()) random_number = random.randint(1, words) for i in dictionary: if dictionary[i] < random_number: random_number -= dictio...
dc560ddb415a5626b077db8028cae5a758e0d902
UCMHSProgramming16-17/file-io-zbreit18
/issTracker.py
637
3.5
4
import requests import time def getIssStatus(): """Returns a dictionary that contains the current status of the ISS""" issURL = 'http://api.open-notify.org/iss-now.json' r = requests.get(issURL) return r.json() def getIssPos(issRequest): """Returns a dictionary containing the current lat and long ...
7f19270dccd0ba6236bac4725aac77389e9f898c
Catalincoconeanu/Python-Learning
/Python - Basiscs/Try and Except.py
215
4.125
4
# Try and Except # Sample: Try the first statement - if first one is not working then it goes to except statement, this will print Otherwise try: if name > 3: print("Hi") except: print("Otherwise")
4b9d86f69389f334cb97cef325bf19d2ef6f3b71
dooking/CodingTest
/SWExpertAcademy/이진수2-5186.py
476
3.578125
4
t = int(input()) for test_case in range(1,t+1): n = float(input()) answer = '' res = 0 p = -1 cnt = 1 while n != 0: if(cnt == 13): answer = "overflow" break if(n>=2**p): res = int(n/(2**p)) n = n % (2**p) answer += str(r...
18c9f77cf5a66991a333cce705011d7727b7dd82
RotemLibrati/Salary
/mysite/salary/sqlInjectionCheck/sqlInjection.py
3,847
3.953125
4
import sys def main(un, p): username, password = sql_injection(un, p) return username, password def sql_injection(username, password): print("before : " + username) tempWord = username tempWord = remove_problem_word(tempWord) tempWord = " ".join(tempWord.split()) if tempWord.__contains__...
37d1e58de3e3235657120f0bb0316eeb563e99a8
LegendsIta/Python-Tips-Tricks
/number/is_odd.py
142
4.25
4
def is_odd(num): return True if num % 2 != 0 else False n = 1 print(is_odd(n)) n = 2 print(is_odd(n)) # - OUTPUT - # #» True #» False
6dca99ea0d2515d3626bf820b2256754f0dd90ab
dcdennis/Blackjack-AI
/getLine.py
273
3.578125
4
#! /usr/bin/python3.6 import sys with open(sys.argv[1]) as f: count = 0 index = int(sys.argv[2]) for line in f: if count+1 == index: print(count, line) if count == index: print(index, line) count += 1 f.close()
2fb8f1136e6eb6613400211ead0ff42f9dd2a08f
limapedro2002/PEOO_Python
/Lista_01/Pedro Lucas/quest2.py
501
3.578125
4
num = [] imp = [] a = 0 b = 0 mult = 0 i = 0 while i < 10: num.append (int (input ("Digite um valor: "))) i += 1 for cont in num: if cont % 2 != 0: imp.append (cont) for a in range (10): for b in range (1, num[a] + 1): if num[a] % b == 0: mult += 1 if mult ...
9e934f1f6223a28819a7d870dbdbcdf24b2b19c5
aimiliya/WorkCollection-
/filetest1.py
1,458
3.71875
4
# 进行文件夹的增量备份 import os import filecmp import shutil import sys def auto_backup(scr_dir, dst_dir): if (not os.path.isdir(scr_dir)) or (not os.path.isdir(dst_dir)) or ( os.path.abspath(scr_dir) != scr_dir) or ( os.path.abspath(dst_dir) != dst_dir): for item in os.listdir(scr_dir): ...
9d88a08dac8cf43a9e11fc248d24aa49bcc4919e
gkcksrbs/Baekjoon_CodingTest
/src/정렬/Baekjoon_1181_단어 정렬.py
769
3.515625
4
# 입력 개수 N을 입력하고 문자열의 길이는 50까지 이므로 50까지 리스트를 만들어주고 리스트 안에 또 리스트를 생성한다. # 리스트에 lst[입력 받은 문자열의 길이]에 문자열을 추가하여 저장한다. # for 루프로 각 리스트 안에 중복되는 것을 set()으로 제거하고 sorted()로 정렬한다. # 각 문자열들을 문자열의 길이 순서대로 출력한다. N = int(input()) lst = [[] for i in range(51)] for i in range(N): Str = input() Len = len(Str) lst[Len].app...
61d5d58302bdca2668bf5eaf72a640f1c0c70af1
BlackSquirrelz/FS21_CALR_TUTORIAL
/main.py
2,831
3.859375
4
import xml.etree.ElementTree as ET # For XML Parsing import csv # For reading CSV import json import requests # For getting content from the web from bs4 import BeautifulSoup # For parsing content from the web import logging # Main Function def main(): """The main function contains examples on how to read each typ...
0737a9571128d07e856a24b80f1108594b2e43ba
eyosi-cmd/CS110-Introduction-to-Computing-Programming-in-Python
/HW7 Using & Creating Data Structures/password_checker.py
752
3.640625
4
import stdio import sys # Returns True if pwd is a valid password and False otherwise. def is_valid(pwd): if len(pwd) < 8: return False if pwd.isalnum(): return False if pwd.isupper(): return False if pwd.islower(): return False for k in pwd: if k.isd...
36fa60c9a932bebd17e406835be46279e1684d54
eusouocristian/learning_python
/Challenges/remove_vowels.py
325
4.21875
4
def disemvowel(word): word = list(word) vowels = ["a","e","i","o","u","A","E","I","O","U"] for vowel in word: if vowel in vowels: word.remove(vowel) else: pass return word word = input("Ditite uma palavra:\n>") new_word = disemvowel(word) print(new_wo...
bc6484400ed66399855a9886417d9acb41afd4e0
greatertomi/problem-solving
/hackerrank-challenges/easy/acm-team.py
616
3.796875
4
# Problem Link: https://www.hackerrank.com/challenges/acm-icpc-team/problem def totalTopics(p1, p2): count = 0 for i in range(len(p1)): if p1[i] == '1' or p2[i] == '1': count += 1 return count def acmTeam(teams): topicArr = [] for i in range(len(teams)): for k in rang...
4b09a1efdac1cc61b7b3e9b3aa29192f98771708
dlenci/BME-160
/Lab 2/coordinateMathSoln.py
3,979
4.28125
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: #!/usr/bin/env python3 # Name: David Lenci (dlenci) # Group Members: none ''' Program docstring goes here ''' import math class Triad : """ Calculate angles and distances among a triad of points. Author: David Bernick Date: March 21, 2013 Point...
7f12587fe86ecd5155b37beb1733822d2f15d7e1
GabrielDVpereira/python_basics
/URI - BASIC/1042.py
548
4.03125
4
def sort(numbers): for i in range(len(numbers)): min_index = i; for j in range(i+1, len(numbers)): if(numbers[min_index] > numbers[j]): min_index = j; numbers[i], numbers[min_index] = numbers[min_index],numbers[i] return numbers def convertToInt(num): return int(num); nu...
5daebfa91380e5480965a7590ec306faff7b46b2
stinekamau/Mock_Registration_System
/textloader.py
2,546
3.59375
4
''' Module that provides a higher abstraction over the text file that make up the data ''' import csv import random class FileManager: def __init__(self): self.resource="resources\\faculty.txt" #Path to the Advisors data types self.courses_resource="resources\\final_courses.txt" #Path to the courses...
75200aecf87e0c6d7e32cfcaa7de14f468debc21
Juancruzc21/Python
/Python/Operadores aritmeticos.py
1,130
4.28125
4
print("Suma: ") primerNumero = 5 segundoNumero = 4 resultado = primerNumero + segundoNumero print("El resultado de la suma es: " + str(resultado)) print("Resta: ") primerNumero = 5 segundoNumero = 4 resultado = primerNumero - segundoNumero print("El resultado de la resta es: " + str(resultado)) ...
027966c3759280c5694f19f2a3c431d076579291
wilshirefarm/Data-Structures
/Python/toStr.py
221
3.578125
4
def toStr(n, base): convString = "0123456789ABCDEF" if n < base: return (convString[n]) else: return (toStr(n//base,base) + convString[n%base]) def main(): print(toStr(1011,2)) main()
bcfdee42f5b69d4a0999688fbfce04e4dc3c91c3
MatthewHird/Pong
/button.py
386
3.765625
4
class Button: def __init__(self, text, x, y, width, height): self.text = text self.x = x self.y = y self.width = width self.height = height def hover(self, mouse_x, mouse_y): if self.x <= mouse_x <= self.x + self.width and self.y <= mouse_y <= self.y + self.heigh...
431b1c36a19d1b67186df95679992d592e16b507
eldhom/Project-Euler
/017 Number letter counts/main.py
1,086
3.6875
4
#!/usr/bin/python3.5 n2w1 = { 0: 'Zero', 1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', 6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', 11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', 15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', 19:...
fc5ffe28f6058d44080ec0848c602c427d6310ee
isabella232/okta-python-flask-sqllite-example
/CreateDB.py
391
4
4
import sqlite3 connection = sqlite3.connect('message.db') cursor = connection.cursor() cursor.execute('''CREATE TABLE messages(id INTEGER PRIMARY KEY AUTOINCREMENT, message TEXT)''') cursor.execute("INSERT INTO messages (message) VALUES('Welcome')") connection.commit() cursor.execute('SELECT id, message FROM messag...
22edc37dc4fb16ededd7348846818d37da87489c
stuartamitchell/rhyme-classifier
/rhyme_classifier/setup/raw_datasets.py
2,366
3.765625
4
''' Gives a function to generate datasets for training and testing the neural network. ''' import json from nltk.corpus.reader import wordlist import random def generate_dataset(n, dict_file, save_file): ''' Generates a dataset for the rhyme-classifier Generates a collection of n word pairs and a boolean...
fc381af5833208547ba2a7244bae39472202b69d
AlexeyBazanov/algorithms
/sprint_1/factorization_2.py
424
3.6875
4
import sys def factorization(n): result = [] divisor = 2 while divisor * divisor <= n: if n % divisor == 0: result.append(divisor) n //= divisor else: divisor += 1 if n > 1: result.append(n) return result def main(): n = int(sys.std...
4be92b5b94a43d78a02d222dad8c1100568774c6
HvyD/AppleSiri-Privacy-Data_Engineer_prep
/LEET/Binary_Tree_Longest_Consecutive_Sequence_II.py
1,642
4.09375
4
""" Given a binary tree, you need to find the length of Longest Consecutive Path in Binary Tree. Especially, this path can be either increasing or decreasing. For example, [1,2,3,4] and [4,3,2,1] are both considered valid, but the path [1,2,4,3] is not valid. On the other hand, the path can be in the child-Parent-chil...
7cf8fc9d4d4b7a335cd0524148ee23f61fe6c7c8
mathieu-lechine/Python-code-library
/collection_tutorial.py
5,269
3.65625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jan 1 10:39:13 2018 @author: mathieu.lechine """ ############IMPORT TEXT WITH NLTK###################### from nltk.corpus import gutenberg from nltk.corpus import stopwords import string from nltk.tokenize import RegexpTokenizer #choose en ebook from ...
356582d56b755b84eb9e3a6773e44e765ba6fdf5
sam-sepi/Py-coding
/imagination.py
728
3.671875
4
import numpy as np from PIL import Image import binascii # RGB images are usually stored as 3 dimensional arrays of 8-bit unsigned integers. # Each pixel contains 3 bytes (representing the red, green and blue values of the pixel colour) width = 4 height = 4 array = np.zeros([height, width, 3], dtype = np.uint8) # 8-...
627bfc714e9a2ce473250c71392a538154e08973
TaurusCanis/ace_it
/ace_it_test_prep/static/scripts/test_question_scripts/math_questions/math_T1_Q23.py
2,066
3.875
4
import random from math import sqrt root = random.randint(2,5) radicand_exp = random.randint(root + 1, root * 5) question = f"<p>If &nbsp;\\(a&gt;0\\)&nbsp;, which of the following expressions is equivalent to \\(\\sqrt[{root}]{{a^{radicand_exp}}}\\)&nbsp; ?</p>\n" coefficient = radicand_exp // root remainder = radi...
83a5868e6ae01c6ab9833187f05daf6d769311e6
satyampandeygit/ds-algo-solutions
/Algorithms/Search/Ice Cream Parlor/solution.py
719
3.546875
4
def main(): # Loop through for each test. for _ in range(int(input())): dollars = int(input()) numFlavors = int(input()) flavors = [int(i) for i in input().split()] # Determine the correct indexes. index1, index2 = -1, -1 for i in range(numFlavors): f...
d65a726eeac7fa611e95d41879c195e4d7504734
srikanthpragada/python_14_dec_2020
/demo/funs/extract_upper.py
289
3.890625
4
def upper(st): chars = [] for ch in st: if ch.isupper(): chars.append(ch) return ''.join(chars) def getupper(st): nst = "" for ch in st: if ch.isupper(): nst += ch return nst print(upper('AbcXyz'), getupper('AbcXyz'))
ed2e754f582a72365a3f540378971cebd444fa56
hedelman4/ShowMeDataStruct
/Problem4.py
1,366
3.78125
4
import sys class Group(object): def __init__(self, _name): self.name = _name self.groups = [] self.users = [] groupList.append(self) def add_group(self, group): self.groups.append(group) def add_user(self, user): self.users.append(user) def get_groups(...
f3fc98cb3d16d0c709104121987dae1cbb4d72f0
vicjulianortiz/Database-project
/TableDemo.py
6,635
3.578125
4
from tkinter import * import tkinter import tkinter.messagebox import sqlite3 import re class MyGUI: def __init__(self): global db db = sqlite3.connect('C:/Users/Victor/Desktop/CITIES.db') global cursor cursor = db.cursor() self.window = tkinter.T...
7603c6723643bd67efaa32d5cf6c8cadc5b96936
anmolparida/Interview_Questions_Python
/IdentityCard_CodeTheSecret.py
1,542
3.671875
4
# Secret information is: # # The identity card should start with digit 2, 6, 9. [Done] # It must contain exactly 12 digits. [Done] # It must contain only digits from (0-9). # It must not have more than three repeated consecutive digits. # It may have digits in a group of four separated by one hyphen “-” and other sep...
94f6592cc1593840b2126d3fc17b35cd7c448a2d
federicoparroni/SpeedsPrediction_DataMining
/src/preprocessing/distances.py
4,700
3.578125
4
from src import data from src.utils.folder import create_if_does_not_exist """ build a dictionary where: key: station id value: dictionary where: key: station_id value: estimated distance between the two stations returns the dictionary """ def compute_meteo_station_distances(di...
389d1239ff2958e7ebd6c11965c3336c24ba618c
Kawser-nerd/CLCDSA
/Source Codes/CodeJamData/12/21/3.py
1,514
3.5
4
# -*- coding: utf-8 -*- # <nbformat>3</nbformat> # <codecell> def readline_ints(): return [int(num) for num in fin.readline().strip().split()] # <codecell> from collections import Counter def tideline(scores, X): cc = Counter(scores) #print(cc) floating = 0 for score in range(max(scores)+1): ...
d45b163a75c9407077701c0bef9399da5ac37803
Lithika-Ramesh/Amaatra-Grade-12-Lab-Programs
/practice programs/program2.py
186
4.1875
4
# 2 . WAP to find if a no. is odd or even. def check(n): if n%2==0: return "even" else : return "odd" n = int(input("enter the number")) print (n,"is",check(n))
32f865c7ead45a6ca6e2f40ce443f32d9f1f7963
akshaali/Competitive-Programming-
/Hackerrank/TaumandB'day.py
3,734
4
4
""" Taum is planning to celebrate the birthday of his friend, Diksha. There are two types of gifts that Diksha wants from Taum: one is black and the other is white. To make her happy, Taum has to buy black gifts and white gifts. The cost of each black gift is units. The cost of every white gift is units. The cost ...
2b3d1189aade700271643a160dccdc9be07e7efa
avtokit2700/resume
/resume-codewars/braser.py
768
4.21875
4
""" validBraces( "(){}[]" ) => returns true validBraces( "(}" ) => returns false validBraces( "[(])" ) => returns false validBraces( "([{}])" ) => returns true '([}{])' - False ')(}{][' - False """ def validBraces(string): bracer = [] pardict = {"{":"}", "[":"]", "(":")", "}":"{", "]":"[", ")":"("} for i i...
e0d3910a9018ac8e4b8bc35cf9160cdcf0c694db
pepinu/Goodrich-Tamassia-Python
/Chapter1/R-1.2.py
127
3.5625
4
def is_even(k): if k & 1: return False return True print(is_even(1)) print(is_even(2)) print(is_even(3)) print(is_even(4))
b0e67f9f15117a4fa946778912fa7d2dea10898a
JIC-CSB/jicgeometry
/jicgeometry/__init__.py
8,131
4.15625
4
"""Module for geometric operations. The module contains two classes to perform geometric operations in 2D and 3D space: - :class:`jicgeometry.Point2D` - :class:`jicgeometry.Point3D` A 2D point can be generated using a pair of x, y coordinates. >>> p1 = Point2D(3, 0) Alternatively, a 2D point can be created from a ...
ad7d8fde249b36f997c7e160f0ac1ca5d809f919
LucasZapico/rabbit
/space.py
16,539
4.53125
5
print("Welcome to our Solar System!") name = input('What is your name? ') print("Hi," + name + "!") print("Whenever we see a star \"*\" press enter when you're ready to move on, lets try now, press enter!") star = input('*') print("Our Solar System is a very large and complex place. It is composed of eight planets, one...
f0612730e3090368de56ef91c9ca5614d088b9d1
hjalves/project-euler
/problems1-25/problem3.py
452
3.84375
4
#!/usr/bin/env python3 #-*- coding: utf-8 -*- """ Project Euler - Problem 3 Largest prime factor """ def is_prime(n): return all(n % i != 0 for i in range(2, int(n**0.5)+1)) def primes(max): return filter(is_prime, range(2, max+1)) def factors(n): return (p for p in primes(n) if n % p == 0) def factori...
b146391b80addb994e1e60d191a6c168e89b9f07
sonymoon/algorithm
/src/main/python/geeksforgeeks/graph/union-find to check cycle of graph.py
1,161
3.984375
4
from collections import defaultdict class Graph: def __init__(self, vertices): self.V = vertices self.graph = defaultdict(list) # default dictionary to store graph def add_edge(self, u, v): self.graph[u].append(v) def find_parent(self, parent, i): if parent[i] == - 1: ...
d0a490b5d2172dd1b5ed380102f8ad160278827c
ayu7/csprag-ahw8
/rpn.py
1,171
3.5625
4
#!/usr/bin/env python3 import operator import readline import colorama operators = { '+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.truediv, } RED = '\033[31m' BLUE = '\u001b[44m' MAGENTA = '\u001b[35m' RESET = '\033[0m' def calculate(myarg): stack = list() for token ...
e65aaf15cad301442ffef19143a5c5e57ea17cc4
kkwietniewski/Python
/Pai/zad1.py
311
3.984375
4
numbers={'1':"Jeden",'2':"Dwa",'3':"Trzy",'4':"Cztery",'5':"Pięć",'6':"Sześć", '7':"Siedem",'8':"Osiem",'9':"Dziewięć",'0':"Zero"} string = input("Podaj ciąg cyfr do przekształcenia na string: ") result = '' for i in string: if i.isnumeric() == True: result += ' '+numbers[i] print(result)
61b1ce16eab2158d88ab2422a29b0efa81bd0532
mjms3/helo
/esp/tests/test_dijkstra.py
857
3.625
4
from math import sqrt from unittest import TestCase from esp.dijkstra import dijkstra class TestDijkstra(TestCase): def test_shortestPathBetweenTwoVertices_isTheJoiningEdge(self): graph = [(0, 1, 1)] cost, path = dijkstra(graph, 0, 1) self.assertEqual(1, cost) self.assertEqual((0...
73a37012daf82c8081875d2cd1dee8312e116651
Lakshya31/BasicGeneticAlgorithm
/Basic_GA.py
6,989
4
4
""" This is a program to demonstrate working of basic genetic algorithm which is searching for the least valued points in the graph of sin(x^2), hope you like it! ^_^ Once the run is complete, you can go to the "Output" folder and slideshow the output Images in order of Generation to visualize the changes """ # Made ...
9f83691ec54ed903b08e84ce2ce412801fa4f037
sasidhara222/Ansible
/Python Programming/Okati/Print.py
1,454
3.875
4
print('Mi Daddy') print(4 / 9) print(200*9336) print('Hello..! Hello..! ani anipinchave gundello...') print("swing zara swing zara... 'swing'") print("Apudye ipoindi anukunavemo...! Epudye modalindi.. Epudye modalindiiiii....!") balaya = "Jai" jai = "Balaya" print(balaya + jai) #Dinthali print(balaya+" "+jai) print("T...