blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
2d0077b3dc92eff29d02c0079053fa4694b5b5e9
felipeonf/Exercises_Python
/curso_py/ex078.py
987
3.921875
4
def leiaInt(mensagem): while True: try: inteiro = int(input(mensagem)) except (ValueError,TypeError): print('\033[0;31mERRO! Digite um inteiro válido!\033[m') continue except KeyboardInterrupt: print('O usuário optou por não escolher ne...
a9d4eb0105738895258ca87b9109fb79b1e03c5e
felipeonf/Exercises_Python
/curso_py/ex007.py
128
3.71875
4
nome = input('Digite seu nome completo: ') sep = nome.split() print(f'Primeiro nome: {sep[0]}\nÚltimo nome: {sep[-1]}')
498e5de107f3c6838ecafc701ada311aba4243e4
AnnaPL8/python-challenge
/PyPoll/main.py
1,796
4
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Feb 13 10:31:18 2019 @author: user """ import pandas as pd df = pd.read_csv("Resources/election_data.csv") print(df.head()) size = df.shape rows = size[0] print(rows) # A complete list of candidates who received votes received_votes = df["Candidate...
e5830a0f8e95a3136a05cd77aeb38aab409ffd91
GeovaniSTS/PythonCode
/841 - Acima_Média.py
195
3.671875
4
A = float(input()) B = float(input()) C = float(input()) media = (A + B + C) / 3 sup = 0 if A > media: sup += 1 if B > media: sup += 1 if C > media: sup += 1 print(sup)
d769092a52c20b982f5d39d42fc9e7045f54f5a0
GeovaniSTS/PythonCode
/49 - Classificação_Triângulos.py
253
4.03125
4
L1 = float(input()) L2 = float(input()) L3 = float(input()) if L1 == L2 and L1 == L3 and L2 == L3: print('equilatero') else: if L1 == L2 or L1 == L3 or L2 == L3: print('isosceles') if L1 != L2 and L1 != L3 and L2 != L3: print('escaleno')
a5ad11bafd37e25d9ece2d1c74b92dc2548d1ddb
GeovaniSTS/PythonCode
/269 - Meses_Extenso.py
216
3.84375
4
Mês = ["janeiro","fevereiro","marco","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"] Data = int(input()) if (1<= Data <=12): print(Mês[Data - 1]) else: print('invalido')
19167e2a00bca8a135c5d69f0a61890b0d0537dd
GeovaniSTS/PythonCode
/1991 - Conta_Luz.py
173
3.546875
4
X = float(input()) A = (X*1.5) B = (A*0.15) C = A-B print('Valor a ser pago: R$', '%.2f' %A, 'reais') print('Valor a ser pago com desconto: R$', '%.2f' %C, 'reais')
72e2b5c8d87effc112414b8297effe9186d085f6
GeovaniSTS/PythonCode
/368 - Salario_Trabalhadores.py
216
3.8125
4
salario = float(input()) if salario > 500: salario = salario + (salario * 0.10) elif salario > 300: salario = salario + (salario * 0.07) else: salario = salario + (salario * 0.05) print('%.2f'%salario)
cc424a0ff9622132cf3fa8f2b5cee0e6ce1241f8
DKassai/Artificial-Intelligence-
/AI_Assignment1/A_search.py
1,010
3.84375
4
import binary_heap.binary_heap as heap import binary_heap.node as node open_list=heap.Heap([start_node]) shortest_path = [] closed_list = [] ''' hey its your AI talking, i know what you did, dont do it again ''' def A_search (start_node, end_node): if start_node=end_node: shortest_path.append(end_node) temp = en...
2e1642b3684368fc7ae775b76190fa12da5aa201
BalaIyyappan/Guvi-CodeKata
/Absolute Beginner/No. of days in any month.py
146
3.65625
4
month={1:31,2:28,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31} m=int(input()) if m<=12 and m>=1: print(month[m]) else: print("Error")
d3b1cdd6a16776fce4373e8d296506d627cdc307
BalaIyyappan/Guvi-CodeKata
/Absolute Beginner/Length of words without White spaces.py
64
3.515625
4
name=input().split() l=0 for i in name: l=l+len(i) print(l)
a2ed4e320f707f48e7769e42a7c8c9159b2d220a
sy12fq/Pascal-Triangle-Printer
/pscal.py
804
3.6875
4
'''Probably the worst way to print out Pascal Triangle''' a1 = {0: {0: 0, 1: 0}, 1: {0:0,1:1,2:0}} def return_dict(a_list): c = {} b = '' for i in range(1, len(a_list)): b = ' '.join([str(x) for x in a_list[i].values() if x!=0]) c[i] = b b ='' return c def print1(x): #x is a dict #like {1: '1', 2: '1 1', ...
f4f55b79e13e837b70a78276d92ff952c8f0d243
MichaelBoegner/algorithms-heatmap-fix
/climbing_stairs/climbing_stairs.py
1,653
3.640625
4
#!/usr/bin/python import sys #Built dict determining the base number of whole actions possible for each option of 3,2,1 respectively #Next step is to iterate over n - base number of whole actions and the subsequent permutations to get n to 0 #if options[3] > 0, then n - (3 * permutation(options[3])) and then recurs...
63cd24b386df26cf2c77ef9961f78353269517c7
arefrazavi/rf_problem_solving
/python/search/pairs/pairs_slow.py
710
3.6875
4
#!/bin/python3 import math import os import random import re import sys # Complete the pairs function below. def pairs(difference, arr): arr = sorted(arr) arr_len = len(arr) difference_count = 0 for i in range(arr_len-1): j = i + 1 while j < arr_len and (arr[j] - arr[i]) <= difference...
037fb32e3872af5b7b2711cbac652d70e3a87314
arefrazavi/rf_problem_solving
/python/search/red_knights_shortest_path/red_knights_shortest_path.py
3,457
3.65625
4
#!/bin/python3 import queue from pprint import pprint # Complete the printShortestPath function below. def printShortestPath(n, i_start, j_start, i_end, j_end): start_cell = [i_start, j_start] bfs_queue = queue.Queue() bfs_queue.put(start_cell) visited = {get_cell_id(start_cell[0], start_cell[1]): {'...
6af64eb6f5619efdba1f042a1aa2d69bd097fe13
arefrazavi/rf_problem_solving
/python/graph_theory/dijkstra_shortest_reach_2/dijkstra_shortest_reach_2.py
3,564
4
4
#!/bin/python3 from queue import PriorityQueue from pprint import pprint class Graph: def __init__(self, nodes_count: int = None, edge_list=None): self.nodes_count = nodes_count self.set_edges(edge_list) def set_edges(self, edge_list: list) -> None: """ Set edges in for Graph...
c5c6bdcde7d17fe1b376a61a308f5566d99d6372
arefrazavi/rf_problem_solving
/python/tree/is_bst_tree/is_bst_tree.py
1,525
3.90625
4
# https://www.hackerrank.com/challenges/ctci-is-binary-search-tree/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=trees """ Node is defined as class node: def __init__(self, data): self.data = data self.left = None self.right = None """ import sys...
f4759061374df10a39c2596280edf0218413242b
arefrazavi/rf_problem_solving
/python/strings/sherlock_and_valid_string/sherlock_and_valid_string.py
1,235
3.90625
4
#!/bin/python3 import os from collections import defaultdict, Counter def get_mode(arr): items_count = Counter(arr) return items_count.most_common(1)[0][0] # Complete the isValid function below. def isValid(string): chars_freq = defaultdict(lambda: 0) # Enumerate frequency of every character in the...
3697d28ffac352595ea539b06fec0c48581c3548
Lomovskoy/Python-quick-start
/Программа 2/colored circles.py
812
4.0625
4
# coding: utf-8 import turtle, random # Скрость черепашки turtle.speed(0) answer = '' while answer != 'N' or answer != 'n': answer = turtle.textinput("Нарисовать окружность","Y/N") if answer == 'Y' or answer == 'y': # Отрыв пера turtle.penup() # Определяем коардинату центра ...
182c03556c2286e129e28bf841c8add409dff733
Minorias/info-f-203
/graph.py
3,672
3.546875
4
from algorithms import * from itertools import chain class Node: def __init__(self,name): self.name = name self.creditors = [] self.debtors = [] def add_creditor(self, creditor, amount): self.creditors.append([creditor, amount]) def add_debtor(self,creditor): self....
a92a3175dd31bf1a000f00d48f1b9391c461b249
haohouh/leetcode
/sort1/NeedwriteAgainInsertionSort.py
298
4.0625
4
def insertionSort(nums): for i in range(len(nums)): cur = nums[i] j = i while j > 0 and cur < nums[j-1]: nums[j] = nums[j-1] j = j - 1 nums[j] = cur if __name__ == "__main__": a = [7,5,6,2,3,1] insertionSort(a) print (a)
b204d42dd18f31274f3e82c3ce6955f01b72a954
haohouh/leetcode
/difficultQuestion/1008ConstructBinarySearchTreefromPreorderTraversal.py
755
3.53125
4
class TreeNode(object): def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution(object): def __init__(self): self.index = 0 def bstFromPreorder(self, preorder): """ :type preorder: List[int] ...
9c991061cbde8975c2a42256804931919169a7cb
jameson401/cat_collector
/main.py
2,134
4.09375
4
#Jameson Smith #Cat Collector v 1.0 #imports import cat import threading #start start_input= input("\nWelcome to Cat Collector!\nPress enter key to start or press (1) to enter the tutorial\n") #tutorial if start_input == "1": print("Cat collector is a game based around creating a collection of cats\n-You start of...
62db7453dc5e4d247cf8d65e50007c1329384c0d
harmbrugge/Bio-informatica
/Thema05/blast_xml_parser.py
7,123
3.5
4
#!/usr/bin/python ''' Reads a BLAST XML output file and inserts relevant information into the database Parsing XML BLAST output using BioPythons NCBI XML parser results in a generator object, i.e. it will give a new result (blast record) each time the records.next() function is called. Two use cases are either conver...
babf8c3dd697855e07a7705f823c89751b558534
richardbradshaw/Nashville_Weather
/ObservedWeather3Day.py
3,093
3.53125
4
#!/usr/bin/env python # coding: utf-8 # In[1]: import pandas as pd import requests # In[2]: # get the data from the url, then parse it as a DataFrame url = 'https://w1.weather.gov/data/obhistory/KBNA.html' r = requests.get(url) df_list = pd.read_html(r.text) # this parses all the tables in webpages to a list dat...
cc371a0909359db74943b719b322217ed82dfce5
Ray-227/Resume-Prototype-CV-
/task-1.py
200
3.640625
4
def squirrel(n): if (n < 0): return 'Error: n < 0, please enter n > 0' factorial = 1; for i in range(n, 0, -1): factorial *= i return int( str(factorial)[0] )
94b625a1cf4091617f2d8bc2f0b5f30a16a1e646
Nilofur/guvi_codekata
/pm7.py
60
3.5
4
n=input() a=0 for i in range(1,n+1): a=a+i print a
e4a053bdab80b99e8eb8ee641a0bd9e483e9cc55
AnnaPetrukhina/fastapi_count_of_avito_ads
/parser_avito/translit.py
1,545
3.546875
4
import re DICTIONARY = { 'а': 'a', 'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd', 'е': 'e', 'ё': 'e', 'ж': 'zh', 'з': 'z', 'и': 'i', 'й': 'y', 'к': 'k', 'л': 'l', 'м': 'm', 'н': 'n', 'о': 'o', 'п': 'p', 'р': 'r', 'с': 's', 'т': 't', 'у': 'u',...
23b19001d32d77a4bf93c6acb59d9a9b55306348
deivondionisio/Praticas-de-Python
/exercicio3.py
183
3.921875
4
def main(): a = input("Digite o primeiro numero: ") b = input("Digite o segundo numero: ") soma = a + b print("A soma de", a, "+", b, "eh igual a", soma) main()
3397c64a5a1c399cb2709db828b2bf56f0a3ec45
montenegrodaniel/criptoanalisis-por-frecuencia
/euler.py
717
3.921875
4
#!/usr/bin/python # -*- coding: utf8 -*- import os, sys def funceuler(primo): ###funcion revisionprimos recibe un valor v_1=int(primo)##convierte la entrada en un entero i=2 res=(i**(v_1-1)) %v_1 #aplica formula fermat print ("\n\tPhi = (",v_1,"- 1 )") print ("\tPhi = ",v_1-1) print("\n\tFormula Euler...
9a3f7f7a8d2699407e10cefbede7cc3c4efe0990
xiepanpan/PythonLearning
/hello.py
4,292
3.765625
4
#coding=utf-8 def hello(): print("hello world") def word(): print("world") # 切片-------------------------- L=range(10) # 复制list print L[:] # 每隔两个取值 print L[::2] # 前五个每隔三个取值 print L[:5:3] # 取第四个到第七个数 print L[3:7] # 迭代------------------------------- from collections import Iterable print(isinstance("abc",Iterable...
dbe72a5f7037ec791dc78cadbae4e1bd712e13f4
xiepanpan/PythonLearning
/DicAndTime.py
2,753
3.828125
4
# -- coding: utf-8 -- # 访问字典里的值 dict ={'name':'Zara','age':22,'class':'First'}; print "字典dic的name值为",dict['name']; print "dic['age']:",dict['age']; # 修改字典 dict["age"]=27; dict["school"]="sdau"; print "dict['age']:",dict['age']; print "dict['school']:",dict['school']; # 删除字典 del dict['name']; dict.clear(); del dict; ...
4c9a61c49b40cf102b42d48eccd8c2e1653c715d
jplhanna/TBD
/parser.py
858
3.875
4
import csv ''' MovieParser: Method meant to parse through a csv file containing information scraped from imdb on films input: text_File: A string which holds the location of the csv file which is going to be parsed output: A list of tupples containing all of the important movie information which is in th...
b87b2f31ddd7442a8a1f2eb09707c05f2cba5c20
getrealzx/python
/class.py
15,867
4.03125
4
#################################### ###functions # def greeting(n): # if n==1: # print("hello world") # if n>1: # print("hello 2 worlds") # greeting(1) # def printnames(): # print("Shu") # print("Thomas") # print("Gustavo") # print("Alim") # print("Day 1: Students in SR...
ed71225c661ce3dca0a1ea5a7b9a92b00bdd5529
FraiVadim/Instructiunea_While
/while 4.py
235
3.703125
4
a=0 s=0 ori=0 n=int(input("dati numarul: ")) while ori<n: ori+=1 s=ori+a a=s print("suma este",s) b=1 p=0 ori=0 while ori<n: ori+=1 p=ori*b b=p print("produsul este",p) print("media este",s/n)
ef3c800a607ea8736198c4fc073f42939892a6ec
mlzxy/blocks
/utils/base.py
485
3.875
4
def unique_list(lst, key=lambda x: x): """ remove redundant items in a list """ d = {} for v in lst: d[key(v)] = d return [v for v in d.values()] def prod_list(lst): """ calculate the multiply of all items in a list """ p = 1 for i in lst: p *= i retur...
d45e8daff6f499be1a43ac234845e33d911e1c76
SavinaRoja/challenges
/Rosalind/Probability/IPRB.py
3,586
4.5
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """Mendel's First Law Usage: IPRB.py <input> IPRB.py (--help | --version) Options: -h --help show this help message and exit -v --version show version and exit """ problem_description = """Mendel's First Law Problem Probability is the mathematical stu...
8d63dc7d36aca415802f58654e76dfbb210a78fb
SavinaRoja/challenges
/Rosalind/String_Algorithms/LCSM.py
3,438
3.6875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """Finding a Shared Motif Usage: LCSM.py <input> LCSM.py (--help | --version) Options: -h --help show this help message and exit -v --version show version and exit """ problem_description = """Finding a Shared Motif Problem A common substring of a col...
620d2dd1eeb665c2ee04e35300041cdc294b368e
SavinaRoja/challenges
/Rosalind/Bioinformatics_Tools/PBMD.py
5,274
3.515625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """PubMed Search Usage: PBMD.py <input> <email> PBMD.py (--help | --version) Arguments: <input> A file containing two lines, author name first, year second. <email> An email address for the submission of requests to Entrez. Options: -h --help ...
8c87a53efb7c39a5fea62cee6005d69d2af7d406
SavinaRoja/challenges
/Project_Euler/1-10/PE_8.py
1,112
3.828125
4
#Problem 8 from Project Euler #Solution by Paul Barton # #Here is the text of the problem: #Find the greatest product of five consecutive digits in the 1000-digit number. # 7316717653133...420752963450 #(I stored the full number in the text file named "PE_8.txt") # #My strategy is to simply parse the number into a l...
c79d3b145e364cf22a65b611763c3b6cca1a0401
SavinaRoja/challenges
/Project_Euler/1-10/PE_3.py
2,379
3.78125
4
#Problem 3 from Project Euler #Solution by Paul Barton # #Here is the text of the problem: #The prime factors of 13195 are 5, 7, 13 and 29. #What is the largest prime factor of the number 600851475143 ? # #This problem requires one to find the prime factors of a number and return the #largest of them. Efficiency for fi...
7bc09ed3640e3f0e32e2ea12725a65cb87d6d39f
SavinaRoja/challenges
/Rosalind/String_Algorithms/RNA.py
2,275
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """Transcribing DNA into RNA Usage: RNA.py <input> [--compare] RNA.py (--help | --version) Options: --compare run a speed comparison of various methods -h --help show this help message and exit -v --version show version and exit """ problem_desc...
6148c3bd4886cae86d600d6f41095f3120ee7e22
penguinsR-cool/Carpe-Diem
/server/dbinit.py
285
3.578125
4
import sqlite3 as sql import sys sqlFile = 'data.db' connection = sql.connect(sqlFile) c = connection.cursor() c.execute('''CREATE TABLE data(type varchar(1), year varchar(2), month varchar(2), day varchar(2), hour varchar(2), min varchar(2), sec varchar(2))''') connection.close()
b7e4b0cc6f542d71952de38302ca628d3ed03e2b
oidebrett/PythonTraining
/Code Samples/Section 3 - Strings/stringAdditionMultiplicationp71.py
211
3.859375
4
word1 = "Leaving" word2 = "Certificate" word3 = "Computer" word4 = "Science" subjectName = word1 + word2 + word3 + word4 print(subjectName) word1 = "Hello" print(word1*3) print(word1[1]*3) print(word1[1:3]*3)
2457e695ead7eea49cdf10b2fc832363d36b4fe0
oidebrett/PythonTraining
/Code Samples/Section 3 - Strings/stringMethodsp80.py
347
4.03125
4
#Program to demo the use of common string methhods pangram = "the quick brown fox jumps over the lazy dog!" print(pangram.capitalize()) print(pangram.upper()) print(pangram.isupper()) print(pangram.islower()) print(pangram.count('o')) print(pangram.find("fox")) print(pangram.find("Fox")) print(pangram.find("the")) pr...
0bf3ae3673294d238a369bf9cd742f2edd55b6a3
indikaimk/learn_python
/advanced/defaulat_dictionary.py
698
3.875
4
import collections from collections import defaultdict def main(): fruits = ['apple', 'pear', 'bananas', 'cherry', 'avacado', 'apple'] fruitCounter = {} for fruit in fruits: if fruit in fruitCounter: fruitCounter[fruit] += 1 else: fruitCounter[fruit] = 1 print(f...
1471af7d5c1b3d0dee0f37f1499883917882637e
indikaimk/learn_python
/advanced/counters.py
589
3.609375
4
from collections import Counter def main(): class1 = ["Bob", "Marc", "Jane", "Johanna", "Katy", "Tom"] class2 = ["Bill", "Marc", "Chan", "Jonny", "Katy", "Phil"] c1 = Counter(class1) c2 = Counter(class2) print(c1['Jane']) print(sum(c1.values()), "students in class 1") c1.update(class2) ...
2209d2bbfd814cf1043bdc71e0e8bba640eae148
indikaimk/learn_python
/advanced/transforms.py
1,033
3.71875
4
def filterFunc(x): if x % 2 == 0: return False return True def filterFunc2(x): if x.isupper(): return False return True def squreFunc(x): return x**2 def toGrades(x): if (x >= 90): return "A" elif (x >=80 and x < 90): return "B" elif (x >= 70 and x < 80...
e87005b01f3eddf9bab24d334f2cdf7662f722fc
reddyprasade/A-Criterion-for-Deciding-the-Number-of-Clusters-in-a-Dataset-Based-on-Data-Depth
/Mahalanobisdepth.py
632
3.796875
4
import numpy as np def mahalanobis(x, y, cov=None): """ This function to Find the depth of Tree The Mahalanobis depth (MD) function is proposed by Liu and Singh18 and it is based on the well-known Mahalanobis distance de¯ned by Mahalanobis.19 MD of a point x with respect to a dataset...
83e5ecc24ee6c4c9e386961b0ee64e3e441cd224
irmadong/info303
/Week3/Exercise_Questions.py
7,963
4.46875
4
#Create a tuple containing the names of five countries. #Then, display the entrie tuple #Then, ask the user to enter one of those five countries. #Based on the users selection, display the indxe number (i.e., position in the tuple) #of that item in the tuple import random countries = ("China", "Japan", "England...
39bfae02b05a07e10b3a67eb098a7632f0d5bd58
saimalleshk/advertising
/LR Exercise.py
3,714
3.90625
4
# coding: utf-8 # ## Logistic Regression Project using Advertising dataset # # In this project we will be working with a fake advertising data set, indicating whether or not a particular internet user clicked on an Advertisement. We will try to create a model that will predict whether or not they will click on ad ba...
7eb30e63abf82b80079d02ec492f5926c1b6930e
Paulo201898/Python520
/aula_2/exercicio_1.py
194
3.671875
4
# Fluxo feliz idade = input('Digite a sua idade: ') # Aqui entra a validação de caracter não numérico for letra in idade: if letra not in '0123456789' print('Caracter invalido') exit()
06233a26210b1af5c645935b9b3de4ffbaa38051
DrAdamRoe/networking-basics
/medium-website/scripts/parseForm.py
531
4.0625
4
#!/usr/bin/env python3 # A simple script to accept input from an html form, # parse the information, and do something - which in this case # is to give user feedback with a simple html page. # use python's the CGI package import cgi # get the output of the form. form = cgi.FieldStorage() # get an input filed from t...
412fe3e7b2a1d6534cea974d753223f593c417ab
baihuaxie/ConvLab
/model/build_models.py
950
3.625
4
""" Return a network builder function """ from model.model_utils import mapping from model import resnet def get_network_builder(name): """ Returns the network builer function by name Args: name: (str) name of network builder Returns: (a customized network object) a network objec...
68728bb93a6cd2f379a2f578494df0005d25941d
mlupin/fullstack-nanodegree-movie-site
/media.py
1,434
3.578125
4
import webbrowser class Video(): """class Video is the base 'parent' class of TvShow and Movie""" def __init__(self, title, story, poster, trailer, genre, rating, imdb_rating, stars): self.title = title self.story = story self.poster = poster self.trailer_yout...
1a3ba082313d9b29195d33d31bd7bb98a2e1f390
hiqsol/dotfiles
/bin/format-changelog
479
3.53125
4
#!/usr/bin/env python3 # Converts # - Prefix: First line # - Prefix: Second line # - Other: Third line # - Other: Fourth line # # To # - Prefix: # - First line # - Second line # - Other: # - Third line # - Fourth line import sys prefix = '' for line in sys.stdin: ps = line.strip().split(' ') ...
d122d93baa813af861b12346e82003bdc91e7d47
Jessica-Luis001/shapes.py
/shapes.py
1,042
4.46875
4
from turtle import * import math # Name your Turtle. marie = Turtle() color = input("What color would you like?") sides = input("How many sides would you like?") steps = input("How many steps would you like?") # Set Up your screen and starting position. marie.penup() setup(500,300) x_pos = -250 y_pos = -150 marie.set...
980e19b80c51daebb18c2886779f483758828b0f
KRHero03/College_Labwork
/4th_Year/CNS/Assignment_1/1.py
5,291
3.6875
4
# Sample Text : once upon a time there was a little girl named goldilocks she went for a walk in the forest pretty soon she came upon a house she knocked and when no one answered she walked right in at the table in the kitchen there were three bowls of porridge goldilocks was hungry she tasted the porridge from the fir...
f4f1dd4d988dfc9783c9247a93db60d4a0c15ca8
KRHero03/College_Labwork
/4th_Year/PPL/Assignment_7/2.py
635
3.75
4
import sys class ERRORS: INVALID_ARGS = """Invalid Arguments.\nPlease enter 2 Arguments which are Input File Path and Output File Path respectively.""" def perform_operation(input_file_path, output_file_path): """ Reads input file, and copies content to output file """ with open(input_file_path, '...
51328c66ea416e0688c9bc339cea19baec6b2f84
Byron1993T/Tareas
/laboratotio.py
320
3.828125
4
# -*- coding: utf-8 -*- """ Editor de Spyder Este es un archivo temporal. """ def isPrime (n): for i in range (2,int(n**0.5)+1): if n%i==0: return False return True print (isPrime(3)) for i in range (1, 100): if isPrime (i+ 1): print(i+1)
d7fa13f86bec69f438463b61f37900f900151d06
Byron1993T/Tareas
/Laboratorio 2.py
846
3.9375
4
# -*- coding: utf-8 -*- """ Created on Sat Jan 18 09:10:30 2020 @author: CEC """ def isYearLeap(year): if year % 4 !=0: return False elif year % 100 !=0: return True elif year % 400 !=0: return False else: return True def dasysInMonth(year,month): i...
14feef37c58ca9451c4a28aed22251c5e50d03eb
xelarock/artificial-intelligence
/Project0/python_basics/fruit.py
360
4.03125
4
fruitPrices = {'apples':2.00, 'oranges':1.50, 'pears':1.75} def buyFruit(fruit, numPounds): if fruit not in fruitPrices: print "Sorry we don't have %s" % fruit else: cost = fruitPrices[fruit] * numPounds print 'That will be %f please' % cost if __name__ == '__main__': buyFruit('a...
fc43709d21d604afa5de0a2158ca7331608c3384
bigfoot79/json_api_python
/process_json_data.py
1,556
3.71875
4
# from the sys module, imports the argv function from sys import argv # import the api_call.py module and the get_api function from api_call import get_api # sets the argv variables for when the script is loaded. The script variable is set automatically # the end_point variable is the url endpoint for the json data s...
a2caeff3ae6aefd919808d8c2aef27920f7f4c24
ji-mango/DKU
/1-2/대학기초SW입문/student, teacher class.py
1,135
3.703125
4
class Person: def __init__(self,name,number): self.name=name self.number=number class Student(Person): def __init__(self,name,number,gpa): super().__init__(name,number) self.gpa=gpa self.classes=[] def setGpa(self,gpa): self.gpa=gpa def ...
4f2bc54db7852d2ecd0e2a07b9b70bbc9fac4557
ji-mango/DKU
/1-2/대학기초SW입문/intersecting party member.py
272
3.828125
4
a=input("파티A명단:") b=input("파티B명단:") partyA=set() partyB=set() for s in a.split(): partyA.add(s) for s in b.split(): partyB.add(s) print("2개의 파티에 모두 참석한 사람은 다음과 같습니다.") print(partyA.intersection(partyB))
811e3a772838f339aef75b02c8d94a837218f940
ji-mango/DKU
/1-2/대학기초SW입문/English-Korean dictionary.py
231
4.09375
4
english_dict=dict() english_dict['one']='하나' english_dict['two']='둘' english_dict['three']='셋' english_dict['four']='넷' english_dict['name']='이름' word=input("단어 입력:"); print(english_dict.get(word,'없음'))
fd8aaa8d174f03d51ee1c14f6ccb678bca66fe56
Dzhemile-dzh/SoftuniPython
/oddevensum.py
323
3.859375
4
num = int(input()) odd_sum = 0 even_sum = 0 for i in range(1, num+1): element = int(input()) if i % 2 == 0: even_sum += element else: odd_sum += element if even_sum == odd_sum: print(f'Yes') print(f'Sum = {even_sum}') else: print(f'No') print(f'Diff = {abs(even_sum - odd_sum)...
0ef9f06eba930101f8db8da99c67bbbdbf14fe66
Dzhemile-dzh/SoftuniPython
/scholarship.py
826
3.75
4
import math income = float(input()) avg_result = float(input()) min_salary = float(input()) excellent_result = avg_result * 25 social = 35/100 * min_salary if income > min_salary: if avg_result < 5.50: print('You cannot get a scholarship!') elif avg_result >= 5.50: print(f'You get a scholarship ...
29180ff38a21143f43e7a8ab5acc2a0e6d7424eb
Dzhemile-dzh/SoftuniPython
/journey.py
681
3.703125
4
budget = float(input()) season = input() discount = 0.0 place = '' destination = '' if budget <= 100: destination = 'Bulgaria' if season == 'summer': discount = 30/100 place = 'Camp' elif season == 'winter': discount = 70/100 place = 'Hotel' elif 100 < budget <= 1000: des...
a919b33554456a5bb83c78984d13a8f7cb772c78
69dog/meth
/weawa.py
364
4.09375
4
#import libraries import math # define function def areaofcircle(r): area = math.pi * r * r print ("returning to main program") return (area) # main program radius = float(input("what is the radius of the circle in units?")) print ("radius is", radius, "units") print ("area of your...
ce99b0fd31d9dc4550c583f20105c2ba6c6a9524
he-dong-sheng/Python
/ceshi1.py
149
3.8125
4
# a = [1,2,3] # b = [9,6,1] # for (i,j) in zip(a,b): # print i,j def two(): a = 1 b = 2 return a, b c, d = two() print(c) print(d)
3c3c88674a32b60eddeffb0e8ebf0fa4a11888a4
thomasballinger/adventures-in-text
/tests/room_test.py
2,734
3.53125
4
from scaffolding import Room, Object from properties import Openable, Lightable from objects import Bed, Dresser, Lamp, Chair import unittest class TestRooms(unittest.TestCase): def setUp(self): self.dresser = Dresser() self.bed = Bed() self.lamp = Lamp() ...
c5f73ff80207dbb06f440aee9722454f26eaa1c0
thomasballinger/adventures-in-text
/tests/grammar_test.py
7,649
3.5
4
from grammar import parse, check_noun from objects import Dresser, Bed, Lamp, Chair, UnreachableLamp from scaffolding import Room import unittest class TestGrammar(unittest.TestCase): def setUp(self): self.dresser = Dresser() self.bed = Bed() self.lamp = Lamp() self.chair = Chair()...
14f15835a90bc85b84528f40622ee216d4bfd2a4
GaloisGroupie/Nifty-Things
/custom_sort.py
1,247
4.28125
4
def merge_sort(inputList): """If the input list is length 1 or 0, just return the list because it is already sorted""" inputListLength = len(inputList) if inputListLength == 0 or inputListLength == 1: return inputList """If the list size is greater than 1, recursively break it into 2 pieces and we...
81ec1de88e828036bf878b473fef3dcdc46cc558
GaloisGroupie/Nifty-Things
/powerSet.py
345
3.515625
4
def powerSet(originalSet = list()): powerSetSize = 2**len(originalSet) powerSet = list() for num in range(0, powerSetSize): aSet = list() indexSpot = 0 for x in reversed(list(bin(num)[2:])): if x == '1': aSet.append(originalSet[indexSpot]) indexSpot += 1 powerSet.append(...
f6175b745e4a2f79523f553fc695f73d304203e9
MikaelLennefors/FIBSEM
/file_conversion/tif_to_png.py
970
3.609375
4
import numpy as np import cv2 from libtiff import TIFF # TODO: Change data folder? path = '../data/' save_path = '../data/all_data_384/' def read_tiff(path): ''' Converts a tiff-file to png. The function calls the user to input the porosity of the file to be read. Input: path (str): path to t...
df1fd9bcafa4d85b9b474cea8c2c51bbaf755dd5
khushbu-joshi/khushbu
/server.py
708
3.53125
4
# -*- coding: utf-8 -*- """ Created on Tue Jan 28 20:15:29 2020 @author: Administrator """ import socket def server_program(): target_ip="11.11.29.200" target_port=2623 server_socket = socket.socket() server_socket.bind((target_ip, target_port)) server_socket.listen(2) ...
8b897aee152872f6f4be842fc48d8f1807a794a9
nikitashrestha/Cryptography
/caesarcypher.py
785
3.90625
4
def encode(message,keys): cipher_text = "" for i in range(len(message)): char = message[i] if char.isupper(): cipher_text += chr((ord(char) + keys - 65) % 26 + 65) elif char.islower(): cipher_text += chr((ord(char) + keys - 97) % 26 + 97) elif char.isspace...
211059a5ac483a524cef9d03ce8081318046a1ba
zhangtongqing/pythonDemo
/base/time.py
434
3.78125
4
import time; timestr = time.time(); print(timestr); #时间戳 format1 = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()); #格式化字符串 2018-05-23 17:11:17 format2 = time.strftime("%a %b %d %H:%M:%S %Y", time.localtime()); #格式化字符串 Wed May 23 17:11:17 2018 var1 = "Wed May 23 17:11:17 2018"; format3 = time.mktime(time.str...
7fd5693cd6e035bb230eb535f4d9b0b0a5ce23bf
israel-dryer/Just-for-Fun
/mad_libs.py
2,489
4.125
4
# create a mad-libs | random story generator # randomly select words to create a unique mad-libs story from random import randint import copy # create a dictionary of the words of the type you will use in the story word_dict = { 'adjective':['greedy','abrasive','grubby','groovy','rich','harsh','tasty','slow'], ...
0f6709a24d339e922f2ad628cdadc9df86e6b0f4
nilavya2000/my_python
/translate/trans.py
98
3.609375
4
import goslate a=goslate.Goslate() b=input("enter the word : ") c=a.translate(b,'fr') print(c)
221695815c4c056431e7eba56370a4eb95c163a8
Yexun/Learning-Python
/Pascal's Triangle.py
762
3.71875
4
# Print out Pascal's Triangle # Used for loop,I think I need a little more time to use generator def triangles(x): a=[1] print(a) for i in range(x): i=len(a)-1 if i>0: while i>0: a[i]=a[i]+a[i-1] i-=1 a+=[1] print(a) else: a+=[1] print(a) triangles(int(input("input number: "))) # This t...
76373ff62c831529c63e2dd4a90ef11a915feeb6
realRichard/-offer
/chapterTwo/algorithmsAndDataManipulation/bitOperation/1.1.py
981
3.765625
4
''' 题目: 请实现一个函数,输入一个整数,输出该数二进制表示中1的个数。例如,把9表示成二进制是1001,有2位是1,。因此,如果输入9, 则该函数输出2。 ''' # def number_of_one(n): # if not isinstance(n, int): # raise TypeError # count = 0 # i = 0 # temp = 2 ** i # while temp <= n: # if n & temp: # count += 1 # i += 1 # tem...
77880b47cdee8a932178e143e5d077c4e7827b9f
realRichard/-offer
/chapterTwo/dataStructure/replaceBlank/replace_blank.py
433
3.5
4
''' 题目:请实现一个函数,将一个字符串中的空格替换成“%20”。 例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy ''' def test(): foo = 'We are happy.' # good result1 = foo.replace(' ', '%20') print(foo, result1) # good result2 = ''.join(c if c != ' ' else '%20' for c in foo) print(foo, result2) if __name__ == '__...
7fb50858a64aacd7b4054f2b9b2b158f62c6f87d
realRichard/-offer
/chapterThree/robust/findKthToTail/find_middle_node.py
1,432
4.09375
4
''' 求链表的中间节点。 如果链表中的节点总数为奇数, 则返回中间节点, 如果节点总数是偶数, 则返回中间节点两个节点的任意一个 ''' ''' 一个指针一次走一步, 另一个指针一次走两步 ''' class Node(object): def __init__(self, value=None, next=None): self.value = value self.next = next def __str__(self): return str(self.value) class LinkedList(object): ...
fb80ac83167377b6fde738dbc60298cd53938593
realRichard/-offer
/chapterTwo/dataStructure/nextNode/next_node.py
4,857
3.921875
4
''' 题目: 给定一个二叉树和其中的一个结点,请找出中序遍历顺序的下一个结点并且返回。注意,树中的结点不仅包含左右子结点, 同时包含指向父结点的指针。 ''' class TreeNode(object): def __init__(self, value=None, parent=None, left=None, right=None): self.value = value self.parent = parent self.left = left self.right = right def __repr__(self): ...
9ac5711f63b7e93b3c5a0a6def6068840ca5036b
realRichard/-offer
/chapterFive/timeEfficiency/minNumber/1.1.py
606
3.5
4
''' 题目: 输入一个正整数数组,把数组里所有数字拼接起来排成一个数, 打印能拼接处的所有数字中最小的一个。例如,输入数组{33,32,321}, 则打印出这3个数字能排成的最小数字321323。 ''' from functools import cmp_to_key def min_number(arr): if not isinstance(arr, list): raise TypeError key = cmp_to_key(lambda x, y: int(x + y) - int(y + x)) res = ''.join(sorted(map(s...
50ba8a35e00260d39f4c1ff996e0bb3b09aa2e91
realRichard/-offer
/chapterTwo/algorithmsAndDataManipulation/recursiveAndIterative/1.1.py
364
3.921875
4
''' 题目:求斐波那契数列的第n项 ''' # recursive def fibonacci(n): if n < 0: print('invalid input') return None if n == 0: return 0 elif n == 1: return 1 return fibonacci(n - 1) + fibonacci(n - 2) def test(): for i in range(33): print(fibonacci(i)) if __name__ == '__m...
0added61c4f425ef880838b3d5409792676b7ffc
realRichard/-offer
/chapterFive/timeEfficiency/longestSubStringWithoutDuplication/longest_subString_without_duplication.py
1,849
3.90625
4
''' 题目: 请从字符串中找出一个最长的不包含重复字符的子字符串,计算该最长子字符串的长度。 假设字符串中只包含‘a’~‘z’的字符。例如,在字符串”arabcacfr“中, 最长的不含重复字符的子字符串是“acfr”,长度为4。 ''' def longest_subString_without_duplication(string): if not isinstance(string, str): raise TypeError # position 用来更新每个字母在字符串中再次出现位置的索引, -1 表示还未出现 # position = [-1] * ...
86ba4be2a95388b188281c01d914626173612159
realRichard/-offer
/chapterThree/robust/mergeOrderLinkList/merge.py
1,755
3.9375
4
''' 题目:输入两个递增排序的链表,合并这两个链表并使新链表中的节点仍然是递增排序的。例如,输入如下的链表1和链表2,则合并之后的升序链表如链表3所示。 链表1:1-->3-->5-->7 链表2:2-->4-->6-->8 链表3:1-->2-->3-->4-->5-->6-->7-->8 ''' class Node(object): def __init__(self, value=None, next=None): self.value = value self.next = next def __str__(self): ret...
37ae8644ebe355a829433e96a4b5cba4fa1e45af
realRichard/-offer
/chapterThree/robust/reverseLinkList/reverse_linkList.py
1,847
4.28125
4
''' 题目: 定义一个函数,输入一个链表的头节点,反转该链表并输出反转后链表的头节点。 ''' class Node(object): def __init__(self, value=None, next=None): self.value = value self.next = next def __str__(self): return str(self.value) class LinkedList(object): def __init__(self): self.header = None def ins...
8ef70ddc22fb812076182dde41eb7d89ee53b86b
realRichard/-offer
/chapterFive/timeEfficiency/leastNumbers/1.1.py
509
3.78125
4
''' 题目: 输入n个整数,找出其中最小的K个数。 例如输入4,5,1,6,2,7,3,8这8个数字, 则最小的4个数字是1,2,3,4,。 ''' ''' 最简单的思路把输入的 n 个整数排序, 排序之后位于最前面的 k 个数就是最小的 k 个数 ''' # time O(nlogn) def least_numbers(arr, k): arr.sort() return arr[:k] def test(): arr = [4, 5, 1, 6, 2, 7, 3, 8] least = least_numbers(arr, 4) print(l...
d3c7edb0d744f444329b35d7e6e12c33db3e0102
AntoineLegrain/ProjetsCampusNumerique
/1_python/affichage.py
2,308
3.546875
4
#!/usr/bin/env python3 from random import choice from turtle import * fenetre = Screen() # la fenetre d'affichage valeurs = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'V', 'D', 'R', 'A'] couleurs = ['P', 'C', 'K', 'T'] # On charge toutes les images des cartes dans le dictionnaire _carte_ carte = {} for c in co...
6c8dc297281f24bebf43450d31fd28a6eccc19e3
ciceropzr/DesafiosPython
/maior.py
441
3.96875
4
n1 = int(input('N1 =>')) n2 = int(input('N2 =>')) n3 = int(input('N3 =>')) def maior(): if n1 > n2 and n1 > n3: print(n1) elif n2 > n1 and n2 > n3: print(n2) elif n3 > n1 and n3 > n2: print(n3) else: print('Tds maiores iguais') def menor(): if n1 < n2 and n3: print(n1) elif n2 < n...
18781240da7925614cb8b27ce7d25e526558dd89
ciceropzr/DesafiosPython
/sorteio2.py
317
4
4
''' Crie um programa que sorteia um valor entre 1 e 30 e receba um valor do usuario, se o usuario acetar exiba uma mensagem parabenizando ''' import random numero = random.randint(1, 30) tentativa = int(input('Digite um numero: ')) if numero == tentativa: print('Acertou!') else: print('Não foi dessa vez!')
a40082b1f88aab52a9b47c2bf79fa85aafddce0e
ciceropzr/DesafiosPython
/numeros.py
317
4.25
4
x = int(input('Insira um número => ')) if x < 0 and x % -2 == -1: print('Número negativo impar') elif x < 0 and x % -2 == 0: print(' Número negativo par') elif x % 2 == 0 and x != 0: print(' Número positivo par') elif x == 0: print('Zero é NULOOOOOOOO....') else: print('Número positivo impar')
7f7cd78a9b522cba5c0ca9d2285ce58cf9d9dd42
heibanke/learn_python_in_15days
/Code/day04/guess_number.py
1,210
3.875
4
#!/usr/bin/env python # coding: utf-8 #copyRight by heibanke from __future__ import print_function from __future__ import unicode_literals from builtins import input import random # 1. 随机产生要猜的数字 # Your code1 secret = random.randint(1, 100) guess = 0 print("你好, 你很幸运, 我是一个路过的神仙, 我有一个秘密!") print("我的秘密是一个...
576636ae28db9f868db966ac7fd375083a8d6ef6
shornikovkir/lesson1
/price.py
357
3.609375
4
def get_summ (one, two, delimiter='&'): get_summ_count = one+delimiter+two print(get_summ_count) return get_summ_count # one='kk' # two='tyuu' # delimeter='&' # get_summ_count = one+delimiter+two # print(get_summ_count) # one2= get_summ_count one2=get_summ('kk', 'tyuu') print(one2) start=get_summ('lear...
066fac2379c7131dac8ab2e64b1e8d31f7142c23
rexcheng1997/cracker-collection
/zip-cracker/generator.py
888
3.953125
4
""" python 3 - Generator Module """ __author__ = "rexcheng1997" from functools import reduce def generator(_plen, _characters): ''' Generate all permutations of passwords of length = _plen, using the characters in _characters. Attributes: - _plen: length of the p...
55776f54cfe7ebf023ce730debb47596de4e0d1c
raginigupta6/data-structures-and-algorithms-implementation-in-Python
/String/344. Reverse string.py
392
3.640625
4
class Solution: def __init__(self, s): self.s = s def reverseString(self): """ Do not return anything, modify s in-place instead. """ n = len(self.s) for i in range(n//2): self.s[i], self.s[n-i-1] = self.s[n-i-1], self.s[i] return self.s s =...