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
e6346167afc3edaf7efd90351c1c075b946bda9a
Harshad06/Python_programs
/Dictionary/01.py
218
3.53125
4
emp1 = {'fname': 'Harshad'} emp2 = {'lname': 'Shringi'} emp = emp1['fname'] + ' ' + emp2['lname'] print(emp) # Harshad Shringi emp1.update(emp2) print(emp1) # {'fname': 'Harshad', 'lname': 'Shringi'}
6824c7f37caca3e464bfacb3da444a075808cf09
Harshad06/Python_programs
/string programs/longestString.py
454
4.59375
5
# Python3 code to demonstrate working of # Longest String in list # using loop # initialize list test_list = ['gfg', 'is', 'best', 'for', 'geeks'] # printing original list print("The original list : " + str(test_list)) # Longest String in list using loop max_len = -1 for element in test_list: if len(element) > max...
f825a678ed5dbfb5b97d5621dd22931698340f64
Harshad06/Python_programs
/py-programs/homo_list2.py
519
3.796875
4
# check if list is homogeneous or not? def checkList(lst): ele = lst[0] chk = True # print(type(ele)) # Comparing each element with first item for item in lst: if type(item) != type(ele): print(item) chk = False break if (chk==True): ...
e11ea7363ff854708c5fd423a0669485a32fb099
cSyu2611/python_knock
/sec1/003.py
365
3.78125
4
import re if __name__ == "__main__": str_003 = "Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics." #method 1 print("".join([str(len(j)) for j in [i.strip(", .") for i in str_003.split()]])) #method 2 print("".join([str(len(i)) if i[-1] not in {',','.'} e...
bac67327496475ed53567351fa74c88411a55259
Bryce21/Crypto2
/point_doubling.py
1,151
3.78125
4
def point_doubling(mod, a, px, py): check = ((3 * px ** 2) + a) / (2 * py) # print(check) if not float(check).is_integer(): den_inv = pow((2 * py), mod - 2, mod) c = (((3 * px ** 2) + a) * den_inv) % mod # print(c) else: c = (((3 * px ** 2) + a) / (2 * py)) % mod rx ...
7720e049578809f84305cf5fa0d9e4bc469ff8d5
leobrasil/AlgoritmoseProgramacaoPython
/exercicio 1.py
200
3.90625
4
grade = 95 if grade >=90: print("Grade A") elif grade>=80: print("Grade B") elif grade >=70: print("Grade C") elif grade>=60: print("Grade D") else: print("Grade E") print("fim")
4360b4921820bf5519f4a23e9300e51cf5a667d8
Robbie-Wadud/-CS-4200-Project-3
/List Comprehension Finding Jones.py
483
4.21875
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 7 20:22:17 2020 @author: Robbi """ print('Let\'s find the last name "Jones" within a list of tuples') #Creating the list (firstName, lastName) names = [('Robbie', 'Wadud'),('Matt', 'Jones'),('Lebron', 'James'),('Sarah', 'Jones'),('Serena', 'Williams'),('Ashle...
426b03ea1cd9d5a46dbdc86d939c302dc17a57f7
zairulmazwan/MultivariateLSTM-Covid-19
/DateTimeFormat.py
604
4.03125
4
import pandas as pd # df = pd.DataFrame( # {"date" : ["28-04-1983", "01-04-2021"]} # ) df = pd.DataFrame( {"date" : ["28/04/1983", "01/04/2021"]} ) print(df) #df['DOB1'] = df['DOB'].dt.strftime('%m/%d/%Y') df['date'] = pd.to_datetime(df['date'], format='%d/%m/%Y') #df["date"] = pd.to_datetime(df.date).dt.str...
6c4fb1dd24886b5f91c90beb41e2f1f61869488a
JosemiOuterelo/Basicos_Python
/basicos_20.py
129
3.84375
4
#!/usr/bin/env python #-*- coding: utf-8 -*- n=int(raw_input()) for ele in range(n): if (ele>0) and (ele%2==0): print ele
77e6615697d2b92f1529259c16b8963f617187c2
sharmasourab93/JustPython
/deepcopy.py
1,028
4.53125
5
""" Python: Copy Deep Copy Vs Shallow Copy """ import copy def deep_copy(array1): array2 = copy.deepcopy(array1) print("The original elements before deep copying") for i in range(0, len(array1)): print(array1[i], end=" ") print('\r') array2[2][0] = 7 # change reflected in ...
84e8b600483e60c959b165aee7f96c88d7902c8c
sharmasourab93/JustPython
/keyword_only_args.py
2,734
3.875
4
""" Python: Keyword Only Arguments Enforce clarity with Keyword-Only Arguments """ # The problem is that it's easy to confuse the position # of the two boolean arguments that control # the exception-ignoring behaviour. # This can easily cause bugs that are hard to track down. def safe_division(number, divisor...
fdca2f44051851ad10fb9ac34b4edf16afe46cb7
sharmasourab93/JustPython
/tests/pytest/pytest_101/pytest_calculator_example/calculator.py
1,470
4.3125
4
""" Python: Pytest Pytest 101 Learning pytest with Examples Calculator Class's PyTest File test_calculator.py """ from numbers import Number from sys import exit class CalculatorError(Exception): """An Exception class for calculator.""" class Calculator: """A Terrible Calculator.""...
1be1e0530d028553e0099989161dc24ebc3e1d41
sharmasourab93/JustPython
/decorators/decorator_example_4.py
612
4.3125
4
""" Python: Decorator Pattern In Python A Decorator Example 4 Using Decorators with Parameter Source: Geeksforgeeks.org """ def decorator_fun(func): print("Inside Decorator") def inner(*args): print("Inside inner Function") print("Decorated the Function") p...
d388144e421b0934877669c0e4a1a49f6afcdf50
sharmasourab93/JustPython
/tkinter/TkInter2.py
514
3.546875
4
from tkinter import * from tkinter import ttk root=Tk() # Multiple components # some of the different widgets: Button, Label, # CanvasMenu, Text, Scale, OptionMenu, Frame # CheckButton, LabelFrame, MenuButton, PanedWindow, # Entry, ListBox, Message, RadioButton, Scrollbar, # Butmap, SpinBox, Image frame= Frame(root)...
48c10f0c45ec6cf91e1307553ed23fbc4d606522
sharmasourab93/JustPython
/oop/oop_class_object.py
1,045
4.0625
4
""" Python: Object Oriented Programming Using Class Object """ class Robot: population = 0 def __init__(self, name): self.name = name print("(Initializing "+self.name+")") Robot.population += 1 def die(self): """I am dying""" print(self.name + "is being ...
937df73a2265bef32d2ba32ca222c47c8db247b9
sharmasourab93/JustPython
/decorators/decorator_example_10.py
950
4.21875
4
""" Python: Decorator Pattern in Python A Decorator Example 10 Func tools & Wrappers Source: dev.to (https://dev.to/apcelent/python-decorator-tutorial-with-example-529f) """ from functools import wraps def wrapped_decorator(func): """Wrapped Decorator Docstring""" """ f...
579b153e633274235a6418a65a8734ccf0eafbc8
sharmasourab93/JustPython
/tests/pytest/pytest_greet_example/test_greet.py
276
3.53125
4
""" Python: Pytest Learning Pytest with Examples Greeting Example """ def greet(person): return "Hi {name}".format(**person) def test_greet(): bob = {"name": "Bob"} # Arrange greeting = greet(bob) # Act assert greeting == "Hi Bob" # Assert
d5320085808347ab18124a1886072b5b9cfdbe0f
sharmasourab93/JustPython
/oop/oop_iter_vs_next.py
947
4.375
4
""" Python: iter Vs next in Python Class """ class PowTwo: """Class to implement an iterator of powers of two""" def __init__(self, max=0): self.max = max def __iter__(self): self.n = 0 return self def __next__(self): if self.n <= self.max: ...
925f565ad01a85dd02a86fb90ca6d55ab57e9293
sharmasourab93/JustPython
/generating_coupon_code.py
737
3.6875
4
""" Python: Program to generate coupon code Using base64 module Using random module """ import os import base64 import random from math import floor def secure_rand(length=8): token = os.urandom(length) return base64.b64encode(token) def get_promo_code(num_chars): code_chars = '012345678...
888a891e172001a2eb58bdcdb7f689818958f5ec
CalvinMars/printer-enclosure
/enclosure_program_notemp.py
1,918
3.5
4
import time import RPi.GPIO as GPIO import board import neopixel pixels = neopixel.NeoPixel(board.D18, 68) # Setup fan and button GPIO pins GPIO.setwarnings(False) # Turn off warnings GPIO.setmode(GPIO.BCM) FAN_PIN = 24 BUTTON_PIN = 27 LED_PIN = 16 GPIO.setup(FAN_PIN, GPIO.OUT) # Set fan pin GPIO.setup(BUTTON_PIN, GP...
49ded3d2ebe0fd2cec11ee3dba3169612047f5fb
VentGrey/Useless-Learning
/Python3/Practices/BasicOperations/circle.py
188
4.0625
4
#!/usr/bin/env python PI = 3.1415 rad = float(input("Ingrese el radio del círculo: ")) print("El área del círculo es: ", PI * (rad **2)) print("La circunferencia es: ", 2 * PI * rad)
35866ec94465fbe497a013550aeefdea8feef979
barlaensdoonn/ML310-final-project
/code/nltk_notes.py
5,885
3.890625
4
# nltk notes and functions # 03/03/17 ''' - - - - GENERAL - - - - ''' # import 9 texts for analysis from nltk.book import * # turn gutenberg text into nltk text object (to be able to call methods like text.concordance()) emma = nltk.Text(nltk.corpus.gutenberg.words('austen-emma.txt')) emma.concordance('surprise') ...
f1fa60caa5f0fe9093536a359079f911a3bde969
AlexDurango/PLAD
/scripts/createPLAD.py
2,588
3.90625
4
import random, string, pyfiglet #Print the PLAD logo def printPLADlogo(): print("\n\n - - - - - - - - - - - - - - - - - - - - - - -") ascii_logo = pyfiglet.figlet_format("PLAD") print(ascii_logo) def main(argv): key_name, number_characters, usage_symbols = get_requirements(argv) RandomPassword =...
6ddd7227de7aa0ba64848ec8a16bd364ee21403c
Valkyrja3607/AtCoder
/atcoder.jp/abc039/abc039_c/Main.py
369
3.734375
4
s=input() #WBWBWWBWBWBWWBWBWWBWBWBWWBWBWWBWBWBW if s=="WBWBWWBWBWBWWBWBWWBW": print("Do") if s=="WBWWBWBWBWWBWBWWBWBW": print("Re") if s=="WWBWBWBWWBWBWWBWBWBW": print("Mi") if s=="WBWBWBWWBWBWWBWBWBWW": print("Fa") if s=="WBWBWWBWBWWBWBWBWWBW": print("So") if s=="WBWWBWBWWBWBWBWWBWBW": print("L...
fca31a98f82261b46b4f76fe114f81779805a89a
Valkyrja3607/AtCoder
/atcoder.jp/abc001/abc001_2/Main.py
216
3.71875
4
m=int(input()) if m<100: print("00") elif 100<=m<=5000: print(str(m//100).rjust(2,"0")) elif 6000<=m<=30000: print(m//1000+50) elif 35000<=m<=70000: print((m//1000-30)//5+80) elif m>=70: print(89)
bafd5dc06903e515e208d8c620174071cc07ec52
Valkyrja3607/AtCoder
/atcoder.jp/abc142/abc142_a/Main.py
94
3.671875
4
n=int(input()) if n%2==0: print(0.5) elif n==1: print(1.0) else: print((n//2+1)/n)
83d137859d575c98ab0081a8048aaea8611b607a
Valkyrja3607/AtCoder
/atcoder.jp/abc002/abc002_2/Main.py
79
3.625
4
w=input() ans="" for i in w: if i not in "aiueo": ans+=i print(ans)
15532bbe87384a34a3bd1f88fac73b5da1560221
Valkyrja3607/AtCoder
/atcoder.jp/abc144/abc144_d/Main.py
183
3.515625
4
a,b,x=map(int,input().split()) import math ans=0 if a*a*b/2>=x: h=2*x/(a*b) ans=math.atan(b/h) else: h=2*(a*a*b-x)/(a*a) ans=math.atan(h/a) print(ans*180/math.pi)
8ec5153babc2bb1f05db5718e6aedc8571e61d15
mifomichael/testproject
/CreateFile.py
299
3.90625
4
from tkinter import * root = Tk() def clicked(): Input = entry1.get() FileName = str("filepath" + Input + ".txt") TextFile = open(FileName,"w") entry1 = Entry(root) button1 = Button(root,text="Press to create text file", command = clicked) entry1.pack() button1.pack() root.mainloop()
28b685b64fe06801f2292b3ae3c4b609b0d905c9
MihaJjDa/uneex_python
/09hw/ex2.py
592
3.71875
4
class vector(): def __init__(self, a): self.body = [x for x in a] def __add__(self, a): tmp = vector([x+y for x,y in zip(self.body,a)]) return tmp def __radd__(self, a): tmp = vector([x+y for x,y in zip(self.body,a)]) return tmp def __getitem__(self, i): r...
0f33e297dc12e0d5075c8bebf25e6b2507032656
MihaJjDa/uneex_python
/03hw/ex2.py
238
3.65625
4
def f(x0, y0, r): x, y = eval(input()) if (x == 0) and (y == 0): return "YES" elif (x-x0)**2 + (y-y0)**2 > r*r: return "NO" else: return f(x0, y0, r) x0, y0, r = eval(input()) print(f(x0, y0, r))
b8428f1de3a5abb4d822ea99d58e05e24739864c
pashadia/treys
/tests/test_flops.py
1,632
3.6875
4
from unittest import \ TestCase, \ main from treys.flop import Flop from deuces import Card class FlopTests(TestCase): """Test the Flop class.""" _base_hand = [Card.new("Qh"), Card.new("Qs"), Card.new("Kh")] _type_1_flop = [Card.new("Qh"), Card.new("Qs"), Card.new("Qd")] _xyz_r = ["Ks", "Ad", "5...
8899f0a75289d6f9f36c1680b4016a6c5743acb3
Ishad-M-I-M/project-euler
/Q66.py
1,559
4.03125
4
from itertools import combinations from time import time from fractions import Fraction def form(n,d=1): ''' Helper function to compute continued fraction.''' i = 0 while n.imag**0.5+n.real-i*d>0: i+=1 i-=1 n = n+i*d-2*n.real d = (n.imag-n.real**2)/d return i,n,d def continuedFrac...
90f23d357c7de38d0fda99ed68a2f66cf59ed987
Sackenh/CrapsS1
/die.py
727
3.5
4
#! /usr/bin/env python3 __author__ = 'Garrett Sacken' from random import randint class Die(object): def __init__(self, beginningSides = 6, beginningStartingValue = 1, beginningColor= "Bone"): self.numberOfSides = beginningSides self.startingValue = beginningStartingValue self.color = begi...
ae519225441b4b0ca74927cc9ea472b4d38a69ea
maryella/got_python_practice
/got_demo.py
2,659
3.875
4
from pprint import pprint from characters import characters #a character count a_characters = [] for character in characters: if character['name'][0] == 'A': a_characters.append(character['name']) num_of_a_characters = len(a_characters) print("There are %s characters that start with A." %num_of_a_characte...
332349a979045aa438f80f293690460e34ba8e19
NicholasDowell/Matrix-Calculator
/Matrix.py
2,856
4.375
4
# This will be the fundamental matrix that is used for Matrix Operations # it stores a 2d grid of values # 11 # To DO: Restrict the methods so that they will not resize the matrix when they shouldnt # CONVENTION is [ROW][COLUMN] BE CAREFUL class Matrix: def __init__(self, rows, columns): self._d...
971383f0baa1427023b3884f19d11c9d1f590055
AGKirby/InClassGit
/calc.py
1,014
4.1875
4
def calc(): # get user input try: num1 = int(input("Please enter the first number: ")) # get a number from the user num2 = int(input("Please enter the second number: ")) # get a number from the user except: # if the user did not enter an integer print("Invalid input: integer expecte...
424ad85942af0fd8935537bf14ed21777693d13d
bswilson7583/ticTacToe.py
/playGame.py
1,588
4
4
#!/usr/bin/python import ticTacToe gameBoard = ticTacToe.Board() print("Welcome to tic-tac-toe!") gameBoard.displayBoard() computerChoice = input("Would you like to play a computer? (y/n)") while not gameBoard.gameOver(): #X's turn notMovedYetX = True while notMovedYetX: try: ...
0b8ef4fb282f2125d42288220a909bc37003defa
HarizHasan/adventure-game
/adventure_game.py
13,657
3.859375
4
import time import random def print_pause(string): print(string) time.sleep(2) def validate_input(prompt, option1, option2, items): while True: response = input(prompt).lower() if response == option1: break elif response == option2: break elif resp...
c44ddcd4190c44141092e91e9771b9718a0ee89a
suyogojha/python_basic
/emails.py
163
3.609375
4
c = ['suyog@gmail.com','ram@yahoo.com', 'sita@hotmail.com','hari@gmail.com','ojha@hotmail.com'] find_list = [x.endswith("@gmail.com") for x in c] print(find_list) # # # print(f"full name\n {c}")
aee63a76b1ba0c7d8e1f51dc260869b4d5f28a37
VettiEbinyjar/py-learning
/1-basics/1-intro.py
606
3.75
4
__author__ = 'ivan' # using 'print' function to print a string, numbers print('Hello, World!') print(1 + 2) print() # Quotes print('Single quote') print("Double quote") print() # Concat strings print('hello ' + 'world') print() # Vars name = 'Ivan' print('hello, ' + name) # Input name = input('what is your name?')...
2a09f466b0eb647e577bf0835a4d55e4cbae1792
iambillal/inf1340_2015_asst1
/exercise2.py
1,212
4.46875
4
def name_that_shape(): """ For a given number of sides in a regular polygon, returns the shape name Inputs: user input 3-10 Expected Outputs: triangle, quadrilateral, pentagon, hexagon, heptagon, octagon, nonagon, decagon. Errors: 0,1,2, any number greater than 10 and any other string """ ...
adfdcdd00c354d5a61f3bd28e88e01ec763538b8
magnetonerd/Physics-Class
/RodgersStage1(1).py
3,935
4.53125
5
#Program:.Stage_1_Project (Bouncing Ball) #Coder:...Christopher K. Rodgers #Class:...PHYS 310 #Date:....Jan 28, 2015 # #This code is intended to show a ball bouncing up and #down on a surface. It does so by starting the ball out #at an initial hight and the proceeds to move the ball #according to the kinimetic ...
a4faefece839a2c526069cde2a3c26eb252c6657
Kashyap90/Assignment-3
/Myfilter() function.py
443
3.90625
4
# coding: utf-8 # In[9]: def myfilter(anyfunc, sequence): result = [] for item in sequence: if anyfunc(item): result.append(item) return result def sum(x,y): return x + y def ispositive(x): if (x <= 0): return False else: return True print ("Filter ...
3d15f40fdb03f9a298a46d5679b3b7b6624a7a0a
thespatializer/pythonScripts
/dealing-with-files/cleanUpFolders.py
3,049
3.84375
4
#! /usr/bin/env python3 """ cleanUpFolder.py v1.1 - 2017 Copyright: TheSpatializer - Apache License 2.0 This script has been written in Python 3.5 and can be used for educational purpose only. Edition is encouraged as well as remarks and ideas for future improvement. Source : Please, link the source of the code you us...
683c1efb416fbd6c54ebefe5e19ec22047cbeb8d
momentum-team-2/py-word-frequency-rajeekarunaratne
/freq-test.py
933
4
4
# import string STOP_WORDS = [ 'a', 'an', 'and', 'are', 'as', 'at', 'be', 'by', 'for', 'from', 'has', 'he', 'i', 'in', 'is', 'it', 'its', 'of', 'on', 'that', 'the', 'to', 'were', 'will', 'with' ] file = open('one-today.txt', "r") def normalize_text(text): line_to_keep = "" for line in text: ...
50a8f53125afb911adf31e8fecb1ddedd1f6a014
kyleellefsen/UCI_Programming_Club
/2014_10_20_for_loop/ForLoopTutorial.py
5,028
5.0625
5
# -*- coding: utf-8 -*- """ For tutorial The goal of this tutorial is to go through the basic logic of how for loops work and when to use them. It will then discuss using for loops on arrays and in multiple dimensions. This assumes you have done the previous intro tutorial, if not, consider running through it. """ ...
977ce48c32f0ae964715f4c739ed422262372406
pauldavid23/TurtleDifferentShapes
/main.py
2,334
4
4
from turtle import Turtle, Screen the_turtle = Turtle() the_screen = Screen() the_turtle.shape("turtle") the_turtle.color("green") def forward_right(): the_turtle.forward(150) the_turtle.right(90) the_turtle.forward(150) def turn_right(): the_turtle.right(90) def create_square(): forward_right(...
2a3c335140c1775793e7cc639afd0a4c3c82eff2
codyhanson/puntective
/old/PunGraphNode.py
923
3.53125
4
__author__ = 'clh' class PunGraphNode: def __init__(self, graph, neighbors): #a reference to the owning graph self.graph = graph self.score = None #finally, tell the owning graph about this edge self.graph.add_node(self) #dictionary keyed by edges, values are nodes...
084cdf9a698d34d6d9d4727c09e2f2958e73e659
ntsum/pythonpractic
/lists.py
310
3.5625
4
# lists are ordered sequences that can hold a variety of object types # [] use brackets and commas to separate objects my_list = [1, 2, 3] other_list = ['string', 100, 40.69] print(len(other_list)) mylist = ['one', 'two', 'three'] print(mylist[0]) x = open('test.txt', 'w') x.write('Hello World') x.close()
9a0763686c57d48fc94563ae01e68fc2df075642
khazaddoom/python-program1
/main.py
1,634
3.53125
4
from __future__ import print_function # for i in range(1, 5): # for j in range(1, 10): # print(j, end='') # if i > 1: # print('.', end='') # for k in range(1, i): # print(j, end='') # print(' ', end='') # print('\n') # a = [1, 2, 3, 4] # b= a[::-1...
4eb5c1eb0d8d2d481b8b2ea5877f6518540d7e5e
HenryChenV/practises
/class/bind/test_bind.py
484
3.875
4
class Human(object): def __init__(self, addr, name): print 'I am a Human.' self.addr = addr self.name = name def get_name(self): return self.name class Female(Human): def __init__(self, addr, name, breast, waist, hip): print 'I am a Female.' Human.__init__(...
50905c64692b368f329b9f9b947a70e27dd85274
DLLJ0711/hello_world.py
/lists.py
1,041
3.890625
4
# #small 1 # numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9] # print(sum(numbers)) #small 2 # numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9] # print(max(numbers)) #small 3 # numbers = [9, 5, 4, 6, 1, 2, 3, 7] # numbers.sort() # print(numbers[0]) #small 4 # numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9] # for num in numbers: # if num % 2 =...
8e5700519c790181f0521b2e532e1d954d390c43
vivek28111992/hrank_algo
/simple-array-sum.py
204
3.796875
4
#Complexity: O(N) def array_sum(array): n = len(array) sum = 0 for i in range(n): sum += array[i] return sum array = [1, 2, 3, 4, 10, 11] array_sum(array) print(array_sum(array))
630982c1a2cb365c7aef1b79367456539c4a7cc3
sarahmcbain/Hot-Girl-Name-Generator
/hot_girl_name_generator.py
544
3.53125
4
import random # Create random_lists below: random_list_first_names = [] random_list_last_names = [] first_name_file = open("firstnames.txt", "r") last_name_file = open("lastnames.txt", "r") #print(first_name_file.read()) #print(last_name_file.read()) for line in first_name_file: random_list_first_names.append(...
3f572b9545a66117e0480780ff495ae58cb08e8e
christofergass02/WF
/wf04.py
44,581
3.546875
4
# wf04.py from sys import exit import time import random # choices: [yes, no], [left, right, forward] #(2) African Pavilion def african_pav(): # money = 0.50 # time = 45 print("The Pavilion is made up of round huts\n that represent 24 nations of sub-Saharan Africa\n stands on a broad platform...
470949f6be7393b7bf02d6b2de20529ed4ef03aa
Renyierwei/AlgorithmVI
/Chapter1_Fundamentals/stack_calc.py
1,298
3.859375
4
class stack: def __init__(self, arr): self.arr = arr self.point = len(arr) -1 def push(self, ele): self.arr.append(ele) self.point += 1 def pop(self): if self.point < 0: print( 'Empty Stack !') self.point -= 1 return self.arr.pop() # 用栈实...
11fc1a3ffac15616a6f63e8e6a0bc2a6a8551b6b
Y0gendra/Bitwise-Operator-Convertor
/projectnew.py
9,061
3.734375
4
from tkinter import * import sqlite3 import tkinter.messagebox conn=sqlite3.connect('Data.db') c=conn.cursor() c.execute("CREATE TABLE IF NOT EXISTS user12(username TEXT , password TEXT )") c.execute("SELECT * FROM user12") conn.commit() conn.close() class main: def __init__(self,master): se...
84d9a0d25cbf9ee107973e1637b9bce4a6e687ae
henryCraig/codingChallengesCodeWars
/questionExclamationBalance.py
1,008
3.890625
4
#https://www.codewars.com/kata/57fb44a12b53146fe1000136/train/python def balance(left, right): leftAmount = 0 rightAmount = 0 for i in range(len(left)): if left[i] == "!": leftAmount += 2 elif left[i] == "?": leftAmount += 3 for i in range(len(right)): i...
85056b0dee171d4d1f5e9ab83bb7edcf30533aae
henryCraig/codingChallengesCodeWars
/kebabize.py
839
3.796875
4
import re #https://www.codewars.com/kata/57f8ff867a28db569e000c4a/train/python def kebabize(string): numberLess = re.split("[]",string) print(re.split("[A-Z]", string)) splitString = re.split("[A-Z]", string) placement = 1 for i in range(len(string)): if string[i].isupper(): ...
fd6bfe0ed53d9ed61cc9c26b0974a337b65228cc
henryCraig/codingChallengesCodeWars
/isNumPrime.py
345
3.984375
4
#https://www.codewars.com/kata/5262119038c0985a5b00029f/train/python def is_prime(num): if num > 1 or num <-1: #print('hello') return True else: return False print(is_prime(-1)) print(is_prime(0)) #False, '0 is not prime') print(is_prime(1)) #False, '1 is not prime') print(is_prime(...
5cdb8f98df5c992aa2890773530bec16f6ae472b
Skyblueballykid/linalg
/Ch_4/Linear_alg4.py
4,408
3.53125
4
import numpy as np import scipy import sympy from numpy import linalg as lg from numpy.linalg import solve from numpy.linalg import eig from scipy.integrate import quad # Question 1 # MC # Question 2 # A. ''' The statement is false. The matrix left bracket Start 1 By 1 Matrix 1st Row 1st Column Upper A Bold b 1 plus ...
37211bb347c851aa4c7a167c659dd8d87d9b1af6
Skyblueballykid/linalg
/Ch_1/linear_alg1.py
1,419
3.734375
4
import numpy as np from numpy import linalg as lg from numpy.linalg import solve from numpy.linalg import eig from scipy.integrate import quad # MAT 350 - Linear Algebra # Homework 1 # Question 1 ''' x^1 + 2x^2 = 8 x^1 - x^2 = 2 [1 2 | 8] [1 -1 | 2] x1 = 4 x2 = 2 ''' # Question 2 ''' x^2 + 3x^3 = 3 x^1 + 2x^2 + 2x...
0ab34f6752e0fd18eb12e0d4cbda51b5b9295294
TheLux83/World-of-Python-Challenges
/count_integers.py
1,086
4
4
# World of Python Discord Server Challenge - Count Integers import sys def main(): #Create a list to save the entered numbers user_input=[] #Greet the Player and give a little info print("Welcome to The_Lux' little \"Count Integers\" script") print("To quit this program enter 'q' instead of a num...
48c5a8b04329fbf8221858d465bcc1799ad9b645
ihuomagold/Python_Progress
/user-input-with-the-input-function.py
281
4.0625
4
# first_name = input("What is your first name ") # print("It's nice to meet you", first_name ) #this is an assignment print("let me add two numbers") A = int(input("The first number is ")) B = int(input("The second number is ")) print("The sum of both numbers is", A + B)
1867e961b339cf3eb3cd2e157938f32d719a8ceb
matushinn/sql-practice
/sample01.py
400
3.9375
4
import sqlite3 """ 目標:PythonでSQLを使ってテーブルを作る """ def main(): conn = sqlite3.connect("users.sqlite") cursor = conn.cursor() #SQLを準備 sql = """CREATE TABLE users(name TEXT,age INTEGER)""" #SQLを実行 cursor.execute(sql) #コミット conn.commit() #接続をきる conn.close() if __name__ == "__m...
dd96a92be3e653402292499a2fa2a914f3101743
willfenton/Stanford-Machine-Learning
/EX1 - Linear Regression/Python/linear_regression_gradient_descent.py
5,248
4.15625
4
#!/usr/bin/env python #--------------------------------------------------------------------- # Author: Will Fenton # Date: July 23 2019 # # Linear regression with multiple variables, using gradient descent #--------------------------------------------------------------------- import numpy as np import matplotlib.pypl...
40bf8608d4958c6f6d36887a62b0d86d7e94a080
StojanV97/Local_Search_Engine
/Project/src/rest/bucketSort.py
554
3.515625
4
''' Created on Jun 28, 2017 @author: vStojan ''' class Item(object): __slots__ = 'key', 'value' def __init__(self, key, value): self.key = key self.value = value def __str__(self): return '(' + self.key + ', ' + self.value + ')' def bucket_sort(S): length = len(S) Bucket...
72ad6a3823fdd83a2a37b3b45f2fef0ddfc64670
Nicogeekit/Prueba_03
/mayor_de_tres.py
276
3.984375
4
primer_numero = int (input (" primer numero: " )) segundo_numero= int (input( " segundo numero: ")) tercer_numero = float (input("tercer numero: ")) resultado =int (max(primer_numero, segundo_numero, tercer_numero)) print ("El numero mas grande es {}".format (resultado))
b4a8cb4262e35d7318154642918a34dcdb24711c
LeoImenes/SENAI
/1 DES/FPOO/python rafa/rafa.py
325
3.703125
4
''' a=int(input("Digite um valor decimal: ")) b=bin(a) print(f"O valor {a} em binario é {b}") #print("O valor {} em binario é {}".format(a,b)) ''' c = int(input("Digite um valor em binário: ")) d = flot(z, 2) print(f"O seu valor em binário {c} é em decimal {d}") #converter decimal para binario e binario para decimal
5302bac1b5e3dde5c2694edf3c3d6735c2a80ae8
LeoImenes/SENAI
/1 DES/FPOO/Exercicios3/2.py
136
4.0625
4
a=int(input("Digite um número inteiro: ")) b=a%2 if b==0: print(f"O resultado é {a+5}") else: print(f"O resultado é {a+8}")
914223a3c22858cbba1d58151dda95d985b5b20b
LeoImenes/SENAI
/1 DES/FPOO/Exercicios1/7.py
148
3.953125
4
m=int(input("Digite a massa da barra em g: ")) v=int(input("Digite o volume da barra em cm³: ")) d=m/v print(f"A densidade da barra é {d} g/cm³")
a6e83344a0aea87e35d4cca71c27eb2c8e4db307
LeoImenes/SENAI
/1 DES/FPOO/python rafa/conv.py
982
4.125
4
print("Digite 1 para converter um número decimal\nDigite 2 para converter um número bínario\nDigite 3 para converter um número octal\nDigite 4 para converter um número hexadecimal") a=int(input()) if a==1: a = int(input("Qual o seu número decimal? ")) b = bin(a) c = oct(a) d = hex(a) print(f"Seu núm...
112be294f9fa5ed7af3ba49f39d2264c2757c4c2
bonnemai/MyPortfolio
/iress4.py
1,766
3.734375
4
import math def delete(S, T): for letter in S: new_word=S.replace(letter, '', 1) if new_word==T: return letter return None def swap(S, T): ''' TODO: Check i>1... ''' for i in range(len(S)): for j in range(i+1,len(S)): new_word=list(S) letter...
1e1fbb93e7fcfc826e5b99878aa1f96d0d4ccb70
cairhart/Verilog-ARMv4
/game.py
2,106
3.65625
4
import time import sys def printString(inputed, wait=1, dellines=0): print(inputed) time.sleep(wait) for i in range(dellines): sys.stdout.write("\033[F") #back to previous line sys.stdout.write("\033[K") #clear line def whatDoYouDo(): level = 1 typeofaxe = "rusty" treescut = 0 bestaxe = "rusty" while...
6bc48b7fa38268f4cb4471dc91cb6aff670c70d9
sidd315/BFS-2.1
/employeeImportanceDFS.py
914
3.9375
4
""" # Definition for Employee. class Employee: def __init__(self, id: int, importance: int, subordinates: List[int]): self.id = id self.importance = importance self.subordinates = subordinates """ class Solution: def __init__(self): self.dataStore = dict() self.result = ...
895c42c0883fbdd9ae1fd3f539bd3b3d7bb72ce7
geekMonaliza/Show-Me-the-Data-Structures
/Problem 1 - LRU Cache.py
1,369
3.75
4
from collections import OrderedDict class LRU_Cache(object): def __init__(self, capacity=5): # Initialize class variables self.capacity = capacity self.cache_dict = OrderedDict() def get(self, key): # Retrieve item from provided key. Return -1 if nonexistent. if key in...
6818bb426e5fdff8658be1b2494673bb13de431d
vedant511/data-structures
/stack/bal_par.py
1,135
3.59375
4
from stack.Stack import Stack def check_bal_par(par_str): if not len(par_str): return True if len(par_str) % 2 != 0: return False s = Stack() for item in par_str: if s.is_empty(): s.push(item) else: if s.peek() == '(' and item == ')': ...
8e5e847c0ef202bc8477786e01a37bc45107bd04
pieisland/ProjectEuler
/pro16.py
287
3.515625
4
#coding:utf-8 """ 2019.03.11.Thur <제곱수 자릿수 모두 더하기> 그냥 하면 되는 문제. """ def main(): num=1000 n=pow(2, num) temp=str(n) sum=0 for i in range(len(temp)): sum+=int(temp[i]) print(sum) if __name__=="__main__": main()
e3271390ce7b0016b36e7c64aa10d47b98e63fb5
andro98/House-Pred
/house.py
2,086
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Apr 14 23:13:45 2021 @author: andrew """ import pandas as pd import numpy as np dataset = pd.read_csv('data.csv') dataset.drop(columns=['date', 'street', 'city', 'statezip', 'country', 'view', 'waterfront', 'condition', 'yr_ren...
9facf8a012a7d6ffb996c5476e375530e7aa8596
alexeii89/lesson01
/task06.py
1,001
3.90625
4
class QueueClass: def __init__(self): self.elems = [] self.correct = [] self.complite = [] def is_empty(self): return self.elems == [] def to_queue(self, item): self.elems.insert(0, item) def from_queue(self): return self.complite.append(self.elems.pop(...
56c5b10a6a33a5c8eb2c87d244082d77a69e4802
AdamJayne/Data_Structures_In_Python
/structures_testing.py
716
3.671875
4
from stack import Stack from queue import Queue from listnode import ListNode """ STACK TESTING """ my_stack = Stack() my_stack.push("Hello") print(my_stack.peek()) my_stack.push("World") print(my_stack.remove()) print(my_stack.length(), my_stack.is_empty()) """ QUEUE TESTING """ my_queue = Queue() my_queue.enqueue...
5c70ab7906b58b58e9a109acab789c3690e714cc
argos-research/taskgen
/blocks/cond_mod.py
692
3.796875
4
import random """ Fulfills the condition, which terminates the program without counting. `cond_mod` immediately, if `args1` is multiple of 2. """ def Value(arg1): return { "pkg" : "cond_mod", "quota" : "1M", "config" : { "arg1" : arg1 } } """ Random argument `arg1`...
e241992ffcedb3124aa402f7ee3fa4cb97193b30
armut/thinkcs-solutions
/chapter-04/4-1.py
346
4.09375
4
# exercise 4.1 import turtle def draw_square(t, sz): """Draws a square with turtle t with size sz of each edge""" t.pendown() for i in range(4): t.forward(sz) t.left(90) t.penup() t.forward(sz + sz) wn = turtle.Screen() turtl = turtle.Turtle() for i in range(5): draw_square...
45b118ed3bf663d99333d8a457d2d38a1d58cac0
armut/thinkcs-solutions
/chapter-20/20-1.py
387
4.03125
4
# exercise 20.1 def letter_count(strng): char_counts = {} for char in strng.lower(): if char != " ": char_counts[char] = char_counts.get(char, 0) + 1 letter_items = list(char_counts.items()) letter_items.sort() for (u, v) in letter_items: print(u + " " + str(v)) ...
b9246d0e5fd5d01cbdff1e0a4daa215ef62fd731
armut/thinkcs-solutions
/chapter-07/7-9.py
205
3.96875
4
# exercise 7.9 def print_triangular_numbers(n): for i in range(1, n+1): tri = 0 for j in range(1, i+1): tri += j print(i,"\t",tri) print_triangular_numbers(5)
6a4b3d431558ae0bf95cd444b135e304d9aa79a1
armut/thinkcs-solutions
/chapter-03/3-3.py
220
3.6875
4
# exercise 3.3 text = "One of the months of the year is " for year in ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]: print(text + year)
959e1ec138a99b9160c0236e82b488520cf92f68
armut/thinkcs-solutions
/chapter-07/7-3.py
235
3.9375
4
# exercise 7.3 def sum_negatives(arr): total = 0 for i in arr: if i < 0: total += i print("Sum of the negative numbers in this list is {0}.".format(total)) xs = [1, 2, 3, 4, -5, -9] sum_negatives(xs)
0df585d6999af876b589b24c01d82757d534c7b7
armut/thinkcs-solutions
/chapter-16/16-1-2-3-4.py
1,908
3.890625
4
# exercise 16.1 from point import Point import sys def test(did_pass): """ Print the result of the test. """ linenum = sys._getframe(1).f_lineno if did_pass: msg = "Test at line {0} ok.".format(linenum) else: msg = ("Test at line {0} FAILED.".format(linenum)) print(msg) class Rec...
e7d5e6065d6645662ddd07ed34d242631b7bd686
robinchew/misc
/interview/Edward/test.py
565
4.125
4
import time import datetime def test(add): print "current date" now = datetime.date.today() print now print add, "days after current time" print now + datetime.timedelta(days=add) test(4) def test2(date): print "current date test2" now = datetime.datetime.now() difference = date - now print...
9f91b59e84211176887fc739e982054f7a5c85bf
satwiksps/Caesar-Cipher-Encrypted-Student-Database
/CAESAR CIPHER ENCRYPTED STUDENT DATABASE BY SATWIK.py
4,962
4.3125
4
dic = {} # ENTERED PASSWORD WILL SHIFT THE LETTERS OR DIGITS BY THE VALUE OF PASSWORD #SUPPOSE PASSWORD IS 2 AND STRING IS SATWIK THE ENCRYPTION WILL BE UCVYKM #SUPPOSE PASSWORD IS 13 AND NUMBER IS 1911 THE ENCRYPTION WILL BE 3133 shift=int(input("Set up a numeric password(any digit) :")) while True : named...
87a5b68acb6ee81c44b684ad971c650caf1b18cd
jjam123007/open-pit-mining
/SOLUTION_mining.py
15,018
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Feb 3 17:56:47 2021 @author: frederic class problem with An open-pit mine is a grid represented with a 2D or 3D numpy array. The first coordinates are surface locations. In the 2D case, the coordinates are (x,z). In the 3D case, the coor...
81bd427ce6f549688eccb4cde396a85c56df5ab1
kwgarylam/pythonWorkshop
/Notes/ans/exercise/checkGrade.py
216
3.984375
4
fMark = float(input ("Your test mark:")) if fMark >= 80: print("Your grade is A") elif fMark >= 60: print("Your grade is B") elif fMark >= 40: print("Your grade is C") else: print("Your grade is F")
ae2cf724e5359cac4746efb72211300d2f2be6e5
NamrataSharma30/ArtificialIntelligence_Algorithms
/Graph_Algorithms/Astar/Astar.py
4,798
3.5625
4
import numpy as np import time import sys def adjacent_nodes(current_node, expanded_nodes, expanded_costs): child = [] r, c = current_node[0], current_node[1] if c > 0: left = (r, c - 1) if cost[left[0], left[1]] != 0: path_cost, expanded_costs, expanded_nodes, child = calcula...
43cf0e6e0374ef141b13e50fbc644bd51efd4e49
99003607/Advanced-python
/2_control_structures.py
802
4
4
#control structures ''' if(condition): statement1; statement2; elif(condition): statement; statement; else: statement; statement; ''' n=-10; if(n>0): print("positive"); elif(n<0): print("negative"); else: print("zero"); print("program end"); #loops ''' wh...
0648123e6e365503ff8082eff1ba4ae0e2d0d593
winthropchang/Leetcode
/algothrism/122_BTBS/PythonSolution.py
631
4.0625
4
#!/usr/bin/env python # coding=UTF-8 def solution(prices): ''' My strategy is very simple. If price is higher than previous date. The price diff is profit. Add all profit is max profit. ''' prePrice = None maxProfit = 0 for price in prices: if prePrice and price > prePrice: ...
4d7fa96ca82a323ae1736217412b2377e2a09dde
Jackojc/aoc2020
/day6/main.py
403
3.59375
4
#!/usr/bin/env python3 with open("input.txt", "r") as f: all_groups = [x.strip().split("\n") for x in f.read().split("\n\n")] anyone = 0 everyone = 0 for group in all_groups: all = set(group[0]) any = set(group[0]) for person in group[1:]: all = all.intersection(person) any.update(*person) everyone += len...
7c4c2d77478fabdb96ada0cb2d4338eb638177d5
Jackojc/aoc2020
/day10/main.py
987
3.609375
4
#!/usr/bin/env python3 import collections from functools import reduce import operator with open("input.txt", "r") as f: adapters = [int(x) for x in f.read().splitlines()] def find_adapter(num, adapters): check = ((x in adapters, x) for x in [num + 1, num + 2, num + 3]) for i, (contained, x) in enumerate(check):...
23065fb4050630bc2438808c0a7b38ad20d16274
ship-engine-room/reactor
/bookgen/markov_v2.py
953
3.578125
4
#markov chain text generator with two word keys import fileio_v1 as reader from random import choice from random import random def generate_chains( fname ): chains = {} text = reader.read_file( fname ) words = text.split() i = 0 while i < len(words) - 2: key = words[i] + ' ' + words[i...
b394a34022ff8b27a88e21a3cfe80a224eba5924
ship-engine-room/reactor
/sengen/sengen11.py
1,352
3.671875
4
from random import random import reader_v2 as reader ## words = reader.get_csv_list( 'wordlist.csv' ) ## nouns = words[0] ## verbs = words[1] ## adjs = words[2] ## advbs = words[3] words = reader.get_csv_dict( 'wordlist.csv' ) nouns = ? verbs = ? adjs = ? advbs = ? articles = ['a', 'an', 'the', 'one'] #takes list ...