blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
baefa5eaf3afaae33952a1ebc4c53fd3c1882086
Sauvikk/practice_questions
/Level7/Dynamic Programming/Word Break.py
1,056
3.953125
4
# Given a string s and a dictionary of words dict, determine if s can be segmented into a # space-separated sequence of one or more dictionary words. # # For example, given # # s = "myinterviewtrainer", # dict = ["trainer", "my", "interview"]. # Return 1 ( corresponding to true ) because "myinterviewtrainer" can be seg...
93a48eba826b20afb8ceae2cab4be4c249b68c3a
Sauvikk/practice_questions
/Level6/Trees/Construct Binary Tree From Inorder And Preorder.py
1,374
3.96875
4
# Given preorder and inorder traversal of a tree, construct the binary tree. # # Note: You may assume that duplicates do not exist in the tree. # Example : # # Input : # Preorder : [1, 2, 3] # Inorder : [2, 1, 3] # # Return : # 1 # / \ # 2 3 from Level6.Trees.Binar...
7708927408c989e6d7d6a297eb62d27ca489ee49
Sauvikk/practice_questions
/Level6/Trees/BinaryTree.py
2,379
4.15625
4
# Implementation of BST class Node: def __init__(self, val): # constructor of class self.val = val # information for node self.left = None # left leef self.right = None # right leef self.level = None # level none defined self.next = None # def __str__(self): ...
3aa92d66e2535e8f29c538ea4d62a928dcac1c6d
Sauvikk/practice_questions
/Level7/Dynamic Programming/Max Product Subarray.py
990
3.6875
4
# Find the contiguous subarray within an array (containing at least one number) which has the largest product. # Return an integer corresponding to the maximum product possible. # # Example : # # Input : [2, 3, -2, 4] # Return : 6 # # Possible with [2, 3] # http://yucoding.blogspot.in/2014/10/leetcode-quesion-maximum-p...
a863a7a5670ee737a2bfadcea0bdfe193aefabb0
Sauvikk/practice_questions
/Level3/Strings/Roman To Integer.py
1,303
3.546875
4
# Given a roman numeral, convert it to an integer. # # Input is guaranteed to be within the range from 1 to 3999. # # Read more details about roman numerals at Roman Numeric System # # Example : # # Input : "XIV" # Return : 14 # Input : "XX" # Output : 20 class Solution: @staticmethod def solution(string): ...
b07db3110b76bfc520d4b6c9c08e7946c65e0729
Sauvikk/practice_questions
/Level3/Two Pointers/Remove Element from Array.py
910
3.90625
4
# Given an array and a value, remove all the instances of that value in the array. # Also return the number of elements left in the array after the operation. # It does not matter what is left beyond the expected length. # # Example: # If array A is [4, 1, 1, 2, 1, 3] # and value elem is 1, # then new length is 3, and...
ac7c9d60f30fe32645ce91b43692610d133230bc
Sauvikk/practice_questions
/Level4/LinkedLists/Reverse Link List II.py
1,244
4.0625
4
# Reverse a linked list from position m to n. Do it in-place and in one-pass. # # For example: # Given 1->2->3->4->5->NULL, m = 2 and n = 4, # # return 1->4->3->2->5->NULL. # # Note: # Given m, n satisfy the following condition: # 1 ≤ m ≤ n ≤ length of list. Note 2: # Usually the version often seen in the interviews i...
4a0eca90de3ce7fb0ab6decb0ec6aadb32c1a9fa
Sauvikk/practice_questions
/Level6/Trees/Identical Binary Trees.py
998
4.15625
4
# Given two binary trees, write a function to check if they are equal or not. # # Two binary trees are considered equal if they are structurally identical and the nodes have the same value. # # Return 0 / 1 ( 0 for false, 1 for true ) for this problem # # Example : # # Input : # # 1 1 # / \ / \ # 2 3 ...
7a0344562a91aa7afd4413b71b045df2e4d1618d
Sauvikk/practice_questions
/Level2/Math/Excel Column Number.py
374
3.59375
4
import math class Solution: @staticmethod def solution(n): size = len(n) - 1 res = 0 power = 0 while size >= 0: curr_char = n[size] res += int(math.pow(26, power) * (ord(curr_char) - ord('A') + 1)) size -= 1 power += 1 return...
f01f207884a49e01abbe088eab7fb9f9080b0dce
Sauvikk/practice_questions
/Level4/LinkedLists/Palindrome List.py
1,569
4.03125
4
# Given a singly linked list, determine if its a palindrome. # Return 1 or 0 denoting if its a palindrome or not, respectively. # # Notes: # - Expected solution is linear in time and constant in space. # # For example, # # List 1-->2-->1 is a palindrome. # List 1-->2-->3 is not a palindrome. from Level4.LinkedLists.L...
6b29be0ef1d29f8a339946489031902b36ca0494
Sauvikk/practice_questions
/Level8/Capture Regions on Board.py
2,104
3.734375
4
# Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. # # A region is captured by flipping all 'O's into 'X's in that surrounded region. # # For example, # # X X X X # X O O X # X X O X # X O X X # After running your function, the board should be: # # X X X X # X X X X # X X X X # X O X X ...
60bd6a8acbae73c72ee3de7585009855256c0cdc
Sauvikk/practice_questions
/Level3/Bit Manipulation/Single Number.py
561
3.921875
4
# Given an array of integers, every element appears twice except for one. Find that single one. # # Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? # # Example : # # Input : [1 2 2 3 1] # Output : 3 class Solution: @staticmethod def solution(arr): ...
cfeee7ddf64c1e21b4aca25370aea489bc15be6a
TrellixVulnTeam/Python-Exercises_3RSX
/Training/Training.py
15,093
3.609375
4
import tkinter from tkinter import * #Page 107~111 class ParentWindow(Frame): def __init__(self, master): Frame.__init__(self) self.master = master self.master.resizable(width=False, height=False) self.master.geometry(f'{700}x{400}') self.master.title('Learning Tkinter'...
8bf85ec04b5f5619a235f1506b7226597a75bef0
Kaushikdhar007/pythontutorials
/kaushiklaptop/NUMBER GUESS.py
766
4.15625
4
n=18 print("You have only 5 guesses!! So please be aware to do the operation\n") time_of_guessing=1 while(time_of_guessing<=5): no_to_guess = int(input("ENTER your number\n")) if no_to_guess>n: print("You guessed the number above the actual one\n") print("You have only", 5 - time_of_gue...
d490be3c8d03e183441c0409ede57369766f695e
Kaushikdhar007/pythontutorials
/kaushiklaptop/sayangym example2.py
1,185
3.6875
4
# QUESTION:there is n seats in a row.you are given a string s with length n ; for each valid i,the i'th character of s is '0' if the i'th seat is empty or '1' if there is someone sitting in that seat. t wo people are friends if they are sitting next to each other. two friends are always are part of the same group of fr...
9c3b52d69f87a42ca2160dfd9ec4ee713b2bc444
juliazrtsk/programmer_school_python
/15_while.py
4,992
4.375
4
# Мы с вами уже изучили цикл for # Если вы его забыли, бегом искать нужный файлик и повторять # Если вспомнили, продолжим :) # Цикл for - не единственный вид цикла в программировании # Сегодня мы изучим с вами новый цикл # Он называется while (читается "вайл") # В переводе while означает "пока" # Давайте сразу к прим...
89a6c4aa2f721d5ea594de77df4db16412182987
juliazrtsk/programmer_school_python
/SnakeGame/01_window_and_up_key.py
2,443
3.5
4
# Как обычно, в самом начале импортируем библиотеку import turtle # Это константа - переменная, значение которой мы не будем менять по ходу выполнения программы # В ней лежит величина шага, котороый будет делать змея step = 10 # Настройка окна win = turtle.Screen() # Создаём объект, с помощью которого мы сможем управ...
65073c8b0166563cde44701c2850fc3aea535463
Faisal-Alqabbani/python_fudamentals_assigments
/OOP/user/alqabbani_faisal.py
977
3.875
4
class User: def __init__(self, name): self.name = name self.balance = 10000 def make_deposit(self,amount): if amount <= 0: print('The amount must be greater than zero') else: self.balance += amount return self def make_withdrawal(self,...
e4d8c093844328eefc7d366c8bf254a73daddf08
LMsmith/tic-tac-toe
/game.py
3,239
3.671875
4
"""game.py - File for collecting game functions.""" import logging from google.appengine.ext import ndb import endpoints import random def check_win(positions, move): """Returns a status string of 'win' or 'continue' Args: positions: The X's or O's, depending on player turn move: The most rece...
f6fe437f066f6732dd994591bd5d2afc9814123c
wangyouwei2016/51rebootstudy
/1day/作业.py
1,757
3.875
4
#!/usr/bin/python # -*- coding: utf-8 -*- # http://blog.csdn.net/onlyanyz/article/details/45177643 参考的算法讲解 # pycharm技巧: 选中 ctrl+/ 批量注释 ctrl+d 快速复制 ctrl+e 快速删除 shift+enter 快速换行 ctrl+alt+l 遵守PEP8编码规范的格式化 # 方法1 unsortedList = [1 , 2 , 3 , 2 , 12 , 3 , 1 , 3 , 21 , 2 , 2 , 3 , 4111 , 22 , 3333 , 444 , 111 , 4 , 5 ...
d3f548a840828e2ee1fea68ccae5e09b10edd5de
Norskeaksel/My-solutions-to-Leetcode-problems
/Valid_Palindrome.py
307
3.515625
4
class Solution: def isPalindrome(self, s: str) -> bool: s=s.lower() print(s) regex = re.compile('[^0-9a-z]') s=regex.sub('', s) print(s) l=len(s) for i in range(l//2): if s[i]!=s[l-1-i]: return False return True
23dcf97cc27e70c5f2ab2a499c72b9e7d200963b
hirethissnake/2017
/app/Snake.py
4,541
4.03125
4
"""Independent snake object for use in Game.""" class Snake: """ Feisty snake object. Has the following attributes: size (int) - > 0, describes length of snake identifier (uuid) - unique identifier describing for each snake coords ([coords]) - array of [x,y...
84565f3ba1ffeafb0142fc91352a38594cd27d8e
i5m/cs_schools
/ps1b.py
895
3.9375
4
def get_int_input(str_to_show): try: var = int(input(str_to_show)) return var except: return get_int_input(str_to_show) def main(): annual_salary = get_int_input("Annual Salary: ") portion_saved = get_int_input("Percentage saved per month out of 100: ") total_cost = get_int_...
be99bff4b371868985a64a79a23e34be58a0831f
KrishnaPatel1/python-workshop
/theory/methods.py
1,722
4.28125
4
def say_hello(): print("Hello") print() say_hello() # Here is a method that calculates the double of a number def double(number): result = number * 2 return result result = double(2) print(result) print() # Here is a method that calculates the average of a list of numbers def average(list_of_numbers): ...
19f67bb106389b6c796e3e81ad41faa285a3d579
mf2492/percolation
/percolate.py
3,264
3.8125
4
################################################# #Author: Michelle Austria Fernandez #Uni: mf2492 # #Program: percolate.py #Overview: Contains functions that runs the #percolation simulations ################################################# import numpy as np import os def gridFile(): """Prompts user to eith...
a302c77cc096388b41f6b6c08dc6722d83f4792a
scottshull/Beer_Song-2
/Beer_song2.py
268
3.796875
4
number = 99 while number >= 1: print (str(number) + " bottles of beer on the wall, " + str(number) + " bottles of beer.") print ("if one of those bottles should happen to fall") number -= 1 print (str(number) + " bottles of beer on the wall.")
6631f58668a892977a251955f7d4301bdf8a0727
JooHis/Euler
/Problem6_sumofnatural.py
253
3.5625
4
def main(): numbers = [] numbers_square = [] for i in range(1, 101): numbers.append(i) for j in range(1, len(numbers)+1): numbers_square.append(numbers[j-1]**2) print((sum(numbers))**2 - sum(numbers_square)) main()
157851270dbf9157dd88a88bfe73abdac9a630d3
TurbulentCupcake/PythonLearning
/MyFirstClass.py
904
3.578125
4
__metaclass__ = type class Person: def setName(self, name): self.name = name def getName(self): return self.name def greet(self): print "Hello, world! I'm %s." %self.name class Secretive: def __inaccessible(self): print "Bet you can't see me..." def accessible(self): print "The secret message i...
6aa525dca1e1706fb98af98b3505d63e0f9af33d
mehulchopradev/first-python
/xyz/supercoders/modules/math.py
408
3.765625
4
# math.py -> math def isEvenOrOdd(n): '''take in n and return a string "even" or "odd"''' return "Odd" if n % 2 else "Even" # testing the functions in the module # magic variable print(__name__) # when running this module separately __name__ = '__main__' # when running this module as part of an import __name__ = 'ma...
e877edd10ee6819c51a5f763c04a02753506028f
mehulchopradev/first-python
/professor.py
446
3.5625
4
from person import Person class Professor(Person): def __init__(self, name, gender, subjects, contact=None): super().__init__(name, gender, contact) # calls the Person class constructor ''' Person.__init__(self, name, gender) ''' self.subjects = subjects # forced t...
8e0be5ef4b1c748f40df19cc63cee5b3023569ea
ashutoshm1771/Source-Code-from-Tutorials
/Python/19_python.py
205
4.0625
4
groceries = {'cereal', 'milk', 'starcrunch', 'beer', 'duck tape', 'lotion', 'beer'} print(groceries) if 'milk' in groceries: print("You already have milk hoss!") else: print("Oh yea, you need milk!")
90fec32f73734fe80caf499592e50c140c881b78
ashutoshm1771/Source-Code-from-Tutorials
/Python/09_python.py
296
3.8125
4
#from 0 to 10 for x in range(10): print(x) print("") #from 5 to 12 for x in range(5, 12): print(x) print("") #from 10 to 40 increment value 5 for x in range(10, 40, 5): print(x) print("") #While loop buttcrack = 5 while(buttcrack < 10): print(buttcrack) buttcrack += 1
8a854cdb27e9d56e28be4e9a3c613261baaef136
sbikash-dev/python-impl-data-structures
/heaps.py
2,499
3.578125
4
''' Implement Heap Data Structure (using Array). 1. minHeap 2. maxHeap ''' def minHeapify(arr, i): index = i n = len(arr) leftChild = 2*i + 1 rightChild = 2*i + 2 if (rightChild < n) and (arr[index] > arr[rightChild]): index = rightChild if (lef...
7b5018c93a21844025317efe9e1d63f6b39a1660
kevinS-code/gapyear
/[2nd]ATM.py
1,573
3.796875
4
#ATM.py money = 20000 print('กด 1 : ถอดเงิน') print('กด 2 : เช็คยอดเงินเงิน') print('กด q : ออกจากระบบ') print('------------') menu = input('กรุณาเลือกเมนู: ') #user เลือกแล้วเราจะเก็บเมนูไว้ while menu != 'q': if menu == '1': print('<<<< ถอดเงิน >>>>') withdraw = int(input('กรุณากรองจำนวนเงิน: '...
e83f064894c6d9a9a64de0bfbfc59f9d99640b79
ArmstrongYang/StudyShare
/Python/string.py
371
4.09375
4
#!/usr/bin/python # -*- coding: UTF-8 -*- str = ('Hello World!') print str # 输出完整字符串 print str[0] # 输出字符串中的第一个字符 print str[2:5] # 输出字符串中第三个至第五个之间的字符串 print str[2:] # 输出从第三个字符开始的字符串 print str * 2 # 输出字符串两次 print str + "TEST" # 输出连接的字符串
0efd3c6d587eaf6406f5663a8ad310791a4b28d1
ArmstrongYang/StudyShare
/Python/shuffle.py
773
3.5625
4
#! usr/bin/python # coding :utf-8 import copy def shuffle(dic): lst = [] if dic['k'] == 0: return dic['l'] else: lst = copy.deepcopy(dic['l']) for i in range(dic['n']): dic['l'][2*i] = lst[i] dic['l'][2*i+1] = lst[i+dic['n']] dic['k'] = dic['k'] - 1 ...
1264dcc56e287f6045788940dc366e09ae5296e2
hoanghuyen98/fundamental-c4e19
/Session04/homeword/turtle_2.py
365
4
4
from turtle import* import random shape("turtle") colors = ['red', 'green', 'blue', 'white', 'yellow', 'pink', 'purple', 'orange'] bgcolor("black") size = 1 speed(-1) for i in range(100): for j in range(4): color(random.choice(colors)) forward(size) left(90) left(5) size = size+3 ...
45503c26f013260c74e10508d82eada3df377039
hoanghuyen98/fundamental-c4e19
/Session01/turtle_ex.py
228
4.0625
4
from turtle import * shape("turtle") color("black") speed(-1) soCanh = int(input("How much edge you want : ")) print("Number of side: ", soCanh) for i in range(soCanh) : forward(100) left(360 / soCanh) mainloop()
06bea009748a261e7d0c893a18d60e4b625d6243
hoanghuyen98/fundamental-c4e19
/Session05/homeword/Ex_1.py
1,302
4.25
4
inventory = { 'gold' : 500, 'pouch': ['flint', 'twine', 'gemstone'], 'backpack' : ['xylophone', 'dagger', 'bedroll', 'bread loaf'] } # Add a Key to inventory called 'pocket' and Set the value of 'pocket' to be a list print("1: Add a Key to inventory called 'pocket' and Set the value of 'pocket' to be a...
2892926d2543128cd90574c3f6d51a43d7b28b6a
hoanghuyen98/fundamental-c4e19
/Session02/rand.py
490
3.5625
4
# # from random import randint # # numb = randint(0,100) # # print(numb) # from random import randint # numb = randint(0,100) # if numb < 30 : # print(" :< ") # elif numb < 60 : # print(" +__+ ") # else : # print(" ^__^ ") n = 10 for i in range(n): for j in range(n): if j < n - i - 1: ...
ddc625938250819c922150061152ab0ca36360c8
hoanghuyen98/fundamental-c4e19
/Session05/homeword/Ex_20_8_1.py
208
3.84375
4
strings = input(" Enter a string ") letter_counts = {} for letter in strings: # print(letter) letter_counts[letter] = letter_counts.get(letter, 0) + 1 # print(letter_counts) print(letter_counts)
05ba21e69dab1b26f1f98a48fc3c186d37f8097b
hoanghuyen98/fundamental-c4e19
/Session02/Homeword/BMI.py
373
4.25
4
height = int(input("Enter the height : ")) weight = int(input("Enter the weight : ")) BMI = weight/((height*height)*(10**(-4))) print("BMI = ", BMI) if BMI < 16: print("==> Severely underweight !!") elif BMI < 18.5: print("==> Underweight !!") elif BMI < 25: print("==> Normal !!") elif BMI < 30: print("...
7bde2e83785eb3c44a6f2b69d1dff64bde4642e1
Hengle/AutoAbstract
/calculate_df.py
663
3.5625
4
from get_data import read_data from split_sentence import SplitSentence from split_word import SimpleSplitWord if __name__ == '__main__': articles = read_data() articles = [SplitSentence(article).split() for article in articles] articles = [[SimpleSplitWord(sentence).split() for sentence in article ] for article i...
5dcd6d8bab47ae6d5eac61616580a52cc572e5a8
j-how/fisher
/app/libs/helper.py
307
3.640625
4
import re def is_isbn_or_key(word): word = word.replace('-', '') prog = re.compile(r'^(\d{13})$|^(\d{10})$') if prog.match(word): isbn_or_key = 'isbn' else: isbn_or_key = 'key' return isbn_or_key if __name__ == '__main__': print(is_isbn_or_key('99937-0-014-2'))
2bb7320fdd7042ad410a1d10f7b58b508f801c1a
nanfeng-dada/leetcode_note
/easy/27.removeElement.py
1,224
3.96875
4
# 在python中复制操作重新赋一个标识符,所以可以直接赋值 class Solution(): def removeElement(self, nums: list, val: int) -> int: lst=[] for i in range(len(nums)): if nums[i]!=val: lst.append(nums[i]) nums[:]=lst return len(lst) #python计数与删除操作 class Solution2: def removeE...
10e747d03c59a1a2f715b752a9f46fcb7351f750
nanfeng-dada/leetcode_note
/easy/112.hasPathSum.py
1,166
3.703125
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None #采用堆栈进行DFS,求解所有路径和,最后判断指定和是否在 class Solution: def hasPathSum(self, root: TreeNode, sum: int) -> bool: if not root: return False q = [(ro...
66e9d55b1eef5d6f57e8ae45f397f3ce087b9b56
nanfeng-dada/leetcode_note
/easy/202.isHappy.py
918
3.578125
4
# 按照快乐数的定义做就是了 # 还有一种找到了不快乐数的循环,这种非一般的解法不做考虑,机试的时候一般想不到 class Solution: def isHappy(self, n: int) -> bool: for _ in range(100): n1 = 0 while n: n1 += (n % 10) ** 2 n //= 10 if n1 == 1: return True n = n1 ...
78a89301dca15e8d0709a881fa53eae4eb30e14a
piglaker/PAT
/AdvancedLevel_Python/1145.py
1,520
3.640625
4
def get_prime(Msize): number = Msize def is_prime(number): for i in range(2, number): if number % i == 0: return False else: return True while 1: if is_prime(number): return number else: number += 1 Msize, M, ...
540983122e053194caafc99d91a49f38da01ae19
StarliteOnTerra/csci127-Assignments
/hw_02/pig.py
474
3.5625
4
# By Jadeja Baptiste & Stacy Li def part_pig_latin(name): vowels = ('a', 'e', 'i', 'o', 'u',) x = name[0] if x.startswith(vowels): return name + "ay" else: return name[1:] + x + "ay" print(part_pig_latin("owen")) print(part_pig_latin("evan")) print(part_pig_latin("k...
71b291f8d923465e73b69f1cbd22d1e7583bd9ec
StarliteOnTerra/csci127-Assignments
/hw_05/hw_05.py
337
3.703125
4
l = [3, 4, 5, 6, 7, 8, 9, 10, 11] def filterodd(l): for x in l: if x % 2 != 1: continue print(x) print(filterodd(l)) l = [2, 3, 4, 5, 6] def mapsquare(l): l = [2, 3, 4, 5, 6] for x in l: x = x ** 2 print(x) print(mapsquare(l)) ...
2ee4e98f1a31c2ec2f85f2e582744301bd7833df
Laurasoto98/Adversarial-Search
/MiniMax.py
1,950
3.59375
4
#class that implements the MiniMax algorithm. import random import sys import math import Square from TicTacToeAction import TicTacToeAction from AlphaBetaSearch import AlphaBetaSearch class MiniMax: def __init__(self): self.numberOfStates=0 #< counter to measure the number of iterations / stat...
5e4b6bd85d831e399fab92b6f745a6f7b0847cdb
kgraghav/expsolver
/expsolver.py
7,105
3.703125
4
class Solver: """ ***Purpose: Solve "exp = 0"*** Inputs: a. exp: expression to be solved e.g. 2*x**2+3*x-100=0 Solve: a. solve(): solves for "exp = 0" Outputs: a. get_order(): Integer order of equation "exp=0" b. get_root():...
d8a8a3a1caed51d397ab4ffe6e23f6ba7e1092c4
arcsingh/DG_Work
/replaceText.py
869
4.0625
4
# Script to read a file and replace the _ with spaces #Step1: Open the file to be modified and store the content in memory #Step2: Replace the text with ' ' using the replace function #Step3: Write the replaced text back to a new file. Note: Can be written to the same file as well #Step4: We can also provide the filep...
9b61d09c177e304bfde25bc6b39050387d86a241
jatin711-debug/PythonProjectVirusdetectorTkinter
/menu.py
3,533
4.0625
4
from tkinter import * from tkinter.messagebox import * txt=""" This project consists of scanning of virus in the following: 1: Domain :-When referring to an Internet address or name, a domain or domain name is the location of a website.\n For example, the domain name "google.com" points to the IP address "216.58.216...
6909505f9fbd960a8cdfb24c294e006a7b695261
bbaja42/projectEuler
/src/problem15.py
714
3.625
4
''' Starting in the top left corner of a 2x2 grid, there are 6 routes (without backtracking) to the bottom right corner. How many routes are there through a 20x20 grid? ''' from math import factorial def find_routes(): ''' Since backtracking is not allowed, it is only possible to go right and bottom. ...
e1139905c3f17bd9e16a51a69853a0923160c84f
bbaja42/projectEuler
/src/problem14.py
1,496
4.15625
4
''' The following iterative sequence is defined for the set of positive integers: n n/2 (n is even) n 3n + 1 (n is odd) Using the rule above and starting with 13, we generate the following sequence: 13 40 20 10 5 16 8 4 2 1 It can be seen that this sequence (starting at 13 and finishing at 1) contains 10...
20cd326aa3fb04948413d015208658a6eb392437
nikshrimali/TSAI_END
/S8_HandsOn2/snippets.py
20,867
4.0625
4
# Write a function that adds 2 iterables a and b such that a is even and b is odd def add_even_odd_list(l1:list,l2:list)-> list: return [a+b for a,b in zip(l1,l2) if a%2==0 and b%2!=0] # Write a function that strips every vowel from a string provided def strip_vowels(input_str:str)->str: vowels = ['a', 'e', '...
d38ca5318a0687d16c49517fcaf6cac030cc1601
sys-ryan/python-django-fullstack-bootcamp
/10. Python Level One/string.py
598
4.40625
4
# STRINGS mystring = 'abcdefg' print(mystring) print(mystring[0]) # Slicing print(mystring[:3]) print(mystring[2:5]) print(mystring[:]) print(mystring[::2]) # upper print(mystring.upper()) # capitalize print(mystring.capitalize()) # split mystring = 'Hello World' x = mystring.split() print(x) mystring = 'Hello/W...
062755f73d0fc0ae3217f5db61e43ed18b53f468
guyeshet/keras-accent-trainer
/data_loader/csv_parser.py
1,567
3.5625
4
from sklearn.model_selection import train_test_split from keras import utils def split_people(df, test_size=0.2): ''' Create train test split of DataFrame :param df (DataFrame): Pandas DataFrame of audio files to be split :param test_size (float): Percentage of total files to be split into test :r...
ed62a80a5374b9115293376b791546fcd5c817c7
sudoghut/Leetcode-notes
/21. Merge Two Sorted Lists.py
1,010
3.828125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def mergeTwoLists(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """ output = [] i...
9b2cef3fdc7aef39811b0c517652bae23dc1066a
sudoghut/Leetcode-notes
/53. Maximum Subarray.py
539
3.546875
4
class Solution: def maxSubArray(self, nums): """ :type nums: List[int] :rtype: int """ sumList = [] ans = nums[0] sumNum = 0 for i in nums: print("i:%d"%i) sumNum+=i print("sumNumi:%d"%sumNum) print("ans:...
dee3f47d3b1befb9835946b10a6b96a711383dbd
drednout5786/Python-UII
/hwp_5/divisor_master.py
1,945
4.125
4
def is_prime(a): """ :param a: число от 1 до 1000 :return: простое или не простое число (True/False) """ if a % 2 == 0: return a == 2 d = 3 while d * d <= a and a % d != 0: d += 2 return d * d > a def dividers_list(a): """ :param a: число от 1 до 1000 :return...
c0f1315caa2d5eb3f1a22a49acc1dc419e3c2069
yuzhucu/AlgoBacktest
/market/interfaces/orderrouter.py
895
3.609375
4
from abc import ABCMeta, abstractmethod class OrderbookException(Exception): pass class OrderRouter(object): __metaclass__ = ABCMeta def __init__(self): self.orderStatusObservers = [] self.positionObservers = [] @abstractmethod def place_order(self, order): # send new or...
62b5cf7cf844601a99c1ecb0301708f34fe4b02d
athina-rm/function-vningar
/functionövningar/fuctionÖvningar/fuctionÖvningar/module5.py
476
3.8125
4
# Skapa en metod som du döper till HittaLangstaOrdet. Metoden skall ta som inparameter en array #med strängar. Metoden skall loopa igenom arrayen och returnera det längsta ordet. def findLongestWord(a): long=a[0] for i in a: if len(long)<=len(a[i]) : long=a[i] return long wor...
1ce923e11d53f1795a578c91accfc71a09b8e58e
Mahedi522/Python_basic
/26_Array.py
626
3.625
4
from array import * val = array('i', [5, 4, -6, 3, 7, 4]) print(val) print(val.buffer_info()) print(val.typecode) val.reverse() print(val) val.append(12) print(val) print(val[0]) for i in range(len(val)): # or for i in range val: print(val[i], end=" ") char = array('u', ['a', 'f', 'r', 'g']) print(char) f...
4ca2727580ddedb855151586875d1c9058b75518
Mahedi522/Python_basic
/70_Bubble_Sort.py
303
3.828125
4
def sort(list): temp = 0 for i in range(len(list)-1, 0, -1): for j in range(i): if list[j] > list[j+1]: temp = list[j] list[j] = list[j+1] list[j+1] = temp li = [34, 45, 57, 32, 87, 34, 9, 4, 23] print(li) sort(li) print(li)
13b0381f260fbb5ad663ac5eff67734f5117e1c4
Mahedi522/Python_basic
/16MathFunction.py
355
4.0625
4
import math x=math.sqrt(25) print(x) x=math.sqrt(15) print(x) print(math.floor(2.9)) print(math.ceil(2.9)) x=3**2 #power print(x) print(math.pow(3,2)) #another way to represent power print(math.pi) print(math.e) import math as m #concept of alise print(m.sqrt(16)) from math import sqrt,pow print(pow(4,5)) pri...
7bea960e37995bb7a8eba9b9a4f8d52345e6deab
Mahedi522/Python_basic
/37_List_Fuction.py
312
3.84375
4
lst = [23, 33, 45, 56, 6, 76, 34, 345, 99] def count(lst): even = 0 odd = 0 for i in lst: if i % 2 == 0: even += 1 elif i % 2 != 0: odd += 1 return even, odd even, odd = count(lst) print(even) print(odd) print("even: {} and odd: {}".format(even, odd))
fc846895589cb0b3d0227622ca53c4c6a62b61bc
Mahedi522/Python_basic
/strip_function.py
384
4.34375
4
# Python3 program to demonstrate the use of # strip() method string = """ geeks for geeks """ # prints the string without stripping print(string) # prints the string by removing leading and trailing whitespaces print(string.strip()) # prints the string by removing geeks print(string.strip(' geeks')) a = list...
d1b87c248a766c8704c7b26712b2306ce213ee01
Mahedi522/Python_basic
/hackerrank_Game_of_Stones.py
248
3.5625
4
def gameOfStones(num): a = "First" b = "Second" if num % 7 < 2: return b else: return a t = int(input().strip()) for t_itr in range(t): n = int(input().strip()) result = gameOfStones(n) print(result)
ad27d21501d4b59c69778bd19341a5c202c26324
Mahedi522/Python_basic
/18input.py
141
4
4
x = int(input("Enter 1st number: ")) y = int(input("Enter 2nd number: ")) # initially input function takes input as string z = x+y print(z)
21309acc49d40ee588913a574d7b163d1b5bb3e5
Mahedi522/Python_basic
/hackerrank_Apple and Orange.py
362
3.640625
4
def countApplesAndOranges(s, t, a, b, apples, oranges): x = 0 y = 0 for i in apples: if s <= (a+i) <= t: x += 1 for i in oranges: if s <= (b + i) <= t: y += 1 print(x) print(y) s = 7 t = 10 a = 4 b = 12 apples = [2, 3, -4] oranges = [3, -2, -4] countApp...
4bddf0f0af9fe99816d0ea840424a1f12469aed5
Mahedi522/Python_basic
/38_Fibonacci.py
235
3.8125
4
def fib(x): first, second = 0, 1 for i in range(x): if i <= 1: print(i) else: fibo = first + second first = second second = fibo print(fibo) fib(3)
fc4968b89fedd1793b2a9db3320529025ce8e479
Mahedi522/Python_basic
/31_multiDimentional_array_matrix.py
426
4
4
from numpy import * arr = array([ [1, 2, 3, 4, 5, 6], [4, 5, 6, 7, 8, 9] ]) print(arr) print(arr.dtype) print(arr.ndim) print(arr.shape) print(arr.size) arr2 = arr.flatten() # 2 dimension to 1 dimension print(arr2) print("Reshape") arr3 = arr2.reshape(3,4) # 1 dimension to 3 dimension print(arr3) print("2 ...
155d2e79918526e4e73e3b80a5675bb7403bda10
jiataoxiang/Chopsticks-and-subtractSquare
/new_version.py
9,094
3.625
4
class Current_state(): def __init__(self, movement): self.movement = movement class Chopsticks_state(Current_state): def __init__(self, movement, left1,left2,right1,right2): """ Create a new Chopsticks self """ Current_state.__init__(self,movement) self.left1 = ...
80a8695e8bb0f05afa36e377f5f2a9635dd99de7
Justinnn07/python-works
/app.py
1,885
4.09375
4
# data types justin = (str(13)) """ str, float, type, variables, int """ # print(type(justin)) # operators a = 3 b = 2 """ addition, subtraction, division(print) normally """ # exponents, remainders , flow division """ print(a%b) remainder """ """ print(a**b) exponents """ """ print(a//b) """ # inline function "...
15e75d4c881460793d2dfa74c0f80c037b32d320
ajivani/movie-trailer-website
/media.py
716
3.515625
4
import webbrowser class Movie(): """Class that is a container for movies. Used with fresh_tomatoes.py to generate an html page displaying movies. """ ## def __init__(): ## self.title = "" ## self.storyline = "" ## self.poster_image = "" ## self.trailer_youtube_url = "" MOV...
3398e9e6043a0fc5d300110d89b16f65085d9485
Tillotama12/Tic-Tac-Toe
/day5.py
660
4
4
#ACCESSING MEMBERS(VARIABLE AND METHOD) OF ONE CLASS INSIDE ANOTHER CLASS ''' class Employee: def __init__(self,name,age,sal,city): #constructor self.name=name self.age=age self.sal=sal self.city=city def display(self): #instance print(self.name) print(self.age)...
0b9e842cbeb52e819ecc2a10e135008f4380f8ed
monadplus/python-tutorial
/07-input-output.py
1,748
4.34375
4
#!/user/bin/env python3.7 # -*- coding: utf8 -*- ##### Fancier Output Formatting #### year = 2016 f'The current year is {year}' yes_votes = 1/3 'Percentage of votes: {:2.2%}'.format(yes_votes) # You can convert any variable to string using: # * repr(): read by the interpreter # * str(): human-readable s = "Hello,...
41c4e9a1d7d865fcb78d78cc2796f46f45cadcda
Conormc98/pyhangman
/gamemodes.py
3,142
3.71875
4
# # pyhangman - 'Hangman' clone developed in python # CREATED BY CONOR MCCORMICK # Script to run the games # import wordhandler import os def player_vs_cpu(): print('\nPlayer vs CPU game.\n') word, definition = wordhandler.get_word() init_game(word, definition) def player_vs_player(): print('\nPlayer...
abb20148c49272284d9820e63c367d2a9302b734
BWizz/TI_Hercules_Development
/LIDAR PC Visualization Applications/Python_Visualization/Lidar_Animation.py
1,218
3.90625
4
""" A simple example of an animated plot """ import numpy as m import matplotlib.pyplot as plt import matplotlib.animation as animation import serial ser = serial.Serial('COM5') ser.baudrate = 115200 ser.bytesize = 8 ser.parity='N' ser.stopbits=1 plt.ion() figure = plt.figure() plt.plot([0], [0],'.') ax = plt.gca() ...
c920125a46523e7319c17d28b7814cb48be44103
Luciana1012/Term-5
/starTriangle.py
356
3.765625
4
# def starTriangle(numberOfLine) # numberOfLine = 9 # numberOfLine = 1("*") # numberOfLine = 2("*+**") # print () def starTriangle(numberOfLine): currentLine = 1 for x in range(0, numberOfLine): numberOfStars = currentLine + (x * 2) print (" " * (numberOfLine-x), "x" ...
809de699e91de3aa4812066e8a05908c025d8142
CesarBoria/backUpProject
/Anton and polyhedrons.py
370
3.875
4
polyhedrons = {'Tetrahedron': 4, 'Cube': 6, 'Octahedron': 8, 'Dodecahedron': 12, 'Icosahedron': 20} number_polyhedrons = int(input()) list_polyhedrons = [] for i in range(number_polyhedrons): list_polyhedrons.append(input()) faces = 0 for i in range(len(list_polyhedrons)): faces += polyhedrons[list...
f4cd623de0c3f572d3a7c21dceb73e484702f3fc
kiram15/ChristmasPacman
/Pacman.py
3,307
3.53125
4
#grinch class Pacman: def __init__(self, Maze): self.location = (5,1) self.maze = Maze() def getLocation(self): return self.location def actions(self): walls = [(0,0),(0,1),(0,2),(0,3),(0,4),(0,5),(0,6), (1,0),(2,0),(3,0),(4,0),(5,0),(6,0), ...
a6e45809dea70e29d090375d1dca15cec867d981
allanko/real-time-red-line
/Control.py
460
3.6875
4
import math from IllegalArgumentException import * class Control: def __init__(self, lon, lat, s, theta): # Check to make sure theta in range if (theta<-math.pi or theta>=math.pi): raise IllegalArgumentException("theta out of range") self.__lon = lon self.__lat = lat self.__s = s self.__theta = the...
1a6d006285b2904126669759afbedbc817c26443
euvictorfarias/Filtros-Chebyshev2
/principal.py
3,209
3.515625
4
# -*- coding: utf-8 -*- from funcoes_cheb2 import * # Boas Vindas print("\nBem Vindo(a)!\n") print("--------------------------------------------------------------------") print("Tipos de Filtros Chebyshev 2:") print("(PB) - Passa-Baixa\n(PA) - Passa-Alta") print("(PF) - Passa-Faixa\n(RF) - Rejeita-Faixa") print("----...
310bd0d238c14f35a0ac9c6a8224b6d7fac97780
arunpandian17/python-problemsolving-programs
/zoho qn.py.py
419
3.59375
4
'''given a array of numbers and a numbers k print the max possible k digit numbers which can be form using given numbers input: 4 1 4 973 97 3 output: 974 ''' import itertools as it n=int(input()) a=input().split() b=int(input()) c=list() for i in range(0,n+1): d=list(it.permutations(a,i)) for j ...
70e65b0ba9069b2aab12d6668bb7d08fa0f1913e
arunpandian17/python-problemsolving-programs
/fibonacci.py
463
4.09375
4
def fib(n): a, b = 0, 1 count = 0 if n <= 0: print("Please enter a positive integer") elif n == 1: print("Fibonacci sequence upto",n) else: print("Fibonacci sequence:") while count < n: print(a) c = a + b a = b b = c ...
39e6f81018ea224401cf4c663245f2df15e19696
arunpandian17/python-problemsolving-programs
/extract num.py.py
184
3.578125
4
'''a=input() sum=0 res=0 a=int(a) while int(a)>0: b=int(a)%10 sum+=b a//=10 while sum>0: sum1=sum%10 res+=sum1 sum//=10 print(res) ''' a=4 c=(a<<3)-a print(c)
0ad6fba21fcf3f030a7421322de0fcbbbfc119f0
miczek2309/logia
/wiatraki.py
1,647
3.65625
4
import turtle t = turtle.Pen() t.speed(0) t.left(90) kratka = 26 def wiatrak(): t.forward(kratka * 3) t.color("black", "orange") t.begin_fill() t.right(90) t.forward(kratka * 2) t.left(135) t.forward(36.77) t.left(45) t.forward(kratka) t.left(90) t.forward(kratka) t.sethe...
d6228dec0847ca4d3cc5d34c07ce66a795c49682
miczek2309/logia
/max_pod_listy.py
204
3.796875
4
def max_listy_list(lista): for i in lista: reka = 0 for x in i: if x > reka: reka = x print(reka,end=" ") max_listy_list([[2, 5], [8, 10], [0, 1]])
2453dd359e7434bddc63fec4f3fab8b6dba97b19
KenOtis/-Automate-The-Boring-Stuff--Youtube-tutorials
/ATBSLesson5.py
511
4.0625
4
#if else statements #If statement name = 'alice' if name == 'alice': print ('Hello Alice') print ('Done') #If else Statement--> Password password='Pencil' if password=='Pencil': print("Acess Granted") else: print("Wrong Password") name='Kenny' age= 21 if name=='Alice': print('Hell...
1262490a7623b49b78f664afe6e697492c3c3ace
harbungenTA/python
/index.py
212
3.609375
4
print("Moj program") print("Podaj swoje imie:") imie=input() print("Twoje imie:") print(imie) x = [1, 2, 3, "ein", "duo"] print(x) print(x[0]) print(x[0:1]) print(len(x)) for e in x: pass
88fe4f96bbd9c35bc4bb02643525a09e919e1a4a
joyfeel/leetcode
/leetcode-algorithms/125. Valid Palindrome/solution.py
239
3.5
4
# # @lc app=leetcode id=125 lang=python3 # # [125] Valid Palindrome # class Solution: def isPalindrome(self, s: str) -> bool: clean_list = [ c for c in s.lower() if c.isalnum() ] return clean_list == clean_list[::-1]
4c14fce06e4ee571f3cea253a07fa49d7b9ea8ce
Jovian2000/forever-young
/derde-opdracht.py
118
3.984375
4
for time in range(1,13): print(str(time) + ":00 am") for time in range(1,13): print(str(time) + ":00 pm")
ad3189f3c124b726a44f0148c6695b67e055d598
antonyngayo/react-upload
/server/db.py
1,094
3.609375
4
#!/usr/bin/python3 from sqlalchemy import create_engine, Column, Integer, String, ForeignKey, TIMESTAMP, func from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker, relationship from sqlalchemy import text Base = declarative_base() class User(Base): __tablename__ = "pe...
ceccbd79d0f1dde0b90510eaf8e9208eead6072d
Demi-Leigh/BMI-Calculator
/main.py
2,332
3.71875
4
# Designing a program that calculates your BMI import tkinter as tk import tkinter.ttk as ttk import tkinter.messagebox as messagebox # Creating a window window = tk.Tk() window.title("BMI Calculator") window.geometry("500x300") window.resizable(0, 0) # Creating labels and entry boxes for Height height_label = tk.La...
2ba4518f80b3e9e582177995541ff97e60b768ff
lgaetano/automate_the_boring_stuff
/randomQuizGenerator.py
1,097
3.9375
4
#! python3 # randomQuizGenerator.py - Creates quizzes with questions # and answers in random order, along with answer key. import random # Quiz data capitals = {'Alabama': 'Montgomery', 'Alaska': 'Juneau', 'Arizona': 'Phoenix', 'Arkansas': 'Little Rock', 'California': '...
3e9ca0a8d378d03c4ae3aa580c4f1e8b12d42953
saimkhan92/Recursion
/list_sum_recursive.py
194
3.921875
4
# Sum of a python list using recursion l=[2,5,2,6,88,4,6,8,7] def listsum(lst): if len(lst)==1: return lst[0] else: return lst[0]+listsum(lst[1:]) print(listsum(l))
b8cf28e3459fe7c637dacef97e6285289b4128d2
SeveroYug/Python-tests-and-exercises
/Разрядность и списки.py
511
3.6875
4
# Задача: вывести на экран N (вводится пользователем) чисел от 0 до бесконечности, которые делятся без остатка на свой порядок (1 на 1, 11 на 2, 111 на 3 и т.д.) n = int(input('Введите N: ')) i = 0 p = 0 lst = [] while len(lst)<n: z = len(str(i)) if i%z == 0: print(i) lst.append(i) ...