blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
1bf24e12e18a033f893682b4a126c1b09b004678
Ankit-Vohra/bank-term-classifier
/bank-term-classifier.py
3,458
3.765625
4
#Importing The Libraries import pandas as pd from sklearn.metrics import confusion_matrix from sklearn.metrics import accuracy_score #Reading The Dataset dataset = pd.read_csv("bank-additional-full.csv",sep=";") #Spliiting X and Y Variables from Dataset X = dataset.iloc[:, :-1].values y = dataset.iloc[:,-1...
b8b59d2c9afc5b751806c6180472dada2823a76d
CornellAutonomousBikeTeam/Navigation
/tests/nav_unit_tests.py
756
3.515625
4
"""Module for testing nav.py functions""" import unittest import bikeState import mapModel import nav import math import numpy as np class TestNav(unittest.TestCase): def test_clamp_steer_angle(self): new_bike = bikeState.Bike(0, 0, 0, 0, 0, 0, 0) waypoints = [] new_map_model = mapModel.M...
5ea28a7b2baae19be468d6577069431d7d7d3b7f
zoeydao/yendao-fundamental-c4e22
/session3/homework/serious2(6).py
805
3.953125
4
#2.5 name = 'Yen' flock = [5,7,300,90,24,50,75] month = 4 print('Hello, my name is',name,'and these are my sheep size',flock) for i in range(1,month): biggest = max(flock) print("Now my biggest sheep has size",biggest,"let's shear it") biggest_size = flock.index(biggest) flock[biggest_size] = 8 pri...
e5de50df8e92c3b7061aacb3916c5fb6ac47c535
ehdrb5011992/Python
/Self_study/2019_Summer/Python Basics/Python Basics (Video , pycharm)/forrange.py
671
3.71875
4
for i in range(5) : print(i) #range(5) list는 아니지만 , 0,1,2,3,4 를 만들어냄 names = ['필수','영화','바둑이','귀도'] for i in range(len(names)) : name = names[i] print(' {}번 : {}'.format(i+1 , name)) for i,name in enumerate(names) : print(' {}번 : {}'.format(i+1 , name)) #'차'함수 print(chr(44032)) print(chr...
214aea54e1f1ff8c6dd1abf5cf2505f572e55072
bayoishola20/HackerRank
/30 Days of Code/Day 25 - Running Time and Complexity.py
343
3.9375
4
# Enter your code here. Read input from STDIN. Print output to STDOUT T = int(raw_input()) def prime(n): for i in xrange(2, int((n)**0.5)+1): if n % i is 0: return False return True for _ in xrange(T): n = int(raw_input()) if n >=2 and prime(n): print "Prime" else: ...
13ee382b9c5a10c6b3a6db4cb8cf2e5148d5718d
jubic/RP-Misc
/System Scripting/Problem15/6P/t10_dict1.py
520
4.0625
4
""" h2. Dictionary Values to String Write a function @getVals@ that takes a dictionary as an argument. Get all the values from the dictionary, sort them, and return them as a string with each value enclosed in a &lt;> bracket. bc. {- python -} d = {"x":"y", "a":"b", "g":"h"} print getVals(d) # returns <b><h><y> (s...
09ea0b459438f524ea4bdee52d425ea2dc69c6af
tatyanashashalina/Python-C
/lab4task3.py
576
4.03125
4
# Написать программу, которая запрашивает строку и определяет, не является ли строка палиндромом # (одинаково читается и слева направо и справа налево) def isPali(str): lst = str.split(" ") newStr = "".join(lst) reverseStr = newStr[::-1] if reverseStr == newStr: print("Строка является палиндро...
cfd031cd32d2a2dfe1f542dcdf4aea9fd15593f0
dexterka/coursera_files
/2_Python_data_structures/week3_files/week3_assignment_7_1.py
343
4.1875
4
import os from os import path # Read file and convert the content to upper-case file_name = input('Enter the name of the file: ') file_path = path.abspath(path.join('..', '..', 'sample_files', 'words.txt')) print(file_path) file_read = open(file_path, 'r') for line in file_read: line = line.rstrip() ...
d0868700f723d88715f4a32ae1a213ba1f66dfa0
quangthinhbui/DM-Projects
/Convex Hull/MergeHull_Algorithm.py
6,229
3.5625
4
import matplotlib.pyplot as plt # Point class with x, y as point class point: def __init__(self, x, y): self.x = x self.y = y # To find the left most point def left_index(points): left = 0 for i in range(1, len(points)): if points[i].x < points[left].x: left = i ...
ccd84b7ba1fa7b67e5ecb146b26bad7fa762e1c8
BraverChiang/JZYPython
/04_image_file.py
1,414
3.875
4
# 21 Module. 22 Download Image from web. 23 Read/Write file. # 24 Download the file from the web. # Setting >> Project interpreter # 21 Module. import m #自定义的 import random #Python自带的 # import urllib.request from urllib import request m.fish() x = random.randrange(100,1000) print(x) # 22 Download Image from web....
e46fcc02cdf15ed9dae428b202b8af669d908b82
LaughLax/Advent-of-Code
/py/2018/13.py
5,359
3.625
4
import time DIR_RIGHT = 0 DIR_UP = 1 DIR_LEFT = 2 DIR_DOWN = 3 class AdventOfCode: def __init__(self, filename): with open(filename) as f: self.input = f.read().splitlines() def make_grid(self): grid = Grid(len(self.input[0]), len(self.input)) for y, lin...
77ced4a46986e31737eb46fc04de3b4bb26aff7b
B-APuAHT/UnionFind
/main.py
1,155
3.859375
4
class UnionFind: """ A union-find data structure. """ def __init__(self, n): """ (UnionFind, int) -> NoneType The UnionFind initialization with n objects """ self.ids = [x for x in range(n)] self.weights = [0 for x in range(n)] def root(self, a): """ ((Uni...
99dbca52c628339c2c96cafe31b4906b68313dd0
blackbogdan/interviewcake
/task3_product_of_three.py
1,105
3.859375
4
lst = [2,3,4,56,7] from itertools import islice def highest_product_of_3(lst): if len(lst)<3: raise Exception("Less than 3 items!!!") highest_num = max(lst[0], lst[1]) lowest_num = min(lst[0], lst[1]) highest_product_of_two = lst[0]*lst[1] lowest_product_of_two = lst[0]*lst[1] ...
a2739369be504c395ea6ec919c8f4a8667522cd5
paulinewalsh/DataStructuresAndAlgorithms
/math_algorithms.py
1,021
4.15625
4
# Euclid's formula states that, given an arbitrary pair of integers m and n, with m > n > 0, # a pythagorean triple will be formed when a=m^2-n^2, b = 2mn, and c = m^2 + n^2 def euclid(m, n): a = m**2 - n**2 b = 2*m*n c = m**2 + n**2 return (a,b,c) def find_pythagorean_triple(x): n = 1 while...
fc430bc377ac226ddb4dc4ed54baf3514436625f
WorkRock/python_lab
/HomeWork/lab4_13.py
651
3.953125
4
"""lab4_13 주제: 1. 사용자로부터 단어를 입력받는다. 2. 입력받은 단어를 출력한다. 3. 해당 단어에 포함된 알파벳을 알파벳 순서로 출력한다. 4. 해당 단어의 길이를 출력한다. 작성일: 17. 10. 01. 작성자: 201632023 이지훈 """ """ a = input("단어 입력 : ") print("입력 하신 단어 : ",a) l = [] size = len(a) for i in range(0,size): l.append(a[i]) l.sort() b = "" for i in range(0,size): b += l[i] print...
9cc119613e1c46cda66c3272a9d549a78fbb1e57
clumsyme/learn
/python/solveleet/validParentheses.py
996
3.9375
4
""" Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]" are not. """ class Solution(object): def isValid(self, s): """ :type s: str ...
f3ede7181fb01b549916b2948bc30dea913cdf17
DariaKnyazeva/project_euler
/problems/p033.py
2,173
4
4
# DIGIT CANCELLING FRACTIONS """ The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that 49/98 = 4/8, which is correct, is obtained by cancelling the 9s. We shall consider fractions like, 30/50 = 3/5, to be trivial examples. There are exac...
6eef2329207341a2e3b10bce45d014ce3802daa7
shaunktw/tipcalculator
/tip_calculator.py
433
3.515625
4
#Assigning variables meal = 44.50 tax = 6.75/100 tip = 0.15 tax_value = tax * meal meal_with_tax = meal + tax_value tip_value = meal_with_tax * tip total = meal_with_tax + tip_value print "The base cost of your meal was $%.2f" % (meal) print "You need to pay $%.2f" % (tax_value) print "Tipping at a rate of %d%%, yo...
ea18a2b2ad2d530d1bb175e3a81fbfbff865ea2e
Tiiaraa1907/basic-python-b3
/list.py
580
4.15625
4
number="The number is 5" numberList=["The", "number", "is" ,"5"] numberCol=["one","two","three","four"] # print(number) # print(numberList) # #to add the string # #before # print(numberList) # # #after # numberList.append("guys!!!") # print(numberList) #looping # for x in numberList: # print(x) # for x in rang...
914b9fc34686ebaa2ed39cc542dda8ef8971a184
maiphuong1809/nguyemaiphuong-fundamental-c4t4
/session07/calculator.py
740
4.15625
4
x = float(input("x = ")) operation = input("operation(+,-,*,/):") y = float (input("y = ")) # if operation == "+" : # print ("{0} {1} {2} = {3}").format (x,operation,y,x+y) # elif operation == "-": # print ("{0} {1} {2} = {3}").format (x,operation,y,x-y) # elif operation == "*": # print ("{0} {1} {2...
72df36905fa17c9e3a212916d8259c05262a8789
rkosakov/COS340
/Lecture 4/Lab/Salary_Calculator.py
391
3.96875
4
hours = eval(input('Enter hours worked: ')) salary = eval(input('Enrter salary per hour: ')) total_salary = 0 if hours > 40: total_salary = 40 * salary overtime_hours = hours - 40 overtime_salary = overtime_hours * (salary * (1 + 0.5)) total_salary = total_salary + overtime_salary else: total_sal...
ee6d481955546bb6c75b2f52197e59b0359e58f1
ferhatelmas/algo
/leetcode/algorithms/easy/check_if_n_and_its_double_exist.py
262
3.5
4
from typing import List class Solution: def checkIfExist(self, arr: List[int]) -> bool: d = set() for e in arr: if e * 2 in d or (e % 2 == 0 and e / 2 in d): return True d.add(e) return False
58478e9d047474071d7f82901f6c3e55d2b25edf
akrherz/iem
/htdocs/plotting/auto/scripts/p64.py
7,186
3.625
4
""" This chart displays either the first or last date of the winter season with a snowfall of a given intensity. The snowfall and snow depth data is not of great quality, so please be careful with this plot. """ import calendar import datetime import numpy as np import pandas as pd import psycopg2.extras from matplot...
2dfb8a75443618aa2d17368774b603a72910f171
chariotrequiem/deep-learning
/chap6神经网络/6.5输出层设计.py
7,703
3.921875
4
# 当前版本 : python3.7.11 # 开发时间 : 2021/9/17 14:55 """ 我们来特别地讨论网络的最后一层的设计,它除了和所有的隐藏层一样,完成维度变换、特征提取的功能,还作为输出层使用, 需要根据具体的任务场景来决定是否使用激活函数,以及使用什么类型的激活函数等。 我们将根据输出值的区间范围来分类讨论。常见的几种输出类型包括: ❑ 𝑜𝑖 ∈ 𝑅𝑑 输出属于整个实数空间,或者某段普通的实数空间,比如函数值趋势的预测,年龄的预测问题等。 ❑ 𝑜𝑖 ∈ [0,1] 输出值特别地落在[0, 1]的区间,如图片生成,图片像素值一般用[0, 1]区间的值表示; 或者二分类问题的概率,如硬币正反面的概率预测...
4c035e3299ea87e0c76f46067e0f20da9e6b70f3
aga-moj-nick/w3resource---Python-Basic-Part-I-
/Exercise 036.py
327
3.96875
4
# 36. Write a Python program to add two objects if both objects are an integer type. def sumowanie (a, b): if not (isinstance (a, int)) or (isinstance (b, int)): return (False) else: return (a + b) a = float (input ("Podaj a: ")) b = float (input ("Podaj b: ")) print ("Wynik to: ", sumowanie (...
a1c90e05ff1b1fac26c6151174c19baf8387a8f8
matgsm/sorting
/ordenação/use_search.py
2,256
3.515625
4
import timeit from menu import Menu from monitor import Monitor from search import linear_search, binary_search from sorting import merge_sort from use_list import print_list def select_search(): #Menu de buscas alternatives = [ ["Linear Search"], ["Binary Search"] ] f1 = "\nSelecione um método de busc...
7733d76b5fecfb9764e46bda65ce4cb309d567be
fhmurakami/Python-CursoemVideo
/Exercicios/Mundo 01 - Fundamentos/Aula 06 - Tipos primitivos e saída de dados/ex004.py
673
3.8125
4
var = input('Digite algo: ') print('O tipo primitivo é: {}'.format(type(var))) print('É alfanumérico? {}'.format(var.isalnum())) print('É alfabético? {}'.format(var.isalpha())) print('É numérico? {}'.format(var.isnumeric())) print('É decimal? {}'.format(var.isdecimal())) print('É um dígito? {}'.format(var.isdigit...
c39e44432b57469f44112ff11aa4493391720dc8
HKRliduan/store
/day2.py
723
3.515625
4
import random print("================猜字游戏==============") print("猜对加150元,猜错减100元,数字在0-50之间哦!") print("首充100元,送初始金额:500元") ran = random.randint(0, 50) A = 500 i = 1 while i <= 3 or A < 00: num = int(input("请输入一个数字:")) if num == ran: print("ok") A = A+150 i = i+1 print...
57ddd91205940ccdf51dc0cf16fe28d54aec6212
SongYippee/leetcode
/Tree/102 二叉树层次遍历.py
1,700
3.984375
4
# -*- coding: utf-8 -*- # @Time : 10/27/20 6:03 PM # @Author : Yippee Song # @Software: PyCharm ''' 给你一个二叉树,请你返回其按 层序遍历 得到的节点值。 (即逐层地,从左到右访问所有节点)。   示例: 二叉树:[3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 返回其层次遍历结果: [ [3], [9,20], [15,7] ] 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/prob...
405273e0d0bf677bf0d64c0c9342087f7322040e
wlj572831/PythonSS17
/day2/数据类型/7.字典.py
1,093
3.5
4
#!/usr/bin/python # -*- coding:utf-8 -*- ################### dict: 字典######### dic = { 'k1':'v1', 'k2':'v2', 'k3':'v3' } # 1.清空 # dic.clear() # print(dic) # 2. 浅拷贝 # v = dic.copy() # print(v) # 3. 根据key获取value值 # v1 = dic.get('k1', 11) #不存在不报错,不存在返回11 # v2 = dic['k1'] # print(v1 , v2) # 4. 删除并获取对应valu...
e21f6d3cdc6c6f98346d55c06021982985b07410
yadlra/fizzbuzz-py
/fizzbuzz.py
138
3.671875
4
def divisibleby3(number): return number % 3 == 0 def divisibleby5(number): return number % 5 == 0 def __init__(self): pass
a1ac5f4115927beab7a31a73e3f8e8860805cac2
ISPritchin/Olympiad
/800/Оформлено/Игра с мячом.py
141
3.515625
4
n = int(input()) c = 1 for i in range(1, n): c = (c + i) % n if c == 0: print(n, end=' ') else: print(c, end=' ')
7e77715d6d1459b4d3e1ecc5e0cc3a23d82a9ab4
jorgehn7/CSCE4910
/PythonExamples/server.py
1,010
3.59375
4
#Server using AF_INET Family import socket HOST = '' # Symbolic name meaning all available interfaces PORT = 50007 # Arbitrary non-privileged port #Creates a Socket for our server sSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #Our socket will now bind at '' on 50007 sSocket.bind((HOST, PORT)) #Li...
0771cf294e8b8a2c31b565dac5c69ed0d53f6eb6
shubhamkanade/Niyander-Python
/string_Tuple_DT.py
142
3.90625
4
tuple=('abcd',786,2.23,'john',70.2) tinytuple=("john",123) print tuple print tuple[0] print tuple[2:] print tuple+tinytuple tuple[0]=5.60
3f30f28b8f3a8db8e53cab846a248d4b8c8f11ff
jeffrlynn/Codecademy-Python
/removeVowels.py
250
4.3125
4
#Remove all vowels from a string def anti_vowel(text): phrase = "" for letter in text: for vowel in "aeiouAEIOU": if letter == vowel: letter = "" else: letter = letter phrase = phrase + letter return phrase
374dc8861db0034e768213f3398abd32a3d04f1d
queryor/algorithms
/leetcode/66. Plus One.py
1,270
3.734375
4
# Given a non-empty array of digits representing a non-negative integer, plus one to the integer. # The digits are stored such that the most significant digit is at the head of the list, and each element in the array contain a single digit. # You may assume the integer does not contain any leading zero, except the nu...
de37d707487e37047b51683e82bb4b2c3bcc6775
isabelle926/flask_portfolio
/algorithms/isabelle_activities/lists_hack_IG.py
1,650
4.0625
4
# Challenge 1: Name the variable types of the following variables. Print them out into console in the format "Variable: Variable Type" (might have to google "how to print variables in python") integer = 3 string = "Mr. Mortensen" character = 'f' float = 0.4 print(integer, ": Variable Type", type(integer)) print(string...
8c356980746803d29587822c9f5a1338e28f8085
tchau209/Study
/python_extract2.py
789
4.03125
4
#!/usr/bin/env python # importing csv module import csv filename = 'test.csv' rowprice = 0 total = 0 #with open('test.csv') as csvfile: # data = csv.DictReader(csvfile) # print("Customer Name Price") # print("---------------------------------") # for row in data: # print(row['Customer Name'], row['Price']) wit...
dd4b649fa64ef52cecdadc83ee325c8a59bf578f
mahesh-keswani/data_structures_algorithms_important_problems
/quickSort.py
1,172
4.125
4
def quickSort(array): quickSortHelper(array, 0, len(array) - 1) return array def quickSortHelper(array, start, end): if start > end: return pivotIdx = start leftIdx = pivotIdx + 1 rightIdx = end while leftIdx <= rightIdx: if array[leftIdx] > array[pivotIdx] and array[right...
71adad5376a2b5a6d424d03e879257fc0fa10f4d
csendranshi/Python_100_DaysOfCode
/Day_1_to_25/Day_3/loveCalculator.py
579
3.765625
4
name1 = input("Enter your name: ").lower() name2 = input("Enter their name: ").lower() digits = [['t','r' ,'u','e'],['l','o','v','e']] value = [0,0] for i in range(len(digits)): for j in range(len(digits[i])): value[i]+=name1.count(digits[i][j]) value[i]+=name2.count(digits[i][j]) score = int(str(v...
46256a135226abdb5d8e6070ad5837ead8df70a0
Patrick-Mahon/Cp1404_Practicals
/prac_05/word_counter.py
415
3.78125
4
word_list = {} word_string = input("Enter string: ") words = word_string.split() for word in words: amount = word_list.get(word, 0) if amount is None: word_list[word] = 1 else: word_list[word] = amount + 1 words = list(word_list.keys()) words.sort() max_length = max((len(word) for word in...
6597216459b6745b8d92ba98180c208df12391d5
LimeOrangeTree/PYTHON
/class7.py
2,655
3.890625
4
# class Test: # @staticmethod # def t1(): # print("t1메서드") # @staticmethod # def t2(): # print("t2메서드") # def t3(self): #일반메서드 # print("t3메서드") # Test.t1() # Test.t2() # # Test.t3() # a=Test() # a.t3() # 인스턴스확인 isinstance() # class Student: # def __init_...
8eeab8819123d87bf4ae5c27fa47f486b39dc404
HuangStomach/the-self-taught-programmer
/6. String Manipulation/10.py
115
3.6875
4
str = "It was bright cold day in April, and the clocks were striking thirteen." str = str.split(",")[0] print(str)
b58bd2d68cde0b17ee8e2cd526e3455c475adb2a
Ellipse404/100-Exercises-Python-Programming-
/100+ Exercises Solved/Question - 19.py
713
4
4
# -*- coding: utf-8 -*- """ Created on Sat Jul 20 21:01:22 2019 @author: BHASKAR NEOGI """ # Level - 3 * from operator import itemgetter as it p = [] print("Follow The Format : Name,Age,Height ; Make Each Option With Same Number of Values(ex : 03 for 3) :") while True : s = inpu...
26167ee69d9afcbadcf56b977acd7cccaa0ee7bb
Jezzamonn/ArduboyLock
/image_to_bitmap2.py
3,391
3.90625
4
""" Generates C++ character arrays containing encodings of bitmaps. This script will search in a directory called "bitmaps", and convert any image file there into a constant character array. The character array will have the same name as the image without the extension. To use these arrays, you can put "#include bitma...
a98038467630977a77e2ba1a767987b9e3eb13e0
dmensah2/Web-Scraping
/SBOneBank.py
1,273
3.625
4
#Author: Deidre Mensah #Date: 05/23/2020 #Webscraping addresses from SB One Bank #import modules import requests, csv #imports Beautfiul soup library from bs4 import BeautifulSoup #opens your csv output = open("SBOneBank.csv", "w", newline='') #defines fields of csv writing = csv.DictWriter(output, fieldnames=["Name"...
b4ecef33e78b7d87e965214e4a73ebd95bd0f2b9
venkateshgb/jenkins
/operators.py
471
4.40625
4
#arthemetic operators num1=10 num2=20 '''print("Num1 + Num2 =", num1+num2) print("Num1 - Num2 =", num1-num2) print("Num1 * Num2 =", num1*num2) print("Num1 / Num2 =", num1/num2) print("5^3 =", 5**3) print("20 % 3 =", 20%3) print("22//7=", 22//7)''' #assignment operators num3 = num1 + num2 #print(num3) num3+=num2 #pri...
9ff3eaed308f9037f1266edc1601f329919d33c1
THYao/EECS545_Github
/HW4/hw4p5_YCC.py
2,705
3.5
4
from __future__ import division import numpy as np from matplotlib import pyplot as plt # Generate the data according to the specification in the homework description N = 500 x = np.random.rand(N) pi0 = np.array([0.7, 0.3]) w0 = np.array([-2, 1]) b0 = np.array([0.5, -0.5]) sigma0 = np.array([.4, .3]) y = np.zeros_l...
eb89a2b566e210d80ef7002b1210c4dd5af9a6b8
Devalekhaa/deva
/set78.py
70
3.703125
4
d=int(input()) if(d%7==0): print("yes") elif(d%7!=0): print("no")
88bf9a9083d7ea3938be2d5f5055cd2235b5ca07
whitneypenn/machine-learning-capstone
/src/k_modes_recs.py
1,909
3.5
4
import pandas as pd import numpy as np from kmodes.kmodes import KModes import matplotlib.pyplot as plt #load data data = pd.read_csv('data/categorical_data.csv') test_data = pd.read_csv('data/test_categorical_data.csv') num_clusters = 100 #clean data data.drop('Unnamed: 0', axis=1, inplace=True) data.dropna(inplace...
211163850a69b52c2a6f92a800a90e0cc99c3a27
homeah/myPython
/019.py
444
3.5
4
''' 【程序19】 题目:一个数如果恰好等于它的因子之和,这个数就称为“完数”。例如6=1+2+3.编程    找出1000以内的所有完数。 1. 程序分析:请参照程序<--上页程序14. 2.程序源代码: ''' for i in range(2,1001): temp = 0 for each in range(1,i//2+1): if i % each == 0: temp += each if temp == i: print('%d是完全数' %i)
6ad96194fb07c02e40b9b7d785d5933580eedc6b
Avery1493/DS-Unit-3-Sprint-2-SQL-and-Databases
/module1-introduction-to-sql/buddymove_holidayiq.py
1,478
3.890625
4
# python buddymove_holidayiq.py import os import pandas as pd import sqlite3 CSV_FILEPATH = 'https://raw.githubusercontent.com/Avery1493/DS-Unit-3-Sprint-2-SQL-and-Databases/master/module1-introduction-to-sql/buddymove_holidayiq.csv' df = pd.read_csv(CSV_FILEPATH) """ User Id Sports Religious Nature Thea...
a3511c731f11568e9f23857f16501b0157d0755c
daniel-reich/ubiquitous-fiesta
/AcEnqyHp9q3Dd92Hn_16.py
270
3.9375
4
def multiply_nums(nums): new_nums = "" total = 1 ​ for char in nums: if char == ",": continue new_nums += char ​ edited = new_nums.split() for number in edited: total *= int(number) ​ return total
c2927ce78c6bb8195437819f896bcb84342b9cdf
fernandesally/peoject98
/code.py
490
3.59375
4
def swapFileData(): filedata=open("sample1.txt") filedata=open("sample2.txt") #print(filedata.read()) lines=filedata.readlines() for i in lines: print(i) name="this is code.py" print(name.split()) swapFileData() def countwords(): file=open("sample1.txt") numbero...
b48f9478eb201d3f2e5d555f2e84fa38bf8ce13a
AmandaAzevedo/URI-Online-Judge
/python3/1010.py
189
3.6875
4
# -*- coding: utf-8 -*- total=0 for k in range (2): n = input().split(" ") quant=int(n[1]) valor=float(n[2]) total+=(quant*valor) print("VALOR A PAGAR: R$ %.2f" %total)
e0f24331c0338e5aff57ff38d36692f367650e3f
ramyasutraye/Python-6
/16)prime no between intervals.py
223
3.859375
4
a=int(input("enter the first interval")) b=int(input("enter the second interval")) for j in range(a, b+1): for i in range(2, j): if(j%i)==0: break else: print(j)
2cceb4c0774b19e153e282cbfd0a5bd4a4f53819
qiang-yu-scd/Python_cursus
/pe8_5.py
140
3.5
4
for i in range(1, 11): for j in range(1, 11): k = i * j print(str(i) + '*' + str(j) + '=' + str(k), end=' ') print()
6fdab0490a3fd4f3de53f3a5be0ee361eb928b1f
Aminaba123/LeetCode
/264 Ugly Number II.py
1,279
3.9375
4
""" Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly numbers. Note that 1 is typically treated as an ugly number. """ import heapq __author__ = 'Daniel' class N...
419102cf23dd00c1c95e7bbda85ada2ea36daa29
AgentT30/InfyTq-Foundation_Courses
/DataStructures and Algorithms Using Python/Day 3/arrange_balls.py
3,830
3.90625
4
# DSA-Assgn-12 class Queue: def __init__(self, max_size): self.__max_size = max_size self.__elements = [None]*self.__max_size self.__rear = -1 self.__front = 0 def is_full(self): if(self.__rear == self.__max_size-1): return True return False def...
675fd7fdadc52d27557ffa116424c82f38bcb085
renmission/scientific-calculator-with-python
/app.py
4,811
4.25
4
import math while True: print("\nChoose the math operation.\n\n0 - Addition\n1 - Subtraction\n2 - Multiplication\n3 - Division\n4 - Modulo\n5 - Raising to a power\n6 - Square root\n7 - Logarithm\n8 - Sine\n9 - Cosine\n10 - Tangent\n") oper = input("\nYour option from the menu: ") # addition if oper =...
498224bbc7fddc6c1f6d6d1c54d6eaafdc028897
osama-mohamed/python_projects
/python projects 3.6/مراحل التطور/شكل مبسط 3 لطباعة اسم بدالة __init__.py
313
3.875
4
print('any time if you want to exit the program just press "q"') while True : name = input('Enter your name : ') if name == 'q' : break class person(): def __init__(self, name): self.name = name print(name) #break #n = person('OSAMA') #print(n.name)
49fdec70fdad60ec07afceec4dbe5c192c54336e
yechenglong/pythonlearn
/python编程快速上手/电话号码和Email地址提取/强口令检测.py
1,000
3.75
4
# 写一个函数,它使用正则表达式,确保传入的口令字符串是强口令。强口令的 # 定义是:长度不少于8 个字符,同时包含大写和小写字符,至少有一位数字。你可 # 能需要用多个正则表达式来测试该字符串,以保证它的强度 import re def checkPassword(str1): q=re.compile(r''' (?=^.{8,}$) (?=.*\d+) (?=.*[A-Z]) (?=.*[a-z]) ''',re.VERBOSE) macth = q.match(str1) return macth is not None # p...
d43f6e5f38914fed57936af2487182ce6bad9c9a
krnets/codewars-practice
/7kyu/Fizz - Buzz/index.py
1,064
4.15625
4
# 7kyu - Fizz / Buzz """ Write a function that takes an integer and returns an array [A, B, C], where A is the number of multiples of 3 (but not 5) below the given integer, B is the number of multiples of 5 (but not 3) below the given integer and C is the number of multiples of 3 and 5 below the given integer. For...
e2f40001f31eaad7e7c7d9e6cd0fed548c4bcf9a
icexmoon/design-pattern-with-python
/pattern16/visitor/src/node.py
960
3.625
4
from collections.abc import Iterator class Node(): def __init__(self) -> None: self.children: list = list() self.parent: Node = None def removeFromParent(self) -> bool: if self.parent is not None: return self.parent.removeChild(self) return False def removeChi...
9f4c6f0abad163ff0bdcdf29874369b0e1102ff6
teejay-tarun-jain/stocks_python
/example_db4.py
698
3.859375
4
# Creates table in sqlite db import sqlite3 import pandas as pd conn = sqlite3.connect('pythonsqlite.db') cur = conn.cursor() #cur.execute('INSERT INTO test (name, description) values ("Aquiles", "My experiment description")') sql_command = """ DROP TABLE IF EXISTS test; CREATE TABLE test ( id INTEGER, name ...
977af1882fbf5727b6d39b17c7414fec81b62006
imxiaohui/exercises_for_programmers
/area_of_a_rectangular_room/python/area_of_a_rectangle.py
374
4.21875
4
length = int(input("What is the length of the room in feet? ")) width = int(input("What is the width of the room in feet? ")) print("You entered dimensions of {:d} feet by {:d} feet.".format(length, width)) area_in_feet = width * length area_in_meters = area_in_feet * 0.09290304 print("The area is\n{} square feet\n{...
1f5b5ec377e5b798714a9230b25e9db0e64db369
celen-hub/python-exercises
/HighScore.py
345
3.78125
4
student_scores = input("Input a list of student scores ").split() for n in range(0, len(student_scores)): student_scores[n] = int(student_scores[n]) student_scores.sort() print(student_scores[-1]) high_score = 0 for i in student_scores: if i > high_score: high_score = i print(high_score) p...
ab94e06ca3bdc0f27cc8381883c832ce62c6b627
shuxiaoyuan/CodingInterviewChinese2_Python
/CodingInterviewChinese2_Python/面试题18:删除链表的节点.py
953
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- class Node: def __init__(self, val): self.val = val self.next = None def delete_node(head, node): if not (isinstance(head, Node) and isinstance(node, Node)): return # 链表有多个节点,且要删除的节点不是尾节点 if node.next != None: ...
f261231dd8b579c30b88b96937d588df56e68149
golkedj/Complete_Python_Masterclass
/Game/enemy.py
2,034
3.640625
4
import random # class Enemy: class Enemy(object): def __init__(self, name="Enemy", hit_points=0, lives=1): self._name = name self._base_hit_points = hit_points self._current_hit_points = hit_points self._lives = lives self._alive = True def take_damage(self, damage): ...
d38a8da0e88f04c7edc1a2ef06061958cd39a391
bigm141414/Algorithms
/merge_sort.py
1,416
4.25
4
__author__ = 'bigm141414' #simple merge sort program in python #------------------------------------------------------------------------------ unsorted = [2, 4, 7, 1, 5, 6, 3, 0] def merge_sort(array,n): print("Splitting ",array) if n < 2: print("end of subarray ") else: print(n) ...
4c5b159eab36191ac708f02b59c4aa96cbca05bb
mango2017/python
/eg/py009.py
276
3.53125
4
# -*- coding: UTF-8 -*- class Parent: def hello(self): #self是对象 print("正在调用父类的方法...") class Child(Parent): #继承父类 def hello(self): print("正在调用子类的方法...") p = Parent() p.hello() c = Child() c.hello()
80ad8f239b5097c889f7067963fdcfa6c575f51a
wuxiukai/python-3.7-daimaku
/classes and objects/DerivedClass.py
961
3.9375
4
class Person: #基类 def __init__(self,name,age): #构造函数 self.name = name #姓名 self.age = age #年龄 def say_hi(self): #定义基类方法say_hi print('你好,我叫{0},{1}岁'.format(self.name,self.age)) clas...
efcb5ddb3766256af257a3c1292485f5cd1c945a
Ayush-kaithwas/Stone-Paper-Seccissor-Game
/stone_paper_seccissor_Game.py
2,163
3.859375
4
import random user = 0 computer = 0 def random_input(): lst = ["Rock", "Paper", "Scissor"] a = random.choice(lst) return a i = 0 while i < 5: print("Choose one to play this game") print("S for Scissor\nR for Rock\nP for Paper") temp = str(input()).capitalize() i = i + 1 if temp == "...
461c309fc96814e5ffe7129d9b8a2b362ce1aa43
TheLostLight/CPSC450_Project
/src/TwoJump.py
2,254
3.609375
4
class TwoJump: index_to_char_map = {0: 'a', 1: 'c', 2: 'g', 3: 't'} char_to_index_map = {i: j for j, i in index_to_char_map.items()} # reversed char dictionary def __init__(self, input_data): self.input_data = input_data def gen_index_table(self): index_table = [[] for i in range(4)] #...
26325bf0be61983ff45a3d995c85405fac3f2deb
15929134544/wangwang
/day5/29 数组中出现次数超过一半的数字.py
1,092
3.53125
4
""" 数组中有一个数字出现的次数超过数组长度的一半, 请找出这个数字。例如输入一个长度为9的数组{1,2,3,2,2,2,5,4,2}。 由于数字2在数组中出现了5次,超过数组长度的一半,因此输出2。如果不存在则输出0。 """ class Solution: """第二种,假设有这个数字,那么它的数量一定比其它所有数字之和还要多,按照这个思路得出num,然后验证 """ def MoreThanHalfNum_Solution(self, numbers): # write code here if not numbers: return 0 ...
6822514a01e63aa3670609972dcbd7404b4c21b4
jungker/leetcode-python
/permutation_sequence.py
691
3.578125
4
class Solution(object): def getPermutation(self, n, k): """ :type n: int :type k: int :rtype: str """ x = range(1, n + 1) k -= 1 res = [] f = self.factorial(n - 1) for i in range(n - 1, 0, -1): j = k / f res.appe...
8a87c16a91e7c26e8e0558204f334d9ec3b6fce3
yosepjeon/python-nadocoding
/문자열/string.py
839
4.28125
4
sentence = '나는 소년입니다' print(sentence) sentence2 = '파이썬은 쉬워요' print(sentence2) sentence3 = """ 나는 소년이고, 파이썬은 쉬워요 """ print(sentence3) print('###### slicing #######') jumin = "990120-1234567" print('성별: ' + jumin[7]) print('연: ' + jumin[0:2]) # 0부터 2 직전까지 (0,1) print("월: " + jumin[2:4]) print("일 " + jumin[4:6]) print(...
3b025258969e6268587dec088773c804888f9b1f
MellanoMatteo/Sistemi
/es_python/es_vacanze_python/es_1.py
1,134
3.859375
4
#Scrivi una funzione generatrice di password. La funzione deve generare una stringa #alfanumerica di 8 caratteri qualora l'utente voglia una password semplice, #o di 20 caratteri ascii qualora desideri una password più complicata. import random, string def generaPassword(lenght): #creo la variabile di no...
8e03147b972e7d5a636ef08509d00a43608dbc29
JessicaParrado/EjerciciosPython
/Ejercicio3/main.py
467
3.71875
4
def conocerCaracter(palabra): primeraLetra = palabra[0] longitud = len(palabra) ultimaLetra = palabra[longitud-1] print("La primera letra es ", primeraLetra, " y la última letra es ",ultimaLetra) return primeraLetra+ultimaLetra; def main(): print("Binevenido, con este programa podrá concocer el ...
6e1bd9c330852ba56fa3c24a9f602d3c8df502b4
Vishvesh-rao/Cipher-Lib
/caesers.py
867
3.9375
4
import string def Caesers(message,key,mode): result = '' message=message.upper() letter=string.ascii_uppercase for i in message: counter=letter.find(i) if mode=="encrypt": counter+=key if mode=="decrypt": counter-=key if count...
a6fc149bf9060507cbfddbb958cb73db8472ff23
rachel2011/Job
/DataStructure/HashTable/SeparateChaining.py
942
4.25
4
""" The idea is to make each cell of hash table point to a linked list of records that have same hash function value """ """ Advantages: 1) Simple to implement. 2) Hash table never fills up, we can always add more elements to chain. 3) Less sensitive to the hash function or load factors. 4) It is mostly used when it is...
3d4b75966d8a585365e8297c3d2dcce6e7da1f16
reedless/dailyinterviewpro_answers
/2019_08/daily_question_20190814.py
703
3.921875
4
''' Given an undirected graph, determine if a cycle exists in the graph. Can you solve this in linear time, linear space? ''' def find_cycle_helper(graph, reached): if (graph == {}): return False result = False for key in graph.keys(): if (key in reached): return True...
444cb83aa816daac84262fdb2f0bacaa04574a71
mrmoss/lawl.org
/directory_service/employees.py
3,694
3.515625
4
#!/usr/bin/env python2 import hashlib import json departments=[ ('MG',49,'Management'), ('HR',55,'Human Resources'), ('AC',33,'Accounting'), ('JA',40,'Janitorial'), ('SC',51,'Security'), ('IT',58,'Information Technology')] class department_t: def __init__(self,data=None): global departments self.initials='...
7e159551f94d38b289b4ef6cc68915addf10ee9d
nire2320/myCode
/myPython/soln09_randGame.py
334
3.953125
4
import random guess = random.randint(1,9) user = input("Guess the number! [0-9] : ") guess_num = 0 while guess != int(user) : if guess < int(user) : user = input("Too High! Guess again : ") else : user = input("Too Low! Guess again : ") guess_num += 1 print("You got it in " + str(guess_num) + " Guess(es)! :: ...
1bfd7add392c6dd67588432234008ba23d1bb135
Meghashrestha/pythonassignment02
/15.py
1,358
4.46875
4
# 15. Imagine you are designing a banking application. # What would a customer look like? # What attributes would she have? What methods would she have? def checkBalance(): print("Balance: ",balance) def deposit(balance): deposit_amt = int(input("Enter amount to be deposited: ")) balance = balance + deposi...
3d703dca89956df3fcb9a4049c465aa6e3f3a790
danieltrut/alused
/3/ylesanne 2.py
469
3.90625
4
#kasutaja sisend ringide_arv = int(input("Sisestage ringide arv: ")) ring_nr = 1 porgandi_arv = 0 #arvutused while(ring_nr <= ringide_arv): print(ring_nr) if(ring_nr % 2 == 0): # arvutused 2 porgandi_arv = porgandi_arv + ring_nr # valjastus print("said " + str(ring_nr) + " porgan...
f5700476f5da97235749379b039b6d2a05053d27
Kennexcorp/Algorithms-DataStructure
/others/resturant.py
519
3.6875
4
class Restaurant : def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type def open_restaurant(self) : print("We are open for trades") def describe_restaurant(self): print(f"Welcome to {self.resta...
ce467bd5a1ced9db635dc0a25153e17c6739cdca
eda3/math_training
/sigmoid_function.py
260
3.546875
4
import math import matplotlib.pyplot as plt import numpy as np def sigmoid(a): s = 1 / (1 + e ** -a) return s e = math.e dx = 0.1 x = np.arange(-8, 8, dx) # y = 1 / (1 + e^(-x)) y_sig = sigmoid(x) plt.plot(x, y_sig) plt.show()
96cccb56511fa99ee43e1ce21b55563d67346ea9
hyoseok-bang/leetcode
/no104.py
517
3.9375
4
# https://leetcode.com/problems/maximum-depth-of-binary-tree/ def maxDepth(self, root): """ :type root: TreeNode :rtype: int """ if root is None: return 0 queue = collections.deque([root]) depth = 0 while queue: depth += 1 for _ in range(len(queue)): ...
613d55ae8d7ddfcf0b32f209fd67fab2ac06b035
dujiaojingyu/Personal-programming-exercises
/编程/8月/8.4/Insert_Sort.py
823
3.859375
4
__author__ = "Narwhale" def insert_sort(alist): """插入排序""" n = len(alist) for j in range(1,n): for i in range(j,0,-1): if alist[i] < alist[i-1]: alist[i],alist[i-1] = alist[i-1],alist[i] else: break #j=1 i=0 #j=2 i=1,0 #j=3 i=2-0 #j=4 i=3-0 ...
754e4ce4c44e2eddc8cf8a8007bbc161795b87d9
ashokbezawada/Data-Structures
/tree/balanced_binary_tree.py
826
4.0625
4
# The main goal of this function is to check whether the tree is balanced or not # The function takes argument as root and boolean value isbalanced class Node: def __init__(self,data): self.data = data self.left = None self.right = None def check_balance(root,isbalance = True): if root...
47b24930dfb1de6f2074a5518343d9b76d8ce2ff
yoyeee/guess-number
/guess-number.py
536
3.796875
4
import random print('這是一個猜數字的遊戲') start = input('請輸入最小值:') end = input('請輸入最大值:') start = int(start) end = int(end) r = random.randint(start, end) count = 0 while True: number = input('遊戲開始,請輸入數字:') number = int(number) count = count + 1 if number == r: print('恭喜正確') print('這是你猜的第', count, '次') break elif...
845335d7ca3a132af1440bff33faf4672976afd1
At1aNt7/Python_1_lessons
/lesson_04/home_work/hw04_easy.py
1,674
4.21875
4
# Все задачи текущего блока решите с помощью генераторов списков! # Задание-1: # Дан список, заполненный произвольными целыми числами. # Получить новый список, элементы которого будут # квадратами элементов исходного списка # [0, 1, 2, 3] --> [0, 1, 4, 9] """ list = [1, 2, 4, 0] list_2 = list list_2 = [item ** 2 for ...
66af82e1f682d21fcdca8d5043c2a116e068928c
SRzhangbob/React-nativedemo
/src/screens/answer.py
5,637
4.46875
4
#!usr/bin/python # conding:utf-8 """ """ def fizzbuzz(lst): """ The Problem is go through all numbers in input list. If the number divisible by three is replaced by the word 'fizz' and any divisible by five by the word 'buzz'. Numbers divisible by both become 'fizzbuzz'. Example ------- ...
b10972e119fc825149a82644c28d47ff0fba8200
keio-ytlab/researchutils
/researchutils/chainer/iterators/unmodifiable_decorable_list.py
2,181
3.75
4
from builtins import range class UnmodifiableDecorableList(list): """ Unmodifiable list which can decorate items in the list by providing decor_fun Parameters ------- items : iterable items of the list decor_fun : callable or None function to apply everytime __getitem__ is cal...
b4a84bfdad9f2c27f7b44fdb7c0b7d76a771a6ea
Ashmianuroop/Python
/python18.py
195
4
4
s = 0 temp = a while temp > 0: digit = temp % 10 sum += digit ** 3 temp //= 10 if a == s: print(num,"is an Armstrong number") else: print(num,"is not an Armstrong number")
7beb0a56beaaf70445c9876568a68da2e6385bf3
Kings42/HelloWorld
/Hola.py
291
3.84375
4
print"Hola" var = int (raw_input("Ingrese un numero: ")) var1 = int (raw_input("Ingrese un numero: ")) if var1 != 0: print var / var1 print "Suma:", var + var1 print "Resta:", var - var1 print "Multiplicacion:", var * var1 print "Residuo:", var % var1
c698040822bc3cdec690b166ad4a930bba3207bf
Dennysro/Python_DROP
/10.0_Utilizando_Lambdas.py
1,720
4.875
5
""" Utilizando Lambdas Conhecidas por expressões Lambdas ou simplesmente lambdas, são funções sem nome. Ou seja, anônimas. #Função em Python: def soma(a, b): return a+b def funcao(x): return 3 * x + 1 print(funcao(4)) """ # Expressão Lambda lambda x: 3 * x + 1 # E como utilizar ...
249e5f924d4b8e8173942c0471f1dfb44ba0f923
cponeill/earsketch_code
/drumLoop.py
548
3.890625
4
# Here is some sample code for creating a drum loop # The first code is written as if there were no loop at all from earsketch import * init() tempo(140) beat = "0-00-00-0+++0+0+" drum = BIG_BEAT_DRUM_001 makeBeat(drum, 1, 1, beat) makeBeat(drum, 1, 2, beat) makeBeat(drum, 1, 3, beat) finish() # This code is w...
a7637530af113314db1dc73c48b3b506583ba202
ebergstein/DojoAssignments
/Python/Python_Fundamentals/Grades/grades.py
349
4.03125
4
import random def grades(): print "Score and Grades" for i in range(0, 10): grade = random.randint(60, 100) letter = "" if grade >= 90: letter = "A" elif grade >= 80: letter = "B" elif grade >= 70: letter = "C" else: letter = "D" print "Score: ", grade, "; Your grade is ", letter print "The...