blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
714da2929f26a6b2788bad27279aec26de30f66b
Ashok-Mishra/python-samples
/python exercises/dek_program053.py
747
4.28125
4
# !/user/bin/python # -*- coding: utf-8 -*- #- Author : (DEK) Devendra Kavthekar # Define a class named Rectangle which can be constructed by a length and # width. The Rectangle class has a method which can compute the area. # Hints: # Use def methodName(self) to define a method. class Ractangle(object): def _...
1e5e2cbb3083c6a9ca4c91d4b71efe964f987bb9
Ashok-Mishra/python-samples
/python exercises/dek_program094.py
725
4.0625
4
# !/usr/bin/python # -*- coding: utf-8 -*- #- Author : (DEK) Devendra Kavthekar # program094: # With a given list [12,24,35,24,88,120,155,88,120,155], write a program # to print this list after removing all duplicate values with original # order reserved. # Hints: # Use set() to store a number of values wit...
ef2f0b6305acf196994ca53109035688722d342e
Ashok-Mishra/python-samples
/python exercises/dek_program001.py
913
4.125
4
#!/user/bin/python # -*- coding: utf-8 -*- # Author : (DEK) Devendra Kavthekar # program001 : divisibleBy7not5 # Write a program which will find all such numbers which are divisible by 7 # but are not a multiple of 5, between 2000 and 3200 (both included). # The numbers obtained should be printed in a comma-separate...
ae0fed29cb1b49c8deb8c0807df7f222c6aae61a
Ashok-Mishra/python-samples
/python exercises/dek_program008.py
722
4.28125
4
#!/user/bin/python # -*- coding: utf-8 -*- # Author : (DEK) Devendra Kavthekar # program008 : # Write a program that accepts a comma separated # sequence of words as input and prints the words # in a comma-separated sequence after sorting them alphabetically. # Suppose the following input is supplied to the program:...
bb8be1f8046be290b5a453dcae9774bbac3df864
analBrotherhood/UCrypt-CLI
/ucrypt.py
1,649
4.21875
4
alphabet = '=>?@[\\]678hiVWlmABCDEpqrsjkJKL01234RюБжэяЩРтшЦМйu&UмоПtлС5хКцvЧёgчwSещFTвНZ#ОькТЖЯЁфбГъуЗиргШЪ$ЮХыЫIXHЕ!ВДG"Фа%АYсЙЬИздЛoxyz<MNOPQnУЭпн9abcdef^_`{|}~ \'()*+,-./:;' def encrypt(): enc = '' msg = input('Type message for encrypting: ') key = input('Enter key for encrypting: ') for c...
5a18389a8063d941ddd7421de6680da28984eeb6
jacokyle/CIS457_Projects
/Project_1/serverDir/server.py
5,340
3.75
4
# Project 1 - Building an FTP Server # CIS 457 - Data Communications # Authors: Kyle Jacobson, Logan Jaglowski # Date of Submission: October 26, 2020 # The server program binds to a port and listens to requests from a client. import os import socket from pathlib import Path HOST = socket.gethostname() # The socket'...
046bd214c938e63595f3d9fdeed82ecf1327b6b7
ayushtiwari7112001/Rolling-_dice
/Dice_Roll_Simulator.py
640
4.4375
4
#importing modual import random #range of the values of dice min_val = 1 max_val = 6 #to loop the rolling through user input roll_again = "yes" #loop while roll_again == "yes" or roll_again == "y": print("Roll the dices...") print("** The values are **") #generating and printing 1st random intege...
86a59878b82707a40a49eb27a362d8f666eb437d
Mikemike-22/Password-Locker
/details.py
1,109
3.859375
4
class Details: ''' class generating new instances of Details ''' def __init__(self,first_name,last_name,email): # properties for the objects self.first_name = first_name self.last_name = last_name self.email = email details_list=[] def save_details(self): ""...
8f3989945afd0defa4477c3955d38869dfad125d
changqing1234/learning
/python语法-学习/tuple_and_list.py
222
3.96875
4
a_tuple = (12, 3, 4, 5, 6) another_tuple = 2,4, 6, 7, 8 a_list = [2,3, 4,6, 8] for content in a_list: print(content) for index in range(len(a_list)): print('index=', index, 'number in list=', a_list[index])
949d5610a81c4092c76eee5a047f3b06cdfe4f3a
changqing1234/learning
/机器学习 -学习/一元线性回归例子.py
1,338
3.6875
4
import numpy as np import matplotlib.pyplot as plt #原理地址 https://www.jianshu.com/p/d8a4d3b9ded0 """ 利用 Python 实现线性回归模型 """ class LinerRegressionModel(object): def __init__(self, data): self.data = data self.x = data[:, 0] self.y = data[:, 1] def log(self, a, b): print("计算出的线性回归...
83d5c61d22d614005973eb782b4da2fc3e7371ac
kenpuca/db.science.uoit.ca
/courses/algorithms/mst/code/mst.py
1,916
3.53125
4
def minimal_edge(H, V0): """pick an edge with the minimal weight from V0 to the rest of the nodes""" w_min = None e_min = None for e in H.E.keys(): if e[0] in V0 and e[1] not in V0: w = H.E[e]["weight"] if w_min == None or w < w_min: e_min = e ...
641c65e39fb210b8d7403b4562be7429e2444017
bewakes/bewakes
/journal/helpers.py
438
3.796875
4
def xor_encrypt(string, password): """ Encrypt the string with password """ passlen = len(password) chunks = [string[x:x+passlen] for x in range(0,len(string), passlen)] xored = [xor_strings(password, x) for x in chunks] return "".join(xored) def xor_strings(s1, s2): """ xor two str...
dd46f1d183a105d8aec13e26ae9cb6a756b8e064
liu13722002716/python-interview
/面试题/位运算符/191 位1的个数.py
1,611
3.703125
4
""" :Author: Mr.Liu :Create: 2020/6/29 9:30 :Github: https://XXXXXXXX Copyright (c) 2020,Mr.Liu Group All Rights Reserved. """ """ 编写一个函数,输入是一个无符号整数,返回其二进制表达式中数字位数为 ‘1’ 的个数(也被称为汉明重量)。 示例 1: 输入:00000000000000000000000000001011 输出:3 解释:输入的二进制串 00000000000000000000000000001011 中,共有三位为 '1'。 示例 2: 输入:000000...
048140f0b4c6212182255ac8b2a4ea344c842f66
liu13722002716/python-interview
/面试题/位运算符/136 只出现一次的数字.py
749
3.875
4
""" :Author: Mr.Liu :Create: 2020/6/29 10:12 :Github: https://XXXXXXXX Copyright (c) 2020,Mr.Liu Group All Rights Reserved. """ """ 给定一个非空整数数组,除了某个元素只出现一次以外,其余每个元素均出现两次。找出那个只出现了一次的元素。 说明: 你的算法应该具有线性时间复杂度。 你可以不使用额外空间来实现吗? 示例 1: 输入: [2,2,1] 输出: 1 示例 2: 输入: [4,1,2,1,2] 输出: 4 """ from typing import Lis...
2620868cedaaddc8b8270c31ad5af040790f5958
liu13722002716/python-interview
/面试题/位运算符/477 汉明距离总和.py
1,755
3.5625
4
""" :Author: Mr.Liu :Create: 2020/6/29 10:29 :Github: https://XXXXXXXX Copyright (c) 2020,Mr.Liu Group All Rights Reserved. """ """ 两个整数的 汉明距离 指的是这两个数字的二进制数对应位不同的数量。 计算一个数组中,任意两个数之间汉明距离的总和。 示例: 输入: 4, 14, 2 输出: 6 解释: 在二进制表示中,4表示为0100,14表示为1110,2表示为0010。(这样表示是为了体现后四位之间关系) 所以答案为: HammingDistance(4, 14) +...
93278240e775bbba67da1572331d7a1d3cb279db
YeomeoR/codewars-python
/sum_of_cubes.py
656
4.25
4
# Write a function that takes a positive integer n, sums all the cubed values from 1 to n, and returns that sum. # Assume that the input n will always be a positive integer. # Examples: # sum_cubes(2) # > 9 # # sum of the cubes of 1 and 2 is 1 + 8 ### from cs50 video python, lecture 2 # def sum_cubes(n): # cubed...
4f481dd9a6205e9979b2f9f17103dd3816a226ab
YeomeoR/codewars-python
/count_by_step.py
827
4.21875
4
# Implement a function named generateRange(min, max, step), which takes three arguments and generates a range of integers from min to max, with the step. The first integer is the minimum value, the second is the maximum of the range and the third is the step. (min < max) # def generate_range(min, max, step): # lis...
92b874bc57e471491517a2c95f8c90f8c45c8531
YeomeoR/codewars-python
/count_of_positives_sum_of_negatives.py
1,223
3.953125
4
# Given an array of integers. # Return an array, where the first element is the count of positives numbers and the second element is sum of negative numbers. # If the input array is empty or null, return an empty array. # Example # For input [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15], you should return [1...
489f6db924c5b734943ac905a4483251a39171d6
W-R-Ramirez/Scrabble-Solver
/board.py
486
3.703125
4
import Tkinter from starter import numbers_to_letters # Creates the GUI for the board before the game root = Tkinter.Tk() canvas = Tkinter.Canvas(root, width = 550, height = 550) canvas.grid() for i in range(9): for j in range(9): column = j+1 v = Tkinter.StringVar() name = numbers_to_let...
3d40b4229c78f200c882547349bf5ad433a87908
goruma/CTI110
/P2HW1_PoundsKilograms_AdrianGorum.py
586
4.40625
4
# Program converts pounds value to kilograms for users. # 2-12-2019 # CTI-110 P2HW1 - Pounds to Kilograms Converter # Adrian Gorum # #Pseudocode #input pound amount > calculate pound amount divided by 2.2046 > display #conversion in kilograms #Get user input for pound amount. poundAmount = float(input('En...
1ef83617a069d51eb924275376f133f4c323d375
goruma/CTI110
/P4HW4_Gorum.py
796
4.3125
4
# This programs draws a polygonal shape using nested for loops # 3-18-19 # P4HW4 - Nested Loops # Adrian Gorum # def main(): #Enable turtle graphics import turtle #Set screen variable window = turtle.Screen() #Set screen color window.bgcolor("red") #Pen Settings myPen = ...
37cf173edeedd27a53151cc74fcf50f42293d5b5
nawazyarkhan/python-challenge
/PyBank/main.py
2,338
3.5
4
#### Import dependencies for os.path.join() import os import csv ### Read in a .csv file csv_file=os.path.join("Resources", "budget_data.csv") output_path=os.path.join("analysis","financial_analysis.csv") #define variables month_total=0 change_month=[] revenue_total=0 greatest_value=0 revenue=[] revenue_previous=0 gr...
9d40a535b1548c9a9d2893bfec30964048843d43
sid597/vadaPav
/transform.py
903
3.53125
4
from PIL import Image import os ''' Rotate and flip the images present into the resized folder ''' ctr = len(os.listdir('/home/siddharth/vadaPav/resized/')) # no of images image_path = '/home/siddharth/vadaPav/resized/' nctr = 900 def rotate(img_path): l = [90,180,270] for degree in l: try: ...
f3de93f96f4247c3bccba5f699eadd168e4439d0
vincent1879/Python
/MITCourse/ps1_Finance/PS1-1.py
844
4.125
4
#PS1-1.py balance = float(raw_input("Enter Balance:")) AnnualInterest = float(raw_input("Enter annual interest rate as decimal:")) MinMonthPayRate = float(raw_input("Enter minimum monthly payment rate as decimal:")) MonthInterest = float(AnnualInterest / 12.0) TotalPaid = 0 for month in range(1,13): print "Month",...
21f9e3f2fdbd00211d4c1d77eaaefcec9f9c627a
fadetoblack72/PracticeRepo
/problems.py
1,013
3.796875
4
"""" given a list of numbers "nums", and a target number "target" finds the indices of the first two numbers in nums whose sum = target """ def twoSum(nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ for i in range(0, len(nums)): for j in range(i + 1, len(...
ff90bd31a30d71b3b60b5f66cd626a4251598b48
melvin3113/lets-upgrade-python-assignment
/python assignment.py
714
3.96875
4
#!/usr/bin/env python # coding: utf-8 # In[1]: print("hello") # In[3]: print("hello python") # In[6]: print(""" ()()()()()(~~~~"") """) # In[7]: print("hy\thello") # In[8]: print("hy\nhello") # In[9]: name="mel" age="20" print("my name is",name,"and of age",age) # In[11]: print(f"my nam...
f36288e8a5623ec4dcfaff80f5891b5a0e2d96f4
vijayb95/blackjackSimplified
/blackjack.py
7,983
3.734375
4
import random, time userCards = [] def main(): print("**************************** Welcome to BlackJack ****************************") count = 0 user = getUser() print(f"\nHi {(user.user).capitalize()}, your current balance in BlackJack wallet is ${user.balance}\n") while True: time.sleep(...
11422b0078063a75e2fa014861a4d25bdc04080f
pisskidney/tc
/199_2/all.py
739
3.5
4
#!/usr/bin/python class StringMult(object): def times(self, s, k): res = "" if not s or not k: return "" if k > 0: for i in range(k): res += s else: for i in range(abs(k)): res += s[::-1] return res clas...
fd5cad42fc0df462969bffec225a2da69fcff093
faithstill/info-security-homework
/乘法逆元.py
1,056
3.796875
4
# -*- coding: UTF-8 -*- #欧几里得算法求最大公约数 def get_gcd(a, b): k = a // b remainder = a % b while remainder != 0: a = b b = remainder k = a // b remainder = a % b return b #改进欧几里得算法求线性方程的x与y def get_(a, b): if b == 0: return 1, 0 ...
df3e7bb0eb16319adb5427e7744545a07fc2660e
rpask00/Data-structures
/linkedlist.py
3,320
3.578125
4
from ttictoc import TicToc class LinkedList: class Node: def __init__(self, data=None): self.data = data self.next = None def __init__(self): self.first = self.head = self.Node() def listprint(self): print_value = self.first while print_value is no...
54dd52ca5bb4f2113c3debbc6f631d0a79a7b215
aemerick/cloudy_tools
/smooth.py
6,630
4.0625
4
import numpy as np def simple_smooth(x, y, window = 1, interp = 1, factor = 3.0, interpolation = 'linear', mode = 'spike'): """ Very simple smoothing method meant to best handle data with occasional single spiked points, where the "spike" is defined as being a factor "factor" larger than the points on ...
1aa890533215be3324fdc63bf9731c2db72804d7
arjunnaik/Python-Programs
/Simple_Interest.py
287
3.90625
4
principleAmount = float(input("Enter principle amount")) rateOfInterest = float(input("Enter rate of interest")) timePeriod = float(input("Enter time period")) si = principleAmount*rateOfInterest*timePeriod/100 print("Interest is",si) print("Total Amount is",si+principleAmount)
942c81b06694be9eb9ad7c003454c596ddcffe71
arjunnaik/Python-Programs
/Number_Plate_validation.py
473
3.8125
4
var = input("Enter Number Plate :") if len(var)==6: var1=var[3:] var2 = var[:3] if var1.isdigit() and var2.isupper(): print("License plate is older...") else: print("Invalid License plate...") elif len(var)==7: var1=var[:4] var2=var[4:] if var1.isdigit() and var2.i...
819ba8350496d22dcf6afbb0baf7a8fcb29ce216
Krunal91/Python_Machine_Learning_Implementation
/LeetCode/removeDuplicates.py
380
3.75
4
def removeDuplicates(nums): """ :type nums: List[int] :rtype: int """ counter = 0 change = nums[0] for i in range(1, len(nums)): if change != nums[i]: counter += 1 nums[counter] = nums[i] change = nums[i] nums = nums[:counter] return counte...
7506f49a24259272ed77b040d1730128fb009ed2
Avithegitty81/Python_Challenge
/**PyPoll**/Main.py
1,299
3.59375
4
# Import modules for reading csv files: import os import csv csv_path= os.path.join("Resources","election_data.csv"); with open(csvpath) as csv_file: csv_reader = csv_reader(csv.file, delimiter = '.') csv_header= next(csv_reader) # Define the Variables: total_votes = 0 candidate = [] candidat...
b6f885976b3571a573bd9c55658932217d921873
WangJinxinNEU/python3_learn
/generater.py
1,204
3.578125
4
g = (x * x for x in range(10)) # print(next(g)) # print(next(g)) # print(next(g)) # print(next(g)) # print(next(g)) # print(next(g)) # print(next(g)) # print(next(g)) # print(next(g)) # print(next(g)) # a = 5 # b = 1 # a, b = b, a + b # # b = a + b # # def fabi(input): # first=1 # second=1 # index =2 # ...
ffb14633bfae95c03e5445919be6c0a8fa251f05
JUANPABLO99YYDUS/Pr-ctica-Complementaria
/18460609-PracticaComplementaria-1/Genarador_figuras2D.py
10,796
3.75
4
import math def main(): op = "" figuras = [] while op !="0" : print("1.-Crear figura \n2.-Listar una clasificacion de figuras\n3.-Listar todas las figuras\n4.-Mostrar suma de todas las areas\n5.-Mostrar suma de todos los perimetros\n6.-Limpiar lista\n0.-Salir") op = input("In...
bc227425b3e569c14434c0a21e72b413adf4d09b
balajikulkarni/hackerrank
/TicTacToe.py
2,922
3.859375
4
not_full = 0 def DisplayBoard(board): print(" "+board[0]+" "+board[1]+" "+board[2]) print(" "+board[3]+" "+board[4]+" "+board[5]) print(" "+board[6]+" "+board[7]+" "+board[8]) def GetInput(): try: data = input('Enter "X" or "O" and Index> ') marker,index = data.split() ...
b272382f80edeabc91c1a33ba847e34ebff32ac0
Holly-E/Matplotlib_Practice
/Dealing_with_files.py
1,051
4.125
4
# -*- coding: utf-8 -*- """ Spyder Editor Master Data Visualization with Python Course """ #open pre-existing file or create and open new file to write to # you can only write strings to txt files- must cast #'s to str( ) file = open('MyFile.txt', 'w') file.write('Hello') file.close() # can reuse file variable nam...
2c69df3ebb4b2cbf13fc537db25e805c7c772250
nibbletobits/nibbletobits
/python/day 2 project 3.py
299
3.734375
4
import math MAX_SIZE=200 pi=float(3.141592) m1=int(input("type input value for m1=")) m2=int(input("type input value for m2=")) p=float(input("type input for value p=")) a=float(input("type input for value a=")) G=(4*pi**pi*a**a**a//p**p*m1+m2) print(float(G)) input("press enter to end")
0d68a4392b0bd73d031c737fd7f385f999be29c6
nibbletobits/nibbletobits
/python/camel game_rand.int in use.py
4,561
4.25
4
# ******************************************** # Program Name: Day 16, in class # Programmer: Jordan P. Nolin # CSC-119: Summer 2021 # Date: 7 26, 2021 # Purpose: program / camel Game - # Modules used: # Input Variables: # Output: print statements for purpose. # ******************************************** ...
b50646362428794271da3b7ee395c16167377d82
nibbletobits/nibbletobits
/python/day 11 in class main.py
534
3.6875
4
# ******************************************** # Program Name: Day 11, in class # Programmer: Jordan P. Nolin # CSC-119: Summer 2021 # Date: 7 12, 2021 # Purpose: A program that sends a word and calls a function. # Modules used: def vert_word # Input Variables: (word) # Output: print statement calls function ve...
39818a02bdab25b77dbfbc76cba087baecbd55d8
nibbletobits/nibbletobits
/python/day 6 in class.py
624
4.21875
4
# ******************************************** # Program Name: Day 5, in class # Programmer: Jordan P. Nolin # CSC-119: Summer 2021 # Date: June 21, 2021 # Purpose: A program to add the sum of all square roots # Modules used: # Input Variables: number() ect # Output: print statements, that output variable answe...
06f3cd7124324a142f42d9f3603d8db6688b3538
nibbletobits/nibbletobits
/python/day_14_1.py
1,095
3.796875
4
# ******************************************** # Program Name: Day 14, HW 1 # Programmer: Jordan P. Nolin # CSC-119: Summer 2021 # Date: 7 24, 2021 # Purpose: program that opens a file and reads than sends it to output location # Modules used: # Input Variables: none # Output: # *******************************...
81db4111784384152f29a88e5f21d0ac706f95a7
nibbletobits/nibbletobits
/python/day 11 home work.py
1,378
4.0625
4
# ******************************************** # Program Name: Day 11, homework # Programmer: Jordan P. Nolin # CSC-119: Summer 2021 # Date: June 30, 2021 # Purpose: A program that asks the user for two inputs [r, h] than calls the list of functions. # Modules used: spherevolume(r,h), spheresurface(r,h), cylinder...
d17890d3692bfbe9c4cc25c1f6a240db48e3c774
arpartch/yogaProject
/drills.py
7,725
3.90625
4
import { map } from "ramda"; from functools import reduce; ######Map Function##### # Capitalize words def capitalize(name): return name.capitalize() x = map(capitalize, names) print(list(x)) #Max out at 350 def max_out_350(size): return size if size <= 350 else 350 sizes = [200, 400, 350, 75, 1200] x = map...
b5996faa9054b9df8af5c050b2f49610826577dc
liyi0206/leetcode-python
/110 balanced binary tree.py
2,063
3.75
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def isBalanced(self, root): """ :type root: TreeNode :rtype: bool """ return self.dfs(root)...
8935772ff86c73b7a42e8e2d002bdf755ef28529
liyi0206/leetcode-python
/116 populating next right pointers in each node.py
1,589
3.84375
4
# Definition for binary tree with next pointer. class TreeLinkNode(object): def __init__(self, x): self.val = x self.left = None self.right = None self.next = None # perfect binary tree (ie, all leaves are at the same level, # and every parent has two children). class Solution(obje...
9168d9fffbbec024bb3a9859f67582f5221e2f31
liyi0206/leetcode-python
/348 design tic-tac-toe.py
3,497
3.875
4
class TicTacToe(object): def __init__(self, n): """ Initialize your data structure here. :type n: int """ self.n=n self.board=[[None]*n for i in range(n)] self.rows,self.cols=[0]*n,[0]*n self.diag,self.anti=0,0 def move(self, row, col, player): ...
e7565cac69265885bd7eeeb8384955302b273adf
liyi0206/leetcode-python
/156 binary tree upside down.py
1,136
4.0625
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def upsideDownBinaryTree(self, root): """ :type root: TreeNode :rtype: TreeNode """ if not ...
7ff50d199e169ce80b69489ef47ce3e4081ec1b5
liyi0206/leetcode-python
/23 merge k sorted lists.py
1,084
3.828125
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def mergeKLists(self, lists): """ :type lists: List[ListNode] :rtype: ListNode """ import heapq dummy = ListN...
a27fb4c09334810b39a3d09690e4afc980ae3c9e
liyi0206/leetcode-python
/236 lowest common ancestor of a binary tree.py
1,958
3.765625
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): #def lowestCommonAncestor(self, root, p, q): # """ # :type root: TreeNode # :type p: TreeNode # :type q...
d05eae952e0adb41ce31d22266f431b031498231
liyi0206/leetcode-python
/237 delete node in a linked list.py
732
3.84375
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def deleteNode(self, node): """ :type node: ListNode :rtype: void Do not return anything, modify node in-place instead. """ ...
3431a14f55b66f3f0c4f9a2010534957f510bd2f
liyi0206/leetcode-python
/225 implement stack using queues.py
821
4.15625
4
class Stack(object): def __init__(self): """ initialize your data structure here. """ self.queue=[] def push(self, x): """ :type x: int :rtype: nothing """ self.queue.append(x) def pop(self): """ :rtype: nothing ...
9fb84cef730806c5dbdba33cd359e9a13aeaec50
liyi0206/leetcode-python
/290 word pattern.py
968
3.71875
4
class Solution(object): def wordPattern(self, pattern, str): """ :type pattern: str :type str: str :rtype: bool """ map1,map2 = dict(),dict() for i in range(len(pattern)): if pattern[i] not in map1: map1[pattern[i]]=[i] else: map1[patte...
306f7459acc5adb3d1901a57c0b064eb1d99ce95
liyi0206/leetcode-python
/173 binary search tree iterator.py
960
3.984375
4
# Definition for a binary tree node class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class BSTIterator(object): def __init__(self, root): """ :type root: TreeNode """ self.stack=[] self.cur=root d...
e1836e6b0a4f5697bf0b4e6e9ee5ffa093612ed5
liyi0206/leetcode-python
/266 palindrome permutation.py
494
3.578125
4
class Solution(object): def canPermutePalindrome(self, s): """ :type s: str :rtype: bool """ mp={} for c in s: if c not in mp: mp[c]=1 else: mp[c]+=1 odd=0 for k in mp: if mp[k]%2==1: odd+=1 if odd==2: re...
0a8fa08729ef1018279ff48292fa916da4c47a07
liyi0206/leetcode-python
/43 multiply strings.py
765
3.53125
4
class Solution(object): def multiply(self, num1, num2): """ :type num1: str :type num2: str :rtype: str """ return str(int(num1)*int(num2)) def multiply2(self,num1,num2): num1, num2 = num1[::-1], num2[::-1] tmp = [0 for i in range(len(num1...
663a59c450aa1d732aa19da8b05d13260ad2b2ae
liyi0206/leetcode-python
/145 binary tree postorder traversal.py
3,220
4.15625
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): #def postorderTraversal(self, root): # """ # :type root: TreeNode # :rtype: List[int] # """ # se...
8d22226a37715e00a378c2ec6496ded100d8ce04
liyi0206/leetcode-python
/152 maximum product subarray.py
562
3.515625
4
class Solution(object): def maxProduct(self, nums): """ :type nums: List[int] :rtype: int """ res = nums[0] minp,maxp = nums[0],nums[0] for a in nums[1:]: tmp_maxp = maxp tmp_minp = minp maxp = max(tmp_maxp*a, tmp_minp*a, a)...
0275fb0a9d6b1725b95058ce03026d3d44b2d69b
liyi0206/leetcode-python
/341 flatten nested list iterator.py
4,239
4.1875
4
# """ # This is the interface that allows for creating nested lists. # You should not implement it, or speculate about its implementation # """ #class NestedInteger(object): # def isInteger(self): # """ # @return True if this NestedInteger holds a single integer, rather than a nested list. # :rt...
a11a9fddd142caea65dd5da517f221553bc1ee65
liyi0206/leetcode-python
/278 first bad version.py
675
3.5625
4
# The isBadVersion API is already defined for you. # @param version, an integer # @return a bool #def isBadVersion(version): class Solution(object): def firstBadVersion(self, n): """ :type n: int :rtype: int """ if n==1: return 1 if isBadVersion(n) else 0 l,h=1,n ...
4e1697c09cfd81f80816c8be6e9fab65a2df8518
liyi0206/leetcode-python
/88 merge sorted array.py
783
3.859375
4
class Solution(object): def merge(self, nums1, m, nums2, n): """ :type nums1: List[int] :type m: int :type nums2: List[int] :type n: int :rtype: void Do not return anything, modify nums1 in-place instead. """ p1,p2,p = m-1,n-1,m+n-1 while p1>=0...
06e8e14c3a3913bcf99df55c07893b761664be4a
liyi0206/leetcode-python
/17 letter combination of a phone number.py
615
3.546875
4
class Solution(object): def letterCombinations(self, digits): """ :type digits: str :rtype: List[str] """ self.lookup=["", "", "abc", "def", "ghi", "jkl", \ "mno", "pqrs", "tuv", "wxyz"] #self.nums self.res=[] self.bt(digits,"") #word, or ...
4dbf4aeffc23b7825388ddc6a20959a9e0efa2d6
liyi0206/leetcode-python
/19 remove nth node from end of list.py
949
3.8125
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def removeNthFromEnd(self, head, n): """ :type head: ListNode :type n: int :rtype: ListNode """ if head == No...
5fcb4db7af96c641d93766e1c69a3dd94311def8
liyi0206/leetcode-python
/139 word break.py
625
3.5
4
class Solution(object): def wordBreak(self, s, wordDict): """ :type s: str :type wordDict: Set[str] :rtype: bool """ dp = [True]+[False]*len(s) s = '0'+s for i in range(len(s)): if dp[i]: for word in wordDict: ...
ad0a004abeef6d79466a709e7f40f8de7b7e77ec
jophy-mj/python
/sample/p20.py
221
4.03125
4
n=int(input("enter no:")) rev=0 temp=n while(temp>0): r=temp%10 rev=(rev*10)+r temp=temp//10 print("reverse of",n,"is",rev) if(n==rev): print(n,"is palindrome") else: print(n,"is not palindrome")
eccad250bb9bdce796b545e9918cbfcebffd1537
jophy-mj/python
/c2/p15.py
129
3.53125
4
color_list1=["red","green","yellow"] color_list2=["blue","green","purple","red"] for i in color_list1: print(color_list1[i])
390cd9ce71f14b42e64831014f4a84d88b9e8207
jophy-mj/python
/c2/p11.py
226
4.03125
4
a=int(input("Enter 1st no:")) b=int(input("Enter 2st no:")) c=int(input("Enter 3st no:")) if((a>b)and(a>c)): print("Largest no is ",a) elif((b>a)and(b>c)): print("Largest no is ",b) else: print("Largest no is ",c)
2a3fcb8dbe6c8ffcd2df87373fb451840522e479
jophy-mj/python
/c4/p3.py
552
4.0625
4
class rectangle: def __init__(self,length,breadth): self.length=length self.breadth=breadth def area(self): return self.length*self.breadth def __lt__(self): if rect1<rect2: print("second rectangle is greater than first!") else: print("first re...
8de62638b39f63bc6186688a3562b6967494ff03
jophy-mj/python
/c3/p11.py
226
3.875
4
import math sq_area=lambda a:a*a rec_area=lambda l,b:l*b tri_area=lambda b,h:.5*b*h print("Area of square(5) is:",sq_area(5)) print("Area of rectangle(5,4) is:",rec_area(5,4)) print("Area of triangle(5,8) is:",tri_area(5,8))
7aa5b051e9b75e76aca01f1f8a24fc3cd5fccf7d
jophy-mj/python
/c4/p5.py
631
3.875
4
class publisher: def __init__(self): print("parent class") class book(publisher): def __init__(self,title,author): self.title=title self.author=author def display(self): print("The title of the book is",self.title) print("The author of the book is ",self.author) cla...
3e7a3f93810ab6574011e00a653b9abe7ad4dbe9
tuthimi/learn-python
/RunooShili/4.py
463
3.890625
4
__author__ = 'Administrator' year = int(raw_input("YEAR:\n")) month = int(raw_input("MONTH:\n")) day = int(raw_input("DAY:\n")) months = (0,31,59,90,120,151,181,212,243,273,304,334) if 1<=month<=12: sum = months[month-1] else: print("MONTH input error!\n") if 1<=day<=31: sum += day; else: print("DAY ...
b7fe6cd8a510170a0da743aebf6e9b65c633dc8a
tuthimi/learn-python
/RunooShili/78.py
277
3.5
4
#!/usr/bin/python # -*- coding: UTF-8 -*- __author__ = 'Administrator' if __name__ == '__main__': person = {"li":18,"wang":50,"zhang":20,"sun":212} mm='li' for m in person: if person[mm] < person[m]: mm = m print '%s,%d' % (mm,person[mm])
c7da97340adedb28ab16e58cc5770f64fef5894c
jordan-stone/Telluric-Fitter
/src/TelluricFitter.py
43,817
3.703125
4
""" Telluric Fitter "TelFit" ===================================================== This module provides the 'TelluricFitter' class, used to fit the telluric lines in data. Usage: - Initialize fitter: fitter = TelluricFitter() - Define variables to fit: must provide a dictionary where the key is the name of t...
6c62049cb5f2edf0f3dcadae97b5d53b59885642
airt1me/first_text_game
/text game attempt 31-7-16.py
3,276
4.09375
4
import random import time def start_intro(): print('You have just woken up and are not sure where you are. \n' 'You look around the room you are in, it is wooden, unremarkable, \n' 'and dirty, there is a door leading out of the room to your left \n' 'and a window to your right...
90153f9040fcb8bec89172512a7aa5986bf16d84
shinji0215/programming
/python/fukusyu_list.py
4,116
3.65625
4
#リスト・・一度セットした値を変更可能 [] #タプル・・一度セットした値は変更不可 () #range・・連続した数値 #これら3つはイテレート可能なオブジェクト #リスト l_data1 = ['aa', 'bb', 'cc', 'dd', 'ee'] print(l_data1[0]) #aa print(l_data1[-1]) #ee 最後の要素 print(l_data1[0:3]) #['aa', 'bb', 'cc'] スライス index=0~2 print(l_data1[-3:-1]) #['cc', 'dd'] print(l_data1[::2]) #['aa'...
2709a6ba676f938e6dfff92cca2cd5446c3f132d
jnnhuynh-web/Python_Challenge
/PyBank/main.py
2,544
4.03125
4
#BANK #import library import csv import os #import filepath csvpath = os.path.join("budget_data.csv") #open the file with open(csvpath) as file: #use filehandle as the name for the file filehandle = csv.reader(file,delimiter=',') #exclude the header row next(filehandle, None) #PART 1 #total m...
c1ac9b4695b9088810cb08fd8eea6a5c63def56c
cjbrooks/weather
/weather.py
993
3.625
4
#!usr/bin/env python from urllib2 import Request, urlopen, URLError import json city_list = ("Cambridge,USA", "Berkeley", "Oakland", "Palo_Alto") api_key = '306e98f72c67de6deffd7ac8f6151565' city_clean = [] temps = [] for city in city_list: #print city weather_api_call = "http://api.openw...
18a868ca4246b213f675d3afd4f4699ced78cf57
bkstephen/milky_way_model_in_python
/milky_way_main.py
3,293
3.65625
4
import tkinter as tk from random import randint, uniform, random import math SCALE = 225 # enter 225 to see Earth's radio bubble NUM_CIVS = 15600000 root = tk.Tk() root.title("Milky Way galaxy") c = tk.Canvas(root, width=1000, height=800, bg='black') c.grid() c.configure(scrollregion=(-500, -400, 500, 400)) # actual...
0c29e056ad03a4c33a459452a3307b34f78c5de9
vy3191/Graphs
/projects/graph/graph.py
8,903
4.40625
4
""" Simple graph implementation """ from util import Stack, Queue # These may come in handy class Graph: """Represent a graph as a dictionary of vertices mapping labels to edges.""" def __init__(self): self.vertices = {} def add_vertex(self, vertex): """Add a vertex to the graph.""" ...
13bb9aaf0c9dc907633a38d3c3fcbead56cd33c2
asutoshpanigrahi07/firstproject
/oct/odd & sum.py
257
3.921875
4
m=int(input("enter the initial value")) n=int(input("enter the final value")) s=0 if m%2==1: for a in range (m,n+1,2): print(a) s=s+a print(s) else: m=m+1 for a in range (m,n+1,2): print(a) s=s+a print(s)
bc8a48186b3f18968005c57bcf0f77908b33cdc3
asutoshpanigrahi07/firstproject
/nov/charloop.py
99
3.578125
4
for i in range(3,0,-1): for j in range(i,0,-1): print(chr(119+i), end=" ") print()
8837a891d0ba345b1e8cbd845626000076072b46
asutoshpanigrahi07/firstproject
/oct/Q. 06.py
175
4.15625
4
a=int(input("enter the value of a")) b=int(input("enter the value of b")) if (b%a==0): print("a is fully divisible by b") else: print("a is not fully divisible by b")
928a8eda342cf9781b7b7fd946bf29541630e05a
asutoshpanigrahi07/firstproject
/leetcode/Queue.py
959
4.09375
4
class Queue: data=[] def __init__(self): data=[] def push(self,x): self.data.append(x) def pop(self): v=self.data.pop(0) print(v,' is being popped out') def search(self,x): if x in self.data: print(x,'is present the Queue') else: ...
9ff93fbc3de742fc58cb653930ab7a12b02dc6b7
asutoshpanigrahi07/firstproject
/nov/fibonacii no..py
225
3.984375
4
n=int(input("Enter the no. of fibonacii no.:")) x=0 y=1 if n==1: print(x) elif n==2: print(x) print(y) else: print(x) print(y) for i in range(2,n): z=x+y print(z) x,y=y,x+y
6423de1df7dee7e6c287de814ab1ef6295c9b49f
prasannaaav/Data_Cleaning_project
/DataCleanerV2.py
1,573
3.796875
4
''' Created on Feb 23, 2021 @author: prasanna ''' import numpy as np import pandas as pd import tkinter as tk from tkinter import filedialog #1.Creating a dialog box enabling the user to select the desired excel root= tk.Tk() canvas1 = tk.Canvas(root, width = 300, height = 300, bg = 'lightsteelblue') canvas1.pack()...
1bee5db70703db3004b93c5c40312602564a8098
pmin825/python-algos
/two_sum.py
197
3.625
4
def twoNumberSum(array, targetSum): hash = {} for i in range(len(array)): num = array[i] diff = targetSum - num if diff in hash: return [diff, num] else: hash[num] = True return []
dd9873e3979fc3621a89d469d273f830371d757a
kingamal/OddOrEven
/main.py
500
4.1875
4
print('What number are you thinking?') number = int(input()) while number: if number >=1 and number <= 1000: if number % 2 != 0: print("That's an odd number! Have another?") number = int(input()) elif number % 2 == 0: print("That's an even number! Have another?") ...
5835ee1ebe75f72cd44a173583ed9ba4b4313edc
sahilbnsll/Python
/Lists & Tuples/Program05.py
152
3.5
4
# Tuple Methods t = (1,4,6,9,1,3,5,1,4,1) print(t.count(1)) # Return number of occurence of values print(t.index(9)) # Return first index of value
d3d012d57ee0d909efb270522d1fdc693c181f03
sahilbnsll/Python
/Lists & Tuples/Practise Set/Problem02.py
441
3.921875
4
# Problem 2. Sorting Marks of 6 Students using sort() in Python m1 = int(input("Enter marks of student number 1: ")) m2 = int(input("Enter marks of student number 2: ")) m3 = int(input("Enter marks of student number 3: ")) m4 = int(input("Enter marks of student number 4: ")) m5 = int(input("Enter marks of student num...
916910d6ca390870186931278824d3d96510137b
sahilbnsll/Python
/Object Oriented Programming/Program01.py
148
3.703125
4
# Creating Class class Number: def sum(add): return (add.a + add.b) num = Number() num.a = 4 num.b = 3 s = num.sum() print(s)
d6a5f32aea3864aea415514dad886b81d434a8cc
sahilbnsll/Python
/Inheritence/Program01.py
949
4.25
4
# Basics of Inheritance class Employee: company= "Google Inc." def showDetails(self): print("This is a employee") class Programmer(Employee): language="Python" company= "Youtube" def getLanguage(self): print(f"The Language is {self.language}") def showDetails(self): ...
6e0f7759356bbfbf474fc5af93eb902e8a875661
sahilbnsll/Python
/Projects/Basic_Number_Game.py
406
4.15625
4
# Basic Number Game while(True): print("Press 'q' to quit.") num =input("Enter a Number: ") if num == 'q': break try: print("Trying...") num = int(num) if num >= 6: print("Your Entered Number is Greater than or equal to 6\n") except Exception as e: ...
f6312249a01979a968a18d9765f44fbc323a55d2
sahilbnsll/Python
/Fuctions and Recursion/Practise Set/Problem03.py
187
4.0625
4
# Preventing python print() to print a new line at the end print("Hello,", end=" ") # By default, this end is end="\n" print("how", end=" ") print("are", end=" ") print("you?", end=" ")
b99568f0c3b67265183fef5bc7718bfb3aa193b8
sahilbnsll/Python
/Dictionary/Practise Set/Problem02.py
388
3.65625
4
# problem 2. - allow 4 friends to enter their favourite language as Values favLang={} a= input("Enter your favourite language Sahil: ") b= input("Enter your favourite language Dhruv: ") c= input("Enter your favourite language Kshitij: ") d= input("Enter your favourite language Parth: ") favLang['Sahil'] = a favLang['Dh...
ed8513152295d58be6afdd3919223131d9a941de
sahilbnsll/Python
/Loops/Practise Set/Problem01.py
199
4.0625
4
# Problem 1. Multiplication Table. i=1 num=int(input("Enter a number: ")) for i in range(1,11): print(str(num)+" X "+str(i)+" = "+str(num*i)) #print(f"{num} X {i} = {num*i}") #same as above
94a3197a7042ed1352ad7b71df61fa0c1dca038b
sahilbnsll/Python
/Files Input Output/Program04.py
323
3.5
4
# With Statement with open('sample04.txt', 'r') as f: # by using with statement, you don't need to close the file as f.close() as it automatically done a = f.read() print(a) with open('sample04.txt', 'w') as f: a = f.write("With Statement Writing") #this line should be overwrite in your sample file ...
97061e39c0f754dc217ad865082a913e36cc6bcb
sahilbnsll/Python
/Object Oriented Programming/Practise Set/Problem05.py
1,095
3.90625
4
# Problem 5. Creating a Class train which has methods to book tickets, get status and get fare info. class Train: def __init__(self,myName,name,fare,seats): self.myName = myName self.name = name self.fare =fare self.seats = seats def getStatus(self): print(f"The name of...
e60ae97af8c17ffa38e9d63a15f0d7adb384e4cf
hihello-jy/portfolio
/과제06(이준영)-최빈값 찾기.py
412
3.8125
4
from collections import Counter def findMax(numbers): c=Counter(numbers) numbers_freq=c.most_common() max_count=numbers_freq[0][1] modes=[] for num in numbers_freq: if num[1]==max_count: modes.append(num[0]) max_value=modes[-1] return max_value a1=[...