blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
06de39e4d48113624fd60d8b87cff29ba595122e | chikurin66/NLP100knock | /chapter1/knock09.py | 675 | 3.890625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import random
def typoglycemia(string):
words_list = string.split()
new_words_list = []
for word in words_list:
if len(word) <= 4:
new_words_list.append(word)
else:
middle_char_list = list(word[1:-1])
random.... |
c5b47e34fba6f594b645eb072509e7a52a20246f | mauricio071/pythonExercicios | /ex011.py | 242 | 3.9375 | 4 | largura = float(input('Digite a largura em metros: '))
altura = float(input('Digite a altura em metros: '))
area = largura * altura
tinta = area / 2
print('Para parede com a área de {}m², vai precisar de {}L de tintas.'.format(area, tinta)) |
47a6f203c4975aaacda0e062f5648545aae7316e | gyoder/coding-competition-archive | /codewars/2015/SampleSolutions2015/prob17_SpiralTriangles_KD.py3 | 2,964 | 3.921875 | 4 | #!/usr/bin/env python
#CodeWars 2015
#
# Spiral Triangles
# Please note that in order to draw the spiral
# on a text console, one unit of horizontal motion uses three dash characters.
# Input
# Each line of input describes a single spiral.
# The first character indicates the direction of the first vertex away from ... |
59e6b97c54ab97c4c03c454eed4fd53ccb602e65 | skcode7/curso-python | /4. Tuplas/listas_tuplas.py | 322 | 3.6875 | 4 | lista = ["Curso", "CodigoFacilito"]
tupla = ("Intro", "Basico", "Avanzado")
print(lista)
print(tupla)
nueva_lista = list(tupla)
nueva_tupla = tuple(lista)
print(nueva_tupla)
print(nueva_lista)
##Los strings son listas
print("========== STRINGS")
mensaje = "Curso gratuito"
nueva_lista = list(mensaje)
print(nueva_list... |
622324ac305984d43307fe4bc8f536c821c4a775 | akaroso/Skryptowy2020 | /JS2020/lab2/histogram.py | 272 | 3.6875 | 4 | import sys
def histogram(string):
print(string)
charList = {'a': 1}
for char in string:
if charList.get(char) == None:
charList[char] = 1
else:
charList[char] += 1
return charList
print(histogram("ala ma kota"))
|
88e7be6d96ec8e784aba5e12b0692d4c5beb1949 | Leahxuliu/Data-Structure-And-Algorithm | /Python/LeetCode2.0/DP/72.Edit Distance.py | 1,595 | 3.703125 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
# @Time : 2020/05/09
'''
input: two words: str; the length of word is from 0 to inf
output: int; the number of modify steps
corner case:
one of the word is ‘’ → len(word2)
both words are ‘’ → 0
Method - DP
Steps:
build DP table; the size of table is (len(word1) + 1)* ... |
b0413a33fda8d58392769297db4ea884775baaf9 | wataoka/atcoder | /abc145/c.py | 556 | 3.59375 | 4 | import math
import itertools
# 引数のリストの全ての順列リストを返す
def fact_list(seq:list):
return list(itertools.permutations(seq))
# n!を返す
def fact_num(n:int):
seq = list(range(n))
return len(fact_list(seq))
N = int(input())
x, y = [], []
for i in range(N):
xi, yi = map(int, input().split())
x.append(xi)
y.... |
92ace990db93885b5f5bbd63daee6b507ea4b74e | dionisioC/pythonperformance2 | /examples/04_1 - Strings format/main.py | 1,161 | 3.84375 | 4 | import timeit
import itertools
NUMBER_OF_LOOPS = 3
def c_style(a, b, c, d):
return "Ms. %s! My %s crawled in my %s and then I %s it. Can I have another one?" % (a, b, c, d)
def format_string(a, b, c, d):
return "Ms. {}! My {} crawled in my {} and then I {} it. Can I have another one?".format(a, b, c, d)
... |
7face64b437e6c4c2f7854f26fbf82eff02fb6e8 | brunoleonpuca/PYTHON | /learning-python/FUNCIONES.py | 1,127 | 4.25 | 4 | """FUNCIONES"""
#LAMBDA
#1 parametro# cuadrado = x: x**2 -> cuadrado(3) -> 9, se reemplaza la x por el parametro x
#2(o mas) parametros# raiz = x,y: x**(1/y) -> raiz(25,2) -> 5, se reemplazan ambos parametros
#def funcionConParametrosVariables(*parametro):
# print(parametro) -> imprime la tupla de argumentos
# ... |
932632553df4787be20fa7312e8eba2c701c53af | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/226/users/4129/codes (1)/1585_2905.py | 205 | 3.671875 | 4 | from math import*
#Lados do triangulo
a = float(input('Lado a:'))
b = float(input('Lado b:'))
c = float(input('Lado c:'))
#semiperimetro
s = (a+b+c)/2
area = sqrt(s*(s-a)*(s-b)*(s-c))
print(round(area, 5)) |
30d92f9d3962828de737891f28b1593bcae7cb06 | TristanSong/Github | /Projects/Toolholder/bluetooth/thread.py | 577 | 3.53125 | 4 | import threading
from time import ctime, sleep
def music(func):
for i in range(2):
print("listening %s.%s"%(music, ctime()))
sleep(2)
def movie(func):
for i in range(2):
print("listening %s.%s"%(movie, ctime()))
sleep(5)
threads = []
t1 = threading.Thread(targe... |
045a85947fa4b6827d465a6b7e6d854bd1c9195f | HoYoung1/backjoon-Level | /backjoon_level_python/11780.py | 3,102 | 3.796875 | 4 | import sys
from copy import deepcopy
def print_matrix(matrix):
for row in matrix:
print(row)
print()
# def solve(n, m, city_infos):
# path = [[[] for _ in range(n+1)] for _ in range(n+1)]
#
# bus_info = [[sys.maxsize]*(n+1) for _ in range(n+1)]
# for city_info in city_infos:
# st... |
5f75a2bc354b990782ff04ad220b3e22220ac4fd | lisagee24/python-challenge | /PyPoll/main.py | 4,095 | 3.8125 | 4 | import os
import csv
#initialize list to hold voter info from election_data.csv
voter_info = []
candidate_dic = {}
csvpath = os.path.join('Resources','election_data.csv')
#initialize counter for total number of votes(records) in election_data.csv file
total_Votes = 0
#define lists to be populated by csvfile withou... |
8638dbdc065d596d508255a827772fab27850655 | ArijitR111Y/Python-programming-exercises | /Solutions/Prog22.py | 354 | 4.15625 | 4 | def main():
word_count = {}
# string = "New to Python or choosing between Python 2 and Python 3? Read Python 2 or Python 3.".split(' ')
string = input().split(' ')
string.sort()
for word in string:
word_count[word] = string.count(word)
for word in word_count:
print ("{}:{}".format(word, word_count[word]))
i... |
a7bfaf99404f1cb2e62f4d7ace56fd42f42a028c | KnJbMfLAgdkwZL/codewars.com | /Kata/6 kyu/Take a Ten Minute Walk/main.py | 399 | 3.578125 | 4 | # Take a Ten Minute Walk
# https://www.codewars.com/kata/54da539698b8a2ad76000228
def isValidWalk(walk):
x = y = min = 0
for v in walk:
if v == 'n':
y += 1
if v == 's':
y -= 1
if v == 'e':
x += 1
if v == 'w':
x -= 1
min += ... |
a799d7dff197399a310100ffd178de191c56793e | timflannagan/COMP.3500 | /labs/lab1.py | 964 | 3.515625 | 4 | import os
from time import sleep
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(24, GPIO.OUT)
GPIO.setup(28, GPIO.OUT)
GPIO.setup(29, GPIO.OUT)
GPIO.setup(14, GPIO.IN)
GPIO.setup(30, GPIO.IN)
counter = 0
while True:
if ((counter & 3) == 0):
GPIO.output(24, False)
... |
dd4e0c8879c3b60b920387f65b3e44684cfc71a5 | jhonec/Python | /PI.py | 815 | 3.953125 | 4 | import turtle as t
import math
a = int(input("Escreva o valor de lados: "))
b = 180/a
if a<3:
print("Não forma um poligono.")
else:
d = math.cos(math.radians(180/(2*a)))
d2 = math.sin(math.radians(180/(2*a)))
area = ((200*d2)*(500*d))/2
areap = area*a
perimetro = (200*d2)*... |
0c1124eaceb69bd61b061e970fa5cbb11d8540da | jhembe/python-learning | /classes/class_exercise_person.py | 319 | 4.15625 | 4 | class Person:
def __init__(self,name):
self.name = name
def talk(self):
print(f'Hi {self.name} can talk')
person1 = Person("Joseph")
print(person1.name)
person1.talk()
person2 = Person("Bob")
print(person2.name)
person2.talk()
# Hence each object is a different instance of a person class
|
1159287fca699388593d05242e505487deba08df | mzamp27/pythonprojects | /Derby/gui.py | 1,582 | 4.03125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jul 4 15:35:52 2019
Prompts user to enter values for all the horses racing or load an existing data set.
@author: mzamp
"""
import tkinter as tk
window = tk.Tk()
window.title("GUI INTRO")
# pack is used to show the object in the window with the size it requires
label = tk... |
d794502520c6fba85ef0764343385d52467e16ae | Tarang-1996/100-days- | /day11/leap.py | 380 | 4.125 | 4 | def is_leap(year):
leap = False
if year % 4 == 0 or year % 400 == 0:
return True
else:
return leap
year = int(input())
print(is_leap(year))
for i in range(1, 11):
print(i, end='')
n = int(input())
if N % 4 == 0 or N >20 and N % 2 == 0:
print("Not Weird")
elif N % 2 == 0 and N >=... |
2ed531a2235a349ae1d3481dd134624682ed0497 | GouravGitHub1/coding | /Array/12_Sum_submatrices_matrix.py | 479 | 3.5625 | 4 | # https://www.geeksforgeeks.org/sum-of-all-submatrices-of-a-given-matrix/
arr = [[1,1],[1,1]] # op: 16
arr = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]] # op: 500
arr = [[1,1,1],[1,1,1],[1,1,1]] # op: 100
N = len(arr)
sum = 0
for i in range(N):
for j in range(N):... |
cfd13163178d103a747d735a1de9a9615a06c890 | xiaochenai/leetCode | /Python/Balanced Binary Tree.py | 884 | 4.09375 | 4 | # Given a binary tree, determine if it is height-balanced.
# For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1.
# Definition for a binary tree node
class TreeNode:
def __init__(self, x):
self.val = ... |
2edff49c2384c07bbefeda2d5240a9e353a2e67b | jozemaria/Logica-de-programacao-com-Python | /Scrips_PY/32° dicionário-metodos.py | 1,138 | 3.984375 | 4 | agenda = {}
for i in range(4):
nome = input('Digite seu nome: ')
telefone = input('Digite seu telefone')
agenda[nome] = telefone
print('')
print('')
print('======================')
print('Chaves dodicionário')
print('======================')
# Acessando as chaves do dicionário
for chave in agenda.key... |
f37a9b4dfed21d231979f40296a467977636005f | SmileAK-47/webderviver | /study/basic/for_demo.py | 937 | 3.6875 | 4 | '''
names = ['hah','lilei','xiaoming']
for name in names :
print(name)
sum = 0
number = [1,2,3,4,5,6,6,7,8,9,10]
for x in number:
sum = sum + x
print(sum)
sum1 = 0
a = range(101)
for x in a :
sum1 = sum1 + x
print(sum1)
sum2 = 0
n = 99
while n >0:
sum2 = sum2 + n
n = n - 2
print("奇数和为: ",sum2)
... |
9318c8fe885ef2b2a62742ec582635425a621709 | YanpuLi/LeetCode-Practice-and-Algo | /Easy/459.py | 924 | 3.671875 | 4 | # divide string into half, to see if meets requirements, otherwise into one/third....
class Solution(object):
def repeatedSubstringPattern(self, s):
"""
:type s: str
:rtype: bool
"""
if len(s) <2: return False
pos = len(s)/2
while pos >0:
if len(s)... |
f5879faa71baa37a594306d26dc9202b9cbd1f89 | CodingPirates/taarnby-python | /uge2/1_logik.py | 1,874 | 3.78125 | 4 | ### Logik ###
# Computere er gode til andre ting end beregninger. Logik er en form for beregning, hvor man
# undersøger om en udtalelse er sand eller falsk. Vi har faktisk en helt speciel type til denne
# slags beregninger: En Boolean. Sådan én har to mulige værdier, sand eller falsk
# (i Python hedder det: true e... |
391c79485f824fc63d327b21e184e029522e4700 | haydenth/ish_parser | /ish_parser/Constant.py | 746 | 3.578125 | 4 | from .Observation import Observation
class Constant(Observation):
''' constant is for constant variables that have types
or indices associated with them like types of clouds, etc'''
MISSING = ["99"]
def __str__(self):
if self._obs_value in self._obs_index.keys():
return self._obs_index.get(self._ob... |
dd61ab94bf9d22ed517604de9f38595f5ed0dc72 | subhashreddykallam/Competitive-Programming | /Codeforces/Educational Codeforces Round 57 (Rated for Div. 2) - 1096/1096C-Polygon for the Angle.py | 260 | 3.5 | 4 | ans = [0]*180
for i in range(3, 361):
angle = 180/i
for x in range(1, i-1):
ang = angle*x
if ang == int(ang):
if not ans[int(ang)]:
ans[int(ang)] = i
for _ in range(int(input())):
print(ans[int(input())]) |
db6813d7fc60898eebd98c6d7898be207b29ca4e | fwparkercode/IntroGames | /Fa18_student_games/Olivia Asteroids/Asteroids.py | 17,539 | 3.84375 | 4 | """
Olivia Hanley
Introduction to Computer Programming
Final Project - Asteroids
"""
import pygame
import random
import math
pygame.init()
# Define some colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
pygame.display.set_caption("Final Project: Asteroids")
done = False
# Define some images
player_... |
35be8bfdb0e85fcda2db0684629498fb4220dbff | Bardamusi/Codewars | /MemoizedFibo.py | 1,257 | 4.03125 | 4 | """
5 kyu - Memoized Fibonacci
For this particular Kata we want to implement the memoization solution.
This will be cool because it will let us keep using the tree recursion algorithm
while still keeping it sufficiently optimized to get an answer very rapidly.
https://www.codewars.com/kata/memoized-fibonacci/train/pyt... |
1b437f79c669d7e96992831ba94bc0c8f2bc8bdb | tianhaopx/Machine-Learning-Algorithms | /6/problem2.py | 5,934 | 3.6875 | 4 | import numpy as np
# -------------------------------------------------------------------------
'''
Problem 2: PageRank Algorithm (Markov Chain and Stationary Probability Distribution)
In this problem, we implement the pagerank algorithm, which create a markov chain and use random walk to compute the stationar... |
6ca67f174ab0dda23f91831c645dda15d6470f0d | sebanazarian/itedes | /modulo1/segmento3/apunte6While/ejercicio2.py | 199 | 3.828125 | 4 | seguir="si"
while seguir=="si":
num=int(input("Ingrese un numero: "))
num2=int(input("Ingrese un numero: "))
resultado=num+num2
print(resultado)
seguir=input("Desea realizar otra suma: ")
|
9f898cb1a22bd62a59ee60e827c18c1d6939b1f2 | lel352/PythonAulas | /PythonExercicios/Desafio081.py | 635 | 4 | 4 | print('=========Desafio 081========')
valores = list()
while True:
valores.append(int(input(f'Digite um valor: ')))
reposta = str(input('Deseja Continuar? [S/N]')).strip().upper()[0]
while reposta not in 'SN':
reposta = str(input('Resposta invlida! Deseja Continuar? [S/N]')).strip().upper()[0]... |
fbf4ac579b597e9b423911fd586abb4d32ba7519 | deshpandearchana5888/python_practise | /class_objects.py | 744 | 3.671875 | 4 | #Instance variable ans class variable
class Employee:
pay_range = 1.05#class variable
no_of_emps = 0
def __init__(self,first,last,pay):
self.fname = first#instance variable
self.lname = last#instance variable
self.sal= pay
Employee.no_of_emps += 1
def fullname(self):
... |
0aebc3f684b3081d894c10296aea708b5a5830da | shreshta2000/list_questions | /reverse.py | 121 | 3.640625 | 4 | places=["delhi", "gujrat", "rajasthan", "punjab", "kerala"]
a=len(places)
i=a-1
while i>=0:
b=places[i]
print(b)
i=i-1 |
4173bc48c7073c6f69b106625eb03ebd24c306d7 | saidileeppr/pylab | /py/p n 0's.py.py | 385 | 3.5 | 4 | l=[]
s1=0
s2=0
c1=0
c2=0
c3=0
a=int(input("enter range:"))
print("enter positive or negative or zeroes:")
for i in range(a):
l.append(int(input()))
for i in l:
if(i>0):
c1=c1+1
s1=s1+i
elif(i<0):
c2=c2+1
s2=s2+i
else:
c3=c3+1
print("avg of positive is:",s1/c1)
pri... |
ea2a5ed021ffa053bf9ded4b48c1864e8e84e69a | cannibalcheeseburger/EpisodesUpdates | /src/Mod_del.py | 1,436 | 3.796875 | 4 | import sqlite3
from texttable import Texttable
import os
from src import display
def mod_del():
conn = sqlite3.connect("./movies.db")
c = conn.cursor()
#df = pd.read_csv("./csv/Choice.csv",index_col=[0])
while(True):
display.display_series()
table = Texttable()
table.header(["ID... |
4d55818cd6169353f9e51ffff51dbbdbbf53e21d | rrr2u/codebase | /python/extr_text.py | 109 | 3.578125 | 4 | s="this is so cool (234) test (123)"
for i in s.split(")"):
if "(" in i:
print (i.split("(")[-1])
|
843214d3316b178c76d03229790ca078f80ad1bc | nahaza/pythonTraining | /ua/univer/lesson09/__main__.py | 2,357 | 3.53125 | 4 | import sqlite3
import mysql.connector
class Artist:
def __init__(self, artist_title, artist_name):
self.artist_id = artist_title
self.artist_name = artist_name
def __str__(self)->str:
return f"{self.artist_id}, {self.artist_name}"
def __repr__(self)->str:
return f"Artist(... |
1bec3f781a1671efefc43d2bcb0dae8be5a8101d | emilianoNM/ProyectoFinal | /ejemplos/ejemploRecuperardatos.py | 841 | 3.75 | 4 | import tkinter as tk
from tkinter import *
root = Tk()
root.title('how to get text from textbox')
mystring = StringVar()
mystring2 = StringVar()
back = tk.Frame(master=root, width=500, height=500, bg='black')
back.pack()
def cargarDato():
jsonobj={"1":"dato", "2":"info" }
datoDeVariable=mystring.get()
... |
10677d2638b619862a4ec6449fd208c056705d81 | dzeban/cool-books | /book.py | 547 | 3.734375 | 4 | #!/usr/bin/env python3
from collections import OrderedDict
class Book:
author = ''
title = ''
def __init__(self, author, title):
self.author = author
self.title = title
class Library:
# Key is a title
# Value is dict of book object and count
_lib = {}
def add(self, book):
b = self._lib.get(book.title)... |
68d2ee7b0bf597ee3098f183780a70e079306828 | hardword/_code | /_HR/Problem Solving/theBiggerTheGreater.py | 1,330 | 3.96875 | 4 | #!/usr/bin/env python
# http://hr.gs/ccfbdb
# https://en.wikipedia.org/wiki/Lexicographical_order
# https://www.nayuki.io/page/next-lexicographical-permutation-algorithm
input=['bbfdgstgggggddssddeeedd', 'akdb', 'fedcbabcd', 'dcbb']
arr=list(input[2])
# Find non-increasing suffix
i = len(arr)-1
while i > 0 and arr[i... |
2cd74daf2dc8128299bb2304a2761be91cc9f24f | mazarbaloch/classifiers | /functions.py | 462 | 4 | 4 | #parameter with default value prefix='pro'
def add_prefix(my_string, prefix='pro_'):
"""Adds a 'pro_' prefix before the string provided, a default value."""
return prefix + my_string
final_string=input("Enter a string so we can put pro_ in front of it!: ")
print(add_prefix(final_string))
def add_number(firs... |
ed37134171eb35ac690290ebf0d80873d6ec2bf2 | prateksha/Source-Code-Similarity-Measurement | /Extras/person/Correct/24.py | 1,808 | 3.53125 | 4 | class Family:
palist=[]
flist=[]
count=0
@property
def headOfFamily(self):
if self.parent==[]:
return Person(self.name)
else:
for i in self.parent:
return i.headOfFamily
@property
def allNodes(self):
return Family.count
@pro... |
56e6be43b9b1e0cdc225704973ea9ad0e2d0d1e8 | theUyonator/Forex_Converter_App_Flask | /test.py | 2,487 | 3.5625 | 4 | from unittest import TestCase
from app import app
from fxconverter import ForexConverter
class ForexConverterTest(TestCase):
"""This class holds methods testing the view functions in app.py"""
def setup(self):
"""This method holds code that runs before every test method"""
app.config["TESTING"]... |
90b64f51eb1b35a5a22b8d03f7823dd8840a5def | sergiogbrox/guppe | /Seção 5/exercicio03.py | 250 | 3.953125 | 4 | """
03- Leia um número real. Se o numero for positivo imprima a raiz quadrada. Do contrário,
imprima o número ao quadrado.
"""
numero = float(input('Digite um número real: \n'))
if numero >= 0:
print(numero**0.5)
else:
print(numero**2)
|
80d497fe1c1038c5caae8b4854d59050f0711b26 | perhells/Euler | /Python/problem20.py | 134 | 3.59375 | 4 | import math
temp = math.factorial(100)
string = str(temp)
result = 0
for i in string:
result = result + int(i)
print(result)
|
4ad6387daa70e662ac015e8c8659a9ed2829b6f5 | mr-zhouzhouzhou/LeetCodePython | /剑指 offer/链表/复杂链表的复制.py | 1,428 | 3.734375 | 4 | """
题目描述
输入一个复杂链表(每个节点中有节点值,以及两个指针,一个指向下一个节点,
另一个特殊指针指向任意一个节点),返回结果为复制后复杂链表的head。
(注意,输出结果中请不要返回参数中的节点引用,否则判题程序会直接返回空)
"""
# -*- coding:utf-8 -*-
class RandomListNode:
def __init__(self, x):
self.label = x
self.next = None
self.random = None
class Solution:
# 返回 RandomListNode
def ... |
486c6cf41a5f2be05193e50d24e666bc3d993036 | Chen-Qixian/2020-Fall-PKU | /python/1-advanced/3-IO/3-pickle.py | 1,322 | 3.5 | 4 | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File :3-pickle.py
@Description :序列化
@Time :2020/11/03 17:07:38
@Author :Chen.Qixian
@Email :chenqixian@stu.pku.edu.cn
'''
# 核心: load 和 dump 操作
import pickle
import json
# 序列化为二进制
d = dict(name='ChrisChen', age=18, score=100)
print(pickl... |
f9a472c485dfd11f6f58985a113774463ac0869b | guxinhui1991/LeetCode | /1143.py | 1,947 | 3.578125 | 4 | class Solution1(object):
def longestCommonSubsequence(self, text1, text2):
"""
:type text1: str
:type text2: str
:rtype: int
"""
print(text1, text2)
m, n = len(text1), len(text2)
if m == 0 or n == 0:
return 0
elif text1[-1] == text... |
8922ec2c2a3c3b000d807385b851174acbd08140 | VVVAlex/bso | /head.py | 4,824 | 3.703125 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
import tkinter as tk
from tkinter import StringVar
from tkinter import ttk
s = ttk.Style()
class Head(ttk.Frame):
"""Информационный верхний лабель"""
def __init__(self, master):
super().__init__(master)
# self.root = root
self.master = mast... |
ba218b57bb71d47c96b58194483ad388795bef7a | GolamRabbani20/PYTHON-A2Z | /ANISUL'S_VIDEOS/Typecast.py | 197 | 3.8125 | 4 | x=int(input("Enter 1:"))
y=int(input("Enter 2:"))
a=x+y
b=x-y
c=x*y
d=x/y
e=x**y
print("The sum is:",a)
print("The sub is:",b)
print("The mult is:",c)
print("The div is:",d)
print("The exp is:",e) |
16fd8433bdf1ab56fc2da3d1b4d9c9f2ca7a4dfc | setu4993/LeetCode | /094_binary-tree-inorder-traversal.py | 1,069 | 4.03125 | 4 | # Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def inorderTraversal(self, root):
"""
:type root: TreeNode
:rtype: List[int]
"""
temp ... |
1d9c89bd6a7101fbb006edb8275b6ab0c313d7a4 | PRodenasLechuga/HackerRank | /Python/DefaultDict-Tutorial.py | 521 | 3.6875 | 4 | def getIndexes(element, listToSearch):
indexes = [i + 1 for i, e in enumerate(listToSearch) if e == element]
return indexes
if __name__ == '__main__':
n = list(map(int, input().split()))
firstList = []
secondList = []
for i in list(range(0, n[0])):
firstList.append(input())
... |
c62d73f84325064711ad7b5106e4462e81908910 | Rimbaud-Lee/Learning-Notes | /归并排序.py | 695 | 3.828125 | 4 |
import random
num = []
total = 25000
for i in range(total):
n = random.randint(10,100000)
num.append(n)
def Merge(left, right):
l, r = 0, 0
result=[]
while l<len(left) and r<len(right):
if left[l] <= right[r]:
result.append(left[l])
l += 1
else:... |
16b17d22f0441ac55610c1dae6ddc8c2a0a4d844 | AngelTNP/Entrenamiento | /ProjectEuler/3.py | 315 | 3.703125 | 4 | import math
def primo(x):
if(x%2==0):
return False
for i in range(3,math.floor(math.sqrt(x))+1,2):
if(x%i==0):
return False
return True
def __main__():
x = 3
max = x
while(x<math.sqrt(600851475143)):
if(primo(x) and 600851475143%x==0):
max = x
x+=2
print(max)
__main__() |
ba7a177f1562dda5318d7b042e8df7208a8b0a98 | TSoumanoASC/Tiemoko_ASC3 | /Name, Fate Generator.py | 1,264 | 4.125 | 4 | from random import *
user_Input = []
get_Input = raw_input("You ready for the M.A.S.H tho?")
user_Input.append(get_Input)
print(user_Input)
def main():
what = [" You will live", "u will live", "You will live", "You will live", "You will live",
"U will live"]
are = ["in a mansion, earning 10Mill Weekly"... |
49820a8779d3713cce8ed145e20210a3b2df938e | jobsdsgn/Atividades_Avaliativas_Python | /21_Primeiros Números.py | 305 | 3.828125 | 4 | # x = int(input('Digite um valor: '))
# y = 0
# for i in range(x + 1):
# y = y + i
# print('a soma dos n termos é: ', y)
#Calcular o somatório dos n primeiros números.
soma = 0
limite_sup = int(input('Entre com o limite superior: '))
for i in range(1, limite_sup + 101):
soma += i
print(soma)
|
76f56f78240d90e6c500de7ac1f365f770ae5744 | habayeb2/Milestones | /milestone2.py | 8,347 | 3.8125 | 4 |
# milestone 2
import math
def find_splice(dna_motif, dna):
index = 0
indexarray = []
for i in range(0, len(dna_motif)): #iterates through once for each character in the DNA snippet
index = dna.find(dna_motif[i], index) #finds the location of each letter of DNA snippet
indexarra... |
e4db17b8afd7b2b464e293c45c9fb2e31dbe84aa | novikov-ilia-softdev/algorithms_datastructures | /hr/python/sets/subset/main.py | 340 | 3.625 | 4 | def isSubset( s1, s2):
if (len( s1) > len( s2)):
return False;
for i in s1:
if( i not in s2):
return False
return True
n = int( input())
for i in range( n):
input()
s1 = set( map( int, input().split()))
input()
s2 = set( map( int, input().split()))
print(... |
41baa534c54136ac26aefa81ae3c786227d383c1 | Cridgevier/Scripting | /08 OO/birds.py | 857 | 3.640625 | 4 | import os
from playsound import playsound
from datetime import date
class Bird:
species = "bird"
def whoIsThis(self):
print(self.species)
class Parrot(Bird):
species = "parrot"
def __calculateAge(self, birthdate):
return date.today().year - birthdate.year
# constructor (fill w... |
4feecd2acc3db2459179e19a41848a1d90e6265e | Oldgram/SINFEDU | /LINFO1101/[INFO1] Informatique 1 - Introduction à la programmation/Session 08/QBF.py | 299 | 3.5625 | 4 | class Employe:
def __init__(self, name, salary):
self.nom = name
self.salaire = salary
def __str__(self):
return '{0} : {1}'.format(self.nom, self.salaire)
def augmente(self, augmentation):
self.salaire += self.salaire*(augmentation/100) |
b64aa0957646a873518fc5e57f17ae06fbf2d80f | anshulg825/Coursera-Assignments | /Coursera Algorithmic ToolBox/week2_algorithmic_warmup/4_least_common_multiple/lcm.py | 300 | 3.546875 | 4 | # Uses python3
import sys
def lcm_naive(a, b):
for l in range(1, min(a,b)+1):
if a % l == 0 and b % l == 0:
gcd = l
lcm = (a*b / gcd)
return lcm
if __name__ == '__main__':
input = sys.stdin.read()
a, b = map(int, input.split())
print(int(lcm_naive(a, b)))
|
cdba7412cbaf48479a98a68a41b0e60b606c7176 | Javiertann/Project | /main.py | 5,755 | 3.53125 | 4 | # Importing of required modules
import pandas as pd
import matplotlib.pyplot as pt
import numpy as np
class stats:
topCountryName = ""
def __init__(self):
self.countries = pd.read_excel(r"Project_File.xlsx")
def getTopCountry(self):
countries = pd.read_excel(r"Project_File.xlsx")
... |
c0ab7868fa57b827010ab577fd2fbac0a7830b78 | krokhalev/GeekBrains | /Lesson1/Number5.py | 613 | 3.984375 | 4 |
a = int(input("Введи значение выручки: "))
b = int(input("Введи значение издержки: "))
c = 0
if a > b:
c = a / b
print("Компания работает в прибыль. Рентабельность выручки составляет: {}".format(c))
d = int(input("Введи количество сотрудников фирмы: "))
c = a / d
print("Прибыль фирмы в расчете ... |
13fa645d685de26f9e2fb08e5f31c1638dff54f2 | dalixwill/dataincubator | /nodeConnection.py | 2,654 | 3.796875 | 4 | #!/usr/bin/env python
"""
Consider a grid in d-dimensional space. There are n grid lines in each
dimension, spaced one unit apart. We will consider a walk of m steps from grid
intersection to grid intersection. Each step will be a single unit movement in
any one of the dimensions, such that it stays on the grid. We... |
78d0e33b5765c895f4ec8ac6ea2f0abe4a1083cf | hughseyxo/module_exam_calculator | /module_exam_calculator.py | 1,009 | 3.90625 | 4 | #!usr/bin/env python
#functions
def ca_worth_calc(ca_worth):
ca_worth = raw_input("Please enter the CA worth: ")
ca_worth = float(ca_worth)/100
return ca_worth
def exam_worth_calc(exam_worth, ca_worth):
exam_worth = 100 - ca_worth
exam_worth = float(exam_worth)/100
return exam_worth
def ca_percent_calc(ca_per... |
5d94a2d2e3d82fa3e3d1730d4fb9d56bbf8226c0 | gimmy1/data_structures | /linkedlists/node.py | 793 | 3.875 | 4 |
class Node:
'''
Node Class
get_value
set_value
set_next_node_value
'''
def __init__(self, value, next_node=None):
'''
Constructor class
'''
self.value = value
self.next_node = next_node
def get_value(self):
... |
21beea11533bcb89dbd71ee9cc6622dd32389513 | danvk/advent2019 | /day10.py | 2,334 | 3.609375 | 4 | #!/usr/bin/env python
from collections import defaultdict
import fileinput
import itertools
import math
def read_asteroid_map(inp):
out = []
loc = None
for y, line in enumerate(inp):
for x, c in enumerate(line.strip()):
if c == '#':
out.append((x, y))
if c ... |
4441e7a5986ac95677ae768348087a8f4dd1f84d | emperwang/python_operation | /base/wknumpy/Demo_slice.py | 868 | 3.796875 | 4 | # coding:utf-8
import numpy as np
# 对多维数组元素的切片存取内容
a = np.arange(1, 10, 1)
print(a)
# 切片获取全部
print(a[0:])
# 间隔两个获取
print(a[0::2])
# 从头获取到倒数第二个
print(a[:-1])
# 倒序获取
print(a[::-1])
print("--------------------------------------------------")
# 使用下标获取数组与原数组不共享地址空间
b = np.arange(1, 10, 1)
c = b[0:3]
b[1] = -10
print(a... |
afbb354a690ac7340275490361cf4d3630b3c9a9 | elifustunel/elff | /lab3/6.py | 249 | 4.0625 | 4 | a=int(input("enter number1"))
b=int(input("enter number2"))
c=int(input("enter number3"))
d=(b**2)-4*a*c
print(d)
if d>0:
print("there are two real roots")
elif d==0:
print("there is one real root")
else:
print("there are two complex roots")
|
d1865228891bfbe112db17f8e253d910d0259a0e | snapf/python-1811 | /Assignments/Assignment 2/simulate_qc.py | 2,652 | 3.734375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Author
------
Roman Takhovskiy (zID: 5364695)
Date
----
23/4/2021
Purpose
-------
To calculate and simulate a quarter car based on the mathematical
models provided in assignments
Description
-----------
This func... |
cd48833b863aff8281ade0f95007e878b3e4d79c | sungminoh/algorithms | /leetcode/solved/794_Swim_in_Rising_Water/solution.py | 3,917 | 3.96875 | 4 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2020 sungminoh <smoh2044@gmail.com>
#
# Distributed under terms of the MIT license.
"""
You are given an n x n integer matrix grid where each value grid[i][j] represents the elevation at that point (i, j).
The rain starts to fall. At time... |
6074398d44d16bcb864ded46843dec0983fccbcb | chhetribsurya/downloads_and_dataparse | /List_duplicates.py | 5,781 | 4 | 4 |
"""Index of duplicates items in a python list"""
source = "ABABDBAAEDSBQEWBAFLSAFB"
from collections import defaultdict
def list_duplicates(seq):
tally = defaultdict(list)
for i,item in enumerate(seq):
tally[item].append(i)
return ((key,locs) for key,locs in tally.items()
... |
44a2394f5e3f5ee736cb1a28a37b2563af2e58e6 | harshitshakya123/Syntax-of-python-program | /IfProgramFlow.py | 1,340 | 4.0625 | 4 | # name=input("Please enter your name: ")
# age = int(input("How old are you, {0}? ".format(name)))
# print(age)
# if age >=18:
# print("you are old enough to vote")
# else:
# print("Please come back in {0} years".format(18 -age))
# print("Please guess a number between 1 to 10: ")
# guess=int (input())
# if gue... |
e4b47f97cb5ef6ba8cafacf30bf9dab7c3f2210c | dsspasov/HackBulgaria | /week0/1-Python-simple-problems-set/problem15.py | 268 | 3.71875 | 4 | #problem15.py
def list_to_number(digits):
new_list = []
for digit in digits:
new_list.append(str(digit))
x = "".join(new_list)
return int(x)
def main():
a= list_to_number([9, 9, 9])
print (a)
# list_to_number(['1', '2', '3'])
if __name__ == '__main__':
main() |
72c0a3337d3a3b58de0a31cfc07673a5716e665e | water-sect/python_book_exercise | /pg_322_7.1_list-methods.py | 523 | 4.1875 | 4 | def main():
name_list = []
again = 'y'
while again == 'y':
name = input("Enter a name: ")
name_list.append(name)
print('Do you want to add another name ?')
again = input('y = yes, anything else = no: ')
print(name_list)
name_list.insert(8, "Ramesh")
... |
bab0ae2631d23fd02ba536f70a19f41ba379a17a | i3ef0xh4ck/mylearn | /Python基础/day014/04 有参装饰器.py | 4,649 | 3.59375 | 4 | # 有参数的 装饰器(根据参数执行装饰内容)
# 开关-条件-函数
# def arg(argv):
# def wrapper(func):
# def inner(*args,**kwargs):
# if argv:
# print("开始装饰")
# ret = func(*args,**kwargs)
# if argv:
# print("装饰结束")
# return ret
# return inner
# re... |
23239f5f97ec25a47d312584fa7da6ba32ff8c6a | gutus/PythonMosh | /07.Classes/03_constructors.py | 232 | 3.703125 | 4 | # CONSTRUCTORS
class Point:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def draw(self):
print(f"Point ({self.x}, {self.y}, {self.z})")
point = Point(1, 2, 5)
point.draw()
|
6ad8d52e2f24e98d3771429931f861b7b5f46aaa | Ethan-IOT-2019-summer/rocket-lander | /rocket lander/lander.py | 800 | 3.828125 | 4 |
old_position=100
initial_velocity=0
old_velocity=0
acceleration=10
old_fuel=100
gravity=-10
thrusters=0
new_fuel = old_fuel - thrusters
acceleration = gravity + thrusters
new_position = old_position + old_velocity + acceleration * 0.5
new_velocity = old_velocity + acceleration
while 1:
if new_position<=0:
... |
aadbf687934eb1d7c8c327286ef3523fa443ed50 | Prathibha1990/python_class | /26.py | 265 | 3.75 | 4 | # range() 0 to n-1
for e in range(100):
print(e)
print('................')
for e in range(10, 35):
print(e)
print('................')
# step
for e in range(0,50,3):
print(e)
print('................')
for e in range(1,11,1):
print(e,'+',e,'=',e*2) |
e83b05de0517ffbc72e2dd8b392fc36cd5a09b18 | DanielJMcCarthy/PythonLabs | /lab9_lecture_lists.py | 5,837 | 4.40625 | 4 | """
Lists are dynamic data structures, meaning that items may be added to them or
removed from them.
• List: an object that contains multiple data items
– Element: An item in a list
– Format: list = [item1, item2, etc]
– Can hold items of different types
"""
"""
Task
• Write a program that will ask th... |
bc6a44c4fd9e680be3d05b1d98d9c6a963fb3d78 | liyu10000/leetcode | /linked-list/#445.py | 2,874 | 3.609375 | 4 | # reverse and add
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
l1 = self.reverseList(l1)
l2 = self.reverseList(l2)
return self.reverseList(self.addTwoNumbers1(l1, l2))
def reverseList(self, head: ListNode) -> ListNode:
if head is None ... |
c91931e26ca84af296ba5bba0863e984714c8001 | Jiezhi/myleetcode | /src/1935-MaximumNumberOfWordsYouCanType.py | 1,274 | 3.609375 | 4 | #!/usr/bin/env python
"""
CREATED AT: 2022/3/18
Des:
https://leetcode.com/problems/maximum-number-of-words-you-can-type/
GITHUB: https://github.com/Jiezhi/myleetcode
Difficulty: Easy
Tag:
See:
"""
class Solution:
def canBeTypedWords(self, text: str, brokenLetters: str) -> int:
"""
Runtime: 5... |
bd09296f54ff87e0b00ac0ab9d732040dc9cecb3 | Elenanikiforov/my_python | /my_tasks.py.py | 586 | 3.921875 | 4 | s = []
while True:
print('Простой todo:\n 1. Добавить задачу.\n 2. Вывести список задач.\n 3. Выход. ')
p = int(input('Укажите число: '))
if p == 1:
a = input('Сформулируйте задачу: ')
b = input('Добавьте категорию к задаче: ')
c = input('Добавьте время к задаче: ')
l = 'Задача: '+ a... |
e20bcd7c5be5217dae5898123975975887724591 | sunoamit2006/Myfirstrep | /first1.py | 183 | 3.78125 | 4 | print("hello")
# comment
a = 3
print(a)
b, c, e = 5, 6.4, "hello"
print("string value is " + e)
print("{} {}".format("value is", b))
print(type(b))
print(type(c))
print(type(e))
|
9ea9e90fb5bea2d8ad9a8b97f054ae6a27a553af | sahiljohari/basic_programming | /Linked list/reverseList.py | 1,236 | 4.21875 | 4 | # Reverse a linked list in-place
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
# recursive
def reverse(head, prev = None):
'''
Time complexity: O(n)
Space complexity: O(n)
'''
if head is None:
return prev
next = head.next
... |
96a524643aaee6d13e5c9939f0b1add565a14f0a | Aasthaengg/IBMdataset | /Python_codes/p02831/s303261293.py | 116 | 3.609375 | 4 | import math
def lcm(A, B):
return int((A * B) / math.gcd(A, B))
A, B = map(int, input().split())
print(lcm(A,B)) |
918bcfa9e3a2ddb7b902624cfc753914e094a450 | martincss/temas-fluidos | /guia_3/ej2/lorenz_animation.py | 3,333 | 4.25 | 4 | # -*- coding: utf-8 -*-
"""
Martín Carusso, Florencia Lazzari
Temas avanzados de dinámica de fluidos, 2c 2017
Guía 3
Programa para la solución numérica del sistema Lorenz '63
"""
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from scipy.integrate import ode
# Ejemplo de us... |
445b75c6fcea8ecf2ce84cae636f4c545eddd8c1 | ck-unifr/babbel-challenge | /part1_task2_solution.py | 2,753 | 3.984375 | 4 | # Part 1- Basic Python
# author: Kai Chen
# date: Jan. 2017
# Task 2
table = [
{'age': 32, 'gender':'m', 'loc':'Germany', 'val':4233},
{'age': 23, 'gender': 'f', 'loc': 'US', 'val': 11223},
{'age': 31, 'gender': 'f', 'loc': 'France', 'val': 3234},
{'age': 41, 'gender': 'm', 'loc': ... |
b2e16e85bfb9f0b53c3838f7b69fe93aed1d47df | Leon-Singleton/Optical-Character-Recognition-Python | /code/system.py | 12,562 | 3.5625 | 4 | """Dummy classification system.
Skeleton code for a assignment solution.
To make a working solution you will need to rewrite parts
of the code below. In particular, the functions
reduce_dimensions and classify_page currently have
dummy implementations that do not do anything useful.
version: v1.0
"""
import numpy as... |
4b328d13fa19cc64579b6292ea2b7cf20d214dd0 | jsoto3000/js_udacity_Intro_to_Python | /HowManyDays.py | 178 | 4.125 | 4 | month = 8
days_in_month = [31,28,31,30,31,30,31,31,30,31,30,31]
# use list indexing to determine the number of days in month
num_days = days_in_month[month - 1]
print(num_days) |
1a5d5a8fe0adfa6ff945338bebf67983c75b9993 | yshshadow/Leetcode | /1-50/37.py | 4,474 | 4.15625 | 4 | # Write a program to solve a Sudoku puzzle by filling the empty cells.
#
# A sudoku solution must satisfy all of the following rules:
#
# Each of the digits 1-9 must occur exactly once in each row.
# Each of the digits 1-9 must occur exactly once in each column.
# Each of the the digits 1-9 must occur exactly once in e... |
c1714427480219d2fa7e8f762b445300e3fec16d | florije1988/manman | /learn/004.py | 495 | 3.734375 | 4 | # -*- coding: utf-8 -*-
__author__ = 'manman'
"""
输出所有的水仙花数,把谓水仙花数是指一个数3位数,其各各位数字立方和等于其本身,
例如: 153 = 1*1*1 + 3*3*3 + 5*5*5
"""
def get_flower():
for i in range(1, 10):
for j in range(10):
for k in range(10):
s = 100*i + 10*j + k
h = i**3 + j**3 + k**3
... |
3cc1fa06eee280dd2890d6270db9491989bd9d03 | bhargavdharan/DSA | /DSA in Python/Arrays/p1.py | 424 | 3.984375 | 4 | '''
store apples stock price for 5 days,
1.What was the price on day1?
2.what was the price on day3?
'''
import array as stockPrices
stockPrices = [298,305,320,301,292]
print("Element in first position:",stockPrices[0]) # price on day 1
print("Element in the last position:",stockPrices[2]) # price on day 3
print("... |
78499df9773330389506f276944b57b50451a0c4 | jamesfallon99/CA318 | /week2/all_the_neighbours.py | 1,655 | 3.65625 | 4 | #
# Use this class definition to work from.
# This way of reading the dictionary is quete messy.
# It is done this way to make testing easier.
#
from Node import Node
from string import ascii_lowercase
from read_dictionary import read_dictionary
valid_words = None
class WordGameNode(Node):
def __... |
8b6659e6fe9dd654a640d3f3bf61fb2972b433ae | YeomanYe/show-me-the-code | /0001/random_code.py | 437 | 3.65625 | 4 | # -*- coding:utf-8 -*-
import random
def rand_series(count, len=10):
str_set = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
series_set = set()
i = 0
while i < count:
series = ''
for j in range(0, len):
series += random.choice(str_set)
if series ... |
102cc147d2562b996a268a755223de6033810a5a | PinkLego/MyPythonProjects | /InventYourOwnGamesWithPython/All projects/if statements.py | 326 | 4 | 4 | is_hot = False
is_cold = False
if is_hot:
print("It's a hot today")
print("Drink plenty of water")
elif if_cold:
print ("Wear a jacket!")
print("It's cold outside!")
else:
print("It's a lovely day")
print("Enjoy your day")
# elif always should be in the middle of the if statements:
# "if" and ... |
06c69908869e4b2b44b33686261dd2319306de4f | hemanthezio/Machine_Learning | /K_Means/Mall_Customer/Mall_advanced.py | 6,045 | 3.515625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Mar 17 22:00:30 2018
@author: Hemanth kumar
"""
''' using K-Means Clustering to segment clients into different groups
based on spending and annual income using the mall dataset '''
# K-Means Clustering
# Importing the libraries
import numpy as np
import matplotlib.pyplot a... |
4527cf61e8ab48bec17942c95fb1382b1f4162c9 | wanglf/numpy101 | /013.py | 281 | 3.765625 | 4 | # 13. How to get the positions where elements of two arrays match?
# Q. Get the positions where elements of a and b match
import numpy as np
a = np.array([1, 2, 3, 2, 3, 4, 3, 4, 5, 6])
b = np.array([7, 2, 10, 2, 7, 4, 9, 4, 9, 8])
result = np.where(a == b)
print(repr(result)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.