blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
15b9b98d0c615adf0cc131c2156882e39e525f62
RenegaDe1288/pythonProject
/lesson15/mission08.py
571
3.84375
4
new_list = list(input('Введите строку: ')) position_number = 3 n_list = [] count = 0 print('Символ слева: ', new_list[position_number-2]) print('Символ слева: ', new_list[position_number]) for index in range(position_number-2, position_number+1): if new_list[index] == new_list[position_number-1]: count += ...
957d878d95ff23ca96e8fded5d1d8f38a0e3ee35
maiorani/CacoStudies
/AC_05.py
3,630
3.71875
4
from abc import ABC, abstractmethod class Funcionario (ABC): def __init__ (self, nome, cpf, data_nasc, salario): self.__nome = nome self.__cpf = cpf self.__data_nasc = data_nasc self.__salario = salario def get_nome(self): return self.__nome def...
1a0084b4dd929f32cfac01a9b0b36cded658feb3
fegoad/Codewars
/VowelCount.py
365
3.8125
4
def get_count(input_str): num_vowels = 0 i = 0 vowels = ["a","e","i","o","u"] len_input_str = len(input_str) while i < len_input_str: validation = input_str[i] in vowels if validation == True: num_vowels = num_vowels + 1 i = i + 1 else: i =...
2d4a4cd5b38efc3d991d1748b0b1d5ed147b385a
Environmental-Informatics/building-more-complex-programs-with-python-kquijano
/kquijano_program_7.1.py
1,388
4.46875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Karoll Quijano - kquijano ABE 651 - Environmental Informatics Think Python - Chapter 4-7 Exercise 7.1 """ import math def mysqrt(a): ''' Compute square roots of 'a' using Newton's method ''' x = 2 a=int(a) while True: y = (x+a/x)/2 ...
29ca78e80a0d3a14e5cb5f6d29b784d82caa2a5c
dyrnfmxm/codeit
/0309_random_number.py
604
3.6875
4
import random random_number = random.randint(1,20) # 코드를 작성하세요. count = 1 while count <= 4: n = int(input(f"기회가 {5-count}번 남았습니다. 1-20 사이의 숫자를 맞혀보세요: ")) if count == 4: print(f"아쉽습니다. 정답은 {random_number}입니다.") count += 1 elif n == random_number: print(f"축하합니다. {count}번만에 ...
ab429f9902fd73063762dd9088674c8057d18794
SaltyPineapple/blackjack
/Game.py
4,370
3.734375
4
import random import math from time import sleep """ =========================================== TO DO 1. Print face cards correctly 2. Correct Aces Functionality =========================================== """ deck = ["A", 2, 3, 4, 5, 6, 7, 8, 9, 10, "J", "Q", "K", "...
b8346f9e11c073ff5606986672d70da3144ed5cd
ksanter1987/Python-test-repo-phase-1
/phonebook_func.py
2,806
3.984375
4
def add_contact(some_dict, some_list): first_name = input('Print first name: ') last_name = input('Print last name: ') full_name = first_name + ' ' + last_name phone = input('Print phone: ') city = input('Print city: ') new_entry = some_dict.copy() new_entry['first_name'] = first_name new_entry['last_name'] ...
0ea13c96841fa081f47f1aa5f08421c0aaa54df9
z21mwKYq/Learning
/2_5_3.py
209
3.5625
4
ls = [int(i) for i in input().split()] ls2 = [] # print(ls.count(3)) for i in ls: if ls.count(i) > 1 and i not in ls2 : ls2.append(i) else: continue ls2 = sorted(ls2) print(*ls2)
8ebb4986ea77d57a71316d90652cf51d40dd4422
jungsiwoo0310/python_study
/20210428/turtle02.py
209
3.90625
4
import turtle as t t.shape('turtle') n = int(input('숫자를 입력 해주세요.:')) t.color('#ADF7BE') t.begin_fill() for i in range(n) : t.forward(1) t.right(360/n) t.end_fill() t.mainloop()
4d0d7a281402e2968b7387a4f9d68913a11a8389
vk536/MiniProject-Calculator
/Calculator/Calculator.py
866
3.59375
4
from Calculator.Addition import addition from Calculator.Subtraction import subtract from Calculator.Multiplication import multipli from Calculator.Division import division from Calculator.Square import square from Calculator.SquareRoot import root class Calculator: result = 0 def __init__(self): pas...
40884bc5b3c4c2edc05381d9f661d7c5f29780a0
cwong2k16/SBML
/hw1/q4.py
394
4.21875
4
import datetime import calendar variable = input("Enter a date in the format MM/DD/YYYY: ") date_arr = variable.split("/") month = int(date_arr[0]) day = int(date_arr[1]) year = int(date_arr[2]) date = datetime.date(year, month, day) day_name = calendar.day_name[date.weekday()] month_name = calendar.month_name[month]...
3e2c4ff23856adbb9942b5e86d695c67740601d5
yashodeepchikte/CP
/5-Recursion/MaxAndMin.py
632
3.828125
4
""" finding maximum value using recursion """ def findMax(arr, n): if n == 1: return arr[0] else: x = findMax(arr, n-1) if arr[n-1] < x: return x else: return arr[n-1] arr = [110000,5,2,3,6,7,2,8,10,1,-9, 100] findMax(arr, len(arr)) def findMin(arr, n=len(arr)): ...
c0bd40629dcc69fa77a6eebee96970716e05ddf3
Hydebutterfy/learn-python
/message/Count(Text, Pattern)函数加强.py
1,260
3.9375
4
__author__ = 'chenhaide' def reverse_string(seq): return seq[::-1] def complement(seq): #return the complementary sequence string. basecomplement={"A":"T","C":"G","G":"C","T":"A","N":"N"} letters=list(seq) letters=[basecomplement[base] for base in letters] return ''.join(letters) def reversecomp...
8756666d312ea1c19c3a4a0a3cafb69f15f12d08
gnsalok/Python-Basic-to-Advance
/PyConcepts/app.py
107
3.8125
4
num1=1 num2=2 result = addNumber(1,2) print(result) def addNumber(val1, val2): return val1+val2
c0bef6a6cc6a83c61394b4c7a797222e76478b38
marielitonmb/Curso-Python3
/Desafios/desafio-09.py
1,103
4.25
4
# Aula 07 - Desafio 09: Tabuada # Digite um valor e informe a tabuada dele n = int(input('Digite um numero: ')) print('='*10, 'Tabuada de adiçao de', n, '='*10) print(f'{n}+1 = {n+1} | {n}+2 = {n+2} | {n}+3 = {n+3} | {n}+4 = {n+4} | {n}+5 = {n+5}') print(f'{n}+6 = {n+6} | {n}+7 = {n+7} | {n}+8 = {n+8} | {n}+9 = {n+9}...
26e06f194ada6a9e744359030396f3695578af4e
Tocsmats/holbertonschool-interview
/0x09-utf8_validation/0-validate_utf8.py
619
3.828125
4
#!/usr/bin/python3 """ validUTF8 """ def validUTF8(data): """Determines if a given data set represents a valid UTF-8 encoding""" count = 0 for x in data: if 191 >= x >= 128: if not count: return False count -= 1 else: if count: ...
3af5b6c9b6521101863e2eea31642096a45c45ad
r0bse/python_VL_snippets
/vl2/functions/functions_2.py
341
3.703125
4
def age_verification(age: int, age_to_be_allowed_to_drink: int) -> bool: return age >= age_to_be_allowed_to_drink if __name__ == "__main__": print("With age 18 and threshold 21: {0}".format(age_verification(18, 21))) print("With named parameters: {0}".format(age_verification(age_to_be_allowed_to...
a45e2202edc7b2d599e6d296812fe51481ae2748
anoubhav/Codeforces-Atcoder-Codechef-solutions
/Codeforces/648 Div 2/B.py
1,629
3.828125
4
# def bubbleSort(n, arr, blist): # tags = list(range(n)) # tagtype = dict() # for ind, elem in enumerate(tags): # tagtype[elem] = blist[ind] # for i in range(n-1): # for j in range(0, n-i-1): # if arr[j] > arr[j+1]: # if tagtype[tags[j]]==tagty...
aa4630021147f5bd5efa6c0f7fefed8ca941a9ba
Shnobs/PythonOzonNS
/les_1_task_2.py
648
4.21875
4
# Сбор пользовательских зарплат salary_1 = float(input('Введите зарплату первого члена семьи: ')) salary_2 = float(input('Введите зарплату второго члена семьи: ')) salary_3 = float(input('Введите зарплату третьего члена семьи: ')) # Расчет средней зарплат average_salary = (salary_1 + salary_2 + salary_3)/3 # Испо...
364dd41443b067eaccefaefd7de4731b68fb74cd
skshamagarwal/EmailBot
/EmailBot.py
5,529
3.59375
4
import smtplib # Simple Mail Transfer Protocol import speech_recognition as sr from email.message import EmailMessage import pyttsx3 # Python Text to Speech version 3 import getpass # Take Hidden Password ...
31e7d9189c461263bc0e719eef16e6798755603e
vrlls/Traspuesta-de-una-matriz
/main.py
328
3.703125
4
def traspuesta(M,n): B = [] for i in range(n): B.append([]) for j in range(n): B[i].append(0) for i in range(n): for j in range(n): B[j][i]=M[i][j] return B n=int(input()) M=[] for i in range(n): M.append([]) for j in range(n): M[i].append(int(input())) print(traspuest...
f6c90c0df7816a210125fb8c46243671306ce39b
BenC0/python_training--ddl
/Code/7. Conditions/example.py
2,459
4.625
5
# ------------------------------------------------------------------------------ # Explanation # Conditions # Python uses boolean variables to evaluate conditions. The boolean values True # and False are returned when an expression is compared or evaluated # -------------------------------------------------------------...
072baa354b8bcfd844d7f0cac6dc5fcadf327d8f
techdragon/historia
/historia/culture/culture.py
1,681
3.84375
4
from uuid import uuid4 class Culture(object): """ Culture. Considerations that go into making up a Culture: - language - history - food - shelter - education - security - relationships - political and social organizations - religions - art e.g. Chinese """ ...
bc22fab0576294338a9a54f160086d92b67270c9
MNandaNH/MNandaNH
/For_s/arguments.py
229
3.96875
4
# -*- coding: utf-8 -*- """ Created on Fri Aug 20 09:26:51 2021 @author: franc """ def suma(*args): print("", type(args)) sum=0 for n in args: sum +=n print("Suma:", sum) suma(3)
5660f3b21c62c0a19e10ee21769c2c30aa43dce0
hurricaney/PythonStart
/PythonApplication1/Data/wordcount.py
338
3.84375
4
def wordcount(readtxt): dict={} readlist=readtxt.split() for every_word in readlist: if every_word in dict: dict[every_word]+=1 else: dict[every_word]=1 return dict readtext=""" this is a test txt! can you see this ? """ dict1={} dict1=wordcount(read...
44468eba064ad8820541903d346cde7840f7d19a
vanch1n1/SoftUni-programming-projects-and-exercises
/Python-programming-fundamentals/data_types_and_variables_lecture/centuries_to_minutes.py
213
3.75
4
century = int(input()) years = 100 * century days = int(365.2422 * years) hours = days * 24 minutes = hours * 60 print(f'{century} centuries = {years} years = {days} days = {hours} hours = {minutes} minutes')
9bfdeb4b762a418dabd0ea6b38f47e9baae29352
ClodaghMurphy/dataRepresentation
/Week6/jsonPackage0.py
374
3.5
4
#run this script to WRITE a new file containing your data{} in a json stylee called simple.json import json data = { 'name':'joe', 'age':21, "student": True#different types of quotes, python doesn't mind. } #print(data) file = open("simple.json",'w') json.dump(data,file, indent=4)#indent makes it loo...
59ae4311539d27c33b9f988bd58572045ee74de2
Davidxswang/leetcode
/medium/324-Wiggle Sort II.py
3,938
3.890625
4
""" https://leetcode.com/problems/wiggle-sort-ii/ Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3].... Example 1: Input: nums = [1, 5, 1, 1, 6, 4] Output: One possible answer is [1, 4, 1, 5, 1, 6]. Example 2: Input: nums = [1, 3, 2, 2, 3, 1] Output: One possible answer is [2,...
b6253b426a5b2d4087edb7c89cf93c9423569852
halfrice/pht
/app/c2/2.3.py
1,761
4.15625
4
# Delete Middle Node # Implement an algorithm to delete a node in the middle (i.e., any node but # the first and last node, not necessarily the exact middle) of a singly # linked list, give only access to that node. # EXAMPLE # Input: the node c from the linked list a -> b -> c -> d -> e -> f # Result: nothing is retu...
7335c04020638bab89e7394d7f6cb6aa6758541f
mqcah/python_lesson
/AI_academy/class.py
216
3.65625
4
class Point: def __init__(self, x, y): self._x = x self._y = y def output(self): print('Point(%d, %d)' % (self._x, self._y)) p1 = Point(1, 2) p2 = Point(3, 4) p1.output() p2.output()
7859b8575c6892a8001f185837c121cde9a872dd
Kunalpod/codewars
/triple_trouble.py
232
3.65625
4
#Kunal Gautam #Codewars : @Kunalpod #Problem name: Triple trouble #Problem level: 6 kyu def triple_double(num1, num2): for i in range(10): if str(i)*3 in str(num1) and str(i)*2 in str(num2): return 1 return 0
f6feb37046c6b81c92e41c0d361f188fa79dd8a9
Kopkins/refactored-telegram
/Datetime.py
1,464
3.59375
4
import re class Datetime(): def __init__(self, mon, day, year, hour, minute): self.month = mon self.day = day self.year = year self.hour = hour self.minute = minute def __str__(self): time_of_day = 'PM' if self.hour > 12 else 'AM' hour = self.hour if ti...
45cab84fd18372bc0f7176644bf3b97cb8ce68b4
qznc/dot
/bin/git-randomline
1,488
3.75
4
#!/usr/bin/env python3 """ Randomly choose a file and a line in it from the repo files. Inspired by http://www.templeos.org/Wb/Accts/TS/Wb2/WalkThru.html Basic idea: 1. Let this script give you some point in the repo. 2. Explain the line in 5 minutes Could be great for impromptu presentations to * get team members f...
5f8e762877c02c03e242f34f460289c563211929
Gaurav-Pande/DataStructures
/leetcode/binary-tree/max_average_subtree.py
957
3.75
4
#link: https://leetcode.com/problems/maximum-average-subtree/ # Definition for a binary tree node. # 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 maximumAverageSubtree(se...
d8ebd4153558082b92f90da4c0d02d85605980f5
heyutao117/pythonPractice
/Python/6.python平方根.py
317
3.875
4
# -*- coding: UTF-8 -*- import cmath num = float(input("请输入一个数字")) num_sqrt = num ** 0.5 print ('%0.3f的平方根为%0.3f'%(num,num_sqrt)) num1 = int(input('请输入一个数字:')) num_sqrt1 = cmath.sqrt(num) print('{0} 的平方根为 {1:0.3f}+{2:0.3f}j'.format(num ,num_sqrt.real,num_sqrt.imag))
eec5493c9d5cce6d8c5b77436517ade17d128984
DivyaMaddipudi/Infosyscc
/week3/1.py
849
3.796875
4
'''#2 dic = { "name" : "Divya", "Dept" : "CSE", "Year" : 3 } print(dic) dic.pop("Year") print("Dictionary values after removing is", dic) #3 count = 0 str = input("enter string:") v = set("aeiouAEIOU") for i in str: if i in v : count = count + 1 print(count) #5 import re str = "abb...
e6a852a3d8e4e604f3431ed871a5cf52dbb2b3c4
AdamShechter9/project_euler_solutions
/32.py
1,992
3.703125
4
""" Project Euler Problem 32 We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital. The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing multiplicand, multiplier, and product is 1 ...
a3b922224b5269a9b8ff4424500b68376b288b01
xhwupup/xhw_project
/105_Construct Binary Tree from Preorder and Inorder Traversal.py
2,366
4.09375
4
# 时间:20190520 # Example1: # preorder = [3,9,20,15,7] # inorder = [9,3,15,20,7] # # Return the following binary tree: # # 3 # / \ # 9 20 # / \ # 15 7 # 难度:Medium(0.5) # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None...
ebf181ffb7a6cbc18b941eb466fba4b704a80cde
carlesm/SITWLabs
/BasicWeb/getweather.py
3,023
3.515625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: set fileencoding=utf8 : ''' Get weather from weather underground Created on 11/22/2014 @author: carlesm ''' import sys import urllib2 import bs4 api_key = None # If assigned won't read argv[1] location = 'Lleida' response_format = 'xml' class WeatherClient(obj...
0882bdf7a4f6701d91a10716727b199e8a59b58f
DMeyer/AdventOfCode
/2020/day5/day5.py
1,165
3.6875
4
def row(boarding_pass): lower = 0 upper = 127 for c in boarding_pass[:-3]: if c == 'F': upper = int((lower + upper) / 2) else: lower = int((lower + upper + 1) / 2) return lower def col(boarding_pass): lower = 0 upper = 7 for c in boarding_pass[-3:]...
f487750a2916acbc761c7dacd6a735d56f97118f
gao51/TPython
/learn/ler1.py
475
3.5
4
import urllib.request as urllib from urllib import request import requests as requests import time import urllib3 def linkbaidu(): url = 'http://www.baidu.com' try: response = urllib.urlopen(url,timeout=3) print(response.info()) except urllib.URLError: print("地址错误") exit()...
925d0114d006b1401a63fd1a4fbe03dab5a2fce7
mridulrb/Basic-Python-Examples-for-Beginners
/Programs/attachments/natnos.py
84
3.84375
4
n=input("enter range") x=1 while(x<=n): print "The number is", x x=x+1
2fd18672f2fa90cdea860012debbef620a06739d
mericar/pyPlay
/pyex/forks_and_threads/forkintro.py
1,395
4.09375
4
""" #Process introduction, forks processes and exits children processes import os def child_process(): print('this is the child : ', os.getpid()) os._exit(0) def parent_process(): while True: newprocessid = os.fork() if newprocessid == 0: child_process() else: print('This is the parent process, ', os....
08e634a8ec9fc870ab80332884e110a7135cc20e
larhrib-Dev/eulerProject
/problem1.py
539
4.21875
4
# mathematical problem # If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. # The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. number_limit = int(input('enter the limit:')) multiple_three = int(input('enter the first multiple:')) ...
7c8eb2bbef1d1533396e68f612842527a8817848
nanmanat/GPA_estimator
/GPA.py
643
3.578125
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split from sklearn import preprocessing #import your file df = pd.read_csv('/GPA.csv') train , test = train_test_split(df,test_size=0.2,random_state=...
b4ab873041bc8060bf8a8bd8ebeddd379abd9496
ludimus/AOC2015
/day02/d2.py
415
3.609375
4
import sys def wrap(l,w,h): return((l*w*2) + (w*h*2) + (l*h*2)) def extra_wrap(l,w,h): nlist=[0,0,0] nlist[0]=l nlist[1]=w nlist[2]=h nlist.sort() return(nlist[0]*nlist[1]) numline=0 totwrap=0 for line in sys.stdin: l,w,h=line.split('x') totwrap+=wrap(...
486f919201cb5ef1330bec0b54a94168a9e2c315
simplyluke/austinlp
/8-27/code_examples/5.py
181
3.734375
4
# Lists a = [1, 3.93, 'hello world'] a.append(2) print a # Tuples b = (10, 20, 83) print b # Dictionaries c = {'a': 3, (10, 182, 18): 42, } print c[(10, 182, 18)]
db32bcf4929e83ec22ca2d3431944bd6fe2efff3
meet-projects/YL1201819team2
/player.py
1,745
3.953125
4
import turtle from turtle import* import random import math import time UP=0 DOWN=1 LEFT=2 RIGHT=3 direction= UP # func = partial(up, running) # turtle.onkeypress(up, UP_ARROW) # turtle.onkeypress(left,"Left") # turtle.onkeypress(up, "Up") # turtle.onkeypress(right,"Right") # turtle.listen() turtle.regis...
8e9e0a55c1ac7987bbe5e28fda6c6f2542a1e3e3
n800sau/roborep
/fchassis_test/lib/pids.py
7,493
3.734375
4
#!/usr/bin/env python # pids - Generic proportional-integral-derivative controllers. ''' Generic proportional-integral-derivative controllers. ABSTRACT A proportional-integral-derivative controller (PID controller) is a generic control loop feedback mechanism widely used in industrial control systems. ...
1bf12b87587c464a85f6637fd45ed77fd2fe990f
christianns/Curso-Python
/02_Operadores y expresiones/11_Ejercicio.py
653
4.25
4
# Ejercicio 3 - Realiza un programa que cumpla el siguiente algoritmo utilizando siempre que sea posible operadores en asignación: # * Guarda en una variable numero_magico el valor 12345679 (sin el 8) # * Lee por pantalla otro numero_usuario, especifica que sea entre 1 y 9 # * Multiplica el numero_usuario por 9 en sí m...
33b8a1e005e5234e3a8dc715d881720254e116ad
nickmwangemi/CodeVillage
/Day9-Python/accountOOP.py
797
4.125
4
""" User inputs their details Account: - balance - customer name - account number - currency """ class Account: myAccount = "" def __init__(self, accNo, name, balance, currency): self.accNo = accNo self.name = name self.balance = balance self.currency = currency def showA...
bd3b35e4b0646694bca58595f0d886e29f059c24
league-python-student/level0-module1-teashopp
/_04_int/_1_riddler/riddler.py
2,014
4.28125
4
''' * Write a python program that asks the user a minimum of 3 riddles. * You can look at riddles.com if you don't already know any riddles. * Collect the response of each riddle from the user and compare their answers to the correct answer. * Use a variable to keep track of the correctly answered riddles...
6489dc0df7d290d75171974f314a56d65e134429
Ragnhied/H20-IN1910
/calculator.py
540
3.8125
4
def add(x,y): #Exercise 1,2,3 return x + y #Her kommer fem funksjoner med utgangspunkt i metoden "Test driven development", exercise 4: def factorial(x): f = 1 while x > 0: f = x*f x -= 1 return f def sin(x, N): s = 0 for i in range(N+1): s += (((-1)**i)*(x**(2*i+1)))/...
6808bf70eaa901133c52a7c3088a59cfa7d0440c
grigor-stoyanov/PythonAdvanced
/workshop/tic_tac_toe/core/logic.py
1,244
3.578125
4
from tic_tac_toe.core.validators import is_position_in_range, is_place_available, is_winner,is_board_full from tic_tac_toe.core.helpers import get_row_col, print_current_board_state def play(players, board, turns): turn_count = 0 while True: current_player_name = turns[turn_count % 2] current_...
bd0a7f12029be4efce14ed730a86cf9e56c9cd04
le314u/Academico
/IFMG/TeoriaDaComputação/MP/MP.py
6,063
3.71875
4
class Fila: def __init__(self, string): self.dados = [] for char in string: self.dados.append(char) def __str__(self): return str(self.dados) def insere(self, elemento): self.dados.append(elemento) def retira(self): return self.dados.po...
6ed073f80973d04a78cc4231536b24752fbb5082
rbabaci1/CS-Module-Algorithms
/eating_cookies/eating_cookies.py
1,350
4
4
""" Input: an integer Returns: an integer """ import time def eating_cookies(n): # Brute force solution if n == 0 or n == 1: return 1 if n == 2: return 2 else: return eating_cookies(n - 1) + eating_cookies(n - 2) + eating_cookies(n - 3) # Memoization Bottom - Up approach ...
1b6d658567a4f65b7933152e44b7cc65de2497c3
jugorcz/PolygonsSumAndProduct
/LinkedList.py
6,683
3.75
4
class Node: def __init__(self, key, value, next=None): self.key = key # line self.value = value # pos y = f(x) -> (x,y) self.next = next class LinkedList: def __init__(self, linesDictionary): self.start = None self.size = 0 self.dictionary = linesDictionary ...
222ebf7bd73e29fbd9a5124cf851e29c287fc363
Adasumizox/ProgrammingChallenges
/codewars/Python/8 kyu/AlanPartridgeIIAppleTurnover/apple_test.py
1,441
3.515625
4
from apple import apple import unittest class TestAlanPartridgeIIAppleTurnover(unittest.TestCase): def test(self): self.assertEqual(apple('50'), "It's hotter than the sun!!") self.assertEqual(apple(4), "Help yourself to a honeycomb Yorkie for the glovebox.") self.assertEqual(apple("12")...
480fba202c1fac7a972d684e57f851dbd475193f
shivansh-max/Algos
/Arrays/Medium/FindSumWithGoalNumber.py
643
3.546875
4
class FindSumWithGoalNumber: def __init__(self): pass def findSumWithGoalNumber(self, goalNumber, array): found_numbers = [] print(f"Array : {array}") found_numbers = [] for i in array: diff = goalNumber - i if i != diff: if ...
aabd32c9358aa2954f3a6fd5d7eedab23f4710b8
olutayodurodola/problems
/draw_flower.py
768
3.734375
4
import turtle def draw_flower(): window = turtle.Screen() window.bgcolor("red") brad = turtle.Turtle() brad.shape("turtle") brad.color("yellow") brad.speed(10) for i in range(0,20): brad.forward(60) brad.left(45) brad.forward(30) brad.left(90) brad.forward(30) brad.left(45) br...
9ab153ba6cce49131906fd5b1b3c95e527187e7b
GitFiras/CodingNomads-Python
/15_generators/15_02_divisible.py
222
4
4
''' Create a Generator that loops over the given list and prints out only the items that are divisible by 1111. ''' my_list = range(1,100000) generator = (num for num in my_list if num % 1111 == 0) print(list(generator))
b74f65e976e94ef75507948fc55727368afd8643
ilmiraS/jobeasy-python-course
/lesson_1/homework_1_6.py
456
4.21875
4
# Write your first proger the temperature right now in Fahrenheit in temperature_fahrenheit variable as # # a string (e.g. '75') and convert it to Celsius. # # !important you should save only number to result_temperature. Formula (32°F − 32) × 5/9 = 0°C # # # type your code here #temperature_fahrenheit = input("Enter ...
701e6f6390c3bffcbbeb4e1626094f3aaaa7b2c6
baysalbektas0/CyberKey_Method_and_MergeList_Method
/Result2.py
1,539
3.609375
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 16 14:15:29 2021 @author: BektasBaysal """ def sortList(array): """ listedeki elemanları büyükten küçüğe sıralama methodu""" print("sort içinde") for i in range(len(array)): IlkDeger = i for j in range(i+1, len(array)): ...
f4fd96ea6138af1666de6470f5c729e347bef127
DUanalytics/pyAnalytics
/01C-IIM/PD00_main.py
11,300
3.53125
4
#Topic:Pandas DF #----------------------------- #libraries import numpy as np import pandas as pd #pandas DF are combination of panda Series.. #one column data is a Series of one datatype, DF can have multiple data types from pydataset import data mtcars = data('mtcars') mtcarsDF = mtcars mtcarsDF #%%describing mtc...
c70cb4d42c6fb8eae5567f67f7007bc27cdc7a13
gnd/cancer-works
/process_reading.py
1,676
3.5
4
# -*- coding: utf-8 -*- import re import sys reload(sys) sys.setdefaultencoding('utf-8') import argparse # process user input parser = argparse.ArgumentParser(description='Processes a body of text into sentence metadata for Tacotron 2.') parser.add_argument('infile', help='Name of the infile.') parser.add_argument('ou...
4c307af457089fe0cb50a811931c925b704505fc
Legacy-Coding/game
/ChildGame.py
2,180
3.875
4
# Stone paper scissors Game # import pyinstaller import random chracters=[ "1", "2", "3"] print( "1 for stone","2 for paper","3 for scissors") computer_choice= random.choice(chracters) no_of_chance=10 chance=0 human_point=0 computer_point=0 while no_of_chance > chance: Your_input=input(" Select your input\nStone...
9a0bd2f22054bbc6c842a3fb0f1ec2d0857f15d9
Farizabm/pp2
/practice pygame/2.py
573
3.703125
4
import pygame pygame.init() #RGB(255,255,255) black=(0,0,0) white=(255,255,255) blue=(0,0,255) green=(0,255,0) red=(255,0,0) size =(400,500) screen = pygame.display.set_mode(size) pygame.display.set_caption("PyGame example") done = False while not done: for event in pygame.event.get(): if event.type =...
15d8d733d947afdf969320803bcd78e1887fb74b
CHENTHIRTEEN/PTA-PYTHON
/chap4/4-3.py
83
3.6875
4
n = int(input()) sum = 1 for i in range(1, n): sum = (sum + 1) * 2 print(sum)
b631b70a1bce5c11a6317600a8ffe995540aff32
brunolange/dcp
/Chapter06/6.2/solution.py
874
3.59375
4
""" Reconstruct tree from pre-order and in-order traversals """ def reconstruct(pre_order, in_order): if not pre_order and not in_order: return None if len(pre_order) == len(in_order) == 1: return pre_order[0] root = Node(pre_order[0]) i = in_order.index(root.value) root.left = ...
3a4eb52866ceaf1315179647396e46ba22182b85
mikeodf/Python_Line_Shape_Color
/ch5_prog_12_line_electrify_randomization_1..py
7,529
4.03125
4
""" ch5 No.12 Program name: line_electrify_randomization_1.py Objective: Add random components to line segments. Test edge conditions. Keywords: line, random, edge cases. ============================================================================79 Comments: Tested on: Python 2.6, Pyth...
6af4235b803101d82cd6fbadcec4c96ec1a3c19e
ss4328/codingProblems
/archieve/leetcode/trees/lc98_validateBST.py
911
4.09375
4
# Definition for a binary tree node. # 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 isValidBST(self, root): """ :type root: TreeNode :rtype: bool ...
2c6e836cac80cc8223cf5c3a8d999bf43ecbf7b1
Louis-sf/BIS-398-498-LiuShufan
/Assignment4/Assignment 4 - Exercise 7.9.py
765
4.3125
4
# 7.9 (Indexing and Slicing arrays) Create an array containing the #values 1–15, reshape it into a 3-by-5 array, then use indexing and #slicing techniques to perform each of the following operations: import numpy as np numbers = np.array([i for i in range(1,16)]).reshape(3,5) #1. Select row 2. numbers[2] ...
eb37a77b3868a887fd1fdb4c600077566f7d5cbe
mckannaj/Insight_Leetcode
/Week2/Problem6/Zephy_McKanna.py
2,715
3.875
4
""" Given an array where elements are sorted in ascending order, convert it to a height balanced BST. Source: https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/#/description """ import math # Constructor for a binary tree node. class TreeNode(object): def __init__(self, x): self.val...
3ae166c356ab2dce9a8b37dc1557632d290ae20d
aWildOtto/chestnut-tutorial
/chestnutcrazy.py
6,748
4.34375
4
from collections import namedtuple Customer = namedtuple('Customer', 'name order') Store = namedtuple('Store', 'name inventory') def part1(customers, stores): """ Function that does Part 1: Part 1A: Assuming the list is sorted in decending price, calculate and print the average item pri...
235b6e3e36c657d3a56def5306da43038902e669
rootAir/selenium-python
/python-intro/functions.py
391
3.53125
4
#Funções são funções como na matemática #def #Funções anônimas lambda #Def > define, definir # nome ( Argumento ou parametro ) #Return devolva um valor def diga_ola (nome_da_pessoa): return f'Olá {nome_da_pessoa}' print(diga_ola('Elza')) print(diga_ola('Maria')) print(diga_ola('João')) print(diga_ola('Fulan...
da6bb267dbbd2e6949478f245c6b7562719fd476
lainekendall/CS61A
/Lecture/Lec1:28.py
1,086
4.15625
4
Lecture 1/28 Fibonancci Sequence 0th element: 0 0 1 1 2 3 5 8... creates a spiral in squares with side lengths of the #s Generalization generalizing patterns with arguments regular geometic shapes relate length and area Area(square)=r^2 Area(circle)=pi r^2 assert 3>2, 'Math is broken' nothing will happ...
fe2d788952dcef1ac3a332b4c90d031aa94d4757
BjaouiAya/Cours-Python
/Other/Tools/docstring_course.py
1,890
4.5
4
#!/usr/bin/env python # -*- coding: utf-8 -*- def add(a, b): """ Adds two numbers and returns the result. This add two real numbers and return a real result. You will want to use this function in any place you would usually use the ``+`` operator but requires a functional equivale...
d3bcc4454fa7337652cdc7ebeb5ee4d525c7e107
schaetimm/cg_1
/Vector/Vector4.py
6,510
3.796875
4
class Vec4(): def __init__(self, x=0, y=0, z=0, w=0): """Constructor for Vec4 DO NOT MODIFY THIS METHOD""" self.values = [x, y, z, w] def __str__(self): """Returns the vector as a string representation DO NOT MODIFY THIS METHOD""" toReturn = '' if self is...
4c7315defe0e946e4e0c6c7d76b208d68c21f592
rajeshkannanb/PythonPrograms
/encapsulate.py
1,243
4.1875
4
class Encapsulate: #declare private variables __speed = None __color = None #Init method for class def __init__(self): self.__speed = 100 self.__color = "Grey" #public method to set the speed of car def set_speed(self, speed): self.__speed = speed #public metho...
8709a3c6773b8dbed3111e14450b51fa76256a8a
Gowri678/ResumeChatBot-Dialogflow
/experience.py
581
3.5
4
import MySQLdb # Open database connection db = MySQLdb.connect("localhost","root","1234","TESTDB" ) # prepare a cursor object using cursor() method cursor = db.cursor() # Drop table if it already exist using execute() method. cursor.execute("DROP TABLE IF EXISTS EXPERIENCE") # Create table as per requirement sql = ...
b960b883c0d1b7a2c5051aca0e6a9a8aa8c46310
stronger-jian/learn_python3
/python/pythonic/c3.py
103
3.796875
4
#列表推导式 #list set dict tuple a={1,2,3,4,5,6,7,8,9,10} b={i**2 for i in a if i>=5} print(b)
36a3a6abd182079786e382092aee71ed230b8bf6
gutierrecunha/urionlinejudge_python
/URI_1012 - (8433094) - Accepted.py
449
3.8125
4
Arr = input().split( ) A=Arr[0] B=Arr[1] C=Arr[2] TRIANGULO = (float(A) * float(C))/2 print("TRIANGULO: {:.3f}".format(TRIANGULO)) pi = 3.14159 CIRCULO= float(C)*float(C) * pi print("CIRCULO: {:.3f}".format(CIRCULO)) TRAPEZIO = ((float(A)+float(B))*float(C))/2 print("TRAPEZIO: {:.3f}".format(TRAPEZIO)) QUADRADO= float...
eaac3eacd730c4ad7d6fc10efbfe1d8adb264ee9
wintryJK/python_project
/day29/03 属性查找.py
833
3.984375
4
# 单继承背景下的属性查找 # 示范一: # class Foo: # def f1(self): # print('Foo.f1') # # def f2(self): # print('Foo.f2') # Foo.f1(self) # # self.f1() # # class Bar(Foo): # def f1(self): # print('Bar.f1') # # obj = Bar() # obj.f2() # Foo.f2 # Bar.f1 # 示范2 # class Foo: # def f1(se...
be3feca0cf391b77b199e22d6a8c6337e884952c
15929134544/wangwang
/py千峰/day13线程与协程/threading01.py
1,839
4.125
4
""" 又想并行执行线程,又想保证数据的安全性,则引入同步 如果多个线程共同对某个数据进行修改,则可能出现不可预料的后果,为了保证数据的正确性,需要对 多个线程,需要对多个线程进行同步。 同步:一个一个的完成,一个完成另一个才能进来。效率就会降低。 使用Thread对象的Lock或者Rlock可以实现简单的线程同步,这两个对象都有acquire和release方法, 对于那些需要每次只允许一个线程操作的数据,可以将其放在acquire和release方法之间。(就可以将 要操作的数据锁住) 多线程的优势在于可以同时运行多个任务(至少感觉起来是这样)。但是当线程需要共享数据时,可能存在 数据不同步的问题,为了避免这种情况,所以才...
eb9a7eeea9e3d9a7f620cc77568350d6d2fb6168
meganjacob/CS50AI
/Project0/tictactoe/tictactoe.py
3,482
3.9375
4
""" Tic Tac Toe Player """ import math import copy X = "X" O = "O" EMPTY = None def initial_state(): """ Returns starting state of the board. """ return [[EMPTY, EMPTY, EMPTY], [EMPTY, EMPTY, EMPTY], [EMPTY, EMPTY, EMPTY]] def player(board): """ Returns player who h...
07dbfdf51b070eb0b6c89a842f2c84d18bb44451
anhnguyendepocen/Dynamics
/lineup.py
1,025
3.5
4
# -*- coding: utf-8 -*- """ Created on Mon Apr 16 20:57:37 2018 @author: shahrear student.eco86@gmail.com ref: https://matplotlib.org/examples/mplot3d/lorenz_attractor.html """ import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D def lineup(x, y, z, a=10,b=1,c=10,d=1,e=3,f=2,g=3...
f16e49e286ffbc27eab62df2f774f7a799e8206a
aesopiaceo/newtest
/create_tables.py
558
3.796875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Apr 26 23:12:37 2020 @author: eddomboAesopia """ import sqlite3 connection = sqlite3.connect('data.db') cursor = connection.cursor() create_table = "CREATE TABLE if NOT EXISTS users(id INTEGER PRIMARY KEY, username text, password text)" # AUTO-INC...
1fd4c8fd677d857fe3dae7005f5d07bb7433dcf3
danielts0121/Begginig
/hello-world.py
89
3.703125
4
num = 12 // 4 num = num * 2 num = num * 2 print(num) def print_hello(): print("HI")
ee5e85b0bd5e4f32fe069c6f14877c3bc396f004
azalduar/cs215_Intro_to_Algorithms
/week3/pset3/BridgeEdge.py
7,402
4.125
4
# Bridge Edges v4 # # Find the bridge edges in a graph given the # algorithm in lecture. # Complete the intermediate steps # - create_rooted_spanning_tree # - post_order # - number_of_descendants # - lowest_post_order # - highest_post_order # # And then combine them together in # `bridge_edges` # So far, we've re...
4c761268c0874cbc16af7f2f6696ad3995b896ec
vishwasks32/python3-learning
/myp3basics/examples/ex4.py
298
3.78125
4
#!/usr/bin/env python3 # # Author : Vishwas K Singh # Email : vishwasks32@gmail.com # aList = [] # an empty list bList = [1,2,3] print(bList[2]) bList.append(4) print(bList.pop()) print(bList) bList.remove(2) print(bList) # Tuples ktuple = (1,2,3,4) print(ktuple) print(len(ktuple)) print(ktuple[2]) print(ktuple[2:4])...
6781a619f3cca60f64e9171692138ac5472152b7
DrunkReaperMatt/LOG635-H2019
/labo2/ImageProcessing/imageprocess.py
1,187
3.75
4
#!/usr/bin/env python # coding: utf-8 ''' Program allowing the conversion of an image to Grey color and crop out the desired region. Inspired from: Programme Python basique pour extraction de primitives Ameni MEZNI, ameni.mezni.1@etsmtl.net Date: 22/08/2018 Necessary command(s): pip install opencv-python ''' # imp...
6c7f802ccd68fed59a9d33efba7f17d4512abfd9
houstonwalley/Kattis
/Python/Planina.py
75
3.765625
4
n = int(input()) h = 2 for i in range(n): h += (h - 1) print(pow(h, 2))
b3cfb3dd5be2370f3e17531498059fff03bebffc
aggykey/Bootcamp
/day_2/sum_digits.py
223
3.9375
4
def sum_digits(A): ''' Takes a list A,and returns the sum of all the digits in the list e.g[10,30,45] should return 1+0+3+0+4=5 ''' total = 0 for i in A: for i in str (i): total+=int(i) return total
b5311e11b16a6b1c61e907a9dfaad97650c53bf8
ksaubhri12/ds_algo
/practice_450/greedy/32_smallest_number.py
1,156
3.796875
4
import math def smallest_number(sum_value: int, digits: int): max_sum = 9 * digits if sum_value > max_sum: return "-1" curr_sum = 1 number = str(int(math.pow(10, digits - 1))) return smallest_number_util(curr_sum, number, sum_value, digits) def smallest_number_util(curr_sum: int, number...
85d9031b2ef97761ea742a363b586fea521c9d4e
omarsinan/hackerrank
/submissions/day_6.py
248
3.75
4
# author: Omar Sinan # date: 01/09/2017 # description: HackerRank's "Day 6: Let's Review" Coding Challenge n = int(raw_input()) strings = [] for i in range(n): s = raw_input() strings.append(s) for i in strings: print i[::2], i[1::2]
60f586e5c910ace0c67d8edcb7bb039bdf58e1ef
mrkiril/softheme
/simple.py
2,571
3.78125
4
from math import sqrt import re import time class SimpleNumb(object): """ Some about this class """ def __init__(self, n): self.n = n def s_num(self): """ Search all simple numbers to the number you input in class identification """ lst = [2] ...
783656258bd5b5fcbff7385b151251f4cbfd3084
yuchen125/mygit
/OOP/practice_school.py
3,348
3.984375
4
Course_list = [] class School(object): def __init__(self, school_name): self.school_name = school_name self.students_list = [] self.teachers_list = [] global Course_list def hire(self, obj): self.teachers_list.append(obj.name) print("我们现在聘请了一个新老师{0}".format(obj....
8fd85f810c2867a2f06435ba4892940632380931
rishinkaku/advanced_python
/generators_and_iterators/generators.py
1,450
3.96875
4
""" Генераторы Генераторы позволяют значительно упростить работу по конструированию итераторов. В предыдущих примерах, для построения итератора и работы с ним, мы создавали отдельный класс. Генератор – это функция, которая будучи вызванной в функции next() возвращает следующий объект согласно алгоритму ее работы. Вмес...
1f2762d5e4b677a7c6d538097c555802e1811556
carmenLi555/python-challenge
/PyBank/main2.py
2,452
3.796875
4
import os import csv budgetcsv = os.path.join("Resources", "budget_data.csv") with open (budgetcsv, 'r') as csvfile: csvreader = csv.reader(csvfile, delimiter=',') header =next(csvfile) print(f"Header: {header}") # find net amount of profit and loss by creating a list PandL = [] months = ...
8a61abc712fa702ca0377382bc1d1caa9d5f944a
Hunter-Chambers/WTAMU-Assignments
/CS3305/Demos/demo0/hello.py
493
3.875
4
#!/usr/bin/env python3 ''' This is a simple Python 3 program Program text should be entered using vim or gvim and saved in a file named hello.py. At the CLI prompt, enter the command: chmod u+x hello.py to inform the Linux OS that the file should be executable. To execute this program, at the CLI prompt enter ...