blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
94ac94de52ca31ecc410eae41a6fa56098339a24 | backpropagator/History-Scrapper | /api/connection_utils.py | 846 | 3.65625 | 4 | import sqlite3
'''
Utility functions to return Sqlite3 database files given the path
'''
def return_db(path):
connection = sqlite3.connect(path, timeout=5)
c = connection.cursor()
query = "SELECT urls.url, urls.visit_count FROM urls, visits WHERE urls.id = visits.url;"
#c.execute("title from urls")
c.execute(que... |
afc87d539e257d0883375a06523ccee1cb02ae04 | raysmith619/Introduction-To-Programming | /exercises/introduction/blazing_intro/my_poly.py | 266 | 3.5625 | 4 | # my_poly.py 11Jan2022 crs, turtle polygon, loop
from turtle import * # Turtle stuff
print("Make polygon")
clr = "orange"
side = 200
color(clr)
nside = 7
angle = 360/nside
i = 0
while i < nside:
right(angle)
forward(side)
i = i + 1
|
7fb7f254895e4bd76d483ef478588d0801587a50 | Doublc-Qluv/code | /Crytpo/crypto1/Affine.py | 1,008 | 3.625 | 4 | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
# E(x) = (ax+b) mod m
# D(x) = (a^-1)(x-b) mod m
# 判断是否互素 即判断a和m是否互素,
def gcd(a,b):
while a!=0:
a,b = b%a,a
return b
def findModReverse(a,m):#这个扩展欧几里得算法求模逆,辗转相除法
if gcd(a,m)!=1:
return None
u1,u2,u3 = 1,0,a
v1,v2,v3 = 0,1,m
whil... |
ce6a8a6e242479b0bb4a472dba25327f7623e060 | RenanBertolotti/Python | /Curso Udemy/Modulo 03 - Python Intermediário (Programação Procedural)/Aula 02 - Funçoes (def) (Parte 2)/Aula02.py | 1,071 | 4.09375 | 4 | """
Funçoes (def) - return
"""
def funcao(msg):
#print(msg)
#Em vez de print, usar:
return msg
variavel = funcao("ola mundo")
print(variavel) #Retorna NULO , pois foi utilizado o print como retorno na funçao!,sendo o correto RETURN
#quando acontecer isso,usar:
if variavel is not None: ... |
3e8cde10b921baf5c082b7e73c9e8bd9402dc6af | angelortizv/itcr-courses | /CE3102 - NUMERICAL ANALYSIS FOR ENGINEERING/Important_Material/Nonlinear_equations/serieTaylor.py | 345 | 3.546875 | 4 | import math
def func_e(x, n):
e_approx = 0
for i in range(n):
e_approx += x**i/math.factorial(i)
return e_approx
x = 2
for i in range(1,11):
e_approx = func_e(x,i)
e_exp = math.exp(x)
e_error = abs(e_approx - e_exp)
print(f'{i} termino: Aproximacion= {e_approx}, exp calc= {e_e... |
7d10e325588edf1e39ee850cf4e0d9e62350a0ec | jakehoare/leetcode | /python_1001_to_2000/1169_Invalid_Transactions.py | 2,306 | 3.515625 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/invalid-transactions/
# A transaction is possibly invalid if:
# the amount exceeds $1000, or;
# if it occurs within (and including) 60 minutes of another transaction with the same name in a different city.
# Each transaction string transactions[i... |
0e01ac62f51ccffc6a5fe3517af7d6bdf738af31 | VSpyridonos/complex-queries-evaluation-algorithms | /aggregate queries/hashing2.1.py | 2,893 | 3.59375 | 4 | # Description: If the titles' average ratings are inside specific ranges (0-1, 1.1-2, 2.1-3, ..., 9.1-10), for each range, find the number of titles whose average rating is inside that range. This version uses hashing.
import csv
with open('title.ratings.tsv', 'r') as file:
tsv_reader = csv.reader(file, delimite... |
aa678234e0aece9571ba8ef6fa0faeb23735a2a3 | BlackHat-Ashura/Data-Structures-And-Algorithms | /Stack and Queue/Queue_List_No_Limit.py | 1,173 | 3.96875 | 4 | class Queue:
def __init__(self):
self.list = []
def __str__(self):
if self.isEmpty():
return "[!] Queue is empty.\n"
else:
values = [str(value) for value in self.list]
return 'Out<- ' + ' '.join(values) + ' <-In\n'
def isEmpty(self):
... |
2f710e93b0bc8b06d4cef958205565d10a3eef6d | liutongling/leetcode | /november1/november_18_GasStation134.py | 2,442 | 3.53125 | 4 | import queue
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def canCompleteCircuit(self, gas: list, cost: list) -> int:
longGas = len(gas)
for i in range(longGas):
... |
2c6624ce6f51d39a0bc8a88c5b9c1df8eef5f9f0 | alexmill/techcamp_2017 | /session5/exercises_solution.py | 906 | 3.796875 | 4 | import requests
from pyquery import PyQuery as PQ
# Insert the URL you want to scrape here
url = "https://en.wikipedia.org/wiki/Canadian_PGA_Championship"
# Initialize the PyQuery object
r = requests.get(url)
raw_html = r.text
pq = PQ(raw_html)
# Select just the set of elements that you want to extract
# Use CSS se... |
d4d052480bbf9f76fc63503496d31a08045ce7aa | au-webdesign/CSC1700 | /drive_loops_theature_PM.py | 652 | 4.15625 | 4 | # Suppose you want to output the cost per each
# seat in a theature. Rules:
# YOu have 6 ROWS and Each Row has 5 seats
# Suppose the cheap seats cost 5.50
# the expensive are 7.50 and they are the center seats
ROWS = 6
COLS = 5
CHEAP = 5.50
CENTER = 7.50
print(" ", end=" ")
for col in range(1,(COLS+1)):
... |
4758c77c76389380fd0d738fabf7dff64b5c5367 | xwil560/263-Project | /benchmark.py | 4,239 | 3.5 | 4 | # imports
import numpy as np
from matplotlib import pyplot as plt
from LPM import *
def pressure_benchmark():
''' Check if the pressure ode is implemented correctly by comparing it to the analytical solution
Parameter:
-------
None
Return
--------
None
'''
... |
2a3a8bb30289eeaa4ee858d7aa2d80bc825d8553 | Okajin/python_work | /Chapter 6/favorite_places_6-9.py | 587 | 3.578125 | 4 | favorite_places = {
'florient': {
'place1': 'Tokyo',
'place2': 'Nantes',
'place3': 'Los Angeles',
},
'sedo': {
'place1': 'Avignon',
'place2': 'Golden Sand',
'place3': 'Reach',
},
'ninie': {
'place1': 'Stormwind',
'place2': 'Darnassus'... |
c3b245d5d7914f9ec6593a96a549365b557af86e | pnevares/python-getting-started | /lesson_06.py | 167 | 4.125 | 4 | five = 5
ten = 10
print("five is " + ("bigger" if five > ten else "smaller") + " than ten")
print("ten is " + ("bigger" if ten > five else "smaller") + " than five")
|
f970a9aa8b2ec7491b6e18e3359bf0ff611efbe3 | saubhik/leetcode | /problems/partition_labels.py | 2,493 | 3.5625 | 4 | from typing import List
class Solution:
# Maintain a partition mapping characters to partitions.
# Maintain a counts of characters in each partition.
# For each character in given string:
# If character is already mapped to a previous partition,
# remap all the characters which are mapped to great... |
6859238438e550bcf298b437c049a370c779c38c | gerecorrea/Curso_Python | /Secao7_Colecoes/dicionarios.py | 4,586 | 4.21875 | 4 | """
Dicionários.
Obs: Em algumas linguagens, os dicionários Python são conhecidos por mapas
Dicionários são coleções do tipo chave e valor.
É possível representá-los em listas e tuplas, através da replicação delas
Representando então outros elementos em um mesmo índice
Importante lembrar que sempre é buscado p... |
08375e061735d1e82675397450f884ebd57b0293 | rtate7/CSS-225-Module-6 | /degrees.py | 454 | 4.625 | 5 | # Bob Tate
# 1/28/21
#
# Solution to Problem #5
# Converts a user-inputted degree measurement to radians using
# both a caluculation and the math.radians() function
import math
degrees = float(input("Please enter the number of degrees: "))
calculated_radians = (degrees * math.pi) / 180
library_converted_radians = m... |
8f394b68ddc782147efa2152a2c04ab052c07c3b | alexcnr/arduino_alexcnr | /termo_v1.0/work.py | 312 | 4.125 | 4 | #Преобразование string во float в списке
str_lst = ['10.505', '2.3', '3.99']
float_lst = [float(x) for x in str_lst]
print (float_lst[0])
#Пример преобразования string в int в списке
str_lst = ['1', '2', '3']
int_lst = [int(x) for x in str_lst]
print (int_lst) |
658eae28dbd318acd554ddc0db193d080baf5eee | yongge666/advancePython | /slice_object.py | 1,454 | 4.15625 | 4 | # coding:utf8
# 实现一个具有切片功能的对象
import numbers
class Group:
def __init__(self,group_name,company_name,staffs):
self.group_name = group_name
self.company_name = company_name
self.group_staffs = staffs
def __getitem__(self, item):
cls = type(self)
if isinstance(item,slice):
... |
108e1107c312780bd21909861689f51d4301f4fd | linfengzhou/LeetCode | /archive/python/Python/breadth_first_search/261.graph-valid-tree.py | 1,176 | 3.765625 | 4 | class Solution:
"""
@param: n: An integer
@param: edges: a list of undirected edges
@return: true if it's a valid tree, or false
"""
def validTree(self, n, edges):
# write your code here
if n == 0:
return False
if len(edges) != n - 1:
return False... |
7e6c89527f3f3322721a4fac673971181c00188a | dcostersabin/Machine-Learning | /DecisionTree/decisiontree.py | 783 | 3.734375 | 4 | # importing the libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.tree import DecisionTreeRegressor
# importing the dataset
dataset = pd.read_csv('Position_Salaries.csv')
X = dataset.iloc[:, 1:-1].values
y = dataset.iloc[:, -1].values
# training the Decision tree regression... |
addfc129de3d1c0111fc2f998bcf3d216a29b625 | cuiy0006/Algorithms | /leetcode/461. Hamming Distance.py | 631 | 3.875 | 4 | class Solution(object):
def hammingDistance(self, x, y):
"""
:type x: int
:type y: int
:rtype: int
"""
res = 0
while x != 0 or y != 0:
if 1 & x != 1 & y:
res += 1
x = x >> 1
y = y >> 1
return res
... |
5c33491702474282cea1d28ad91c9324f910ada5 | YunusEmreAlps/Python-Basics | /4. OOP/Encapsulation.py | 1,468 | 4.40625 | 4 | # Encapsulation (Kapsülleme)
# Bir sınıfa ait değişkenlerin veya niteliklerin ancak o sınıfa ait metotlar tarafından değiştirilebilmesi ve okunabilmesi ilkesidir.
# Bu ilke sayesinde nesnelerde oluşacak anlamsızlıkların önüne geçilebilir.
class Book:
# instance attributes
def __init__(self, author, book_... |
b5f106c987d61553a0a4affe978e5a840fee8c3a | YunYouJun/LeetCode | /problems/ping-heng-er-cha-shu-lcof/solution_2.py | 621 | 3.5625 | 4 | from helpers.py.tree_node import TreeNode
class Solution:
"""
时间复杂度较高
"""
def depth(self, root: TreeNode):
if not root:
return 0
return max(self.depth(root.left), self.depth(root.right)) + 1
def isBalanced(self, root: TreeNode) -> bool:
if not root:
... |
73ca3925410932bb18b86b3026b8def4ff65fb52 | Denis8967167/FirstProject | /309.py | 207 | 3.828125 | 4 | def election(x, y, z):
if a != b and a != c:
return b
if b != a and b != c:
return a
if c != a and c != b:
return a
a = 1
b = 0
c = 1
res = election(a, b, c)
print(res)
|
1c6ed1c87107bf571f652b7e8e5d11c6342bba78 | anaskhan28/Python-practice-codes | /Chapter 4/04_01_fruit_store.py | 307 | 3.890625 | 4 | f1 = input("Enter the fruit name:")
f2 = input("Enter the fruit name:")
f3 = input("Enter the fruit name:")
f4 = input("Enter the fruit name:")
f5 = input("Enter the fruit name:")
f6 = input("Enter the fruit name:")
f7 = input("Enter the fruit name:")
myfruitlist = [f1,f2,f3,f4,f5,f6,f7]
print(myfruitlist) |
01cb6ebb97347d44a4f57db379c23e53529c11b8 | anbansal/Python-for-Everybody | /Ch4-Functions/exerciseEndOfChp1.py | 453 | 3.890625 | 4 | def computepay(hours,rate):
multiplier = 1.0
if hours > 40:
multiplier = 1.5
pay = multiplier * hours * rate
print("Pay: ", round(pay, 2), "$")
promt = "Please enter hours: "
try:
hours = float(input(promt))
except:
print("Please enter hours in numeric!")
quit(0)
promt = "Please ent... |
0453435b0a77cbc1dfc0c2db64e76ae9f47e3c35 | Greek-and-Roman-God/Athena | /codingtest/week06/level10_recursion/fibonacci_num_5.py | 175 | 3.65625 | 4 | # 피보나치 수 5
def fibonacci(n):
if n==0:
return 0
elif n==1:
return 1
else:
return fibonacci(n-2)+fibonacci(n-1)
n=int(input())
print(fibonacci(n)) |
af2343a2830bed0acaff9851c6752087433b801a | rodcoelho/python-practice | /cracking_coding_interview/ch_1/prob_1.py | 1,211 | 3.609375 | 4 | #!/usr/bin/env python3
import unittest
class UniqueChecker:
def characters_are_unique_v1(self, string: str) -> bool:
num_of_chars = len(string)
final_set = len(set(char for char in string))
if num_of_chars == final_set:
return True
return False
def characters_are_unique_v2(self, string: str) -> bool:
... |
31afda1ac811aecde431cb33694eb02ea58ed5e9 | overnightover/git-test | /src/py/f01.py | 613 | 4.0625 | 4 | def print_triangle(n):
if n == 0:
return []
elif n == 1:
return [[1]]
else:
triangle = print_triangle(n-1)
row = [1]
for i in range(1, n-1):
row.append(triangle[n-2][i-1] + triangle[n-2][i])
row.append(1)
triangle.append(row)
return... |
9fe1ea81d71d49f36f950b3794e43044eb91e88b | yashaslokesh/100-Days-Of-Code | /Python/d029_first_genetic_algorithm/dna.py | 1,281 | 3.5 | 4 | import random
import math
class DNA():
def __init__(self, data_length):
self.chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .!,?"
self.genes = [letter for letter in random.choices(self.chars, k=data_length)]
self._fitness = 0
def phrase(self):
return "".... |
20e255b0344ea14056fe95c7fbf90d0219dd5347 | alvaronaschez/amazon | /leetcode/amazon/arrays_and_strings/group_anagrams.py | 653 | 4.09375 | 4 | """
https://leetcode.com/explore/interview/card/amazon/76/array-and-strings/2970/
Group Anagrams
Given an array of strings, group anagrams together.
Example:
Input: ["eat", "tea", "tan", "ate", "nat", "bat"],
Output:
[
["ate","eat","tea"],
["nat","tan"],
["bat"]
]
Note:
All inputs will be in lowercase.
The o... |
149f4af8a6b1dc0c30f60a6c8817984475b30e9e | dionwang88/lc1 | /algo/367_Valid_Perfect_Square/Q367.py | 501 | 3.578125 | 4 | class Solution(object):
def isPerfectSquare(self, num):
"""
:type num: int
:rtype: bool
:desc: binary search
"""
if (num < 1): return False;
left, right = 1, num
while left <= right:
mid = left + (right - left) / 2
t = mid * mid... |
d2c5252cc074c7c0f2b6ed92ca7b48bdb0919112 | parthu12/DataScience | /daily practise/evennum.py | 137 | 4.03125 | 4 | a=float(input("enter a num"))
def even(a):
ev=a%2
if ev==0:
print("even")
else:
print("odd")
even(a)
|
75abffb0419a9425ad8966a3bd5df6d7e5f9bf82 | 2099454967/python_wang | /07day/8题.py | 358 | 3.59375 | 4 | s_acc = "123456"
s_pwd = "123456"
s_mon = 10000
acc = input("请输入账户")
pwd = input("请输入密码")
if s_acc == acc and s_pwd == pwd:
print("登录成功")
mon = float(input("请输入金额"))
if mon < s_mon:
print("已取金额:%f,剩余金额:%f"%(mon,s_mon-mon))
elif mon <= s_mon:
print("没钱取毛线")
else:
print("非法账户")
|
9c405ef5bdb7c44894be08c7fc24ae70486a51d6 | wartinmt/python-B17class | /homework3.py | 1,244 | 4.15625 | 4 | # Martin June3,2020
# homework3 - page175,problem9 Roulette Wheel Colors
def main():
number = int(input("Enter a pocket number between 1 and 36:"))
if ((number >= 0) and (number <= 36)):
if (number == 0):
print("The pocket is green.")
for red in range(1, 10, 2):
if (numb... |
43ee1fd1acc5fad317a26de899509dbd305669a8 | sandeshgajare55/LiveTraining | /Assingment_5/String_2.py | 127 | 3.59375 | 4 | l1=["Red","Green","White","Black","Pink","Yellow"]
l2=list(l1)
print('Original List : ',l1)
print('Expected List : ',l2[1:4:])
|
8ededfedf9036cca4dd200873cc44caf046cea5c | inkyu0103/BOJ | /Dynamic Programming/lisPractice.py | 272 | 3.703125 | 4 |
people = int(input())
cute =0
nocute = 0
for i in range(people):
val = int(input())
if val == 1:
cute+=1
elif val == 0 :
nocute += 1
else:
pass
if cute > nocute:
print("Junhee is cute!")
else:
print("Junhee is not cute!") |
44cb840ee707b088632197652d35b386a0509a46 | karimeSalomon/API_Testing_Diplomado | /HenryBenito/second_class/area_circle.py | 145 | 3.890625 | 4 | from math import pi
def area_of_circle(r):
if float(r) > 10:
return pi * r**2
print(area_of_circle(30))
print(area_of_circle(3))
|
205a90a7ceb7c2bd1b6ac78b93edaa9721cf97e0 | Jaidev810/Competitive-Questions | /LeetCode/MinDepthBT.py | 2,197 | 4.0625 | 4 | import queue
class BinaryTree:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def takeLevelwiseinput():
print('enter the root Data:')
rootData = int(input())
if rootData == -1:
return None
root = BinaryTree(rootData)
q = queue.Queu... |
c463f20e76191985df839a3693694c96dbc14c59 | davide090/Big_Data_first_project | /Job1/HW1_mapper.py | 883 | 3.5625 | 4 | #!/usr/bin/python3
"""mapper.py"""
import sys
import csv
import datetime
from string import punctuation
columns = ["Id","ProductId","UserId","ProfileName","HelpfulnessNumerator","HelpfulnessDenominator",
"Score","Time","Summary","Text"]
def strip_punctuation(s):
return ''.join(c for c in s if c not ... |
82274018908439bee6a53b9db24914502f6c4727 | Gravity-2012/python-challenge | /PyBank/main.py | 1,837 | 3.6875 | 4 | import os
import csv
read_csv = "budget_data.csv"
total = 0
total_months = 1
average_change_list = []
greatest_increase_in_profits = ["", 0]
greatest_decrease_in_profits = ["", 9999999999]
with open(read_csv, newline='') as csvfile:
csvreader = csv.reader(csvfile, delimiter =',')
csv_header = next(csvreade... |
8da7ceedb1c878a43e08f0c478693ca8927f939a | green-fox-academy/Atis0505 | /week-02/day-02/append_a_02.py | 225 | 3.84375 | 4 | # - Create a variable named `nimals`
# with the following content: `["kuty", "macs", "cic"]`
# - Add all elements an `"a"` at the end
li = ["kuty", "macs", "cic"]
for i in range(0,len(li)):
li[i]+="a"
print(li[i]) |
e3ec3d2766ff04dbbdf6469b36bd9c5162b988ff | TylerBolles/Random-Chord-Player | /pitchHelper.py | 7,079 | 3.671875 | 4 | ''' pitchHelper.py is a collection of methods and data related to computing
with the pitches on the piano or the 12 pitch classes C, Db, ... Bb, B.'''
import numpy as np
import itertools
import matplotlib.pyplot as plt
import re
def encode_custum_chords(chords):
''' chords is a list of strings representing ... |
778a616a668c150c7f96656c3b8cea5c5fba4a4c | pmontesd/katando_python | /20180915/01_foobarquix/foobarquix.py | 368 | 3.65625 | 4 | def foobarquix(number):
pattern = {
3: "Foo",
5: "Bar",
7: "Quix"
}
value = ''.join([text for factor, text in pattern.items() if not number % factor])
value += ''.join([text for digit in str(number) for factor, text in pattern.items() if digit == str(factor)])
if not value... |
67b960e92e1b01975951befeb90098daccc7593b | DanielWimpress/Project-Euler---Python | /problem2.py | 612 | 3.71875 | 4 | #Problem 2:
#Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
#1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
#By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued t... |
99ccd0e7b1148d494d95a7b36b4336f65b230ba8 | yoga-nugroho129/python-dasar-kelasterbuka | /part08/continue, pass.py | 425 | 3.90625 | 4 | for i in range(0,10):
if i == 6:
print("angka",i,"ditemukan")
#break ### untuk menghentikan ketika kondisi tercapai
#continue ### untuk melanjutkan ke step berikutnya
print("Sekarang angka",i)
print(150*"-")
for i in range(0,10):
if i == 6:
print("angka",i,"ditem... |
6f345eaf34c06373351a5247f2dec41bb8809c3f | ihsanizwer/AZDemo1 | /main.py | 1,094 | 4.25 | 4 | # This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press ... |
327ec9825c42eadd1645821beba89469575a8f2c | jkim23/Python-Programming-Level-2- | /mod3problem2.py | 176 | 3.703125 | 4 | #JTKIM
#4/22/19
wordList = ["Sunday", "Monday", "Tuesday"]
def reverse(words):
return [words[-1]] + reverse(words[:-1]) if words else []
print(reverse(wordList))
|
ce1c1725555230512b63ae149291ee264dac2883 | arushi09207/codingloops-fibonacci-series | /programming-task-3.py | 1,199 | 4.59375 | 5 | # operations on data structures
#1. ASSIGNING ELEMENTS FROM A LIST IN PYTHON
#Append method : adds element to the end of the list
lst = [] #empty list
lst.append(4)
print(lst)
lst1 = ['a','b',2,3] #existing list
lst1.append(4)
print(li)
#Insert method : inserts element to the specific position in the list
lst1 = [... |
840747104f3913d9b4fe16e0dd9a807a651e4fdd | devrrior/convert-youtube | /main.py | 824 | 3.734375 | 4 | from youtube import YoutubeDownload
def main():
url = input("Give me the video's URL: ")
loop = True
while loop == True:
option = int(input("""
What would you download?
1. Video
2. Audio
3. Change URL
4. Exit
Type: """))
if option == 1:
... |
aef210ae5d48e252d60aa2acc4ff343ca22f26b8 | SeelamVenkataKiran/PythonTests | /Pandas/pdAdv3.py | 665 | 3.78125 | 4 | #Reshaping with Hierarchical Indexing
import pandas as pd
import numpy as np
data = pd.DataFrame(np.arange(6).reshape((2, 3)),
index=pd.Index(['india', 'europe'], name='ctry'),
columns=pd.Index(['one', 'two', 'three'], name='number'))
data
print(data)
#stack method on this data pivots the columns into the rows
result... |
b24d556ddfaea15c6d9e176d511c8a10cb90b702 | harikeshbg/SoftwareTesting_lab | /software_testing/part_a/quick_sort_first_element_pivot.py | 771 | 4.21875 | 4 | def get_pivot_position(array,start,end):
i=end+1
for j in range(start+1,end+1):
if array[j]>array[start]:
i-=1
array[i],array[j]=array[j],array[i]
array[i-1],array[start]=array[start],array[i-1]
return i-1
def quick_sort(array,start,end):
if start<end:
pivot_... |
bfc1b510ce1ba1f8e3bb1ab27e1275790202b5e5 | adodge88/COVID-19 | /assets/rss_feed/bs4_scrape.py | 840 | 3.546875 | 4 |
# Dependencies
from bs4 import BeautifulSoup
import requests
# URL of page to be scraped
url = 'https://www.cdc.gov/coronavirus/2019-ncov/whats-new-all.html'
# Retrieve page with the requests module
response = requests.get(url)
# Create BeautifulSoup object; parse with 'lxml'
soup = BeautifulSoup(response.text, 'lxm... |
f3b4903be1b735dd8d3caa5dc2dcd9d6ec24bfac | red3141/ProjectEuler | /P5.py | 701 | 3.5625 | 4 | from collections import defaultdict
from Utils import factor
def P5():
primeFactorsOfAnswer = defaultdict(int)
for i in range(1, 21):
factors = factor(i)
currentFactor = None
currentFactorCount = 0
for f in factors:
if currentFactor is None or f != currentFactor:
currentFactor = f
... |
e03202ae3ebab28a51749f45a2a5c1e2982f5848 | lvonbank/IT210-Python | /Ch.03/P3_17.py | 798 | 4.28125 | 4 | # Levi VonBank
# Write a program that reads in a string and prints whether it
userInput = str(input("Enter a string: "))
# contains only letters.
if userInput.isalpha():
print("Contains only letters.")
# contains only uppercase letters.
if userInput.isupper():
print("Contains only uppercase letters.")
# co... |
ff0a0d675d412741eff8ad7fc3159f9baf851de5 | juanitopereza/Basics | /TaylorSin.py | 711 | 3.671875 | 4 | import sys
import math as m
#%%
n = int(sys.argv[1])
#%%
def factorial(n):
if (n == 0):
return 1
else:
return n * factorial(n-1)
def SINpecadoconcebido(x,m):
if ( m == 1):
return x
else:
return (-1)**(m - 1) * (x**(2*m -1))/factorial(2*m-1) + SINpecadoconcebido(x,m-1)... |
e5ae248b251c97f1dabda8cb98886b1304392267 | Infinidrix/competitive-programming | /Day 4/Selection_Sort.py | 373 | 3.71875 | 4 | from randomly import randomizer
def find_min(li, starter):
minn = starter
for i in range(starter, len(li)):
if minn > li[i]:
minn = i
return minn
def selection_sort(li):
for i in range(len(li)):
swapper = find_min(li, i)
li[i], li[swapper] = li[swapper], li[i]
return li
if __name__ == "... |
f0304d8480c429e425c9388024d893e66340d5db | bthowe/data_science | /python_crash_course/calvin/basics/user.py | 2,542 | 4.15625 | 4 | class Users:
def __init__(self, first_name, last_name, age, height, richness,):
self.first_name = first_name
self.last_name = last_name
self.age = age
self.height = height
self.richness = richness
self.login_attempts = 0
"""Print a summery of this informa... |
437fea1137dc979f4c91be059ae564d55c90bf04 | jpleboeuf/exercism_python | /twelve-days/twelve_days.py | 2,791 | 3.96875 | 4 | """
This module offers a solution to
the "Twelve Days" exercise on Exercism.io.
"""
import sys
from typing import List
def recite(start_verse: int, end_verse:int) -> List[str]:
verse: List[str] = []
# Ordinal numerals:
on: List[str] = [ "zerost", "first", "second", "third",\
... |
53d4fb380bda1ba4adf89ad50dc05beef5c685b8 | 14E47/InterviewBit | /Academy/Day3/maximum_consecutive_gap.py | 307 | 3.515625 | 4 | class Solution:
# @param A : tuple of integers
# @return an integer
def maximumGap(self, A):
n = len(A)
A = list(A)
A.sort()
max_distance = 0
for i in range(1, n):
max_distance = max(max_distance, A[i] - A[i - 1])
return max_distance
|
8ce5541535d5f4bb7e8fbeb45a42b67b539aebd6 | littleghost2016/myPythonExercise | /17.斐波那契数列(2016.11.18)/斐波那契数列.py | 1,818 | 3.71875 | 4 | '''
【程序11】
题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月
后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少?
1.程序分析: 兔子的规律为数列1,1,2,3,5,8,13,21....
2.程序源代码:
main()
{
long f1,f2;
int i;
f1=f2=1;
for(i=1;i<=20;i++)
{ printf("%12ld %12ld",f1,f2);
if(i%2==0) printf("\n");/*控制输出,每行四个*/
f1=f1+f2; /*前两个月加起来赋值给第三个月*/
f2=f1+f2; /*前两个月加起来... |
03cf9bec0fe9501bf303badd4d38530c01fd6e3c | pardalaco/python-practicas | /18exepciones2.py | 542 | 4.0625 | 4 | def divide():
try:
op1=(float(input("Introduce el primer numero: ")))#En vez de int ponemos float para poder trabajar con decimales
op2=(float(input("Introduce el segundo numero: ")))
print("La division es: " + str(op1/op2))
#Si ponemos un except: captura una esseccion general
except ValueError:
pri... |
fc3991896f56a82dac2456d85e89f638c1688bac | qeedquan/challenges | /dailyprogrammer/331-intermediate-sum-of-digits.py | 1,621 | 4.125 | 4 | """
Description
For some xn, find the sum of its digits. The solution to this problem is extremely simple. Say, I give you 34. You could calculate 3n and add the digits.
However things might get a bit complex for 5100. It's a 70-digit number. You could come up with a larger data type that could handle the product of... |
5ccf8ddf9ccb4f5aa2cbd55ad153680f4ef4fae6 | piyushmoolchandani/Lab_codes | /cryptography_and_network_security/lab_assignment_2/7.py | 1,506 | 3.640625 | 4 | from collections import Counter
def additive_statistical(s):
"""
Input: ascii 97 to 122
Output: ascii 97 to 122
"""
s = s.lower()
char_count = Counter(s).most_common(1)
most_occuring_char_text = char_count[0][0]
most_occuring_chars_established = ['e', 't', 'a', 'o', 'i', 'n', ... |
d2852046ea32728fd6f4ed5d971a041be619e1fe | seanlab3/algorithms | /algorithms_practice/19.strings/11.Strings_group_anagrams.py | 304 | 4.15625 | 4 | """
Given an array of strings, group anagrams together.
For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"],
Return:
[
["ate", "eat","tea"],
["nat","tan"],
["bat"]
]
"""
from algorithms.strings import group_anagrams
a=["eat", "tea", "tan", "ate", "nat", "bat"]
print(group_anagrams(a)) |
920f7e3231ae08f4021195e5a1f216d88115c037 | MinaMohsen1/test | /HackerRank-python/intro/Write a function.py | 125 | 4.03125 | 4 | def is_leap(year):
x=year%4==0 and (year%400==0 or year %100 !=0)
return x
year = int(input())
print(is_leap(year))
|
31e538a63d7d4ddd18d81e7843fa1d55bf9426f7 | jixinfeng/leetcode-soln | /python/117_populating_next_right_pointers_in_each_node_ii.py | 1,405 | 4.1875 | 4 | """
Follow up for problem "Populating Next Right Pointers in Each Node".
What if the given tree could be any binary tree? Would your previous solution
still work?
Note:
You may only use constant extra space.
For example,
Given the following binary tree,
1
/ \
2 3
/ \ \
4 5 ... |
94dae23fdc31a095cb60e1026b54e901c6cf1a9e | allanzh/CursoEmVideo-Python | /Exercicios/Exs_023.py | 319 | 4.0625 | 4 | # ==== Exercício 23: Ler um numero e mostrar digitos separadamente
num = int(input('Digite um número: '))
strnum = str(num)
print('Separando o numero digitado...')
print('Unidade: {}'.format(strnum[3]))
print('Dezena: {}'.format(strnum[2]))
print('Centena: {}'.format(strnum[1]))
print('Milhar: {}'.format(strnum[0])) |
77a2e6c5307722a0ad2ac3d709312c1639478304 | jobliz/i-can-has-code | /python/eulers/old/010.py | 602 | 3.75 | 4 | def isprime(n):
for x in range(2, int(n**0.5)+1):
if n % x == 0:
return False
return True
def nextprime(n):
x = n
while True:
x += 1
if isprime(x):
return x
def prevprime(n):
x = n
while True:
x -= 1
if ((x == 1) or (x == 0) ):
return False
if isprime(x):
return x
def primesbelow(n):
c... |
115ebf12c16a0030e9d9dfa69c1a84b647cf26b4 | quqixun/Hackerrank_Python | /Algorithm/Warmup Challenges/compar_the_triplets.py | 773 | 3.5 | 4 | #!/bin/python3
import sys
def score(a, b):
if a > b:
return 0
elif a < b:
return 1
else:
return -1
def add_score(score, result):
if score != -1:
result[score] += 1
return score
def solve(a0, a1, a2, b0, b1, b2):
# Complete this function
result = [0, 0]
... |
ce1e7bcbc3da37c9a1276a665d9d7cf2a5997f17 | Mvahini/Python-Programs | /CustomerViewer.py | 2,416 | 4.25 | 4 | #!/usr/bin/env python3
# Activity7
# Vahini Madipalli
# Course: ISQA3900-850: Web Application Development
# Date: 11-12-2020
# Creating python program which reads from the csv files, display the list, search based on cust_id
from Customer import Customer
import csv
FILENAME = "customers.csv"
customer_details = []
d... |
3e93492555623c9ac44d742dd4b1954140c79cc7 | John-L-Jones-IV/mc21 | /freshtake/main.py | 680 | 3.546875 | 4 | #!/usr/bin/env python3
"""
main.py
Runs Monte Carlo Simulations of 21 card game.
John L. Jones IV
"""
import matplotlib.pyplot as plt
import multiprocessing
import numpy as np
import game
NUM_HANDS_TO_PLAY = 1200
NUM_SIMULATIONS = 25
NUM_PROCESSES = 6 # Processes for multithreading
def plot(matrix):
matrix = ... |
f41704dc25c8601eddc255f1b564cb62c5f700a2 | sergioluisfilho/crudSQLite3 | /base.py | 316 | 3.71875 | 4 | # DDL - Manipulação da tabela
import sqlite3
con = sqlite3.connect('base.db')
cur = con.cursor()
sql = """CREATE TABLE USERS (
id INTEGER
NOT NULL
PRIMARY KEY
AUTOINCREMENT,
name TEXT NOT NULL,
phone TEXT NOT NULL,
email TEXT UNIQUE NOT NULL
)"""
cur.execute(sql)
con.commit()
con.close() |
d8c234ae6429c7958008748c04cee0ec2fa6b3d0 | JasonkayZK/Python | /Python_Fundamental_Lesson/1_Control_Structures/In_NotIn.py | 173 | 3.859375 | 4 | words = ["spam", "egg", "spam", "sausage"]
print("spam" in words)
print("egg" in words)
print("tomato" in words)
nums = [1, 2, 3]
print(not 1 in nums)
print(4 not in nums)
|
73fb3e39fe454efa0a1324fd56c917c60354b481 | gpfenniger/CarWars | /src/modules/records/character_record.py | 6,113 | 3.640625 | 4 | '''
Methods:
+ Character(name)
+ Character.add_exp(skill_name, exp)
+ Character.level_skill(skill_name, levels)
+ Character.change_money(amount)
+ Character.change_prestige(amount)
- Character.create_character()
- Character.select_starting_skill(remaining_choi... |
ef5668b23222bc212d4a3e718e74d1121f01d9af | LuisGomez11/Python | /Corte 1/TALLER #1 - INICIANDO CON PYTHON/SeptimoEjercicio.py | 167 | 4.1875 | 4 | print('---Factorial de un numero---')
numero = int(input('Digite un numero: '))
con = 1
resultado=1
while con<numero+1:
resultado *=con
con+=1
print(resultado) |
eb9825a3b6e3567266e3074378f5e914f8b96977 | naegelejd/ismrmrd-python-tools | /ismrmrdtools/show.py | 1,679 | 3.9375 | 4 | """
Simple tiled image display
"""
import numpy as np
import matplotlib.pyplot as plt
def imshow(image_matrix, tile_shape=None, scale=None, titles=[], colorbar=False):
""" Tiles images and displays them in a window.
:param image_matrix: a 2D or 3D set of image data
:param tile_shape: optional shape ``(row... |
bcd011cb538b65091af0728a4079aeadec485a2c | RubaiyatAraaf/celtofarenconverter | /python.py | 120 | 3.78125 | 4 |
cel = input('Enter the celcius: ')
fahrenheit = (float(cel) * 1.8) + 32
print(float(fahrenheit))
print("fahrenheit")
|
d0bb96fc4fc73e2c3264b99c9982f67eb5ea62bc | vivekaxl/LexisNexis | /ExtractFeatures/Data/kracekumar/train-timetable-2.py | 3,894 | 3.8125 | 4 | # Problem
#
# A train line has two stations on it, A and B. Trains can take trips from A to B
# or from B to A multiple times during a day. When a train arrives at B from A
# (or arrives at A from B), it needs a certain amount of time before it is ready
# to take the return journey - this is the turnaround time. For e... |
21cf23a41920667e122a1110d48c2de95643e92a | Net-Admin/TitanPay | /src/Accounting/allemployees.py | 496 | 3.734375 | 4 | import csv
import sys
import pprint
#function to convert a csv file to a list of dictionaries.
#Takes in variable - "all_employees"
def csv_dict_list(all_employees):
reader = csv.DictReader(open('D://Users/medic/PycharmProjects/TitanPay/src/Accounting/Data/all_employees.csv'), delimiter = ',')
result = {}
... |
bcc0cd7ed3d483c6116d75a0ecca40be760819a2 | ronakHegde98/InstagramBot | /timefunctions.py | 1,766 | 4.125 | 4 | def time_difference(start, end):
"""
Calculate number of minutes elapsed between two standard time strings
Args:
start: int: start time of task
end: int: end time of task
Returns:
minutes: number of minutes elapsed
"""
#convert standard times into military
start = military_time(start.u... |
badcc8c4b67d18c2ca1b31bffb3ff5a22738147f | Nancy214/Python_clg | /Assignment 1/Q8.py | 178 | 4.28125 | 4 | #Print first letter of every word in a string
s = input('Enter the string: ')
words = s.split()
for i in words:
print('The first letter of "{}" is {}'.format(i,i[0]))
|
b546f09534054983f604a3a533bd6b78fa293641 | sravyapara/python | /lab1/Source/lab1/question2.py | 838 | 4.3125 | 4 | #input statement
s = input("Enter the sentence")
#splitting the sentence
words=s.split()
#calculating the length of the words after the split
a=len(words)
#if the length of the word is even then it will print 2 words in the middle
if a%2==0:
x=a/2
y=int(x-1)
print("The middle word is :", (words[y]+" "+word... |
df80f84947137e7ee58212b3d7f9184980db57d4 | tizinv/TiagoVieiraSantos_P1 | /Q4.py | 490 | 3.90625 | 4 | # Autor: Tiago Vieira Santos
def Nob(entrada1, entrada2):
resultado = (entrada1//10) + (entrada1%10) + (entrada2//10) + (entrada2%10)
return resultado
def main():
entrada1 = int(input("Entre o primeiro valor:\n"))
entrada2 = int(input("Entre o segundo valor:\n"))
print("O resultado do enigma de Nob... |
908041e8700d90e1d2aafe258f21a569f729fe02 | wngus6429/PythonMake | /5.if.py | 547 | 3.9375 | 4 | # def plus(a, b):
# if type(b) is str:
# return None
# else:
# return a + b
# plus(12, "10")
def plus(a, b):
if type(b) is int or type(b) is float:
return a + b
else:
return None
print(plus(12, 1.2))
def age_check(age):
print(f"you are {age}")
if age <= 18:
... |
db12407cc51df71cfa1ae2f779554a3d06550fea | wonwooro/laftel_coding_test_wonwoo_ro | /laftel_p3/p3_test.py | 413 | 3.5 | 4 | #-*- coding: utf-8 -*-
from autocomplete import find_keywords
def printElements(list):
for item in list:
print item,
print ''
if __name__ == "__main__":
input = "동해물과 백두산이 마르고 닳도록, 하느님이 보우하사 우리나라 만세~"
prefix = ['ㅁ', '우린', '록한']
for p in prefix:
print "Prefix: %s >>" % p
printElements(find_keywords(input, p... |
1a4e4bba7d59760ad1121c032824178398ae44fb | Payas17/orga-datasciense | /src/python/tests/test_distancias.py | 604 | 3.640625 | 4 | import unittest
from distancias import *
from math import sqrt
class TestDistancias(unittest.TestCase):
def test_distanciaEcluedianaEntreIgualesPuntosEsCero(self):
self.assertTrue(euclediana((0,0),(0,0)) == 0)
def test_distanciaEcluedianaEntreEsIgualA1(self):
self.assertTrue(euclediana((1,0),(0,0)) == 1)
sel... |
00115b7b4e472581bce58e98806da27cc29f59ad | wenhuabin/python3 | /learning/classjson.py | 680 | 3.546875 | 4 | import json
class Student(object):
def __init__(self, name, age, score):
self.name = name
self.age = age
self.score = score
def student2dict(std):
return {
'name': std.name,
'age': std.age,
'score': std.score
}
def dumps(s):
with open('/Users/huabin.wen... |
9ef330b5ba63532e724d91c3e903b157babf513b | Hunt66/holbertonschool-higher_level_programming | /0x01-python-if_else_loops_functions/1-last_digit.py~ | 617 | 4.1875 | 4 | #!/usr/bin/python3
# this program makes a random number and prints the last diget of (that
# number) is (last digit) is greater than 5 less than 6 and not 0 or
# is zero
import random
number = random.randint(-10000, 10000)
if number % 10 > 5:
print("Last digit of {:d} is {:d} and is greater than 5" .format(
... |
e284a01655e1f0906c74c2a9222d446e1c1b8eae | lazarevdmitry92/net_py15_hw9 | /hw8.py | 702 | 3.890625 | 4 | class Animals:
def eat(self):
print("хочу есть")
color = None
legs = 4
sound = None
def say(self, sound):
print(sound, "-", sound)
age = 0
def birthday(self):
self.age += 1
class Goats(Animals):
color = "white"
sound = "мее"
class Sheeps(Animals):
sou... |
a35d23f8cbd4cc1302a6c7fa35cc72476ac0799c | christian-miljkovic/python_projects | /python_project9/MiljkovicChristian_Assign9_Part1.py | 6,780 | 4.09375 | 4 | # Christian Miljkovic
# CSCI-UA.0002 section 03
# Assignment #9
# answer key for part 3
answerkey = ["B","A","D","D","C","B","D","A","C",'C','D','B','A','B','A','C','B','D','A','C','A','A','B','D',"D"]
# select a class file
filename=input("Enter a filename: ")
# open the file
try:
myfile= open(filename + ".t... |
e6cd611cd74a94ab966b3972441d7bf76f7afd54 | winterash2/algorithm_study_2021_1 | /210204/그래프/팀 결성/배진수.py | 689 | 3.71875 | 4 | import sys
input = sys.stdin.readline
def union_parent(parent, a, b):
a = find_parent(parent, a)
b = find_parent(parent, b)
if a < b:
parent[b] = a
else:
parent[a] = b
def find_parent(parent, a):
if parent[a] != a:
parent[a] = find_parent(parent, parent[a])
return paren... |
a2c2b45de697fa7b2fe3d63703dc1528cb2ffc49 | lincolnhalim/List_Spinner | /nomor2.py | 275 | 3.515625 | 4 |
def counter(x):
hasil = list(map(list, zip(*x)))[::-1]
print("", hasil[0], '\n', hasil[1], '\n', hasil[2])
return hasil
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
B = [[9, 8, 7],
[6, 5, 4],
[3, 2, 1]]
counter(A)
print("="*50)
counter(B)
|
125885f3e8aa731c253527dfefa7f6a469f1eb6f | H-Cong/LeetCode | /139_WordBreak/139_WordBreak.py | 1,999 | 3.828125 | 4 | """
see discussion: https://leetcode.com/problems/word-break/discuss/169383/The-Time-Complexity-of-The-Brute-Force-Method-Should-Be-O(2n)-and-Prove-It-Below
m is a dict to store whether any substring can be broke by the words in wordDict
"""
class Solution:
def wordBreak(self, s: str, wordDict: List[str]) -> bool:
... |
0a2f8cfbd8b1b835825dd0e706644fd5c2121b49 | mshsarker/PPP | /While Loop/047.py | 859 | 4.125 | 4 | ## My solutions to the 150 Challenges by Nichola Lacey
## Get this wonderful book to know with the explanations and quick tips.
## 047 Ask the user to enter a number and then enter another number. Add these two numbers together and then ask if they want to add another number. If they enter “y", ask them to enter anoth... |
7144776334d0487c98129fd5795f0ac4c75e3530 | cmnaveen/study_cmp | /python/add_2num.py | 66 | 3.765625 | 4 | # add two numbers
num1 = 3
num2 = 5
sum = num1 + num2;
print(sum)
|
8f023d843332d8caec8199672f555d1c0d508ad2 | kabanyasu/python-training | /tax_calculation.py | 1,505 | 3.5625 | 4 | def main():
zigyo = calc_business_income()
kyuyo = calc_employment_income()
the_total_income = zigyo + kyuyo
return the_total_income
def calc_dividend_income():
pass
def calc_business_income():
income = int(input("今年度の事業収入の合計額はいくらですか?"))
outcome = int(input("今年度の事業経費合計額はいくらですか?"))
bus... |
31a0472f3889f4fca6fe3bd6e98f1e051070bae4 | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/355 Design Twitter.py | 3,907 | 3.6875 | 4 | """
Design a simplified version of Twitter where users can post tweets, follow/unfollow another user and is able to see the
10 most recent tweets in the user's news feed. Your design should support the following methods:
postTweet(userId, tweetId): Compose a new tweet.
getNewsFeed(userId): Retrieve the 10 most recent ... |
08e26946f02f596a7e451a071b08ec21826116bf | hasant99/Python-Class-Projects | /music_compare.py | 4,847 | 4.09375 | 4 | """ File: music_compare.py
Author: Hasan Taleb
Purpose: This file uses imported functions
from utils.py to calculate find the similarity between
two songs.first it prints the list of all songs in the
file, then it prints the similarity valuies of all songs,
and finally prints information about t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.