blob_id stringlengths 40 40 | repo_name stringlengths 5 119 | path stringlengths 2 424 | length_bytes int64 36 888k | score float64 3.5 5.22 | int_score int64 4 5 | text stringlengths 27 888k |
|---|---|---|---|---|---|---|
354d97b591d9bc39952bf63e6d01e63724781f17 | tahir24434/py-ds-algo | /src/main/python/pdsa/lib/LinkedLists/singly_linked_list_queue.py | 3,190 | 4.09375 | 4 | """
we can use a singly linked list to implement the queue ADT while supporting
worst-case O(1)-time for all operations. Because we need to perform
operations on both ends of the queue, we will explicitly maintain both a
head reference and a tail reference as instance variables for each queue.
The natural orientation f... |
2f289fa69983fcc05bf0361153059f073de24e88 | gsoares1928/ProjEvolutivos | /utils.py | 1,365 | 3.75 | 4 | import numpy as np
rng = np.random.default_rng()
class UnionFind:
'''Implementation of the union-find data structure.'''
def __init__(self, size):
self.parent = [-1] * size
def find(self, x):
root = x
while self.parent[root] != -1:
root = self.parent[root]
... |
121ee129660770cfb067b3452ef43e8d1169cd39 | Voron3121/python | /les01/les03.py | 1,156 | 3.875 | 4 | # coding: utf-8
# Комментарии
import os
import psutil #стороний
print("SUPER PROGRAMM!!!")
print("Привет программист!")
name = input("Ваше имя: ")
print(name, ", добро пожаловать в мир Python!")
answer = input("Давай поработаем? (Y/N)")
# PEP-8
if answer == 'Y' or answer == 'y':
print("Чем бы ты хотел занят... |
baa0754264a26fb87bd5569fa818aad15842c61c | rozzs74/psmds | /applied-machine-learning/applied-regression-analysis/multilinear_regression/scikit-learn/multilinear_regression.py | 1,328 | 3.625 | 4 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
# Step 1 Load the Data
df = pd.read_csv("housing_data.csv")
df.head()
# Step 2 Check Linearity between independent variables and dependent variables
fig = plt.figure(figsize=(10, 7))
fig.suptitle(... |
a177a8b92bd7c96a59bf368d715d79a8af8fe1ca | maryyang1234/hello-world | /hashing/searchNumber.py | 799 | 3.859375 | 4 | """Given a limited range array contains both positive and non-positive numbers,
i.e., elements are in the range from -MAX to +MAX. Our task is to search
if some number is present in the array or not in O(1) time."""
def search(arr,n,x):
max=1000
has=[[0 for i in range(2)] for j in range(max+1)]
... |
64a6b84542292bb661db33ff76c42f23f654b1f7 | Aledutto23/Sistemi-e-Reti | /es_liste_nuovo.py | 156 | 3.640625 | 4 | lista = [1,2,3,4,1,6,2,8]
for i, n in enumerate(lista):
for j, m in enumerate(lista):
if n == m and (i>j):
print("Doppione")
|
8059e9cdc7900bee794feadb22680dfc6f70fa61 | Sumeets2597/Artificial-Intelligence | /Games and Bayes/viterbi/mountain.py | 5,141 | 3.5625 | 4 | #!/usr/local/bin/python3
#
# Authors: Ruta (rutture), Rushikesh (rgawande), Sumeet (ssarode)
#
# Mountain ridge finder
# Based on skeleton code by D. Crandall, Oct 2019
#
from PIL import Image
from numpy import *
import numpy
from scipy.ndimage import filters
import sys
import imageio
import pandas as pd
# calculate ... |
97237a0e05d982dbabb91c504a98e2a86cb237f2 | rajawatshivam/python | /training/solutions provided by forsk/shopping.py | 1,123 | 4.28125 | 4 | """
Name:
Shopping List
Filename:
shopping.py
Problem Statement:
We are going to make a "Shopping List" app.
Run the python script to start using it.
Put new things into the list one at a time
Enter the word DONE - in all CAPS - to QUIT the program
And once i quit, I want the app t... |
110c2ed76ba72599dc12ac9bbdb992233935d986 | xumaxie/pycharm_file-1 | /Algorithma and Data Structures/图解算法数据结构/03剑指offer09用两个stack实现Queue.py | 1,931 | 3.796875 | 4 | #@Time : 2021/11/211:22
#@Author : xujian
# Question:
# 用两个栈实现一个队列。队列的声明如下,请实现它的两个函数 appendTail 和 deleteHead ,
# 分别完成在队列尾部插入整数和在队列头部删除整数的功能。
# (若队列中没有元素,deleteHead 操作返回 -1 )
from typing import List
class CQueue:
def __init__(self,s1:List[int],s2:List[int]):
self.s1=s1
self.s2=s2
... |
ee4cd51cbf1d7f80735a641d6671f56c96c1222a | szhongren/leetcode | /patching_array/main.py | 2,478 | 3.625 | 4 | """
Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be formed by the sum of some elements in the array. Return the minimum number of patches required.
Example 1:
nums = [1, 3], n = 6
Return 1.
Combinations of nums a... |
dd8a93ea9bcb1e77e644af20f5164695ecd82cbb | liuweilin17/algorithm | /leetcode/289.py | 1,857 | 3.96875 | 4 | ###########################################
# Let's Have Some Fun
# File Name: 289.py
# Author: Weilin Liu
# Mail: liuweilin17@qq.com
# Created Time: Sat Jan 26 12:47:16 2019
###########################################
#coding=utf-8
#!/usr/bin/python
#289. Game of Life
class Solution:
def gameOfLife(self, board):... |
89740b3eda17f3c5c441a207caf11cd4e2244126 | acc-cosc-1336/cosc-1336-spring-2018-BarndonSelesino | /src/assignments/assignment6.py | 870 | 4 | 4 | def get_count_A_C_G_and_T_in_string(dna_string):
'''
Create a function named get_count_A_C_G_and_T_in_string with a parameter named dna_string.
:param dna_string: a DNA string
:return: the count of As, Cs, Gs, and Ts in the dna_string
'''
count_A = 0
count_C = 0
count_G = 0
coun... |
f63c375e104496d10890e4c9b3d98af717d9c4fb | emi1337/Ex8-Markov | /tinymarkov.py | 4,017 | 3.546875 | 4 | from sys import argv
import re
from random import choice
import string
import twitter
api = twitter.Api(consumer_key='DSL1YlRGJWzN4YC23pBZQ',
consumer_secret='xNpXY7WjmsHmaUP1p9cAkw0Sh8fu6oQdySUhncQ0U',
access_token_key='1278792427-k9UpLpiYKL6MfTmuLJrFtMJ2VTD3lQ9KAYiG35B',
access_token_secret='zOgkUB5ri... |
4f1cf486ee4cf530ba1d1539da722d347d689e69 | pokurin123/lecture_aitech_year2 | /quicksort.py | 989 | 3.84375 | 4 | import random
N = 10
def input_data(data):
for i in range(N):
data.append(random.randint(0,N))
return data
def quicksort(left,right):
if left >= right:
return
else:
pivot = data[right]
partition = division(left,right,pivot)
quicksort(left,partition -1)
q... |
4b6a5a6ba5d725aeb63405fea92b2242bb3b88df | qiwsir/LearningWithLaoqi | /PythonBase/06program.py | 241 | 3.578125 | 4 | #coding:utf-8
def fibs(n):
'''
前n项的斐波那契数列,n表示数列长度
'''
r = [0, 1]
for i in range(n-2):
r.append(r[-1] + r[-2])
return r
if __name__ == "__main__":
f = fibs(10)
print(f) |
815e32c8cff94d109ff058c4ef854d1ab7309158 | shanmugapriya296/basic-python | /a2.py | 193 | 3.96875 | 4 | name=input("enter name")
clg=input("enter clg name")
cgpa=float(input("enter cgpa"))
#print("iam",name,"studying",clg,"with",cgpa,)
print("iam{}studying{}clg{}cgpa".format(name,clg,cgpa))
|
931b686065c52243b8119a85c2dab1a0d00e5db6 | Aasthaengg/IBMdataset | /Python_codes/p02747/s556544432.py | 207 | 3.546875 | 4 | def main():
S = input()
lst = []
for i in range(1, 100):
lst.append('hi' * i)
for it in lst:
if S == it:
print('Yes')
return
print('No')
if __name__ == '__main__':
main() |
611cb248698cdefef2d8b89cf046eb7e54b679b6 | lim1202/LeetCode | /Dynamic Programming/perfect_squares.py | 1,356 | 3.84375 | 4 | """Perfect Squares
Given a positive integer n,
find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.
For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n = 13, return 2 because 13 = 4 + 9.
"""
import sys
def num_squares(n):
dp = [sys.maxsize for i in ran... |
e7b4e6630c07d9c83c31a4a82cf5c3e62c02a519 | arjungoel/PyCon | /Generators_Coroutines_Nanoservices/my_gen1.py | 249 | 3.625 | 4 | #!/usr/bin/env python3.9.0
def mygen():
x = None
# using walrus operator (PEP 572)
while x := (yield x): # exit the loop when we get `None` or an `empty value`
x *= 5
g = mygen()
print(next(g)) # prime it
print(g.send(10))
|
867a4658d503ae35a0d4e40ed22934cd41a723b0 | ak66h1989/test | /python/functional programming.py | 422 | 3.765625 | 4 | def f(i):
while i>3:
return
print(i)
f(i+1)
print(i)
f(1)
def curry(prior, *additional):
def curried(*args):
return prior(*(additional+args))
return curried
def add(x, y, z):
return x+y+z
add(1,2,3)
c = curry(add,1)
c1=curry(c,2)
c1(3)
def add(*args):
return sum(args)... |
d2b3cea33576c693c362d8f9d025dad4d6f7bf24 | TejasBhavsar03/21-DAYS-PROGRAMMING-CHALLENGE-ACES | /pythonudemy12.py | 1,159 | 3.953125 | 4 | # Function defination
# y = x +2
#
#
# def Turnonlight(input):
# statement or Block of code
# # return something
#
# def add2(x):
# y = x +2
# print(y)
#
#
# add2(2)
#
# what is *args
# def greet(*args):
# print(args)
# # a,b,c,d = args
# print('Hello '+args[0]+' How are you')
# print(... |
158f940b1b354f6e7acd0987bdf45706be14247e | lmw8864/MyFirstPython_part1_python_basic | /6_dictionary/exercises/6-5.py | 521 | 3.75 | 4 | # 6-5.py
"""
6-5. 강
"""
rivers = {
'nile': 'egypt',
'mississippi': 'usa',
'han': 'korea',
}
for river, country in rivers.items():
if country == 'usa':
print(river.title() + "강은 " + country.upper() + "에 있습니다.")
else:
print(river.title() + "강은 " + country.title() + "에 있습니다.")
print... |
800eb7bf8b741cf149c45041fae0bf3de119a648 | harammon/Visual_Programming | /과제1/problem1.py | 411 | 3.5625 | 4 | """
* 파일명 : 1.py
* 작성일 : 2020년 10월 3일
* 작성자 : 문헌정보학과 20142611 이하람
* 출력예시 : 숫자를 입력하세요. 98
98
숫자를 입력하세요. 06
6
숫자를 입력하세요. 0
"""
while True:
num=int(input("숫자를 입력하세요. "))
if num!=0:
print(abs(num))
else:
break
|
a0a736e4807009615418e10478f01b77a4775e4d | nixsala/Anuradha_MITE | /Functional_Programming-ANUDHRADHA/RemoveDuplicateList.py | 255 | 4.21875 | 4 | my_list = [1,1,2,3,4,5,5,6]
myFinallist = []
for i in my_list:
if i not in myFinallist:
myFinallist.append(i)
print("Display MY_list :")
print(list(my_list))
print("Remove Duplicate and Print the newlist :")
print(list(myFinallist))
|
640c47343e21b3907546b4f306f43e5123bba854 | Md-Monirul-Islam/Python-code | /Numpy/Broadcasting - NumPy Tutorials.py | 216 | 3.578125 | 4 | import numpy as np
a = np.array([[1,2],[3,4],[5,6]])
b = np.array([10,20])
print(a)
print(b)
print(a+b)
#another
x = np.array([[1],[2],[3]])
y = np.array([1,2,3])
print(x.shape)
print(y.shape)
print(x+y)
print(x*y) |
0c48d74a89daeac25386c5222fc34f9767330f11 | sayali-bamhande/PythonAssignments | /pythonPrograms/Assignment_2/Assignment2_8.py | 181 | 3.828125 | 4 | def printPattern(n):
for j in range(1, n+1):
print(*range(1, j+1))
if __name__ == '__main__':
print("Enter the number : ")
n = int(input())
printPattern(n) |
4603f5b6bbf1761487e4fda2d305f7061f2fb1e4 | webclinic017/python-4 | /foobar/re-id.py | 915 | 3.65625 | 4 | def solution(i):
start, end = 4, 10
string = '23'
label = [False, False, True, True]
while len(string) < i+5 :
new_string, label = findPrimes(start, end, label)
string += new_string
start = end
end += 100
for i, elem in enumerate(label):
if elem:
... |
aa686bf17014c5718918bb9e56e776418c7ba1af | mecomontes/Higher-Level-Programming | /0x03-python-data_structures/6-print_matrix_integer.py | 375 | 4.28125 | 4 | #!/usr/bin/python3
def print_matrix_integer(matrix=[[]]):
"""
prints a matrix of integers to STDOUT
"""
for row in matrix:
row_len = len(row)
for i in range(row_len):
if i != row_len - 1:
print("{:d}".format(row[i]), end=' ')
else:
... |
e0669e8eeb22688d15c9b3a3958c46682d29b8a6 | bruceasu/word-process-src | /python-src/sort_order_file.py | 1,903 | 3.5625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
__author__ = 'Suk Honzeon'
class Dic:
""" 排序字典
"""
def __init__(self, simplified=True, encoding='utf-8'):
self.encoding = encoding
self.simplified = simplified
self.dic = self.load_dict()
@staticmethod
... |
ad7c2707da9e3e6dee90d4b26c37dff94650a22d | Mandella-thi/Exercicios-Massanori-py | /exercícios-massanori-py/exercicios/lista 9 first last 6.py | 275 | 4 | 4 | # A. first_last6
# verifica se 6 é o primeiro ou último elemento da lista nums
# first_last6([1, 2, 6]) -> True
# first_last6([6, 1, 2, 3]) -> True
# first_last6([3, 2, 1]) -> False
def first_last6(nums): #
return nums[0]==6 or nums[-1]==6
print(first_last6([3,6,4]))
|
f50953a401882636d010551bd75f62754fba763e | lavanyaSR/python_0730 | /AllFiles/email.py | 354 | 3.890625 | 4 | #fname = input("Enter file name: ")
#fh = open(fname)
fh = open("/Users/lavanyamallikharjuna/Downloads/mbox-short.txt")
count = 0
for line in fh:
list = line.rstrip().split()
if len(list)<1:
continue
if list[0]!='From ':
continue
print(list[1])
print("There were", count, "lines in the fi... |
3febd4afa37b799f400aed0c60f1cb5187ea249a | BhavaniKanumuri/FST-M1 | /Python/Activities/Activity10.py | 204 | 4.3125 | 4 | my_tuple=input("Enter your numbers").split(",")
print("The given list of numbers are", my_tuple)
for num in my_tuple:
if (int(num) % 5 == 0):
print("Numbers that are divisible by 5 are:",num) |
0e883636e15b664642d05aaea74f9100dbc963cc | KenMercusLai/checkio | /checkio/Elementary/Three Words/three_words.py | 695 | 4.125 | 4 | def is_word(x):
return 1 if x.isalpha() else 0
def checkio(words):
word_list = [is_word(i) for i in words.split()]
consecutive_words = [
sum(word_list[i : i + 3]) for i in range(len(word_list)) if word_list[i]
]
return any([True for i in consecutive_words if i >= 3])
# These "asserts" us... |
aa486b90c5d06553d71fa557c253d37b30ce6da9 | weidi0629/statistical_pattern_recognition | /ch2/Gaussian_classifier.py | 1,097 | 3.59375 | 4 | # statistical_pattern_recognition
#Models discussed in book Statistical Pattern Recognition (Webb) with Python
import numpy as np
X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])
Y = np.array([1, 1, 1, 2, 2, 2])
from sklearn.naive_bayes import GaussianNB
clf = GaussianNB()
clf.fit(X, Y)
'''
>>>>Gaus... |
f2dae0bb0b9eda5b5d526cc06f4235b162ba3b3f | Vodolazskyi/algorithmic-toolbox-course | /week3_greedy_algorithms/2_maximum_value_of_the_loot/fractional_knapsack.py | 896 | 3.65625 | 4 | # Uses python3
import sys
from typing import List
def get_optimal_value(capacity: int,
weights: List[int],
values: List[int]) -> float:
value = 0.
# write your code here
values_per_weight = []
for v, w in zip(values, weights):
values_per_weight.appen... |
9bc68df5efd76f1620643283cf0d4575322f0f05 | ckallum/Daily-Coding-Problem | /solutions/#047.py | 732 | 3.859375 | 4 | from math import inf
def maxProfits(prices): # Each time their is a new low buy in price, we shift the buy in point to see if there is
# better buy, sell window after that time as we always want to buy at it lowest price.
maxprof = -inf
buy = 0
sell = 0
for index, price in en... |
a4a1916e7202cbab13cf7d7958edc1cc738d679b | PeriLara/Checkio | /Incinerator/dialogues.py | 1,977 | 3.609375 | 4 | class Chat:
def __init__(self):
self.human_dialogue = []
self.robot_dialogue = []
self.to_0 = 'aeiouAEIOU'
def connect_robot(self, robot):
# connects robot to the chat
self.robot = robot
robot.chat = self
def connect_human(self, human):
... |
fef1dc58868745c6b18cb1aa2bf5345ad65a9e9d | daniel-reich/turbo-robot | /Rep3fHbrLGKDatZ2L_12.py | 995 | 4.46875 | 4 | """
You will be given a string that is made up of some repeated pattern of
characters. However, one of the characters in the string will be missing and
replaced by an underscore. Write a function that returns the missing
character.
### Examples
complete_pattern("ABCABCA_CAB") ➞ "B"
complete_pattern("_... |
3892fe7108164015cdf15eca5a137b34bf134de9 | Vanditg/Leetcode | /Best_Time_Buy_Sell_Stock/EfficientSolution.py | 1,519 | 3.96875 | 4 | ##==================================
## Leetcode
## Student: Vandit Jyotindra Gajjar
## Year: 2020
## Problem: 121
## Problem Name: Best Time to Buy and Sell Stock
##===================================
#
#Say you have an array for which the ith element is the price of a given stock on day i.
#
#If you were on... |
a35383c51320a7eeaefd7b40727444a68434be90 | technetium0x32/neural_nets_course | /Functions&Recursion/negative_power.py | 236 | 3.828125 | 4 | a, n = [int(input()) for i in range(2)]
def power(a, n):
res = 1
if n >= 0:
for i in range(n):
res *= a
else:
for i in range(-n):
res /= a
return res
print(power(a, n))
|
0a578092f6b5651b8646cd19b794c7f945d18e94 | PDXDevCampJuly/ChelsDevCamp_July27-1 | /blackjack/player.py | 1,352 | 3.640625 | 4 | from card import Card
class Player:
def __init__(self, name, is_dealer=False):
self.hand = []
self.name = name
self.is_dealer = is_dealer
self.score = 0
self.target_score = 21
if self.is_dealer:
target_score = 17
def calculate_score(self):
"""
keeps track player score
returns total points
""... |
124849255c856dc9f300efacde8eb0872a5e3e3c | Akashtyagi/DataStructure | /Problems/most_repetitve_in_list/most_repititve_in_list.py | 1,419 | 3.84375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 24 19:37:41 2020
@author: Akash Tyagi
"""
# =============================================================================
# Question: Find maximum repeating elem in list
# ===========================================================================... |
02c8d9e6f872ce2bc41b7225c40616081f753cc4 | houyinhu/AID1812 | /普通代码/xuexi/input.py | 107 | 3.5625 | 4 | #此示例
s=input("请输入整数:") #此函数返回的是字符串
x=int(s)
print("结果是",x*2)
|
3d098828943afd117b47f8cb160e16b20f49d66b | cbeach512/dailycodingproblem | /day20.py | 692 | 3.984375 | 4 | #!/usr/bin/env python3
"""Problem - Day 20
Given two singly linked lists that intersect at some point, find the intersecting node. The lists are non-cyclical.
For example, given A = 3 -> 7 -> 8 -> 10 and B = 99 -> 1 -> 8 -> 10, return the node with value 8.
In this example, assume nodes with the same value are the exac... |
c88b612d51dd036a2a95508d406b5b00e6c2deef | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/4429/codes/1595_1015.py | 377 | 3.65625 | 4 | # Teste seu codigo aos poucos.
# Nao teste tudo no final, pois fica mais dificil de identificar erros.
# Nao se intimide com as mensagens de erro. Elas ajudam a corrigir seu codigo.
a=(int(input("digite o numero a: ")))
b=(int(input("digite o numero b: ")))
c=(int(input("digite o numero c: ")))
r=((a+b+c)-min(a,b,c)-m... |
19fd7f9a39c5e5b5f08672cc318ca2ebf7052a23 | katshun0307/sort-algorithms-in-python | /merge_sort.py | 740 | 3.703125 | 4 | import random
import time
def Mergesort(A, p, q):
if q-p == 1:
pass
else:
if (p+q)%2 == 0:
r = (p+q)/2
else:
r = (p+q+1)/2
B = A[p:r]
C = A[r:q]
#print B
#print C
return Merge(B, C)
def Merge(B, C):
max1 = max(B)
m... |
9747c2c9607bfe1826ae670a2064f3479ddf3859 | bharathbiju/cal | /final.py | 16,062 | 3.53125 | 4 | import sympy
import tkinter
from tkinter import *
from tkinter import messagebox
# setting up the tkinter window
root = tkinter.Tk()
root.geometry("400x590")
root.resizable(0, 0)
root.title("Calculator")
global li
li = []
global ip
ip = 0
global count
count = 0
val = ""
A = 0
operator = ""
#... |
996ce567efe69bac2c68b14a81e0b1da892804c5 | Smilejarik/O-Reilly-Training---Intermediate-Python | /01-1_WarmUp.py | 618 | 4.3125 | 4 | import scrabble
text = "ka"
#print all words containing "text"
for word in scrabble.fonts:
if text in word:
print(word)
#print letters that are not doubled
import string
alphabet = string.ascii_lowercase
print(alphabet)
for letter in alphabet:
print("Next letter is: " + letter)
exists = False
... |
b0480f028394d501eb5e8d003632c464bf5a810b | lebm/coursera-interactive-python-1 | /rspls/rspls.py | 1,356 | 4.28125 | 4 | import random
# dicts to simplify name_to_number and number_to_name
name_number = {"rock": 0, "Spock": 1, "paper": 2, "lizard": 3, "scissors": 4}
number_name = {0: "rock", 1: "Spock", 2: "paper", 3: "lizard", 4: "scissors"}
def name_to_number(name):
""" Maps name to its number
Well, I am not sure if we ... |
e717d99d99706ee990f062d65c75a2b2fb694f31 | pattharaphon/My-Script | /lambda.py | 398 | 3.828125 | 4 | def function_1(x) : return x ** 2
def function_2(x) : return x ** 3
def function_3(x) : return x ** 4
callbacks = [function_1 , function_2 , function_3]
print("\nNamed Functions:")
for function in callbacks : print("Result:",function(3))
callbacks=\
[lambda x:x**2,lambdax:x**3,lambdax:x**4]
print("\nAnonym... |
4e596675447ea44b7a8888b2dad6d6091ac2765b | imalkov97/Python | /Week 3/Lab Q2.py | 433 | 4.21875 | 4 | width=input("Enter the width of your tree (Odd numbers only!)")
length=input("Enter the length of the tree trunk")
w=int(width)
l=int(length)
t=("*") #The character used to display the tree
r=(1) #The start of the tree (top)
n=(1) #The number of rows of the tree trunk
e=(3) #The number of "*" character columns in the... |
c3f6601d44cea5b7192300ce3273400780392b0e | ajaxhe/house | /tax/tax-counter.py | 1,262 | 3.5 | 4 | #!/usr/bin/python
# -*- coding:UTF-8 -*-
# 房屋交易税费计算器
def counting_tax_zengzhi(info):
if info['years'] >= 2 and info['normal'] == True:
return 0
else:
return (info['sale_price']-info['beian_price'])/1.05*0.05
def counting_tax_qi(info, tax_zengzhi):
tax_point = 0.01
if info['size'] > 90:... |
0ea90699826cd424e168b71925211c4cce2a40e4 | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/226/users/4140/codes/1638_2729.py | 89 | 3.75 | 4 | x=int(input())
y=int(input())
if((x*y)%2==0):
a=x+y;
print(a);
else:
a=y-x;
print(a) |
6a2fc9a33ccd848e39503fe13e14213f3a70626e | eyshah/Eyshah-Nadeem---Project-Brief--Task-4-Csv-file-analysis | /code5.py | 634 | 3.890625 | 4 | # imports the csv module
import csv
# created a reader_variable for the opened up csv file
with open("boardmeetingnew.csv", "r") as emails_info:
reader_variable = csv.reader(emails_info)
# created a variable email giving number "0" as csv file has many rows
email = 0
for line in reader_variab... |
f8802cdd74551700aacc90cb01fd296bc91f58f8 | MrHamdulay/csc3-capstone | /examples/data/Assignment_8/gndree002/question2.py | 775 | 4.03125 | 4 | """Recursive function to count the number of pairs of repeated characters in a string
Reece Gounden
7 May 2014"""
string = input("Enter a message:\n")
strcnt = '' #string to store pairs char pairs
def cntPairs(string):
global strcnt
if len(string)>1:
if string[0]==string[1]: #if 1st and 2nd... |
6ff691a54b38ee37807ba45346c73e0e7e0724be | pavel-malin/game_python3 | /game_python3/buggy_en.py | 288 | 3.890625 | 4 | import random
number1 = random.randint(1, 10)
number2 = random.randint(1, 10)
print('How much will: ' + str(number1) + ' + ' + str(number2) + '?')
answer = input()
if int(answer) == number1 + number2:
print('Right!')
else:
print('Not! Correct answer -' + str(number1 + number2))
|
7f32cbc98a8dafa31a5dbac272f1b7e653d7635d | fiqriardiansyah/python | /3.perulangan dan runtunan/segitga infinite loop.py | 346 | 3.84375 | 4 | #perulangan
'''
program ini akan menghasil segita bintang yang tidak akan pernah berhenti
(infinite loop)
'''
true = True
while true:
for i in range(1,11):
for j in range(1,i):
print("*",end="")
print()
for i in range(11,1,-1):
for j in range(i,1,-1):
print("*"... |
950daa642f5cf6d6f75633c7fec4a27464d37931 | Jerry1014/Pygame | /Snake/borad.py | 2,469 | 3.578125 | 4 | import pygame
class Scoreboard():
"""显示得分信息的类"""
def __init__(self,screen):
self.screen = screen
self.screen_rect = screen.get_rect()
self.score = 0
self.high_score = 0
# 显示得分信息时使用的字体设置
self.text_color = (30,30,30)
self.font = pygame.font.Sys... |
7e309b9ed4d48bdcc20b4bdd00b48bc683eec1fc | tudennis/LeetCode---kamyu104-11-24-2015 | /Python/decoded-string-at-index.py | 1,705 | 3.96875 | 4 | # Time: O(n)
# Space: O(1)
# An encoded string S is given.
# To find and write the decoded string to a tape,
# the encoded string is read one character at a time and the following steps are taken:
#
# If the character read is a letter, that letter is written onto the tape.
# If the character read is a digit (say d),
... |
06357a0cba0e87f6ce55335585632b5bd07061b8 | skfreego/Python-Maths | /power_mod_power.py | 482 | 4.3125 | 4 | """
Task:- You are given three integers: a, b, and m, respectively. Print two lines.
The first line should print the result of pow(a,b). The second line should print the result of pow(a,b,m).
Input Format:- The first line contains a, the second line contains b, and the third line contains m.
"""
"""
3
4
5
... |
040cd1be960973bb1791ab516de225bcd9d02e26 | PIvanov94/python_oop_2021 | /encapsulation_exercise/wild_cat_zoo/zoo.py | 3,501 | 3.796875 | 4 | class Zoo:
def __init__(self, name, budget, animal_capacity, workers_capacity):
self.__animal_capacity = animal_capacity
self.__workers_capacity = workers_capacity
self.__budget = budget
self.name = name
self.animals = []
self.workers = []
def add_animal(self, an... |
623700031ae37b7983c9a4c75af142f05364f6b4 | BennetLeff/Project-Euler-Solutions | /euler 14/longest_collatz.py | 426 | 4.09375 | 4 | # store num and iterations of largest
max_collatz = {"num": 0, "iter": 0}
def collatz(x):
num = x
count = 0
while not num == 1:
if num % 2 == 0:
num = num / 2.0
else:
num = (3 * num) + 1
count += 1
if count > max_collatz["iter"]:
max_collatz["nu... |
d32c6b5716d3520c1e918ce8ec22d95c0675b598 | minluoxu/tensorflow_example | /minst_multi_softmax.py | 1,616 | 3.546875 | 4 | # -*- coding: utf-8 -*-
from tensorflow.examples.tutorials.mnist import input_data
import tensorflow as tf
# the network is to recognize the image use mnist dataset
# the struct network is two layer network have one hidden layer.
#
# Import data
mnist_data = input_data.read_data_sets("MINIST_data/",one_hot=True)
... |
9c8257cf917cf0196913241693317dc5d367d6da | usaramazan/LearningPython | /Day1/less11_ifStatement.py | 190 | 3.578125 | 4 | credit_score=input("how is your credit score? ")
if credit_score=="good":
print("you will have 10% down payment")
elif credit_score=="bad":
print("You need to make 20% down payment") |
0374a7977cbf1ae0f04778dccd2d1c61f000141a | soaresderik/IFLCC | /01semestre/introducao-algoritmo/python/atv02.py | 171 | 3.9375 | 4 | celsius = int(input("Digite a temperatura em Celsius: "))
f = (9 * celsius + 160) / 5
print("Temperatura em Celsius: ", celsius)
print("Equivale ", f , " em Fahrenheit") |
14f7d0efb359aea7c8c4a8ce02544281db39c0f4 | Souro7/python_fundamentals | /tuple_set.py | 616 | 3.953125 | 4 | # Tuples: ordered, unchangeable, allows duplicate
fruit_tuple = ('Apple', 'Orange', 'Mango')
# get single value
# print(fruit_tuple[1])
# fruit_tuple[1] = 'Grape' --> unchangeable
# tuples with one value should have trailing comma
fruit_tuple2 = ('Apple',)
del fruit_tuple2
# print(fruit_tuple2)
#-------------... |
87e90cd8e6024edfd324ab979d94da761d20b399 | etnaviv/etna-gpu-tools | /bin2img.in | 1,089 | 3.578125 | 4 | #!/usr/bin/python
'''
Convert binary framebuffer to an image
'''
from __future__ import print_function, division, unicode_literals
import argparse,struct
from binascii import b2a_hex
def parse_arguments():
parser = argparse.ArgumentParser(description='Convert binary framebuffer to an image.')
parser.add_argume... |
fc36ef5039f1d13a8121284d8a62cce6f4c98ff5 | HeyArtem/python_lesson_8 | /light.py | 726 | 3.6875 | 4 | import time
def show_time(f):
def wrapper(*args, **kwargs):
t = time.time()
f(*args, **kwargs)
print(f'{time.time() - t:.5f} сек.')
return wrapper
@show_time
# генератор
def int_gen_explicit(num = 1000000):
for i in range(num):
yield i + 1
@show_time
# генератор
def int_it... |
b088f8be9b7cd968c37c481bd1b795930b2f8b94 | PeterWolf-tw/ESOE-CS101-2015 | /b04505033_HW03.py | 1,902 | 3.703125 | 4 | # !/usr/bin/env python3
# -*- coding:utf-8 -*-
def charFreqLister(inputSTR):
n = len(inputSTR)
resultLIST = []
for i in inputSTR:
j = float('%.3f'%(str(inputSTR).count(i)/n))
if (j,i) not in resultLIST:
resultLIST.append((j,i))
resultLIST = list(resultLIST)
resultLIST... |
f5cee2f2cb65bb8bca96df7e7fa4daa63a5d9031 | kamilioner/MyProjects | /TestingFirstPyCharmProject/TestingFirstPyCharmProject.py | 9,769 | 4.03125 | 4 | # ### Print
#
# a = ['Mary', 'had', 'a', 'little', 'lamb']
#
# for i in range(len(a)):
# print(i, a[i])
#
# ### Breaking
#
# for n in range(2, 10):
# for x in range(2, n):
# if n % x == 0:
# print(n, 'equals', x, '*', n // x)
# break
# else:
# # loop fell through wit... |
8e7f3bd9439cb9989913b3ea1508e0bb93bb00fe | AnuLakshmi26/ucla-2019 | /Dictionaries.py | 372 | 3.796875 | 4 | dictionary = {
"dekho ":" look",
"na" : "please",
"Yaar":"hey!dude",
"bultaoreune":"I'm on fire",
}
sentence=("Yaar dekho na (Hindi to English). bultaoreune (Korean to English ) ")
wordList=sentence.split(" ")
print(wordList)
for word in wordList:
if word in dictionary.keys():
print(... |
285c23a8df17058dfd9c5849d0b7a0584d9243b6 | amol-a-kale/exersicepython | /basic_coding/sum_1to_n.py | 377 | 3.96875 | 4 | # Write a code that helps to display the sum of 1 to N numbers
def sumofn_no(N):
sum = 0
for i in range(1, N + 1):
# print(i)
sum = sum + int(i)
print('sum of 1 to' + str(N) + ' number is ' + str(sum))
sumofn_no(20)
def sum_by_formula(N):
a = 1
sum = N / 2 * (a + N)
print('su... |
2bcf1a7d4cc96aa12572730dabce7eb0c6f706ba | Aria17Armada/Assignment-Circle-Cylinder | /Main.py | 263 | 3.96875 | 4 | import math
from Cylinder import Cylinder
radius = input("Radius= ")
height = input("Height= ")
color = input("Color= ")
test = Cylinder(height, radius, color)
print("The result is= ", test.getVolume(), " with the ", color, " color")
print(math.pi)
|
4c4ef29d2e2ff6d4487cfe54f6a6557a5722d9c1 | Yashwant-Tailor/LeetCodeSolution | /python_solutions/767.py | 1,469 | 3.578125 | 4 | class Solution:
def reorganizeString(self, s: str) -> str:
# Solution Oveview
# if the maximum frequency of any character is greater than the half of the elements,then its not possible otherwise we can arrange the elements in some order to get any two adjacent character different
# first mak... |
c1b86dfd181e3ac681d363d805350ae5788fb386 | q3dm17/python | /algor/insertion_sort.py | 444 | 4.125 | 4 | from itertools import count
def insertion_sort(array):
for j in range(1, len(array)):
key = array[j]
i = j - 1
while i >= 0 and array[i] > key:
array[i + 1] = array[i]
i -= 1
array[i+1] = key
print(array)
def main():
insertion_sort([3, 7, 33, 2,... |
4c9a1d4c395e634efd223b5d85214b04bbd9bf01 | HenryProjects/cosmetic_relics | /beauty_site_scrape.py | 2,705 | 3.671875 | 4 | #!usr/bin/env python3
# import the library used to query a website
import urllib.request
# import the Beautiful soup functions to parse the data returned from the website
from bs4 import BeautifulSoup
# import the library for obtaining random values
import random as r
def get_html(url):
# Query the website and ... |
ba7bf9e091277172609f492438b9c6295b405114 | alannguyencs/alutils | /alstr.py | 1,630 | 3.578125 | 4 |
def num2str(n, k=6):
ans = str(n)
while(len(ans) < k):
ans = '0' + ans
return ans
def longest_common_child(X, Y):
# find the length of the strings
m, n = len(X), len(Y)
# declaring the array for storing the dp values
lcc_length = [[None for _ in range(n+1)] for _ in ... |
124671f1167602118470fd041ae94c404bf2f343 | aman-singh7/training.computerscience.algorithms-datastructures | /09-problems/lc_268_missing_number.py | 2,537 | 4.03125 | 4 | """
1. Problem Summary / Clarifications / TDD:
What is the max size of the input?
Output([3,0,1]): 2
Output([2,0,1]): 3
2. Inuition: 3 different solutions:
- The naive solution 1:
- To sort the array in ascending order and then
- Find the missing... |
cd6f73fa08124813457f3a934fe4f8b2a86c7676 | killynathan/problems | /codeJam2016/countingSheep/script.py | 576 | 3.59375 | 4 | def findLastNumberBeforeSleep(n):
if n == 0:
return 'INSOMNIA'
visited = set()
for i in range(1,1000):
num = i * n
# get every digit in n and add to visited
strNum = str(num)
for char in strNum:
visited.add(char)
# if visited is full, return n
... |
58b16c98bfc6e89d450693396de17af5b8ef63e6 | TechnionENIC/ENIC_scoring_program | /Questionnaires/BeckDepression.py | 7,730 | 3.65625 | 4 |
import pandas as pd
from .Questionnaire import Questionnaire
class BeckDepression(Questionnaire):
"""
A class used to represent an the Beck Depression Questionnaire
Attributes
----------
df : DataFrame
A Pandas data frame with the specific columns
for the questionnaire
Methods
-------
grade()
Calcul... |
ec03772d377efd4b715149695d2a1bac4c78793c | pyccel/pyccel | /ci_tools/summarise_pyspelling.py | 4,720 | 4.21875 | 4 | """ Script to output pyspelling results in a more digestible markdown format
"""
import argparse
import difflib
import os
import sys
import json
import re
def find_all_words(file_path, search_word):
"""
Find all occurrences of a word in a file.
Find all occurrences of a word in a file and return the line... |
6f690d8ae3e1e6f03d186ed6398692f4f38075fa | RickyUlman/Odd-Even-list-remover | /ex8-2_Barnes.py | 690 | 4.21875 | 4 | # Author: Richard n Barnes iii
# Title: Exercise 8 - 2
# Purpose: Removes odd or even numbers from a list
intList = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
nn = True
# removes odd numbers from list
def getEven(list):
for i in list[:]:
if i % 2 !... |
724a24614c4e4575f2ba48b6a1d68d0057165fc7 | SaiCharanParuchuri/Competitive-Programming | /Week-03/Day-01/7-sidedDice.py | 512 | 3.890625 | 4 | import random
def rand5():
return random.randint(1, 5)
def rand7():
# Implement rand7() using rand5()
while True:
first = 5 * (rand5() - 1)
second = rand5()
total = first + second
if total <= 21:
return total % 7 + 1
print 'Rolling 7-sided die..... |
9430d6adaa37b52b52b23a493e7aad2f47e7f9ea | betty29/code-1 | /recipes/Python/578663_Simple_but_Complex_Calculator/recipe-578663.py | 2,167 | 3.671875 | 4 | done = False
while not done:
import cmath
import time
import math
import Audio_mac
print "+--------------------------+"
print "|RAW_CALCULATOR 0.6 (BASIC)|"
print "|A)Addition |"
print "|B)Subtraction |"
print "|C)Multiplication |"
print "|D)D... |
c8056d529a2743b487f48e6038dc87834746edb0 | gyang274/leetcode | /src/1500-1599/1516.move.subtree.n-ary.tree.nt.py | 1,679 | 3.671875 | 4 | """
# Definition for a Node.
class Node:
def __init__(self, val=None, children=None):
self.val = val
self.children = children if children is not None else []
"""
from collections import deque
class Solution:
def moveSubTree(self, root: 'Node', p: 'Node', q: 'Node') -> 'Node':
def scanTree():
r_q... |
8dad186ce73d9133f3694915b33a308f75da3d15 | jO-Osko/racunalniske-delavnice | /classes_untyped.py | 1,278 | 3.734375 | 4 | # -*- coding: utf-8 -*-
"""Types with classes"""
class Person:
def __init__(self, first, last, children=None):
self.first_name = first
self.last_name = last
self.children = children or []
def get_full_name(self):
return self.first_name + " " + self.last_name
def get_numb... |
f9c94ca1235ad32a66e933e179d4ffe1321ab516 | Zasterify/Python-Practice | /Console Output Practice/show.py | 945 | 4.4375 | 4 | print("My name is Damiete") # To print my name
print("I am from Nigeria") # To print my country
print("I attend Gallaudet University") # To print my college
name = "Damiete Oruwari" # To preserve the variable called 'name'
age = "21" # To save the variable called 'age'
country = "Nigeria" # To preserve the vari... |
b023bff4ca58a1bb9dd3abaafd236635bed4ab07 | ilshadrin/lesson3 | /date.py | 522 | 3.875 | 4 |
'''
Напечатайте в консоль даты: вчера, сегодня, месяц назад
Превратите строку "01/01/17 12:10:03.234567" в объект datetime
'''
from datetime import datetime, timedelta
dt_now = datetime.now()
print('today ',dt_now)
delta = timedelta(days=1)
print('yesterday ',dt_now-delta)
delta2 = timedelta(days=30)
print('mo... |
cbe6e765bdd34ab0f6e5aa74eb6733d833e8ea17 | sixtead/MIT.6.00.1x | /02_week_2_simple_programs/02_functions/03_fourth_power.py | 448 | 3.96875 | 4 | # -*- coding: utf-8 -*-
"""
Write a Python function, `fourthPower`, that takes in one number and returns that value raised to the fourth power.
You should use the `square` procedure that you defined in an earlier exercise (you don't need to redefine `square` in this box; when you call `square`, the grader will use our... |
466b6353b4f35aeb075853670b4f66d28a11b2b2 | Agatha234/bootcamp | /Assignments/datatypes.py | 672 | 3.84375 | 4 | #1.Can I use matching double quotes for string literals instead of single quotes? Yes/No
Yes
#2. Can I compare strings using comparison operators such as = and < or built-in functions such as max () and min ()? Yes / No
Yes
#3. What does the expression 1/0 evaluate to in Python?
c. Error
#4. Is the... |
180a6b900e7528a9f0190d7b9bf6547be94e0251 | sanjay-chahar/Python-3.5 | /whileloops.py | 767 | 4.03125 | 4 | #Turtle with while loop
import turtle
length = int(input('please enter a length '))
colour = input ('please enter a colour ')
angle = int(input('please enter an angle '))
counter = 0
while counter < 4:
turtle.color(colour)
turtle.forward(length)
turtle.right(angle)
counter = counter + 1
# Answer = '0'
... |
4c3eea0095bd2fa236c2671cdac3c6df5256d4e2 | vh62/artificial-intelligence | /vwh2107_hw4/driver_3.py | 4,817 | 4.125 | 4 | #!/usr/bin/env python
#coding:utf-8
"""
Each sudoku board is represented as a dictionary with string keys and
int values.
e.g. my_board['A1'] = 8
"""
ROW = "ABCDEFGHI"
COL = "123456789"
def print_board(board):
"""Helper function to print board in a square."""
print("-----------------")
for i in ROW:
... |
09cd6a52f2d2dea98a2194a21f1e7d412c227256 | daviddwlee84/LeetCode | /Python3/BinaryTree/CheckIfAStringIsAValidSequenceFromRootToLeavesPathInABinaryTree/Naive.py | 950 | 3.953125 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
from ..TreeNodeModule import TreeNode
from typing import List
class Solution:
def isValidSequence(self, root: TreeNode, a... |
cea2872079c9fa352d2ab3e684decfd5f7361ce6 | marychew97/python_tutorial | /first.py | 1,606 | 4.1875 | 4 | name = "Mary"
if name is "Bucky":
print("Hey there Bucky")
elif name is "Lucy":
print("What up Lucy")
elif name is"Sammy":
print("What up Sammy")
else:
print("Please sign up for the site")
#looping
food = ['bacon','tuna','ham','sausages','beef']
menu = []
for item in food[:2]:
print(item)
pr... |
3fd3b5312cfbf7a37284cf802fa3ec485f721914 | jsc-coding-sandbox/unit-tests-python | /lib/math.py | 210 | 3.515625 | 4 | def add_two(x: int, y: int) -> int:
return x + y
def sub_two(x: int, y: int) -> int:
return x - y
def div_two(x: int, y: int) -> int:
return x / y
def printeger(x: int) -> str:
return str(x)
|
85f0be6e665ced1ea0a411bbf08e664de54a065c | memoherreraacosta/AlgoritmosComputacionales | /exercises/sumaDig.py | 231 | 3.5625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 20 10:27:19 2018
@author: memoherrera
Sumatoria de digitos
Dado un entero, sumar todos los digitos del numero:
43 = 4+3 = 7
"""
def sumaDig():
|
92e71ea55683d850d284f417b628145cec2f80a6 | harman666666/Algorithms-Data-Structures-and-Design | /Algorithms and Data Structures Practice/LeetCode Questions/Greedy/1029. Two City Scheduling.py | 1,922 | 3.828125 | 4 | '''
1029. Two City Scheduling
Easy
1295
166
Add to List
Share
There are 2N people a company is planning to interview. The cost of flying the i-th person to city A is costs[i][0], and the cost of flying the i-th person to city B is costs[i][1].
Return the minimum cost to fly every person to a city such that exactly... |
7275aa4f7457105c1a82aa17dc6d2d381f5a76fc | YJL33/LeetCode | /old_session/session_1/_369/_369_plus_one_linked_list.py | 1,122 | 3.515625 | 4 | """
369. Plus One Linked List
Total Accepted: 5079
Total Submissions: 9876
Difficulty: Medium
Given a non-negative number represented as a singly linked list of digits,
plus one to the number.
The digits are stored such that the most significant digit is at the head of the list.
Example: Input: 1... |
3924d045dac86c410f0c75409c9bf99489fbb466 | angelstrikesback/python-practice | /TwoSum.py | 1,512 | 3.96875 | 4 | """
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
You can return the answer in any order.
Example 1:
Input: nums = [2,7,11,15], ta... |
8afcb7364fadb30bded82a7ee4109e6e278ee85d | judyohjo/Python-exercises | /Python exercise 23 - Random().py | 255 | 4.15625 | 4 | '''
Exercise 23 - Random() exercise 3 - Print any two random numbers between 0 and the number you input.
'''
import random
number = int(input("Input a number: "))
for i in range(2):
print("Random number: ", random.randrange(0, number))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.