blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
bb3fadcb3d1bceeaedd473ef4d69fa99a79246a4 | rosita-hormann/programacion-basica-python | /MATRICES/mouse_maze/solucion.py | 8,186 | 3.6875 | 4 | """
SOLUCIÓN PROPUESTA PARA PROBLEMA DEL LABERINTO DEL RATÓN
Autor: Rosita Hormann Lobos.
Contacto: rosita.hormannlobos@gmail.com
"""
import numpy as np
def separacion():
print("- - - - - - - - - - - - - - - - - - - - - - - - -")
######################################################
# LECTURA DEL ARCHIVO expe... |
4acf284913c1e526aa53b8158bfcb70030cb69a8 | KnightSlayerTsorig/Zoo | /menu_functions.py | 1,340 | 3.78125 | 4 | def split(animals):
# function that split user input
return animals.replace(' ', '').lower().split(',')
def add_animals(a_list, a_to_add_list, corrals):
# function that allows user add animals to existing corrals
for el in corrals:
if corrals[el].kind == 'herbivore':
herb = corrals... |
374b4d99b6bfd005d9843a5fb500b4886c8058ac | DKNY1201/cracking-the-coding-interview | /LinkedList/2_4_Partition.py | 2,804 | 4.21875 | 4 | """
Partition: Write code to partition a linked list around a value x, such that all nodes less than x come
before all nodes greater than or equal to x. If x is contained within the list, the values of x only need
to be after the elements less than x (see below). The partition element x can appear anywhere in the
"righ... |
b792d8a0f9697236576721acd7a85d326feef613 | daniel-reich/ubiquitous-fiesta | /pSrCZFim6Y8HcS9Yc_20.py | 205 | 3.8125 | 4 |
def convert(deg):
if deg[-1] == "F":
C = (int(deg[:-2])-32)*5/9
return "{:.0f}*C".format(C)
if deg[-1] == "C":
F = int(deg[:-2])*9/5 + 32
return "{:.0f}*F".format(F)
return 'Error'
|
afebde0bb976635cfae3f9e7dece7e6093adf6e9 | Lindisfarne-RB/GUI-L3-tutorial | /Lesson62_REFREACTOR.py | 5,393 | 4.28125 | 4 | '''14.4
Using the account names in the GUI code
We have a list called account_list which contains our 3 account objects. We want to use this list like account_names on lines 93‑100 for the Combobox. However, the account_list is actually a list of objects, so if we plug that list straight in we will have some issues.
C... |
36ca1ce8a5e4727a90ac76ead6922ed5be5dc8ef | lixiang2017/leetcode | /lintcode/009010_·_Closest_Binary_Search_Tree_Value_II.py | 772 | 3.515625 | 4 | '''
86 mstime cost
8.74 MBmemory cost
Your submission beats78.80 %Submissions
'''
"""
Definition of TreeNode:
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
"""
import heapq
class Solution:
"""
@param root: the given BST
@param target: the gi... |
433ad7d74007d201b8a44717839f05d75f9f4916 | ProdigyX6217/interview_prep | /word_count.py | 728 | 4.25 | 4 | str_1 = "Anyway, like I was sayin', shrimp is the fruit of the sea. You can barbecue it, boil it, broil it, bake it, \
saute it. Dey's uh, shrimp-kabobs, shrimp creole, shrimp gumbo. Pan fried, deep fried, stir-fried. There's pineapple \
shrimp, lemon shrimp, coconut shrimp, pepper shrimp, shrimp soup, shrimp stew, shr... |
bfe4574c88dcc7d6cd57a3c634e85fb2dc44c2d3 | rahulsrma26/manim | /from_rahul/assignments/11_isosceles_triangle.py | 796 | 4.28125 | 4 | '''
## Printing Isosceles Triangle using asterisk
This is a star isosceles triangle with base as 4.
```text
*
* *
* * *
* * * *
```
You are given a number *n*. We want to print the triangle with base *n*.
Hint: You may need to use nested loop. Inner loop will be printing stars in
a single row.
... |
a95bfe8b40612444ec696801176912073bb3ab07 | MELCHIOR-1/myleetcode | /No33_Search in Rotated Array.py | 1,274 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Mar 19 21:32:48 2017
@author: shawpan
"""
# Suppose an array sorted in ascending order is rotated at some
#
# pivot unknown to you beforehand.
#
# (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
#
# You are given a target value to search. If found in the array
#
# return ... |
ca2b504b0c6701cde8b219b4cd688f04778c59e5 | asnewton/Data-Structure-and-Algorithm | /arrays/spiralTraversal.py | 852 | 3.6875 | 4 | arr = [
[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]
]
def spiralTraversal(arr):
n = len(arr)
m = len(arr[0])
T = 0
B = n-1
L = 0
R = m-1
direction = 1
while( T <= B and L <= R):
if(direction == 1):
for i in range(L, R):
print(arr[T][i])
... |
722bf5c8157b0ccf99bc3f3d2a03c45d169abcba | srikanthpragada/PYTHON_12_JULY_2021 | /demo/assignments/common_factors.py | 154 | 3.609375 | 4 | num1 = 450
num2 = 250
small = num1 if num1 < num2 else num2
for i in range(2, small // 2 + 1):
if num1 % i == 0 and num2 % i == 0:
print(i)
|
406d0f3423ecc279606cf31f7e6b169114552250 | Abhi1o/python_learning- | /4_day/3_list.py | 434 | 4.03125 | 4 | #list is a organized set of data in python.
#List enclosed with in [] and seperated by ,comma.
State_in_India=["Jammu&kashmir", "punjab", "Haryana", "Himachal_Pradesh", "Uttar_Pardesh"]
print(State_in_India[1])
print(State_in_India[1:])
print(State_in_India[:3])
print(State_in_India[1:4])
print(State_in_India... |
9670b699d421375a8f78c218dc6f698762c140c2 | olegbrz/coding_every_day | /CodeWars/018_291120_man_boy_sort.py | 1,244 | 4.1875 | 4 | """Scenario
Now that the competition gets tough it will Sort out the men from the boys .
Men are the Even numbers and Boys are the odd!alt!alt
Task
Given an array/list [] of n integers , Separate The even numbers from the odds,
or Separate the men from the boys!alt!alt
Notes
Return an array/list where Even numbers com... |
04f0177ed40f107486c7831b340736acc5e88e34 | ababa831/atcoder_beginners | /progcon_book/alds1_1_a_3rd.py | 774 | 4.1875 | 4 | # Accepted
# Ref: http://interactivepython.org/courselib/static/pythonds/SortSearch/TheInsertionSort.html
def insertation_sort(a, n):
for i in range(1, n):
# Temporary memorize the current value
# because the value vanishes if shiftings (a[i] = a[i-1]) are executed.
current_val = a[i]
... |
e912f0b29416d0bfab57d21267f115abbc841c53 | cmgn/problems | /kattis/whatdoesthefoxsay/whatdoesthefoxsay.py | 350 | 4.0625 | 4 | #!/usr/bin/env python3
number_of_tests = int(input())
for _ in range(number_of_tests):
sounds_made = input().split()
other_animals = set()
s = input()
while s != "what does the fox say?":
other_animals.add(s.split()[-1])
s = input()
print(" ".join(sound for sound in sounds_made if... |
02cdd366f889483176ddaadf122e5056d6a9eb0b | rtribiolli/520 | /aula4/func4.py | 406 | 3.78125 | 4 | #!/usr/bin/python3
#testar com diciionario
convidados = []
def adicionar(nome, idade):
""" funcao para adicionar convidados na lista """
global convidados
convidados.append(nome, idade)
return True
while True:
nome = input("nome ou sair: ")
if nome.strip().lower() == 'sair':
break
... |
ef4177ab546ef296a9d1e8e93c92730a22ef685e | pmstangmailcom/2020_1_homework_4 | /Tasks/Like.py | 1,059 | 4.3125 | 4 | '''
Мне нравится 👍
Создайте функцию, которая, принимая массив имён, возвращает строку описывающая количество лайков (как в Facebook).
def likes(*arr: str) -> str:
pass
Примеры:
likes() -> "no one likes this"
likes("Peter") -> "Peter likes this"
likes("Jacob", "Alex") -> "Jacob and Alex like this"
likes("Max", "J... |
f9bf6bbebdedc3b38f40fdea2dafe7c18e0469ce | hernandez26/Projects | /4.10-4.12 try exercises.py | 1,258 | 4.40625 | 4 | # 4.10 Practice using slices
numeros =["uno","dos","tres","cuatro", "cinco","sies","siete","ocho","nueve","diez","once","doce"]
print(f"Here are the first 4 items of my list {numeros[0:4]}")
print(f'Here are the 4 items of my list found in the middle {numeros[4:8]}')
print(f"Here are the final four items found on m... |
0a7e93b2838cf0f789ef8639306b6c08f6f9edd7 | MurilloGodoi/Cota-o | /cotacao_moedas.py | 961 | 3.65625 | 4 | import requests
import json
class ListValors():
def __init__(self, currency):
self._currency = currency
def request_api(self):
response = requests.get(
f'https://economia.awesomeapi.com.br/json/{self._currency}')
if response.status_code == 200:
return resp... |
16193746bcca70345ead8cfefd55a5923a26b9b5 | Makhosandile/abantu | /api/utils.py | 918 | 3.546875 | 4 | import pandas as pd
import numpy as np
population_df = pd.read_csv('data/population.csv')
population_df = population_df.fillna(0)
population_df['Population'] = population_df['Population'].astype(int)
def male_population():
df = population_df.query('Series == "Population, male"')
df = df.drop('Series', axis=1... |
78166046acedeececdf45d76734f355b84a2407c | wpsymans/PythonCourse | /Section 4 - Loops/Section 4 - For Loops.py | 539 | 4.0625 | 4 | groceries = ["ham","spam","milk","bread"]
#this block removes spam from the grocery list using continue
for item in groceries:
if item == "spam":
continue
print(item)
print("a second list with break")
for item in groceries:
if item == "spam":
break
print(item)
item_to_find = input(... |
36644164ffd88c6c29e4c5c3ef05be587a9d9823 | brunadelmourosilva/cursoemvideo-python | /mundo2/ex049_tabuada.py | 263 | 4 | 4 | # Refaça o DESAFIO 009, mostrando a tabuada de um número que o usuário escolher,
# só que agora utilizando um laço for.
n = int(input('digite um número para ver sua tabuada: '))
for cont in range(1,10+1):
print('{} X {} = {}'.format(cont, n, cont * n)) |
5cc2285365636bf9538185fc13bb921874486b18 | suvimanikandan/PYTHON_CODES | /python codes/keyword variables args.py | 166 | 3.546875 | 4 |
def person(name,**data):
print(name)
for i,j in data.items():
print(i,j)
person('swetha',age=24,city='Chidambaram',mob=8903098719) |
8d3fbbdcf23d555db18199aab42622a379bbad8f | AdityaNarayan001/Basic_Library_App-GUI- | /main_code.py | 5,999 | 3.59375 | 4 | # GUI for Library
from tkinter import *
from tkinter import messagebox
from tkinter.filedialog import askopenfile
root = Tk()
root.title('LIBRARY GUI')
root.geometry("1250x640")
root.configure(bg='black')
bn = []
bid = []
bc = []
newbooklist = []
name = " "
cost = 0
id = 0
def reversecontents():
bn.reverse()
... |
3b4a8144a99e07a45f2bd43f6e2c110844cf2e81 | kunalsxngh/qa_python_excercises | /excercises/classes.py | 274 | 3.515625 | 4 | class students:
def __init__(self, name, age, className = "student"):
self.name = name
self.age = age
self.className = className
def average_test_scores(self, test1, test2, test3):
return round(((test1 + test2 + test3) / 3), 2) |
4e0ca1fbe89cf1e7359f3cd5faaa4efe94050e89 | RaelViana/Python_3 | /ex025.py | 1,575 | 3.703125 | 4 |
"""
Manipulando Texto
"""
# Fatiamento
frase = 'Curso em Video Python '
print(frase[9]) # Apresenta a letra no indice 9
print(frase[3:5]) # Apresenta somente o valor fatiado do indice 3 ao 5
print(frase[:14]) # Apresente valor fatiado do inicio até o indice 14
print(frase[9:]) # Apresente valor fatiado do inc... |
8b4700056666483d2d61556dfe7010648b4a92b6 | gscho/Ackermann | /src/python/iterative.py | 609 | 3.921875 | 4 | import time;
def Ackermann(m,n):
stack = [m]
i = 0
while (len(stack)):
x = stack.pop()
if(x == 0):
n = n + 1
elif(n == 0):
n = 1
stack.append(x-1)
else:
n = n - 1
stack.append(x-1)
stack.append(x)
ret... |
4e28b258bb49fce1bb9def195375fc41f7404f48 | zephyr123/blibli | /book/p8/8_4.py | 179 | 3.578125 | 4 | def make_shirt(size,type='I love Python'):
print("This shirt's size:" + size,"字样是: " + type)
make_shirt('big')
make_shirt('middle')
make_shirt('small','life is short')
|
f13c3225c24bd5d9bdf5ddd7ceef12b5128b3a7e | mattjax16/DFS_data_analysis | /draftkings_files/draftkings_scrapper.py | 3,319 | 3.515625 | 4 | """
draftkings_scrapper.py
this file is to scrape draft kings mlb data
"""
import psycopg2
import pandas as pd
import sys
from configparser import ConfigParser
from requests_html import HTMLSession
import bs4
class DkScrapper():
'''
This is a class to scrape date from draft kings
'''
def __init... |
8c8eee3fd67c1b50cc49e0acbae8643de1b6b59a | tanmaybhoir09/SSW567-HW02 | /TestTriangle.py | 1,961 | 4.03125 | 4 |
"""
Updated Feb 22, 2019
The primary goal of this file is to demonstrate a simple unittest implementation
@author: jrr
@author: rk
@auther: Tanmay Bhoir
"""
import unittest
from Triangle import classifyTriangle
# This code implements the unit test functionality
# https://docs.python.org/3/library/unit... |
12830ea78130f0dc74e139a03517c8f6727ae661 | HazelIP/Programming-21 | /week4/lab 4.1.2 grade.py | 366 | 4 | 4 | # This program print a student's corresponding grade based on the student's % marks
# author: Ka Ling IP
grade = int(input("Enter the percentage:"))
if grade < 40:
print("fail")
elif grade>=40 and grade<49:
print ("pass")
elif grade>=50 and grade <59:
print ("Merit 2")
elif grade>=60 and grade<69:
prin... |
0b4b60ca311565ccc3eab5e47b580f2e10725193 | delvinlow/coding-practices | /RomanToInteger/Solution.py | 1,003 | 3.5625 | 4 | class Solution:
mapping = {
"I": 1,
"V": 5,
"X": 10,
"L": 50,
"C": 100,
"D": 500,
"M": 1000
}
def romanToInt(self, s: str) -> int:
numerals = []
str_reversed = [char for char in s]
while len(str_reversed) != 0:
cha... |
d257939403666c82af753e8f998c0e57102e1b01 | Ashi-s/coding_problems | /DevPost/fb_sorted_square.py | 511 | 3.796875 | 4 | '''
Input: a sorted array
Output: Squared sorted array
O(n) complexity
e.g = [-6,-4,1,2,3,5]
output: [1,4,9,16,25,36]
'''
def sorted_square(s):
if s == []:
return "Invalis"
n = len(s)
low = 0
high = n-1
out = [0]*n
while n > 0 :
if abs(s[low]) > abs(s[high]):
out[n... |
1b8f4ea067ebc66d450ba92d32d9cb862596a3b5 | jketo/arcusysdevday2015 | /team2/python/rasacalculator.py | 909 | 3.609375 | 4 | #!/usr/bin/env python
import argparse
def calculate_file_rasa(file_path):
row_count = 0
multiplier = 1
rasa = 0
for line in open(file_path):
row_count += 1
for char in line:
if char == '{':
multiplier += 1
if char == ';':
rasa +=... |
95f2e1d452678a302fb1b3052730ac55864b31bf | hacktoolkit/code_challenges | /project_euler/python/056.py | 684 | 3.671875 | 4 | """http://projecteuler.net/problem=056
Powerful digit sum
A googol (10^100) is a massive number: one followed by one-hundred zeros; 100^100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits in each number is only 1.
Considering natural numbers of the form, a^b,... |
531b202e0b2ba20e2321c824c4b4330c794b6114 | sdamashek/gb500 | /stack.py | 377 | 3.71875 | 4 | pointer = -1
stack = []
def push(value):
global pointer
""" Push to top of stack """
stack.append(value)
pointer += 1
def pop(index=hex(pointer)):
# Pop the passed index of the stack, or pop the top value
return stack[hextopointer(index)]
def hextopointer(value):
""" Convert hex point... |
56a0f0e3f45bebd27a3c6c71f5fb43a25bb6628b | YCJGG/Leet-Code | /JGG/twoSum_2.py | 1,080 | 3.828125 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def addTwoNumbers(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"""
re = ... |
6bee0f8b6331a842fc49b92c8cc3b39eaf684e6b | 0xJinbe/Exercicios-py | /Ex 002.py | 755 | 3.578125 | 4 | """Faça um Programa que pergunte quanto você ganha por hora e o número de horas trabalhadas no mês. Calcule e mostre o total do seu salário no referido mês, sabendo-se que são descontados 11% para o Imposto de Renda, 8% para o INSS e 5% para o sindicato, faça um programa que nos dê:
salário bruto.
quanto pagou ao INSS.... |
f17701647e9f6a0d93746f30b5c9c6f0d5d4a36d | XuYiwen/Machine-Learning | /hw4/NN.py | 9,723 | 4.0625 | 4 | '''
A 3 layer neural network (input layer, hidden layer, output layer) for MNIST dataset
'''
import random
import numpy as np
import NN_functions as nf
from numpy import argmax
"""
Initializes and returns an instance of the NN class.
Parameters:
-domain: one of ['mnist', 'circles']
-batch_size:... |
4df8752e45e5a7a7495e6f354484ec306f96b396 | RaymondDashWu/tweet-generator | /histogram.py | 5,299 | 3.5 | 4 | import re
import sys
import random
def read_sterilize_source(source_text):
"""Filters out all punctuation and white space (line breaks + spaces) using regex and
substitutes with a space " ". Then splits into array
Updated for edge cases '. Now keeps words that use ' as part of word (I've, haven't, etc.)"""... |
4615b36c7005248fc1566367325dc8e73daaff8d | Tuchev/Python-Fundamentals---january---2021 | /08.Text_Processing/02.Text_Processing_-_Exercise/05. Emoticon Finder.py | 126 | 3.828125 | 4 | text = input()
for index in range(len(text)):
if text[index] == ":":
print(f"{text[index]}{text[index + 1]}") |
35644a547148decd7e8545dd8c93e88a5b6ef5c8 | TahaKhan8899/Coding-Practice | /LeetCode/assignEmployeesToEmails.py | 1,545 | 3.546875 | 4 | def solution(S, C):
emailList = []
personInfo = []
emailDict = {}
finalStr = ""
#parse string S:
s = S.split('; ')
print(s)
prefix = ""
#read fname, mid(if possible) and last into an array
for name in s:
fullName = name.split()
#mid name
... |
8281791c98b8adb1191e97a3473dbcb561e1ca87 | Ngiong/Indonesian_Parser | /python/src/parsetree/WordToken.py | 361 | 3.53125 | 4 | class WordToken(object):
def __init__(self, word, tag):
self.WORD = word
self.TAG = tag
def __str__(self):
return self.WORD + "#" + self.TAG
def __eq__(self, other):
return self.WORD == other.WORD and self.TAG == other.TAG
def __hash__(self):
return hash((self.... |
0151374f9d500bb496cdb6f6a29b9a790eba9955 | SimasRug/Learning_Python | /Chapter3/D1.py | 1,867 | 4.1875 | 4 | def weight():
print('For converting pounds to grams enter 1')
selection = int(input('For converting grams to punds enter 2: \n'))
if selection == 1:
pounds = float(input('Input pounds: '))
total = pounds * 453.59
print(pounds,' pounds are ',total, 'grams')
else:
grams = ... |
2098d8b056fca130d1c25ac89b695d5a83fb022b | Scott-Larsen/LeetCode | /383-RansomNote.py | 594 | 3.59375 | 4 | # Given an arbitrary ransom note string and another string containing letters
# from all the magazines, write a function that will return true if the ransom
# note can be constructed from the magazines ; otherwise, it will return false.
# # Each letter in the magazine string can only be used once in your ransom note.
... |
00420cdc2c6f7b2af868d701540ed396b7947862 | etkinpinar/ScriptProgramming | /Script_B.py | 556 | 4.0625 | 4 | ################## METADATA ##################
# NAME: Etkin Pınar
# USERNAME: a18etkpi
# COURSE: Scriptprogramming IT384G - Spring 2019
# ASSIGNMENT: Assignment 1 - Python
# DATE OF LAST CHANGE: 2019-04-09
##############################################
number = input("Enter a number: ")
while number:
if... |
abeee2b124cb5c0a6bf881b5ab8a0c2cd864ad40 | alekseyzelepukin/python_algorithms_and_data_structures | /lesson_03/scripts/exercise_06.py | 907 | 3.625 | 4 | # 6. В одномерном массиве найти сумму элементов, находящихся между минимальным и максимальным элементами.
# Сами минимальный и максимальный элементы в сумму не включать.
from random import randint
from typing import List
if __name__ == '__main__':
n: int = 4
arr: List = [randint(0, 9) for _ in range(n)]
... |
330850e867dc75950fe84d9784e354dd6694bbc9 | Amansingh1811/Programing-Interview-Questions- | /Main.py | 491 | 3.921875 | 4 | import majority_number as m
import array_length as a
import convertToIntArray as c
promptStr = "Please enter your value: "
userstring = input(promptStr)
arrLen: int = a.lengthofarray(userstring)
print("your array length is ", arrLen)
m.findMajority(userstring)
arrtype = userstring.split(",")
intArr = c.convertToI... |
ab969509e22cb710602874ce99b48fa722854989 | QuentinDuval/PythonExperiments | /linked/Node.py | 870 | 3.515625 | 4 | class Node:
def __init__(self, val):
self.val = val
self.next = None
@classmethod
def from_list(cls, xs):
if not xs:
return None
h = Node(xs[0])
t = h
for x in xs[1:]:
curr = Node(x)
t.next = curr
t = curr
... |
0c9ed9bcf7b678025daf8192a4cba3a31dec737c | leezzx/Baekjun-Study-Python | /입출력과사칙연산.py | 1,611 | 3.515625 | 4 | # 2557 Hello World
print('Hello World!')
# 10718 We love kriii
print('강한친구 대한육군\n강한친구 대한육군') # \n으로 엔터역할
# 10171 고양이
print('''\\ /\\''')
print(''' ) ( ')''')
print('''( / )''')
print(''' \\(__)|''')
# 10172 개
print('''|\_/|''')
print('''|q p| /}''')
print('''( 0 )\"\"\"\\''... |
2dbe6427ba14b9247ffd799adae18885fff427aa | cavad2187/Neon | /math.py | 651 | 3.90625 | 4 | import math
print("Neon K Proqramına Xoş Gəlmisiniz")
a=int(input("a Əmsalını Qeyd Edin: "))
b = int(input("b Əmsalını Qeyd Edin: "))
c = int(input("Sərbəst Həddi Qeyd Edin: "))
d = (b*b)-(4*a*c)
if (d>0):
x1 = math.floor((-b - math.sqrt(d))/(2*a))
x2 = math.floor((-b + math.sqrt(d))/(2*a))
... |
9eb03f9f587f6eba3c98de04236474e610058229 | guyao/leetcode | /number-of-islands.py | 2,272 | 3.515625 | 4 | #Union Find
class Solution(object):
def numIslands(self, grid):
"""
:type grid: List[List[str]]
:rtype: int
"""
if not any(grid):
return 0
ht = len(grid)
wd = len(grid[0])
uf = [i for i in range(ht*wd)]
def find(x):
p = ... |
a58609aba69dcb376f6e9eb5cd64af054d57d3a5 | Uthsavikp/Python_Data_Structures | /Dictionary_Programs/convert_list_to_nested_dictionary.py | 680 | 4.15625 | 4 | '''
@Author: Uthsavi KP
@Date: 2021-01-08 23:27:24
@Last Modified by: Uthsavi KP
@Last Modified time: 2021-01-08 23:27:24
@Title: To convert a list into a nested dictionary of keys
'''
class NestedDictionary:
def get_nested_dictionary(self):
"""
converting list to nested dictionary
using list... |
c6b5a909f074c4547040155ca17f876848adfb6c | jamiedotpro/etc | /tf/tf21_rnn2_1to100.py | 2,219 | 3.75 | 4 | # 1 ~ 100 까지의 숫자를 이용해서 6개씩 잘라서 rnn 구성
# train, test 분리할 것
# 1,2,3,4,5,6 : 7
# 2,3,4,5,6,7 : 8
# 3,4,5,6,7,8 : 9
# ...
# 94,95,96,97,98,99 : 100
# predict: 101 ~ 110까지 예측하시오.
# 지표 RMSE
import numpy as np
def split_n(seq, size):
aaa = []
for i in range(len(seq) - size + 1):
subset = seq[i:(i+size)]
... |
4e2f1535de3b2ff70375800a05b837368ae2066f | mhaut/pythonExamples | /ASR_audioExample/ASR.py | 3,699 | 3.515625 | 4 | import pyaudio
import wave
import audioop
from collections import deque
import os
import urllib2
import urllib
import time
import json
def listen_for_speech():
"""
Does speech recognition using Google's speech recognition service.
Records sound from microphone until silence is found and save it as WAV and then con... |
206bd6db2d53bba97dd58e293bdd5556286587c3 | LeoTod/learning_python | /learn_python_freecodecamp/mad_libs_game.py | 347 | 3.734375 | 4 | adjective1 = input("Enter an adjective: ")
adjective2 = input("Enter another adjective: ")
type_of_bird = input("Enter a type of bird: ")
room = input("Enter a room: ")
print("It was a " + adjective1 + ", cold November day. ")
print("I woke up to the " + adjective2 + " smell of " + type_of_bird)
print("roasting in the... |
6abb80247985baec5f013fb024551aeaf7fc948a | PythonicNinja/elliot-test | /utils/reverse.py | 460 | 3.90625 | 4 | from math import log10
def how_many_digits(number):
return int(log10(number))
def reverse_num(value):
if not isinstance(value, int):
raise ValueError(
'Unexpected value for reverse_num which requires integers. '
'Passed type = %s', type(value))
if -10 < value < 10:
... |
86c4bde551158d82ab181405efd726176774ed17 | WagnerSF10/curso_intensivo_python | /python_work/chapter7/rollercoaster.py | 169 | 4 | 4 | height = input("Qual a sua altura, em metros? ")
height = float(height)
if height >= 1.70:
print("\nVoce tem altura ideal!")
else:
print("Altura insuficiente!") |
3703ef62dff7a995d12405b589dc362ed8dd90bd | nnur/Cracking-the-Coding-Interview-in-Python | /linkedLists/2-5.py | 1,174 | 4.03125 | 4 | from LinkedList import LinkedList
def add_linked_lists(list1, list2):
list3 = LinkedList()
p1 = list1.head
p2 = list2.head
numbers_to_add = []
position = 0
while True:
if p2 and p1:
numbers_to_add.append(p1.data*10**position + p2.data*10**position)
p2 = p2.next_node
p1 = p1.next_nod... |
8555fd529d1cd8fb0329fc0f88c3cc0f499c7a2c | shinysu/test | /Q2.py | 363 | 3.828125 | 4 | def is_multiples(l):
return [(((num % 3) == 0) or ((num % 5) == 0)) for num in l]
def is_multiple(n):
if ((n % 3) == 0) and ((n % 5) == 0):
return "GraphQL"
elif (n % 3) == 0:
return "Graph"
elif (n % 5) == 0:
return "QL"
print(is_multiples([1,2,3,4]))
print(is_multiple(3))
p... |
92e466ce9fbf44153b824dc46c9439d5849d7466 | Sandhie177/CS5690-Python-deep-learning | /ICP3/codon.py | 948 | 3.875 | 4 |
import csv #imoprting library
i=1
while i%3 !=0:
string=input('Give the sequence of DNA:')
i=len(string)
if i%3 !=0:
print ('Sequence is invalid. Give the Sequence Again') #if there is a sequence
#with 1 or 2 characters it can't proces... |
a3d023460b9a6dd915ee9129a128325fef966a7a | devmanner/security | /bin/anonymize_hashfile.py | 1,416 | 3.8125 | 4 | #!/usr/bin/python
import sys
import re
from coolname import generate_slug
if len(sys.argv) != 7:
print("Script to anonymize a list of usernames and hashes. Good step to do when auditing passwords.")
print("Usage: anonymize_hashfile.py file_with_hashes_and_names user_field hash_field delimiter user_output_file hash... |
df74aa1a255a124f1a7cd6486e38c30c266e8f57 | isabellahenriques/Python_Estudos | /ex068.1.py | 1,205 | 4.0625 | 4 | ''' Faça um programa que jogue par ou ímpar com o computador.
O jogo só será interrompido quando o jogador perder,
mostrando o total de vitórias consecutivas que ele conquistou no final do jogo.'''
from random import randint
print("=+" * 20)
print("Vamos jogar Par ou Impar")
print("=+" * 20)
while True:
numeroJogad... |
8f6a348e6c9f6b9bee57d0c27ebbfae82adbdd3b | iluy420/Qwiz | /Python/pr_2_2.py | 1,941 | 3.640625 | 4 | import sqlite3
import string
def in_base (cursor):
list_staff=[(1,'Костиков','1977-02-05','Специалист'),(2,'Рой','1977-11-15','Специалист'),(3,'Пестов','1975-11-11','Председатель ПЦК'),(4,'Ожигова','1976-07-24','Специалист')]
cursor.executemany("INSERT INTO staff VALUES (?,?,?,?)", list_staff)
databa... |
a45426b4300e2edbe4571fbe238fe838415c9cff | udani95/Python-Exercises | /Printing_Input.py | 172 | 4.1875 | 4 | # How to get a input from the user and print it
val = input("Please Enter your Name: ")
val2=input("Enter your Age: ")
print("Your name is",val)
print("Your age is",val2)
|
a4c0f733388143433a58ba82141eaa9615e3b47e | spoliv/Algorithms_Python_10.09.2019 | /DZ/Lesson_3/test_2.py | 743 | 4.09375 | 4 | # 2. Во втором массиве сохранить индексы четных элементов первого массива. Например, если дан
# массив со значениями 8, 3, 15, 6, 4, 2, второй массив надо заполнить значениями 0, 3, 4, 5,
# (индексация начинается с нуля), т.к. именно в этих позициях первого массива стоят четные числа.
import random
SIZE = 10
MIN_ITE... |
f1932696124d8bb8e11fd121edb010fbb91488ca | rawitscherr/python_speaks | /speak.py | 1,183 | 3.5 | 4 | import os
import record
import transcribe
import keyboard
import stt
import time
SAVE_FILE = "output.wav"
simple_rules = {
"declare":["variable","list","class","function"],
"control":["if", "for", "while"]
}
declared = []
time.sleep(2)
while True:
print "recor... |
28ea92b2caefae8a39d276fd85a06440991dda1b | Americacastaneda/SIP-2018-starter | /U2-Applications/U2.1-Data/data_vis_project_starter.py | 2,616 | 3.703125 | 4 | '''
In this project, you will visualize the feelings and language used in a set of
Tweets. This starter code loads the appropriate libraries and the Twitter data you'll
need!
'''
#is meant for the tweets text
import json
from textblob import TextBlob
import matplotlib.pyplot as plt
#is meant for the graph
import numpy ... |
7ffb29e3d870630c6ddab8cc07ec71426f829374 | jailukanna/Python-Projects-Dojo | /16.Functional Programming with Python - SW/02.Python - Functional Parts/lambda.py | 308 | 3.953125 | 4 | numbers_list = range(10)
# simple lambda
# add = lambda x, y : x+y
# print(add)
doubled_numbers = list(map(lambda x: x*2, numbers_list))
print(doubled_numbers)
# using lambda for multiplier
def multiplier(multipler_num):
return lambda x: x * multipler_num
doubled = multiplier(2)
print(doubled(4))
|
697ef44f7c35d4a9440d1f09d0cfb71df5de3084 | rainman0709/algorithm_python | /Tree/Tree.py | 1,946 | 4.125 | 4 | from collections import deque
class Node:
def __init__(self, data=-1, lchild=None, rchild=None):
self.data = data
self.lchild = lchild
self.rchild = rchild
class Create_Tree:
def __init__(self):
self.root = Node()
self.myQueue = deque()
def add(self,elem):
... |
c7dc29329893195431fbe36cb1650de15dc78764 | runzedong/Leetcode_record | /Python/wiggle_sort.py | 671 | 3.875 | 4 | def wiggleSort(nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
"""
if len(nums)%2==0:
max=len(nums)-1
else:
max=len(nums)-2
i=1
while i<=max:
if nums[i-1]>nums[i]:
... |
60a4a5cbc1f3a5a9be121a556cfbd3ba3597dcb2 | giuliom95/python-tree-silhouettes | /src/renderer.py | 3,179 | 3.65625 | 4 | import numpy as np
import examples
FILM_DIMENSIONS = (800, 800)
def bounding_box(polygon):
"""
Calculates bounding box of a convex polygon.
:param polygon: List of vertices of the polygon.
:return: The lower left point, the width and the height.
"""
vtx = polygon.T
lower_left = np.arr... |
1266e83edea885939664796ba5018c9e31733a4b | xinshengqin/DistributedComputing | /src/client_app/computing.py | 922 | 3.609375 | 4 |
from numpy import *
#from math import * ##we can use numpy or math
def solve_simple_problem(p1,p2,p3,p4,p5):
return p1+p2+p3+p4+p5
def solve_problem(p1,p2,p3,p4,p5):
'''solve the function with Newton's method
'''
def f(x):
return p1*sin(p2*x)-p3-p4*exp(int(p5)*x)
def df(x):
re... |
497acea529793d30a5f7237e81443b59024db3f7 | MeriDm7/statistic | /the_end_result.py | 2,489 | 3.546875 | 4 | # In this file, I import a list of dictionaries that contain mortality information.
#I calculate the percentage of deaths in total and for various reasons (Heart Disease and Cancer)
# relative to the total population each year in a particular area and record that percentage
# instead of the previous one. And I cal... |
c8687d26b8a0e24d706e33627461eb3be9f0392a | natnaelabay/comptetive-programming | /CP/D6/Intersection of Two arrays.py | 376 | 3.640625 | 4 | # Natnael Abay
# se.natnael.abay@gmail.com
class Solution:
def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
ans = []
for i in nums1:
boolean = True
for j in nums2:
if i == j:
boolean = False
... |
2120c581c6e43b612a668b5e04081198705cbc25 | addisonVota/addisonVota.github.io | /odds or even.py | 968 | 4.15625 | 4 | import random
Question = raw_input("Please choose either odd or even: ")
if Question == "odd" or Question == "even" :
Question_number=int(input("Pick a number between 0 and 5"))
else:
raw_input("Please choose either odd or even: ")
bool_number = False
if Question >= 0 or Question <= 5:
bool_number = True
else:
... |
58de9f033f9366a08cb2b47142ed105981e03784 | J-0-K-E-R/Python-Programs | /07. Dictionary.py | 1,103 | 4.40625 | 4 | # Dictionay consists of keys and value. Every key is unique and every key is used to access the value associated with it.
dic = {'I': 'am Joker', 'Goku': 'is the strongest', 'Naruto': 'is a Ninja', 'Python': 'is a snake. :P'}
print(dic)
print(dic['Python'])
for key,value in dic.items():
print(key, value)
'''
... |
f9998d21e1eb1c0eae5764a9eda556eb3b4f58a2 | gabriellaec/desoft-analise-exercicios | /backup/user_253/ch16_2020_04_26_16_09_11_140823.py | 106 | 3.71875 | 4 | a=int(input("Qual o valor da conta? "))
b=a+a*10/100
print ("Valor da conta com 10%: R${:.2f}" .format(b)) |
08efd7b2924983c57e436f50c7702a9f12c50de2 | ParshvaTimbadia/Aglorithms | /Hard/Longest Subarray with Ones after Replacement.py | 1,237 | 4.03125 | 4 | '''
Problem Statement #
Given an array containing 0s and 1s, if you are allowed to replace no more than ‘k’ 0s with 1s, find the length of the longest contiguous subarray having all 1s.
Example 1:
Input: Array=[0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1], k=2
Output: 6
Explanation: Replace the '0' at index 5 and 8 to have the ... |
24aa223acd5c6845bb3dc01cc8dae6e558180ae4 | MalsR/python-learning | /puzzles/random/parity_outlier.py | 437 | 3.734375 | 4 | class ParityOutlier:
def find(self, number):
odd_numbers = []
even_numbers = []
for number_to_check in number:
if number_to_check % 2 != 0:
odd_numbers.append(number_to_check)
else:
even_numbers.append(number_to_check)
if len(... |
5bc04936a2aa550b52f50f1056309ee24efa00cf | jfgilman/Lab | /Snake.py | 3,630 | 3.921875 | 4 | """Trying to start learning python for reals."""
import pygame
import random
pygame.init()
white = (255, 255, 255)
black = (0, 0, 0)
red = (255, 0, 0)
green = (0, 175, 0)
display_width = 800
display_height = 600
block_size = 10
gameDisplay = pygame.display.set_mode((display_width, display_height))
pygame.display.s... |
ee807af5d135c806dabbce769377dd3959cc9542 | nbrahman/HackerRank | /01 Algorithms/02 Implementation/Equalizing-the-Array.py | 1,484 | 3.90625 | 4 | '''
Karl has an array of n integers defined as A=a<0>,a<1>,...,a<n-1>. In one operation, he can delete any element from the array.
Karl wants all the elements of the array to be equal to one another. To do this, he must delete zero or more elements from the array. Find and print the minimum number of deletion operatio... |
45814113c2b74b0d001e170b8789c19ae0b50364 | joseangel-sc/CodeFights | /Arcade/MirrorLake/IsSubstitutionCipher.py | 1,613 | 4.0625 | 4 | '''A ciphertext alphabet is obtained from the plaintext alphabet by means of rearranging some characters. For example "bacdef...xyz" will be a simple ciphertext alphabet where a and b are rearranged.
A substitution cipher is a method of encoding where each letter of the plaintext alphabet is replaced with the correspo... |
1b5561ba409b750a4bfd5ec9815c1cce8795bffa | azure1016/MyLeetcodePython | /JavaImpl/EPI/parallel_computation/syschronization_interleaving_threads.py | 1,212 | 3.671875 | 4 | import threading
class OddEvenMonitor(threading.Condition):
ODD_TURN = True
EVEN_TURN = False
def __init__(self):
super().__init__()
# would always start with an odd number
self.turn = self.ODD_TURN
def wait_turn(self, waited_turn):
with self:
while self.tur... |
4da8146bfe89e7d110b4b4c55b136590cfdd6f9c | AdamZhouSE/pythonHomework | /Code/CodeRecords/2704/59140/319056.py | 717 | 3.59375 | 4 | def find(x):
if x == parent[x]:
return x
else:
return find(parent[x])
def union(x, y):
xroot = find(x)
yroot = find(y)
if xroot != yroot:
if rank[xroot] > rank[yroot]:
parent[yroot] = xroot
else:
parent[xroot] = yroot
rank[yroot] ... |
0f00a7652d46e33be20039b4d48e598fd0eff23d | Yoozek27/PyPodstawy | /fizzbuzz.py | 317 | 3.65625 | 4 | import sys
inputs = sys.argv
inputs.pop(0)
for i, item in enumerate(inputs, start=1):
check = int(item)
if check % 3 == 0 and check % 5 == 0:
print("fizzbuzz")
elif check % 3 == 0:
print("fizz")
elif check % 5 == 0:
print("buzz")
else:
print(item)
|
acba64d22329e0e9a43bd54d9f4b7c1dcdcb04a3 | pedroceciliocn/programa-o-1 | /strings/exe_2_print_nome_escala_string.py | 102 | 3.859375 | 4 | nome = input("Dê o seu nome: ")
escala = ""
for letra in nome:
escala += letra
print(escala)
|
d72cf386f3d9d458f577ec70a2c69c2e80877837 | timole/experiment-analysis | /data_helper.py | 516 | 3.546875 | 4 | import sys, re
import pandas as pd
def import_and_clean_data(file_name):
print "Parse CSV: " + file_name
df = pd.read_csv(file_name, parse_dates=['datetime'], sep='|')
print "Done."
print "There are {:.0f} rows in the data.".format(len(df))
idx = df.target_email.str.contains('solita.fi$|stt.fi$|st... |
4a41fe40adac36a319c1995525ae514b59a9c4ff | mwhittemore2/vocab_manager | /devops/aws/configurations/lib/config_loader.py | 511 | 3.8125 | 4 | from abc import ABC
class ConfigLoader(ABC):
"""
Generates a config file from a template.
"""
def write(params, destination):
"""
Writes a config file according to the template
specified by the class that instantiates this
method.
Parameters
----------
... |
f8071e8965db0da6e61345e3ad479d2f8b0bc855 | Amaayezing/ECS-10 | /ConnectN/connectn.py | 19,530 | 4.15625 | 4 | #Maayez Imam 11/10/17
#Connect N program
import time
import random
matrix_height = int(input("Enter the number of rows: "))
matrix_width = int(input("Enter the number of columns: "))
connect_n = int(input("Enter the number of pieces in a row to win: "))
def el(): # Empty line - Makes spacing nicer
print(' ')
... |
91ff0e33e112780b7c680379261f24ebf4dad519 | wasabidina/pie | /mad.py | 4,300 | 4.0625 | 4 | #print('hello Madina')
#print('Hello Arkhat')
# x = 5
# y = 7
# print(x)
# print(x,y)
# print(x+y)
# name = "Madina"
# #print(name)
# surname = "Imangaliyeva"
# print(name,surname)
# if 6==6:
# print(x,y,'matematika')
# a = "string Madina"
# b = 77 #integer
# c = 5.12 #float
# list1 = [1,2,'ASdsd']
# dictionar... |
bfe4f38860012acb11c7045563159f759408c168 | abhaysinh/Data-Camp | /Cleaning Data with PySpark/Cleaning Data with PySpark/04- Complex processing and data pipelines/01-Quick pipeline.py | 1,181 | 3.53125 | 4 | '''
Quick pipeline
Before you parse some more complex data, your manager would like to see a simple pipeline example including the basic steps.
For this example, you'll want to ingest a data file, filter a few rows, add an ID column to it, then write it out as JSON data.
The spark context is defined, along with the p... |
d47fae19d75a6324efa9361831a9f7a8793b98bc | caroline-mccain/aiddata-technical-test | /question1.py | 2,945 | 4.125 | 4 | # https://docs.python.org/3/library/math.html
import math
# https://docs.python.org/3/library/os.html
import os
# create arrays to hold the points
a_points = []
b_points = []
# hard-coded file paths
# file_path_a = "C:\\Users\\carol\\Desktop\\Sophomore Year\\TechnicalTest\\TechnicalTest\\Question1\\a.csv"
... |
2aae111f0c9efcbe4f6ac66ae578893d2c89e100 | 981377660LMT/algorithm-study | /7_graph/带权图最短路和最小生成树/floyd多源/2642. 设计可以求最短路径的图类-更新边的floyd.py | 2,270 | 3.921875 | 4 | # https://leetcode.cn/problems/design-graph-with-shortest-path-calculator/solution/geng-da-shu-ju-fan-wei-diao-yong-shortes-ibmj/
# 请你实现一个 Graph 类:
# !Graph(int n, int[][] edges) 初始化图有 n 个节点,并输入初始边。
# !addEdge(int[] edge) 向边集中添加一条边,其中 edge = [from, to, edgeCost] 。
# 数据保证添加这条边之前对应的两个节点之间没有有向边。
# !int shorte... |
3888bb19bf99926d1de3977ead6ffff9b4cd0bf0 | Mattia-Tomasoni/Esercizi-Python | /es14pag189.py | 1,095 | 3.578125 | 4 | '''
ESERCIZIO 14 PAG 189
Organizza in una struttura di dati i valori degli occupati
negli ultimi dieci anni. Utilizza un dizionario, assegnand
il ruolo di chiave all'anno. Inserisci i dati da tastiera
e memorizzabili nel contenitore. Calcola poi il valore medio
dei dieci anni e visualizzane il risultato.
'''
from sta... |
3f92984f231196b6aaf729b847561d40c0e87bc0 | zabdulre/Algorithms- | /codeforces/71A-LongWords.py | 198 | 3.859375 | 4 | numberOfWords = input()
for i in range(int(numberOfWords)):
word = input()
if len(word) > 10:
abbreviation = word[0] + str((len(word) - 2)) + word[-1]
print(abbreviation)
else:
print(word)
|
a2b82ac3665372c112fb10ef8f4250d255155acf | usunday/python_examples | /left.py | 223 | 3.875 | 4 |
def left_join(phrases):
"""
Join strings and replace "right" to "left"
"""
string = ','.join(phrases).replace('right', 'left')
return string
s=left_join(("left", "right", "left", "stop"))
print(s) |
af8f970440e7c54e77090d026603a63392c18c0f | chinnuz99/luminarpython | /regular expression/rules1.py | 438 | 4.03125 | 4 | import re
n="hello"
x='\w*' #"\w" word including special character, "a*" count including zero number of a
match=re.fullmatch(x,n)
if match is not None:
print("valid")
else:
print("invalid")
#
# import re
# n = "hello*-+"
# x = '\w*' # "\w" word including special character, "a*" count including zer... |
940679b03d9576fb44b099ea32556d4a7d10d2ef | Eric-Wonbin-Sang/CS110Manager | /2020F_hw6_submissions/bunissamuel/homework 6 p 2.py | 489 | 4.28125 | 4 | def main():
date = input("Enter the date: ")
mm,dd,yy = date.split('/')
mm = int(mm)
dd = int(dd)
yy = int(yy)
if(mm == 1 or mm == 3 or mm == 5 or mm == 7 or mm == 8 or mm == 10 or mm == 12):
day = 31
elif(mm == 4 or mm ==6 or mm == 9 or mm == 11):
day = 30
if(mm < 1 or m... |
14d631e1c269eb1b5777ade6db55db3af845bcf9 | ywpark/Python3 | /STEP8/ExRegular.py | 5,966 | 3.828125 | 4 | # Regular Expressions
import re
# pattern = r'spam' # raw string
#
# if re.match(pattern, 'spamspamspam'): # re.match 는 string beggining 이다
# print('Match')
# else:
# print('No match')
#
# if re.match(pattern, 'eggspamsausagespam'):
# print('Match')
# else:
# print('No match')
#
# if re.search(patter... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.