blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
d5297e6171ea9e92e6ba880a5b14f3d3c171bc90
shanroy1999/Miscellaneous
/Currency-Converter.py
959
3.640625
4
with open(r"C:\Users\Lenovo\Desktop\New folder\python\Small Projects\Currency.txt") as f: lines = f.readlines() print(lines) curr_dict = {} for line in lines: split = line.split("\t") curr_dict[split[0]] = split[1] print(curr_dict) amount = int(input("Enter the amount: ")) print("Enter Conversion...
ced9e02afe5595046dd60e1a6f085d07a7206b40
bsdworkin/Regression
/SimpleLinearRegression/slr.py
1,104
4.03125
4
#Simple Linear Regression import numpy as np import matplotlib.pyplot as plt import pandas as pd dataSet = pd.read_csv('Salary_Data.csv') #The colon means we take all the lines X = dataSet.iloc[:,:-1].values y = dataSet.iloc[:, 1].values #Splitting to test and training set from sklearn.cross_validation import train_...
538da5198b5fcf1f6ef17569fb5b8f0e869216ae
MrZebarth/PythonCheatSheet2019
/Loops.py
782
4.375
4
# Loops # Repeat code using a condition (while loop) password = "" while password != "Irish": password = input("Enter your password: ") # any of the conditions in the "conditionals.py" file will work here # Repeat code over a range (for loop) # We can repeat starting at 0, stopping before a value ...
8118ded6c60484d14b114646b736c8ff145c9fe4
OpenMined/PyStatDP
/pystatdp/utils.py
1,771
3.578125
4
from collections import deque from logging import getLogger, basicConfig, INFO logger = getLogger(__name__) basicConfig(level=INFO) def arr_n_check(privacy, test_range, n_checks): """ returns the test_privacy tuple seek for it to be symmetrical, therefore, equal number of observations on eithe...
88fff08f162268e757a765355cc03b6a9509f02c
felipmarqs/exerciciospythonbrasil
/exercicios/EstruturaSequencial/peso_ideal_homem_mulher.py
359
3.875
4
#Tendo como dado de entrada a altura (h) de uma pessoa, construa um algoritmo que calcule seu peso ideal, utilizando as seguintes fórmulas: h = float(input("Qual sua altura ?")) s = str(input("Você é homem ou mulher ? [H/M]?")).lower() if s == 'h': pi=(72.7 * h) - 58 elif s == 'm': pi = (62.1*h) - 44.7 p...
beb6441f70f9081ae7c02e2fc48de69477f4c489
Mirkics/probazarovizsga2
/testproject/guess_the_number.py
2,706
3.578125
4
'''3 Feladat: Guess the number automatizálása Készíts egy Python python applikációt (egy darab python file) ami selenium-ot használ. A program töltse be a Guess the number app-ot az https://witty-hill-0acfceb03.azurestaticapps.net/guess_the_number.html oldalról. Feladatod, hogy automatizáld selenium webdriverrel az app...
39d1a6f82194e1e2702c7a1e2f37d5a5d1ce5991
oirk/school
/progam 4 m.py
2,370
4.03125
4
import math def deflatlong(lat1,long1,lat2,long2): deltaLong = math.radians(long2) - math.radians(long1) deltaLat = math.radians(lat2) - math.radians(lat1) a = (math.sin((deltaLat/2))**2) + (math.cos(math.radians(lat1))) * (math.cos(math.radians(lat2))) * (math.sin((deltaLong/...
af6e378801755d6b72d20be32dc516cf3867e95b
garciacello/Python-Exercises
/módulos.py
443
4
4
#FUNCOES DA BIBLIOTECA MATH # ceil = > arredonda pra cima # floor => arredonda pra baixo # trunc => tira as casas decimais em excesso # pow => potencia # sqrt = >raiz quadrada # factorial => fatorial #import math => Importa toda a biblioteca # from math import sqrt => importo apenas uma funcao from math import sqrt,fl...
5824918ea189497767632c3b4e489153300202f8
hemantghuge/HackerRank
/Algorithms/Implementation/12 - Counting Valleys.py
651
3.578125
4
#!/bin/python3 import math import os import random import re import sys # Complete the countingValleys function below. def countingValleys(n, s): list_s = list(s) count = 0 count_prev = 0 valley = 0 for l in list_s: if l == 'D': count -=1 elif l == 'U': coun...
20e1f6800469b28764157ff50c4dbfa974df4dba
deepcpatel/data_structures_and_algorithms
/Graph/satisfiability_of_equality_equations.py
1,354
4.03125
4
# Link: https://leetcode.com/problems/satisfiability-of-equality-equations/ # Approach: Union Find. Firts iterate all the equations having '==' operation. Union both the LHS and RHS symbol to connect to a common parent. Now, iterate through all the equations having '!=' # operator. For each LHS and RHS, find their pae...
9aacd55956076d1a3151c66a40d17e31243d3a47
nivipandey/python
/exception_handling/e4.py
118
3.65625
4
a=5 b=0 print("exception demo") try: c=a/b print(c) except: print("zero division error") finally: d=a+b print(d)
af39852d0bd6afc2dd61eda2215c4b8e8ccff7fb
habibabdo/firstpython
/Functions.py
489
3.6875
4
def person(name,age=12): print(name) print(age) def mathimatics(x,y): a=x+y b=x-y c=x*y d=x/y return a,b,c,d def sum(*b): c=0 for i in b: c = c + i print(c) def person1(name, **data): print(name) for i,j in data.items(): print(i,j) resul1,result2,re...
720be6194cf012100c54e20866955656db8d4db0
Lekuro/python_core
/CodeWars5/3_name_start_R_r.py
669
4.3125
4
# Create a function which answers the question "Are you playing banjo?". # If your name starts with the letter "R" or lower case "r", you are playing banjo! # The function takes a name as its only argument, and returns one of the following strings: # name + " plays banjo" # name + " does not play banjo" # Names given...
25627f2bf4831a58400d43ce8f94623864edc154
Zahidsqldba07/codingbat-programming-problems-python
/Solutions/list-2/centered_average.py
809
4.21875
4
# Return the "centered" average of an array of ints, which we'll # say is the mean average of the values, except ignoring the largest # and smallest values in the array. If there are multiple copies of # the smallest value, ignore just one copy, and likewise for the # largest value. Use int division to produce the fina...
41e624c7f005c15f6bcbb0ff0bb5108d6ca1b8cf
mjkushman/automate-stuff
/mapIt.py
563
3.640625
4
#! python3 #mapIt.py - Launches a map in the browser using an address from the # command line or clipboard. import webbrowser, sys, pyperclip if len(sys.argv) > 1: # Get address from command line. address = ' '.join(sys.argv[1:]) else: #Get address from clipboard address = pyperclip.paste() webbrows...
1a1fe52a2c7b3b6c2790a09fff00a1906328e214
makrandp/python-practice
/Other/Companies/Amazon/AmazonBlind/SubtreeWithMaximumAverage.py
2,740
4
4
''' Given a tree, find the subtree with the maximum average. Return the root of the subtree. A subtree of a tree is any node of that tree plus all its descendants. The average value of a subtree is the sum of its values, divided by the number of nodes. Examples Example 1: Input: Output: 13 Example 2: Input: Outpu...
a2bb75a06fc80ba6b2ab34dc5e6554618876624d
rehmanalira/Python-Programming
/28 JOin Func.py
349
4.40625
4
""" JOIn function: it is used for example if we have list and we write all names and then we want to add a word in it so we simply can add this by writing "word".join(list) """ list=["Rehman","ALi","Ehsan","Rizwan","Tayyab","jutt"] #for item in list: # print(item,end=" ") by this we get the names l=" ...
b0ddb26ae094f4ba0631c14306c66c35ecbc7946
Ajit171098/python-lab
/3(a).py
179
3.9375
4
n=int(input("Enter the number:")) list1=[] for i in range(1,n+1): if n%i==0: list1.append(i) print("the possiblr divisors of {} are {}".format(n,list1))
36fd599cedf0d524a1f205deedcff9627d476397
SnoopySYF/leetcode
/leetcode_814.py
1,018
3.875
4
class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def pruneTree(self, root): """ :type root: TreeNode :rtype: TreeNode """ if(not root): return None self.chec...
300731285be9017a267e816ab156b6840104daa9
AT538/Python-Programs
/9.py
819
3.859375
4
m=[[1,2],[3,4]] n=[[5,6],[7,8]] def add(m,n): print("Sum is") for i in range(len(m)): print() for j in range(len(m[0])): print(m[i][j]+n[i][j],end=" ") def sub(m,n): print("\n Difference is") for i in range(len(m)): print() for j in range(len...
52e6da5338713a17e2b57c00e85f1677cccfa3d5
MeatballNissan/py
/untitled/day06/dog.py
1,262
3.625
4
__author__ = "bxd" class Dog: def __init__(self, name): self.name = name def bulk(self): print(" %s :wang wang wang" % self.name) d1 = Dog("bxd1") d2 = Dog("bxd2") d3 = Dog("bxd3") d1.bulk() d2.bulk() d3.bulk() roles = { 1:{},2:{} } class Role(): n = 123 # 类变量 def __init__(s...
5e7ebd0f7e608de5bfaea14e3d3ecf103cc0b640
Niranjana55/Array-Programs
/2prg.py
281
4.09375
4
#2.Given an unsorted integer array A and an integer value X, # find if A contains the value X. def unsorted(A,x): for i in A: if i==x: return True else: return False A=[2,3,5,7,8,9] x=int(input("enter the num:")) print (unsorted(A,x))
683f57699579618a048cdd4f6e4e948811d6a125
Vicuko/100DaysOfCode
/Day20-21/SnakeGame/snake.py
1,893
4.09375
4
import turtle as t class Snake: def __init__(self, initial_size = 3, body_size = 20, body_shape = "square", color = "white"): self.body = [] self.init_size = initial_size self.body_size = body_size self.body_shape = body_shape self.snake_color = color self.create_sna...
76b271670264e42e982f9daa12dc04b4d366daa9
sammienjihia/dataStractures
/Strings/stringPermutation.py
1,258
3.921875
4
class Permutation: def __init__(self): self.mySet = set() def swap(self, myString, left, index): # NB: String are imutable, meaning you'll have to change it to an array, perform the swap then change it back to a string stringAsList = list(myString) # swap the characters in the ...
13692915a1c5f25407a17b0dcfc958772f6cdacc
OksanichenkoFedor/Order-of-the-flame
/LevelParts/Map.py
6,036
3.984375
4
from math import sqrt class Map: """ Class of level Map :field x: First coordinate of left up corner of map :field y: Second coordinate of left up corner of map :field width: Width of picture of map :field height: Height of picture of map :field number_of_left_roads: Number of left roads ...
a5fe435935e00a32db6d6a0868e2ad4742876f0a
PK1NONLY/python
/5Ifelse.py
303
4.28125
4
name = "parshant" if name is "raj": print (name) elif name is "rahul": print (name) elif name is "Pkay": print(name) else: print "please sign up to the website" # you can try this also age = 27 # age = 13 if age < 21: print("No! you can't vote!") else: print " you can vote!"
034302f51d82d58dd3b01940a1ec86d30d6a4de5
TangBean/AdvancePython
/chapter11/python_thread.py
1,159
3.734375
4
# 对于 IO 操作,多线程和多进程的差距不大 import threading import time # 实现多线程的方法 # 1. 通过 Thread 类实例化 def get_detail_html(url): print("get detail html started") time.sleep(2) print("get detail html end") def get_detail_url(url): print("get detail url started") time.sleep(4) print("get detail url end") # 2....
4674375fe2a38fd76ff83632aceca5e8854c13f7
rathinitish29/Python
/check_emptyor_not.py
151
4.125
4
#check empty or not name = input('Eneter your name :') if name: print(f'your name is {name}') else : print('you didn\'t enter anything')
cdc2be5bb77e26ac52d0ca2dc565d66e3afa6442
markdrago/caboose
/src/repo/date_iterator.py
450
3.546875
4
from datetime import timedelta class DateIterator(object): def __init__(self, start, end, delta=timedelta(days=30)): self.start = start self.end = end self.delta = delta self.current = start def __iter__(self): return self def next(self): if self.current > ...
0cc50ea2a9a700bc8996a9df41224ca1c2eaf993
hasnasaal/Basic-Python
/Soal 1 (Tugas 2).py
912
3.984375
4
print("Selamat Datang!") #menu def fungsiMenu(): print(''' --- Menu --- 1. Daftar Kontak 2. Tambah Kontak 3. Keluar''') menu = (int(input("Pilih menu: "))) while menu != 3: while menu == 2: menudua() while menu == 1: menusatu() ...
48ea7c35cd4a93694836db5d88b480d818ea3da5
bharadwajpro/food-recommender-bot
/services/foods.py
627
3.859375
4
import sys foods = { 'samosa': ['C3'], 'sandwich': ['Yummpys', 'C3', 'Bits & Bytes', 'ANC 1', 'ANC 2'], 'rice': ['ANC 1', 'ANC 2', 'Mess 1', 'Mess 2'], 'noodles': ['Yummpys', 'ANC 1', 'ANC 2'], 'paratha': ['Mess 1', 'Mess 2', 'C3'] } if len(sys.argv) == 2: for food in foods: if food == ...
de1cdd7c24ce9e56af7baaf562ad915960eb246d
AusCommsteam/Algorithm-and-Data-Structures-and-Coding-Challenges
/Challenges/uniquePaths.py
1,433
4.15625
4
""" Unique Paths A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). How many possible unique paths ...
371fc70d5c5e21a2dd95f777535db187ce1ec949
jaioo7/python
/aag.py
574
3.828125
4
# Python Tupnle Methods tp=(5,8,9,69, 'jai',5.9) tp1=(5,7,8,9,3,1,4,5,6,8) # Iteration for t in tp: print(t) # Tuple Indexing & Tuple Slicing ([]) print(tp[0]) print(tp[-1]) print(tp[0:4]) # Tuple lengh, Maximum,minumum print(len(tp)) print(max(tp1)) print(min(tp1)) # Repetition (*) print(tp*3) # Concatenation...
5a264798ae57f511b82b72776c4f7d5bca453196
RajeshA76/EdyodaPracticeArena
/Dictionary/Student_Record.py
2,284
4.125
4
""" Given n names and phone numbers, assemble a students record that maps student's names to their respective phone numbers. You will then be given an unknown number of names to query your phone book for. For each name queried, print the associated entry from your phone book on a new line in the form name=phoneNumber; ...
47e49757962bc312ee052bcae6e00f9ca0046d04
AntonioPelayo/leetcode
/all/387-first-unique-character-in-string.py
758
3.828125
4
''' Antonio Pelayo April 2, 2020 Problem: 387. First Unique Character in a String Difficulty: Easy Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" return 0. s = "loveleetcode", return 2. Note: You may assume the string con...
f6e4581494ebc2540a6880e0df199ec85d0f0c3f
ahmedyoko/python-course-Elzero
/DB_insert_data79.py
1,821
3.625
4
# insert data into db #............................................................ # cursor => all operation in sql done by cursor not by the connection itself # commit => save all changes #............................................................ # import sqlite module # import sqlite3 # # create db and connect ...
09292f64408b201dddfb8c1341880653da9de0f9
freedomDR/coding
/codeforces/1101B.py
590
3.734375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- s = input() ans = -1 left = 0 right = len(s) - 1 lok = 1 while left < len(s): if s[left] == '[': lok = 2 left += 1 elif s[left] == ':' and lok == 2: break else: left += 1 rok = 1 while right >= 0: if s[right] == ']': ...
d24489dff97599fed289230cabc0290a609655d2
rafaelperazzo/programacao-web
/moodledata/vpl_data/330/usersdata/299/93537/submittedfiles/lista1.py
451
3.5625
4
# -*- coding: utf-8 -*- n_valores=int(input('Digite quantos valores sua lista terá: ')) l=[] contpar=0 contimpar=0 somapar=0 somaimpar=0 for i in range(0,n_valores,1): l.append(int(input('Digite o valor %d: ' %(i+1)))) for i in range(0,n_valores,1): if l[i]%2==0: contpar+=1 somapar+=l[i] el...
9aaec35c7d6b8da75144c6b513f849c7fc495548
dmurawski/python
/26kwietnia/9.py
451
3.828125
4
def Upper(wyraz): for index in range(len(wyraz)): yield wyraz[index].upper() generator = Upper("Hello World") print(next(generator)) print(next(generator)) print("costam123") print(next(generator)) print(next(generator)) print("costam123") print(next(generator)) print(next(generator)) print(next(generator)...
5ffd285c0a7f08b21aec8dca00f4dd10a31de1fa
JeromeLefebvre/ProjectEuler
/Python/Problem057.py
1,082
4.40625
4
#!/usr/local/bin/python3.3 ''' It is possible to show that the square root of two can be expressed as an infinite continued fraction. √ 2 = 1 + 1/(2 + 1/(2 + 1/(2 + ... ))) = 1.414213... By expanding this for the first four iterations, we get: 1 + 1/2 = 3/2 = 1.5 1 + 1/(2 + 1/2) = 7/5 = 1.4 1 + 1/(2 + 1/(2 + 1/2)) ...
1a49ee2acfd1b2d010ac0236499a637f2207cd15
akfunes/studyProblems
/diameter_of_binary_tree.py
691
3.90625
4
# https://leetcode.com/problems/diameter-of-binary-tree/ # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def __init__(self): self.s = 0 def helper(self,node): if not...
516fefd701102458050fae4e839ce89a5f736cfa
homawccc/PythonPracticeFiles
/2x3.py
239
3.78125
4
x=2 y=3 z=x*y teams = ["Pirates","Phillies","Expos", "Mets", "Cubs", "Cardinals"] for i in teams: print(i) print("Hello Git") #new comment from GitHub #new comment from GitHub Windows Version #new comment from GitHub Lab 226
d33c25e54bea555c6e8ecb5e8897246bd74eb5d5
larners/ACA_HW
/homework2/digit_product.py
175
3.921875
4
def digit_product(n): res = 1 while(n) : if( n % 10 ) : res *= n % 10 n //= 10 return res n = int(input()) print(digit_product( n ))
5aabdc6e0e839ba00770e0b61b475aa72bdea5bb
Peett2/infoshare
/day_6/scopes.py
272
4.03125
4
name = 'Ola' def hello(username): ''' Returns uppercased username\n :param username: string\n :return: str.upper() ''' name = username.upper() return name data = input('Podaj imie:\n') uppercased = hello(data) print(uppercased) print(name)
648969571c611e38839d072ee20a03371da2b38b
duoduo3369/exercise
/algorithm/fibonacci/fibonacci.py
1,097
3.90625
4
# coding=UTF8 def fibonacci(n): """树形递归""" if n is 0: return 0 if n is 1: return 1 return fibonacci(n-1) + fibonacci(n-2) def fib_line(n): def fib_iter(a,b,count): if count is 0: return b else: return fib_iter(b,a+b,count-1) ...
372004aa3fd1c9bade120a862cebc657b538fa12
wassm/Gltps
/VectorHelper.py
3,080
4.28125
4
import math as math class VectorHelper: """A class that handle vectors handle a vector presented in a list contain functions that: sort a vector. add two vectors. return its minimum and maximum. reverse a vector. apply a function on the elements of a vector. """ @staticmet...
ea8ba7623b25bda8f17d34e0cb49a4e7fe230f44
abenetsol/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/8-uppercase.py
218
3.9375
4
#!/usr/bin/python3 def uppercase(str): strig = "" for i in str: if (ord(i) in range(97, 123)): strig += chr(ord(i) - 32) else: strig += i print("{:s}".format(strig))
c572ec5246fd786379aae2e8debd7bb037967991
crystalapril/python-notes-april
/exercise-filter.py
775
4.21875
4
''' 前两题来自于codewars 1.筛选出不包含在geese列表中的值 2.筛选出偶数 第三题是构造filter函数 ''' #1.Filter out the geese.py #A1.1 def goose_filter(birds): a=[] for x in birds: if x not in geese: a.append(x) return a #A1.2 def goose_filter(birds): return list(filter(lambda x:x not in geese,birds)) #2.Find numbe...
af7adf16f9ab6bf84080e38a8a9c9d23c46299b8
ksompura/python_training
/guessing_game/guess_game.py
1,057
4.21875
4
import random # play = "y" # while play == "y": # rand_num = random.randint(1,10) #randint is inclusive and numbers are from 1-10 # intro = int(input("Guess a number between 1-10: ")) # while intro != rand_num: # if intro > rand_num: # intro = int(input("Too high, keep gussing: ")) # elif intro < rand_num...
441734b46c071d56e427bf50137bafb3dc3afc3c
psujug/Leetcode
/3_sum.py
1,661
3.5625
4
''' 给定一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?找出所有满足条件且不重复的三元组。 注意:答案中不可以包含重复的三元组。 例如, 给定数组 nums = [-1, 0, 1, 2, -1, -4], 满足要求的三元组集合为: [ [-1, 0, 1], [-1, -1, 2] ] ''' from typing import List class Solution: def threeSum(self, nums: List[int]) -> List[List[int]]: res = [] ...
278720ddf3447fa4c2645767637f566a6b5bbcf9
khalidsalata/py_practice
/vector.py
7,265
3.984375
4
from misc import Failure #Class implementing a fixed-length vector class Vector(object): #Constructor for a vector. Size can either describe the size of the #vector object, or the elements you wish to see in the Vector. def __init__(self,size): if isinstance(size, list): self.vec = size...
484408d5afa0fcab725c4edb35dce3185d269a51
IaroslavaDubitkaia/07.10.2020
/Problema_4.py
110
3.640625
4
a=int(input('Numarul de globulete albe:')) r=a+3 n=(a+3)-2 print("Bradul are in total", a+r+n, "globulete")
db13f3cd70a12b17793ef202a0c8f4b0303b02b6
SKosztolanyi/Python-exercises
/78_Creating Spell class and sublass.py
1,331
4.375
4
## Creating an object and a subclass of the object + function that calls the method of parent object, that is a superclass. class Spell(object): def __init__(self, incantation, name): self.name = name self.incantation = incantation def __str__(self): return self.name + ' ' + self.incan...
d280009ef531e6b75291d1de5fd547151714a5e3
vimalanignatius/unsorted-array
/get_index.py
374
4.03125
4
#3. Given an unsorted integer array A and an integer value X, # return the index at which X is located in A or return -1 if it is not found in A. def count(a,x): index=-1 count=0 for i in a: if(i==x): index=count break count+=1 return index a=[2,3,4,5,7,7] x...
8a93fe32bcfa87f5ef795ce2c8ac14d5927d59fe
Anusha260/dictionary
/.vscode/saral14.py
263
3.984375
4
word _dict={'bijender':45,'deepak':60,'param':20,';'anu':30,'roshini':50} sorted_dict = dict( sorted(word_dict.items(), key=lambda item: item[1], reverse=True)) print('Sorted Dictionary: ') print(sorted_dict)
ffa4eaabf64a3c933b7055fe407a04dac88ccd4a
yejinee/Algorithm
/Algorithm Concept/Fractional_knapsack.py
1,587
3.75
4
""" [ Fractional Knapsack ] n개의 물건과 1개의 배낭이 있다 물건 i의 무게는 W(i), 값어치는 P(i), 배낭용량은 M까지 가능 이윤이 최대가 되도록 물건을 담는 방법? (물건을 잘라서 담을 수 있다) [ solution ] - Greedy Algorithm을 사용 < Fractional Knapsack Function > 1. 무게 당 값어치가 큰 물건순서대로 정렬해준다 -> Sortitem 2. list의 앞에서 차례로 가방에 담을 수 있는 물건들을 담아준다 -> 즉, M-item의 무게가 0보다 크면 계속해서 반복 ...
b9f0710057cfee0caac55d262dbbf00a6dc84629
brunogh88/Teste-Python
/src/utils/timer.py
679
3.984375
4
"""This module contains the Timer class""" import time class Timer(object): """Timer class""" def __init__(self): self.start_time = None self.end_time = None self.duration = None def start(self): """Start timer""" self.start_time = time.time() def end(self): ...
09ee91d49b39df4aeddeae0109781a8bcf85360e
Mahmoud-Shosha/Fundamentals-of-Computing-Specialization-Coursera
/Principles of Computing (Part 1)/Week 2 - Testing, plotting, and grids/plotting2.py
1,458
4.625
5
""" Example of creating a plot using simpleplot Input is a list of point lists (one per function) Each point list is a list of points of the form [(x0, y0), (x1, y1, ..., (xn, yn)] """ import matplotlib.pyplot as plt # create three sample functions def double(num): """ Example of linear function """ ...
e91bb582041f3d98eeba01a3eca4039d55cdfc27
Tevitt-Sai-Majji/fun-coding-
/Abundant number.py
114
3.671875
4
n=int(input()) a=0 for i in range(1,int(n/2+1)): if n%i==0: a=a+i if a>=n: print("Abundant Number")
fae1122d0b5f4a9ffb8fa954f66a55205333f6b2
Waldij/py-programs
/test_tasks/tetrika/task_1.py
1,128
3.734375
4
""" Дан массив чисел, состоящий из некоторого количества подряд идущих единиц, за которыми следует какое-то количество подряд идущих нулей: 111111111111111111111111100000000. Найти индекс первого нуля (то есть найти такое место, где заканчиваются единицы, и начинаются нули) print(task("111111111111111111111111100000000...
d5ee5a2eb7879ff8fe2fb8e684f4ab098fd228be
ArunDruk/Repo1_python_basic_pgms
/Anonymous_Lambda.py
1,804
4.3125
4
# # lambda argument_list : expression # n=int(input("Enter a num: ")) # s=lambda n:n*n # print(f'Square of {n} is:', s(n)) #filter(function,sequence) #We can use filter() function to filter values from the given sequence based on some condition. #Filter function will only return the value for the function which is TRU...
754f6b0587541bffa9b5fbcb792cca1251bcf1a0
piskunovma/logic_python
/lesson6/task_1.py
5,172
3.640625
4
# Подсчитать, сколько было выделено памяти под переменные # в ранее разработанных программах в рамках первых трех уроков. # Проанализировать результат и определить программы # с наиболее эффективным использованием памяти. import sys # macOS Catalina 10.15.4, 64-разрядная. Версия интерпретатора - Python 3.7 # Функци...
a8439d0e1af3b77cdeade3c23e91d2987d5680ba
kiranmah92/Pattern-matching
/pattern_matching.py
5,083
3.59375
4
import pandas as pd from matplotlib import pyplot as plt import numpy as np from datetime import datetime as dt from matrixprofile import * class Matrix_profile: def __init__(self): pass def get_date(self , df): max_ = df['temp'].max() min_ = df['temp'].min() print("max = " , m...
7959789e8c04c980a63eb1ef1cbf0ddbcd78e508
ckallum/Daily-Coding-Problem
/solutions/#163.py
672
3.890625
4
def reverse_polish(equation): num_stack = list() operations = {"*": lambda x, y: x * y, "/": lambda x, y: x / y, "-": lambda x, y: x - y, "+": lambda x, y: x + y} for char in equation: if char in operations: if len(num_stack) < 2: ...
2471c93f83fb7c0e5567897c4b3df7602a50a231
kdung109/OpenSource_Class
/7주차 6번.py
269
3.59375
4
import math d = [1, 2, 3, 4, 5] print("총점은? :",sum(d)) mean = sum(d) / len(d) print("평균은? :",mean) vsum = 0 for x in d: vsum = vsum + (x - mean) ** 2 var = vsum / len(d) print("분산은? :",var) std = math.sqrt(var) print("표준편차는? :",std)
5fb42551f78c852b27903f5853cae21f2683059f
AndrewKalil/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/models/base.py
3,528
3.53125
4
#!/usr/bin/python3 """Base class""" import json import csv class Base: """class Base """ __nb_objects = 0 def __init__(self, id=None): """Instantiation for the class Args: id (int, optional): id of object. Defaults to None. """ if id is not None: ...
e320c9bd1c6d7bc73bcd22628fd2bbbea91b84b7
Geekersen/Python_Exercises
/100_Python_Exercises/006-sensitive_word_detection_shield.py
779
3.609375
4
""" 006-sensitive_word_detection_shield.py 描述:敏感词文本文件 filtered_words.txt ,当用户输入敏感词时,将敏感词用 ** 代替。 """ import os def sensitive_word_detection_shield(detected_words, filter_words): for word in filter_words: detected_words = detected_words.replace(word, len(word) * '*') print(detected_words) if __nam...
7027f97674e9b8bb7f361a77030111a423530449
ActuallyACat/cs4920
/noj/data_structures.py
7,200
3.671875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from db_interface import * SENTENCE = 0 PHRASE = 1 CORPUS = 0 DICTIONARY = 1 FORMAT_TABS = 0 class Dictionary(object): """docstring for Dictionary A Dictionary contains a 'name' for the dictionary and a subsequent list of 'entries'. """ def __init__(self,...
c32176487913aebb4d2787bbc116537f952be7b4
Tony-Mok/Date-Timer
/date_string.py
2,148
4.4375
4
class DateString: ''' A class containing year, month and day of a date ''' def __init__(self, year: int, month: int, day: int) -> None: self.day = day self.month = month self.year = year def __lt__(self, other) -> bool: if self.year != other.year: # different...
0ed85021bf3f32ea2e53a45a9f58c5d920c44220
kiara-williams/ProgrammingII
/prac_02/files.py
693
4
4
FILE = "name.txt" NUMBER_FILE = "numbers.txt" # asks for input and prints name to file read_file = open(FILE, "w") name = str(input("Please enter your name: ")) print(name, file=read_file) read_file.close() # reads name from file and prints it to console. write_file = open(FILE, "r") name = write_file.readline()...
0664ca69436e62ceed541e1188eada82c0abcaa1
steliostss/advent-of-code2020
/day03/day03.py
884
3.75
4
# implementation for the day03 quiz of "advent of code" def read_input(infile): input = [] with open(infile) as f: for line in f: input.append(line.strip('\n')) return input def begin_slope(ground, step_right=3, step_down=1): counter = 0 dest = 0 row = 0 while row < le...
c129b15baab105863264af400c1ac70dbf3673c3
mustafasisik/mstfssk
/contains.py
178
3.578125
4
def contains(x, liste): if x in liste: return True else: return False assert contains(2, [1, 2, 3, 4, 5]) == True assert contains(1, [3,4,5,6]) == False
229a3f9015ce0639a2f4ae7b07a46895133f3634
cgifford99/Artificial-Intelligence
/Tensorflow/tf_understanding 9-21-17.py
2,049
3.953125
4
import tensorflow as tf #tf.constant is essentially a variable in tensorflow node1 = tf.constant(3.0, dtype=tf.float32) node2 = tf.constant(4.0, dtype=tf.float32) print(node1, node2) #It ends up printing data information about the nodes, not the values #To print the values of the nodes, run the computational graph wi...
349eec672ac4c218ffbacc0f61b705e8e7f91e9a
abnerfcastro/ml-nanodegree
/chicago-bikeshare/chicago_bikeshare_en.py
13,436
3.859375
4
# coding: utf-8 # Here goes the imports import csv import matplotlib.pyplot as plt import datetime as dt from os import path # Let's read the data as a list print("Reading the document...") filepath = path.abspath(path.join(path.dirname(__file__), "chicago.csv")) with open(filepath, "r") as file_read: reader = csv....
28dbe8f55fc17efe8204634256f0afff65664e04
sptuan/RL-playground
/01_Q-learning/ex2/main.py
1,648
4.03125
4
""" Reinforcement learning maze example. This script is our main script, in which a bike driver tries to arrive at FINAL POINT. This script is modified from https://morvanzhou.github.io/tutorials/ """ from env_tk import Maze from RL_brain import QLearningTable def update(): for episode in range(10000): ...
36bdabd0f343ca80fd00888bec8ef7f706477edf
mrmattuschka/python-lecture-mobi-17
/exercises_3/task_1/task_1_d.py
2,122
4.1875
4
# Task 1d: get counts statistics for the sequence dna_seq = "GATTACA" rna_seq = "GAUUACA" permitted_letters = "ATCGU" seq_list = [dna_seq, rna_seq] for seq in seq_list: print("Validating sequence:", seq) seq = seq.upper() for letter in seq: if not letter in permitted_letters: print("...
7198a98c34a433054030e673a2f7ab640f348f4f
Anirudh-Muthukumar/Python-Code
/BFS.py
750
3.984375
4
class Node: def __init__(self, key): self.val = key self.left = None self.right = None def bfs(root): if root is None: return # create a queue queue = [] dis = [] temp = [root.val] dis.append(temp) queue.append(root) while len(queue)>0: print...
d0cfa4c2d10a6da6dad9a89a06a43864602a642e
kevyang1004/LPTHW
/mygame.py
2,624
4.09375
4
from sys import exit def first_floor(): print "There is the way to go the office" print "There is the way to go to the basement" print "There is the way to go to second floor" print "Where do you want to go?" choice = raw_input("> ") if choice == "office": print "No one is there" ...
9dde11bb2c8340fd79a7e1cc8fb0f1f1ddfcb913
Hiten-98/Password-Manager-Using-Python
/main_password_manager.py
4,059
3.59375
4
from tkinter import * from tkinter import messagebox import random import json GREY = "#DCDCDC" #Password Generator def generate_password(): letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', ...
95c7b8be7bee37a6272df4199a3257b1c852c053
ghostassault/AutomateTheBoringWithPython
/Projects/combinePdfs.gyp
1,468
3.671875
4
#Combine select Pages from many PDFs #This program allows you to customize which pages you want in the combined PDF #At a high level this is what the program will do #TODO: Find all PDF files in the currnt working directory #TODO:Sort the filenames so The PDFs are added in order. #TODO:Write each page, excluding the fi...
e0f7151db0a5cdd844399ca669f8bc8deffa0170
JPWS2013/SoftDes_Project
/trace_playback.py
1,107
4
4
import time import math import numpy class Trace(object): """ Trace is a class that inherits from object and provides methods for simulating data from sensors. For the purposes of the project for the class Software Design, Fall 2013, this module only simulates the data from a hall effect sensor "...
9984765d81a45fd68c31346f38a31d5953da6fc5
maryammouse/ud036
/random_builtin_abs.py
350
4.03125
4
# the assignment is to look at the built in python function documentation # pick a function to use and write a program using it. # here is mine: def is_absolute(number): if number == abs(number): print True else: print False # a few test cases is_absolute(3) is_absolute(-3) is_absolute(14...
008c2fa5630fb7bba2e3e5da20db884c7ff8a26e
gangyou/python_execrise
/magicmethod/functional_list.py
1,020
3.75
4
# coding=utf-8 class FunctionalList(object): def __init__(self, values=None): if values is None: self.values = [] else: self.values = values def __len__(self): return len(self.values) def __getitem__(self, key): # may raise a KeyError if the key is not exists return self.values[key] def __setite...
8f41c59fb973c5ec442de4d30687e5629496b85e
WillianJefferson/teste
/Aula 5/Aula 5 - Tarefa_7.py
496
3.734375
4
def valor_pagamento(valor, dias_a): if (valor < 0): return None if (dias_a > 0): multa = valor * 0.03 adicional = valor * (dias_a * 0.01) return valor + multa + adicional else: return valor valor = 1 while (valor != 0): valor = float(input('Informe o valor da pr...
1a18c17f5949bd7fb3169928031ad1fa86838b7a
Shristipatne/github-demo
/math.py
247
3.8125
4
#addition def add(x,y): return x+y #subtract def subtract(x,y): if y>x: return negative_value_error else return x-y #multiply def multiply(x,y): return x*y #divide def divide(x,y): return x/y
ce94cc05ec40c1ff696c14610a57a941d2ddd967
Daisyhaxx/Cryptography-App
/codes/main.py
1,260
3.53125
4
import onetimepad from tkinter import * root = Tk() root.title("Python Cryptography App") root.geometry("700x200") def encryptMessage(): pt = e1.get() # * encrypt function ct = onetimepad.encrypt(pt, 'random') e2.insert(0, ct) def decryptMessage(): ct1 = e3.get() # * decrypt function pt1 = on...
8f753e7c5d2e52b587a4865734d5235139effd74
AlexMetodieva/SoftUni
/toy_shop.py
665
3.53125
4
excursion = float(input()) puzzles = int(input()) dolls = int(input()) bears = int(input()) minions = int(input()) trucks = int(input()) sum_puzzles = puzzles * 2.6 sum_dolls = dolls * 3 sum_bears = bears * 4.1 sum_minions = minions * 8.2 sum_trucks = trucks * 2 total_sum = sum_puzzles + sum_dolls + sum_bears + sum_mi...
a9dbbfc96e273875ecbca944ff13f2e02785ab69
fxyyy123/book_codes
/ch2/exercises/ans2_10.py
82
3.609375
4
sum = eval(input("Please Enter an Addition formula:")) print(f"The sum is {sum}.")
f14633fb648f8c092dbd7f7df20d3cb01451362b
kene111/DS-ALGOS
/Hackerrank and Leetcode/collections_deque.py
306
3.609375
4
from collections import deque n = int(input()) d = deque() for i in range(n): m = input().split() if m[0] == 'append': d.append(m[1]) if m[0] == 'appendleft': d.appendleft(m[1]) if m[0] == 'pop': d.pop() if m[0] == 'popleft': d.popleft() print(*d)
e4d51cebe30ca0fa1ea9724fa12eec10fcb5633b
crystalarnspiger/scripts
/test/palindrome.py
182
3.84375
4
import copy def palindrome(word): new_word = '' x = len(word) - 1 while x >= 0: new_word += word[x] x -= 1 if word == new_word: return True
fa113f93cb2a15aaed18ef7b1bdc2ee90f50e648
zaarabuy0950/assignment-3
/assign10.py
659
4.53125
5
"""10. Write a function that takes camel-cased strings (i.e. ThisIsCamelCased), and converts them to snake case (i.e. this_is_camel_cased). Modify the function by adding an argument, separator, so it will also convert to the kebab case (i.e.this-is-camel-case) as well.""" def naming_style(string, seperator): glu...
d98afb1dc83ad00bd5f8f287796ad67aafb4aacd
JoMaAlves/ArtesaoDeGrafos
/src/components/graph.py
10,528
3.546875
4
from components.prints import * from components.vertex import vertex class graph: def __init__(self, direc, weight): self.nodeList = [] self.edgeList = [] self.direc = direc self.weight = weight self.size = 0 # Adds a vertex def addNode(self): printAddNode(...
5cbbfcf02882dac09c1752d64df96f74f69d4689
ISdawu/Python-study
/01 Guess01.py
305
3.703125
4
score = 0 print('guess the animals!') print('最大的树是什么树?') guess = input() if guess == '巨杉谢尔曼将军': print('回答正确!!!!!!!!!!') score = score + 1 else: print('回答错误' + '!!!!!!!!!!') print('得分:' + str(score))
183c5d0542c1ad71c03f0ab504d1beb4a9369524
thailanelopes/exercicios_em_python
/23exercicio.py
1,642
3.828125
4
#variáveis contador_total = 0 contator_sit_1 = 0 contator_sit_2 = 0 contator_sit_3 = 0 contator_sit_4 = 0 #entrada identificador = int(input("Informe a identificação: ")) #processamento/processamento while identificador != 0: print("1- Necessidade de esfera.") print("2- Necessita de limpeza.") print("3- N...
1dd083983de4f00d15edd3ea6bb56fb6344516aa
syurskyi/Algorithms_and_Data_Structure
/_algorithms_challenges/exercism/exercism-python-master/zebra-puzzle/zebra_puzzle.py
2,112
3.59375
4
from itertools import permutations def solution(): """Finds solutions to the zebra puzzle""" solutions = list(zebra_puzzle()) assert(len(solutions) == 1) return ("It is the %s who drinks the water.\n" "The %s keeps the zebra." %(solutions[0]['water'], solutions[0]['zebra'])) def zebra_puzzle()...
987f9a5bb1c9c82230c29dd433d6b2644e4c6163
TemitopeOladokun/My-Python-Notebook
/Emoji Converter.py
205
3.734375
4
message = input (">") words = message.split(' ') emojis = { ":)" : "😊", ":(" : "☹" } converter = "" for ch in words: converter += emojis.get(ch, ch) + " " print(converter)
36710adc0bf78650eacd3cf340054b43be2a8457
jeffrey-hong/interview-prep
/Daily Coding Problem/Problem16.py
855
3.796875
4
""" You run an e-commerce website and want to record the last N order ids in a log. Implement a data structure to accomplish this, with the following API: record(order_id): adds the order_id to the log get_last(i): gets the ith last element from the log. i is guaranteed to be smaller than or equal to N. """ class...
2852253a1a4727a31a22ed0f1070b4700974d21f
maximkfd/ibfk
/public_key_gen.py
1,163
3.578125
4
import random # Bob generates these. # So Alice will encrypt m with PK and send it (M) to bob for sign, # so Bob will return M and sign to Alice, # and she will recover her message. Does she need it? Probably no, she only needs sign to send it further. # and what is further? # So now Alice has m and sign for M (and m t...
d83c407a055812a4b889e4585db0adf225a9943f
InseongJoe/SoftwareDesign
/hw4/random_art.py
3,362
3.921875
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 11 11:34:57 2014 @author: pruvolo """ # you do not have to use these particular modules, but they may help from math import * from random import * import Image def build_random_function(min_depth, max_depth): # your doc string goes here '''This function takes in...
d2e1d508c2ef7e3cc94ef351483f38c4e79f950f
ChangxingJiang/LeetCode
/1601-1700/1634/1634_Python_1.py
1,489
3.90625
4
class PolyNode: def __init__(self, x=0, y=0, next=None): self.coefficient = x self.power = y self.next = next class Solution: def addPoly(self, poly1: 'PolyNode', poly2: 'PolyNode') -> 'PolyNode': ans = node = PolyNode(0, 0) while poly1 and poly2: if poly1.p...