blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
5261153d00c3d2245bc97c5498e37cee5b6ce0aa
lucasfermo/inter
/chapter6_6.py
1,724
3.75
4
import math,os, sys,random,time,turtle from current import Stack #Quick sort class BinaryTree: def __init__(self,rootObj): self.key=rootObj self.leftChild=None self.rightChild=None def insertLeft(self,newNode): if self.leftChild==None: self.leftChild=BinaryTree(newN...
1904705567f31d6f44b0d583fa562c854e62f72e
lucasfermo/inter
/chapter5_9.py
936
3.84375
4
import math,os, sys,random,time,turtle def insertion(myList): for i in range(1,len(myList)): current=myList[i] position=i while position>0 and myList[position-1]>myList[position]: myList[position-1]=myList[position] position=position-1 myList[position]=curr...
a100e608bda812770208520548bee01dc6824a39
erastus-1/Password-Locker
/run.py
13,529
3.953125
4
#!/usr/bin/env python3.9 from user import User from credentials import Credentials import random, string import getpass # import pyperclip def create_user(fname,lname,username,password): ''' Function to create a new user ''' new_user = User(fname,lname,username,password) return new_user def save...
560f2a8fc703b93ca81bf1e4399bd050f139900d
mkowsiak/python3
/src/tuples_packing_and_unpacking.py
2,118
4.71875
5
# -*- coding: utf-8 -*- # automatic packing into tuple # Copyright © 2021 Michal K. Owsiak. All rights reserved. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMEN...
76293da9f8af637139769a41a7a56d95dd3bdb51
mkowsiak/python3
/src/dictionaries.py
3,756
4.46875
4
# -*- coding: utf-8 -*- # Copyright © 2021 Michal K. Owsiak. All rights reserved. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTH...
0897563492b768d923a06ace986dd81286a9ba86
bradyborkowski/LPTHW
/ex35.0.py
5,536
4
4
# Imports the exit module from the sys directory # -- (Not yet sure what this does exactly) from sys import exit # Defines function gold_room() # -- accepts no arguments def gold_room(): # Prints a string prompting the user to input a value print("This room is full of gold. How much do you take?") # Used ...
19dc5ec55b887afff87855efefcd421235828053
bradyborkowski/LPTHW
/ex18.0.py
1,342
4.5625
5
# this one is like your scripts with argv def print_two(*args): arg1, arg2 = args print(f"arg1: {arg1}, arg2: {arg2}") # that *args is actually pointless, we can just do this def print_two_again(arg1, arg2): print(f"arg1: {arg1}, arg2: {arg2}") # this just takes one argument def print_one(arg1): ...
504b7df72aca14058a42a27a5a4a12242442e064
bradyborkowski/LPTHW
/ex19.1.py
1,005
4.28125
4
def how_many(people, cars, seats_per_car): seats = cars * seats_per_car cant = people - seats print(f"You'd like to know how many out of {people} people can come?") print(f"There are {cars} cars and {seats_per_car} seats in each") print(f"This means there are {seats} available") print(f"Since th...
bd06aa956a9dc8709d8b81fa0e05138c323271f6
bradyborkowski/LPTHW
/ex3.1.py
722
4.40625
4
print("How many hours have I worked this pay period?") print("Let's see... I've worked 8 hours every day except for one.") print("On that day, I only worked for 5 1/2 hours.") print("This pay period had 10 work days, so how many did I work 8 hours for?") print("If I worked for 10 days total, then I must've worked 8 hou...
9d62a4f4898d4c299a531c0a46dd084dfd66707a
bradyborkowski/LPTHW
/ex13.1.py
940
4.15625
4
from sys import argv first, second, third, fourth = argv print(f"So your first favorite color is {second}? \nWhat would you say it looks nice with?") first_combo = input() print(f"{first_combo} looks nice with {second} then, huh? Alright, moving on.") print(f"Your second most favorite color is {third}?\nWhat other c...
5397cc461241d3ef0363b057e937d1d3cdf46443
bradyborkowski/LPTHW
/ex18.1.py
583
4.375
4
print("\nBelow are the first two custom functions for converting inches: the first into feet; the second into centimeters:\n\n") def inches_to_feet(inches): print(f"You want to know what {inches} inches is in feet?\nOkay, give me a second.") feet = inches / 12 print(f"{inches} inches is equal to {feet} fee...
83e1669b5088db1f9536163eca1006f32f29d765
bradyborkowski/LPTHW
/ex32.1.py
1,671
4.4375
4
# This script is to find out if the range() loop in ex32.0 # -- could have been easier (and the same) if we made # -- elements = the range() rather than an empty list # As it turns out, it would've been the same for ex32.0 # -- as it was written, but it doesn't make elements equal # -- to a list containing values 1-5 #...
8428958013e8282a656737913bbef6a5c609c079
lospoyos/lpthw
/ex6.py
1,059
4.375
4
# Types of people in binary :3 types_of_people = 10 # String with the amount of types of people inside of it x = f"There are {types_of_people} types of people." # Just a place to store the string binary binary = "binary" # Do not string do_not = "don't" # String with the explanation of the joke y = f"Those who know {b...
f22d4b5543b9992889999dee877e0662bfc89a94
zefaxet/school-stuff
/انيسه/CYEN/132/CG Reloaded/The Chaos Game.py
2,908
4.0625
4
###################################################################################################################### # Name: Anisah Alahmed # Date: 5/13/2019 # Description: Builds various fractals in a tkinter canvas #####################################################################################################...
a58bb4102ccee4f56ee95d0551cf73f5433247ab
zefaxet/school-stuff
/انيسه/CYEN/130/Assignment 2 - Easy goes it reloaded.py
1,490
4
4
########################################################################################### # Name: Anisah Alahmed # Date: 10/43/2018 # Description: Prompts the user for their name and age. Provides a greeting and the value equal to twice their age. Implementation is done in functions. #############################...
5de3954c1b2df4f81c44f843c0ff6955314e2c1d
zefaxet/school-stuff
/انيسه/CYEN/131/coinflip.py
2,124
4.03125
4
# Name: Anisah Alahmed # Date: 2/4/2019 # Description: A program that performs a variable number of matches consisting of a user-defined number of coin flips, and prints statistics from random import randint # get user input for number of games and coin flips per game games = int(input("How many games?")) coi...
2f268e90b2ac89370106747644468915a1cf34c2
Lohkrii/holbertonschool-higher_level_programming
/0x0B-python-input_output/0-read_file.py
217
3.8125
4
#!/usr/bin/python3 """ Opens a dile to read """ def read_file(filename=""): """ Opens and reads a file in UTF-8 """ with open(filename, "r", encoding="utf-8") as holder: print(holder.read(), end="")
81abd74f676913debd6fee064df6c857c3f3944c
Lohkrii/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/2-uniq_add.py
161
3.890625
4
#!/usr/bin/python3 def uniq_add(my_list=[]): my_set = set() if my_list: for item in my_list: my_set.add(item) return sum(my_set)
d18ed6e775f72b0da86f1a15c297561eb9167a5d
Lohkrii/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/9-print_last_digit.py
132
3.921875
4
#!/usr/bin/python3 def print_last_digit(number): last_num = (abs(number) % 10) print(last_num, end="") return(last_num)
32aded5bc2dd1094014314a2dc5f3ef25313cee8
Lohkrii/holbertonschool-higher_level_programming
/0x06-python-classes/1-square.py
235
3.75
4
#!/usr/bin/python3 """ Task 1 [Class: Square, Size:NULL] """ class Square: """Represents a square with size data (private)""" def __init__(self, size): """Initializing size data variable""" self.__size = size
6c9e5cf6e68fd51ed4ca6652f2f0667344b38c61
Lohkrii/holbertonschool-higher_level_programming
/0x0B-python-input_output/4-from_json_string.py
186
3.75
4
#!/usr/bin/python3 """ JSON object """ import json def from_json_string(my_str): """ Returns an object represented by a JSON string """ obj = json.loads(my_str) return obj
a4e980e5ecfeff34f668dc503c7e3f8543be8a10
Beornwulf/Battleships
/battleships_gui.py
11,936
3.765625
4
import turtle import const ########################################################### ## ## DISPLAY ## ########################################################### class BattleshipsGraphics: def __init__(self, gridSize): self.turtle = turtle.Turtle() self.screen = turtle.getscre...
74d5a9b67496222fbf470ce116fb1d20345d5e20
prakhar-5447/cfc-assignments-pyboot
/Assignment-2/Sorting.py
251
3.5
4
arr = [0,0,0,1,1,0,1,1,1,0,0,1,1,1,0,0] for i in range(len(arr) - 1): min = i for j in range( i + 1, len(arr)): if(arr[j] < arr[min]): min = j if(min != i): arr[i], arr[min] = arr[min], arr[i] print(arr)
d79c457a712610e219e9e8bafdbcb01b6fc9be1d
prakhar-5447/cfc-assignments-pyboot
/Assignment-1/DigitCount.py
151
3.984375
4
num = int(input("Enter number : ")) count = 0 while(n>0): count = count+1 n = n//10 print("The number of digits in the number are:",count)
fc612dc56ca8b4a2ae0b50bc8793f57e181d2ca4
katielys/Algorithms
/sorting/python/insertion_sort.py
463
3.921875
4
#Insertion sort is a simple sorting algorithm that works the way we sort playing cards in our hands. # Time complexity : O(n^2) # Space complexity: O(1) def insertion_sort(vec): for i in range(1, len(vec)): pivot = vec[i] j = i-1 while (j >= 0 and pivot < vec[j]) : vec[j...
7844bf148f5aaa10427c459a1fb12958171de287
Winterbl00m/URISE-solarforecasting
/Junk Drawer/gui_extra.py
2,158
3.53125
4
""""" from tkinter import * window = Tk() window.title('Appliance Selection') window.geometry('400x300') window.config(bg='white') def showSelected(): itm = lb.get(lb.curselection()) var.set(itm) var =StringVar() lb = Listbox(window) lb.pack() lb.insert(0, 'air1') lb.insert(1, 'solar') lb.insert(2, 'clothe...
2d013f9eda9ef000a56857b6453e1260a33f2f60
nikki-wolf/Work_at_Home
/HW3/PyBank/main-Bank.py
1,694
3.6875
4
#PyBank financial Analysis, # MMB -021919 import csv with open('budget_data.csv') as csvfile: readCSV = csv.reader(csvfile, delimiter=',') dates = [] corr_dates=[] PLs = [] for row in readCSV: dates.append(row[0]) PLs.append(row[1]) #remove the headers dates.pop(0) ...
081814d1f005d8c84f28331763e8cdec9ef6f114
pypmannetjies/coding-exercises
/arrays/urlify.py
959
4.125
4
# URLify - replace all spaces with %20 - extra spaces are added to the end of the string to accommodation # in-place substitution # In place - O(n) # String must be converted to array due to Strings being immutable in Python # An easier approach would be to just insert the spaces as chars are copied into array #...
45a17c4fd605b2d38d2a93339b50357bdca8537c
tasbihaasim/snakes
/balanced parenthesis.py
809
4.09375
4
def isEqual(opening,closing): if( opening == '(' and closing == ')' ): return True; elif ( opening == '[' and closing == ']' ): return True; elif ( opening == '{' and closing == '}' ): return True; return False; def balanced_parenthesis(exp): """ Args: ...
afd3749b6c47a8d31f3048c23f1d45e849a65c89
shadowfax-ring/Udacity-CS101
/hws/hw3/set/exercise.py
128
3.671875
4
## Python Question??? def proc1(p): p[0] = p[1] def proc2(p): #p = p + [1] p += [1] p = [1,2,3] print p proc1(p) print p
7502b5e27e378abce6368eb2dbbedb1d5d0a5f0e
tianhaoo/PythonHomework
/第三章作业/017.py
312
3.921875
4
x=int(input()) y=int(input()) z=int(input()) if x>=y: if z>x: print(y,x,z) else: if y>z: print(z,y,x) else: print(y,z,x) else: if x<=z: if y<=z: print (x,y,z) else: print (x,z,y) else: print (z,x,y)
d99b5977a5b9c4f5ea985536357c796f02f92191
tianhaoo/PythonHomework
/第三章作业/015.py
213
3.90625
4
import math x1=float(input()) y1=float(input()) r=float(input()) x2=float(input()) y2=float(input()) l=math.sqrt((x1-x2)**2+(y1-y2)**2) if l <= r: print('inside') else: print('outside')
f491a1eb134a101d8fb0a5e04f0b491ec9d61e1f
tianhaoo/PythonHomework
/2015/001.py
1,735
3.609375
4
n = int (input('please enter an integer:')) #判断是否能被3和4 if n % 3 == 0 and n % 4 == 0: print ('{0}能被3和4整除'.format(n)) else: print ('{0}不能被3和4整除'.format(n)) #判断是几位数 counter = 0 temp = n while temp % 10 > 0: temp = temp // 10 counter +=1 #输出逆序数 temp2 = n s = 0 counter2 = 0 while counter2 < counter: ...
56cde18766d0bafe14e013fdff7ac50a9637590a
shinsung3/Algorithm-Programmers
/PYTHON/Level1/makingString.py
523
3.796875
4
#람다식을 활용해서 문제풀기 def solution1(strings, n): answer = [] answer = sorted(sorted(strings), key=lambda x:x[n]) return answer # 앞에다가 정렬할 자릿수의 숫자를 앞으로 붙인 후에 정렬하기 def solution(strings, n): answer = [] for i in range(len(strings)): strings[i] = strings[i][n] + strings[i] strings.sort() for i...
424c156d1e5036b17961be2a221e905624be49fd
Shad87/python-programming
/UNIT-1/games.py
454
4.40625
4
#ask user to guess secret number #loop as long as users input is not equal to secret no #print message if it is equal and end loop secret = 9 guess = int(input("guess my secret number: ")) while guess != secret: print("not correct") guess = int(input("guess my secret number: ")) print("yeah you got it") #...
abeb297a6552a79a813599ad407307f1b6c02174
vladzlydar/Statki
/test_Board.py
1,611
3.546875
4
from unittest import TestCase import Board import HorizontalShip import EmptySea import VerticalShip class TestBoard(TestCase): def setUp(self): self.board = Board.Board(10, 10) self.horizontalShip = HorizontalShip.HorizontalShip(4) self.verticalShip = VerticalShip.VerticalShip(3) def ...
3fe6e04144994313b743784369740f14b4735428
mahesh0605/mycap-python-programing-task-1-and-2
/area of circle (1).py
289
4.25
4
#!/usr/bin/env python # coding: utf-8 # In[1]: # task 1 - Write a python program which accepts the radius of a circle from the user and computes area from math import pi r = float(input ("Enter radius of circle : ")) print ("Area of the circle is: " + str(pi * r**2)) # In[ ]:
c0f99a9e922b7bc2c00954547ffa90546eb4bf8d
sullivanj91/CiscoPythonTraining
/deadlock.py
1,699
3.640625
4
''' Creating deadlock, then solving. ''' from threading import Lock, Thread import random class Account: ''' Changing the value in an account should only be done by an acct.transfer() which ensures no double-spending. ''' def __init__(self, name, value): self.name = name self._val...
f2632608bd1d93260b0647b06e5ffbfc4fcbda01
sullivanj91/CiscoPythonTraining
/words.py
1,877
4.125
4
import collections #Task 1: Count the frequency of words in Hamlet counts = {} with open('notes/hamlet.txt') as f: for line in f: for word in line.split(): counts[word] = counts.get(word, 0) + 1 print sorted(counts.items(), key=lambda p: p[1], reverse=True)[:3] #collections.Counter provides 2 features: .get(k...
19dee600b1eab3e0f06cccb619c22c0ce3780722
akbargithub260403/ProgramScrapingYoutube-Python
/main program.py
1,645
3.546875
4
# Melakukan Import Package library Python Selenium from selenium import webdriver """ Melakukan Inisialisasi untuk Web Driver [ Disini saya menggunakan browser Firefox , untuk browser lain. Cara untuk melakukan inisialisasi nya berbeda. ] """ driver = webdriver.Firefox(executable_path='./geckodriver') driver.implici...
c064d37990aaa7ae446b7b07e269b2b4ba4f0966
FouSpeed/Texas-Instruments-TI-83-Premium-CE-Graphing-Calculator
/numberset.py
1,810
4
4
from fractions import * import fractions nbr = input("What number do you want find is set: ") res = ["N", "Z", "D", "Q", "R"] def simplifyoperation(nbr:str): nbrreplace=nbr.replace("-","+-") nbrlist = nbrreplace.split("+") listdenominator = [] for n in nbrlist : denominator = Fraction(n...
84f51a627758d7b347e155f1b4636b532ff0c8de
kjonathan024/rpg-game
/rpggame.py
13,354
3.53125
4
#build out character classes ******ALSO ADD AN EVASION ATTRIBUTE TO ALL PLAYER CLASSES******* import math import random class Player: #constructor def __init__(self, name="Player", level=0, hp=0, speed=0): self.name = name self.level = level self.hp = hp self.speed = s...
7bb4cfb522d4367b21ef87e9bacf1b5a0d648e96
mishrakeshav/Competitive-Programming
/binarysearch.io/303_tree_traversal.py
635
3.53125
4
# class Tree: # def __init__(self, val, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def solve(self, root, moves): UP = 'UP' RIGHT = 'RIGHT' LEFT = 'LEFT' stack = [] idx = 0 stack.append(...
e31634e157bcca37cf53dbfa3e2d91f90e5e48ec
mishrakeshav/Competitive-Programming
/AlgoTalks/LinkedList/intersection_of_two_ll.py
3,430
3.546875
4
""" Problem link: https://leetcode.com/problems/intersection-of-two-linked-lists/ Solution By Keshav Mishra """ from sys import stdin,stdout from collections import Counter , deque from queue import PriorityQueue import math helperConstants = True helperUtilityFunctions = True def input(): return stdin.readline()...
9cdf3089b484d1061c6411c30e34ed4bba18ff62
mishrakeshav/Competitive-Programming
/binarysearch.io/188_complete_binary_tree.py
916
3.671875
4
# class Tree: # def __init__(self, val, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def solve(self, root): if root is None: return True stack = [root,] while stack: new = [] ...
64581f85735a49cabf7e633c97bae087eba3cd87
mishrakeshav/Competitive-Programming
/binarysearch.io/sibling_tree_value.py
831
3.6875
4
# class Tree: # def __init__(self, val, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def solve(self, root, k): # Write your code here def solve(node,parent,dr): if node is None: return ...
8764b57688e378aea7bbf2cb703c42d33bf9b2e1
mishrakeshav/Competitive-Programming
/Code Forces/Problem Set/B/young_physicist.py
180
3.609375
4
X,Y,Z = 0,0,0 for t in range(int(input())): x,y,z= map(int,input().split()) X += x Y += y Z += z if (X,Y,Z) == (0,0,0): print("YES") else: print("NO")
2735595424995ae99d65c34461be94acd3cbeb4a
mishrakeshav/Competitive-Programming
/binarysearch.io/matrix_search_sequal.py
713
3.734375
4
class Solution: def solve(self, matrix, target): # Write your code here def binary_search(target,array): n = len(array) start = 0 end = n - 1 while start < end: mid = (start + end)//2 if array[mid] == target: ...
268aef9b7d9710021c09d607266dc35b5dd8ee4e
mishrakeshav/Competitive-Programming
/CodeChef/Practice/MXMLCM.py
467
3.640625
4
#TODO # def isPrime(n): # for i in range(2,int(n**0.5)): # if n%i==0: # return False # return True # for t in range(int(input())): # N,M = map(int,input().split()) # A = list(map(int,input().split())) # primes = [] # for n in range(M,0,-1): # if isPrime(n) and n not...
34b75a8c47a951bf71a5c703215394826c74c86a
mishrakeshav/Competitive-Programming
/binarysearch.io/stack_sequence.py
613
3.546875
4
""" Problem Link: https://binarysearch.io/problems/Stack-Sequence Solution by Keshav Mishra """ class Solution: def solve(self, pushes, pops): # Write your code here n1 = len(pushes) n2 = len(pops) i = 0 j = 0 stack = [] while i < n1 and j < n2: ...
480bb41a072ab840ed1302275070173b1cc19357
mishrakeshav/Competitive-Programming
/Data Structures/Graphs/detect_cycles_in_a_graph.py
782
3.640625
4
from graphs import Graph def detect_cyles_in_the_graph(g): def dfs(v, g): v.setVisited(True) for node in v.getConnections(): vertex = g.getVertex(node) if vertex.isVisited(): return True if dfs(vertex, g): return True v.se...
b38aa2014b156493fd720ae1e776fb78ffcc8ba0
mishrakeshav/Competitive-Programming
/Data Structures/Graphs/center_of_a_DAG.py
880
3.5
4
from graphs import Graph def treeCenters(g): n = g.getSize() leaves = [] for node in g: vertex = g.getVertex(node) if vertex.degree == 0 or vertex.degree == 1: leaves.append(vertex) vertex.setDegree(0) count = len(leaves) while count < n: new_leaves =...
a3e3a0ce3818b4504850fee0bbcfedad758d462d
mishrakeshav/Competitive-Programming
/binarysearch.io/expression_tree.py
645
3.625
4
# class Tree: # def __init__(self, val, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def solve(self, root): # Write your code here s = "" def evaluate(root): if root.left is None and root...
3c652fb2b3509765f01bcf2fc2dbadf966008917
mishrakeshav/Competitive-Programming
/AlgoTalks/Linear DS/maximum_xor_secondary.py
502
3.515625
4
""" Problem link: https://codeforces.com/problemset/problem/281/D Solution By Keshav Mishra """ from sys import stdin,stdout def input(): return stdin.readline().strip() # def print(s): stdout.write(str(s)+'\n') from collections import Counter # Constants YES = 'YES' NO = 'NO' yes = 'yes' no = 'no' true = 'true' fa...
ee7fc66b4b978c007ad53fd650aaec92c4e3de2d
mishrakeshav/Competitive-Programming
/binarysearch.io/only_child.py
767
3.53125
4
# class Tree: # def __init__(self, val, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def solve(self, root): # Write your code here siblings = [] count = 0 if root: siblings.append(root) ...
82f56416747d145e397286cdcc70a18966645512
mishrakeshav/Competitive-Programming
/CodeChef/AUG19B/CHEFDIL.py
200
3.75
4
for _ in range(int(input())): string = input() count = 0 for i in string: if i == '1': count+=1 if count%2==0: print("LOSE") else: print("WIN")
4b3f0146cd8fbb7da77218e7669a5f4fb8dd5647
mishrakeshav/Competitive-Programming
/Project Code 2.0/gen_test.py
263
3.5
4
import random print(10) for i in range(10): print(random.randint(1,10)) print(random.randint(1,10), random.randint(1,10), random.randint(1,10)) q = random.randint(5,101) print(q) for i in range(q): print(random.randint(2,1000000001))
34ee804584fba54460939af75b22ef197bd4252e
mishrakeshav/Competitive-Programming
/binarysearch.io/word_search.py
698
3.609375
4
class Solution: def solve(self, board, word): # Write your code here for i in range(len(board)): if "".join(board[i]).count(word) > 0 : return True for i in range(len(board[0])): w = [] for j in range(len(board)): ...
8bb822f8be44b05047a3d8628349b60f5cb9f6b7
mishrakeshav/Competitive-Programming
/Data Structures/Graphs/dijkstras.py
681
3.71875
4
from queue import PriorityQueue from graphs import Graph def dijkstras(g, startNode, dstNode): if startNode == dstNode: return P = PriorityQueue() g.getVertex(startNode).setDistance(0) P.put((0, startNode)) while not P.empty(): dst, val = P.get() if val == dstNode: ...
e264bf4ad7beae30afbd9ed2114e4d09eee4cfba
mishrakeshav/Competitive-Programming
/CodingNinjas/SecondLargest.py
339
3.8125
4
def secondLargest(arr,n): largest = -999 slargest = -999 for i in range(n): if arr[i] > largest: slargest = largest largest = arr[i] if arr[i] > slargest and arr[i] < largest: slargest = arr[i] return slargest print(secondLar...
7f7edb025dd8bf9eee2563a76c9902e4e35da137
shubham-dixit-au7/test
/coding-challenges/Week07/Day02_(03-03-2020)/Ques2.py
1,408
3.8125
4
#Question- https://www.geeksforgeeks.org/kruskals-minimum-spanning-tree-algorithm-greedy-algo-2/ #Answer- from collections import defaultdict class Graph: def__init__(self,vertices): self.V=vertices self.graph=[] def addEdge(self,u,v,w): self.graph.append([u,v,w]) def find(self,parent,i): if(parent...
376d57a613e5adbc1b5a431a6999980f64a7f637
shubham-dixit-au7/test
/assignments/Week05/Day04_(20-02-2020)/Ques1.py
1,243
3.8125
4
#Question- https://www.geeksforgeeks.org/exchange-first-last-node-circular-linked-list/ #Answer- import math class Node: def __init__(self, data): self.data = data self.next = None def addIt(head, data): if (head != None): return head temp = Node(data) temp.dat...
bc719a40a5e3b891a6ff0ea234a87f7b2e2d0d57
shubham-dixit-au7/test
/Important Py Programs/Python Patterns/Star Patterns/Pattern2.py
297
4.15625
4
# Question- (when n=6) # ****** # ***** # **** # *** # ** # * value = int(input("Enter the value of lines to which this pattern works:")) for number in range( value , 0, -1 ): print( "*" * number )
741efbddba2fe3d27dfae61395c354328d65f50e
shubham-dixit-au7/test
/Important Py Programs/Python Patterns/Alpha Patterns/Pattern5.py
347
3.96875
4
# Question- (when n=6) # A # AB # ABC # ABCD # ABCDE # ABCDEF value = int(input("Enter the value of lines to which this pattern works:")) for line in range(0,value): for char in range (0, line + 1): print(chr(65 + ...
0ba9869a19249df9fc793c64082d89e984e45ead
shubham-dixit-au7/test
/Important Py Programs/Python Patterns/Star Patterns/Pattern7.py
477
3.765625
4
# Question- (when n=4) # ******* (0 * space + star * 7) # ***** (1 * space + star * 5) # *** (2 * space + star * 3) # * (3 * space + star * 1) value = int(input("Enter the no. of rows ->")) for line in range(val...
3be7f25b0425acdd2b1794e60efae18998054313
shubham-dixit-au7/test
/Important Py Programs/Python Patterns/Special Patterns/Alphabet_Rangoli_problem(HR).py
3,252
3.625
4
# Question-(HR Problem) (URL-https://www.hackerrank.com/challenges/alphabet-rangoli/problem?h_r=internal-search) # You are given an integer, N. Your task is to print an alphabet rangoli of size N. (Rangoli is a form of Indian folk art based on creation of patterns.) # Different sizes of alphabet rangoli are shown bel...
303dad5886cd0b5e29cd9db8442582904a4511f0
shubham-dixit-au7/test
/Important Py Programs/Python Patterns/Alpha Patterns/Pattern7.py
396
3.75
4
# A # BC # CDE # DEFG # EFGHI # FGHIJK value = int(input("Enter the value of lines to which this pattern works:")) for line in range(0,value): for char in ran...
ca3f5fce82fe19466edc41c9288c14d6abeb6fc0
shubham-dixit-au7/test
/Important Py Programs/Sorting/BubbleSort.py
514
4.0625
4
def bubbleSort(lst, n): for i in range(1, n+1): swapped = False for j in range(n-i): # to loop over right side values of lst[i] to check values if lst[j] > lst[j+1]: # checking adjacent values lst[j],lst[j+1] = lst[j+1], lst[j] # swapping values swapped = True if not swappe...
17091014ee3e223e20e841ee2e62a2bc16a76a6f
shubham-dixit-au7/test
/coding-challenges/Week05/Day01_(17-02-2020)/Ques2.py
1,221
4.34375
4
#Question- Write a python program to do merge sort iteratively. #Answer- def mergeSort(a): current_size = 1 # traversing subarrays while current_size < len(a) - 1: begin = 0 # subarray being sorted while begin < len(a)-1: # calculating mid value mid = begin + current_size...
1c0f12dd8be26ef239f6970af819e618ec8d6e2d
Y0-L0/simplePythonGame
/simple_random_number_game_v1.0.py
761
4.0625
4
# Simple random number game # By Johannes Lohmer # Version 1.0 # Random Number = r # Guess Number = g # Generate Random Number import random r = int(random.randint(1,100)) print("Ready Player One") # 1st Try while True: try: g = int(input("Please Guess the randomly generated number betwee...
d52d914882f479bd8132730aaf96b4d258ef928e
atul26337/sentiment-pro
/Az.py
560
3.5625
4
# -*- coding: utf-8 -*- """ Created on Tue Jan 14 23:00:30 2020 @author: Atul """ import nltk nltk.download('punkt') nltk.download('stopwords') import string from nltk import word_tokenize from nltk.corpus import stopwords def text_process(text): tokenized_sent = [word.lower() for word in word_token...
2f5a17edf07c6c60ea3afdff6508f7b3605da19d
quenadares15/python-course
/2-day/index.py
913
4.21875
4
# 2 DAY # Data types: #BOOLEAN (True, False) print("\nData types:\n") a = True b = False print(a) print(b) input("\nPress Enter to continue\n") # INTEGER int() first = input("First Number: ") second = input("Second Number: ") print(int(first) + int(second)) input("\nPress Enter to continue\n") # int() convert string ...
ef3cbf1e51e83124c2b8061a11c158d4b0acb728
sarbar2002/lab2python
/main.py
651
3.65625
4
# Author: Sarthak Singh sxs6666@psu.edu #Collaborator: Nicholas Cole nyc5096@psu.edu # Collaborator: Bryce Awono bna5160@psu.edu # Section: 12R # Breakout: 8 def getLetterGrade(grade): if grade >= 93: return "A" elif grade >= 90: return "A-" elif grade >= 87: return "B+" elif grade >= 83: retur...
3f39edf2ec732a5bf8fc1e78039369c333c09a14
MattBlaszczyk/cmpt120Blaszczyk
/madlib.py
426
4.21875
4
# Introduction to Programming # Author: Matt Blaszczyk # Date: 1/30/2018 # madlib.py # A program that produces a madlib when a user enters a series of words. def madlib(): adj = input("Enter an adjective:") animal = input("Enter a type of animal:") location = input("Enter a store name:") song = input...
91fe4097da3f24a09b651790660397d38918e479
MattBlaszczyk/cmpt120Blaszczyk
/CalcProject4Final.py
9,592
4.125
4
# Introduction to Programming # Author: Matt Blaszczyk # Date: 4/13/2018 # CalcProject4.py # A program that can calculate values. # Has functioning buttons including memory and special operations and grouping characters with modularized code # Prints the values of the buttons clicked to assure the user that the operat...
aa3d49b09ec05fcb6255fa65d2a24abf7c0bcbbb
yasamanfaizi/C-103
/line.py
187
3.75
4
import pandas as pd import plotly.express as px df = pd.read_csv('line_chart.csv') graph = px.line(df,x = "Year", y = "Per capita income", color = "Country", title = "Graph") graph.show()
345dfcc567489d966a3e45d0605e8054ff587ea2
Pratster95/Python-Code
/Tuples.py
527
3.625
4
def get_data(aTuple): nums=() words=() for t in aTuple: nums=nums+ (t[0],) if t[1] not in words: words=words+(t[1],) min_n=min(nums) max_n=max(nums) unique_words=len(words) return (min_n,max_n,unique_words) tswift=((2014,"Katy"),(2014, "Harry"),(2012,"Jake"),...
91af92b5b204d4ac5ea5fd02b4c2ab8faeeb5cb3
ShinyShips/Triangle567
/triangle.py
1,399
4.40625
4
"""Classifies Triangles based on the given side lengths side_a, side_b, side_c""" def classify_triangle(side_a, side_b, side_c): """ Parameters: side_a (int): triangle side a side_b (int): triangle side b side_c (int): triangle side c requires that the input values be >= 0 and <= 200 verifi...
8737507891398f45a2b83033a798087fe16718cc
forsooth/Turing-Machine
/src/tape.py
11,217
3.953125
4
import colors import shutil # The tape structure is a doubly-linked list with no access to # its head or tail. Each space contains a character 'bit', and # we store a blank character. 'None' is used for blank nodes. class Tape: def __init__(self, blank, bit, prev=None, after=None): self.bit = bit ...
a76fff92ce4286d36ef611e6ac128c5a39813d45
raghuprasadks/Python_August_2020
/pythonprograms/Operators.py
1,258
3.984375
4
# -*- coding: utf-8 -*- """ Created on Wed Aug 5 20:26:01 2020 @author: lenovo """ ''' Multi line Comments Operators 1. Arithmetic Operators - +,-,*,/,//,%,** ''' #single line comment n1=100 n2=250 n3=n1+n2 print('Result of Addition ',n3) n3=n1-n2 print('Result of Subtraction ',n3) n3=n1*n2 print('Result of ...
8bc0a6bd898988434dfb76ed41eab805ea93acf9
jmaq-cr/BMC-Pr2-RutasMetabolicas
/src/global_alignment.py
4,607
3.703125
4
# VARIABLES GLOBALES MISMATCH = -1 MATCH = 1 GAP = -2 matrix = [] def clean_matrix(): global matrix matrix = [] # MODIFICA LOS VALORES DE MATCH, MISMATCH Y GAP SI EL USUARIO LO SOLICITA def setValues(new_match, new_mismatch, new_gap): global MISMATCH global MATCH global GAP if (new_mismatc...
56c8ebea2e796d9ed95602d608e126337bc6a295
Felixiuss/Python_notes
/Type_datas/int.py
197
3.84375
4
# Функция поиска минимума def mins(*args): res, *rest = args for i in rest: res = i if i < res else res return res lst = [3, 4, 5, 1] print(mins(*lst))
8e75be07d49bd1958a74523237f91f6f07b47616
Felixiuss/Python_notes
/raznoe.py
3,602
3.640625
4
# -*- coding: utf-8 -*- # print('hello world') # print(sorted(x.upper() for x in dir(str) if not x.startswith('__'))) # # print([x ** 2 for x in range(10) if x % 2 == 0]) # gen = (x ** 2 for x in range(10)) # print(gen) # print({x ** 2 for x in range(10)}) # x = {x: x ** 2 for x in range(10)} # d = {c.upper(): ord(c) f...
75ca117e5469a8143f9c59e011e8ae7e8954266b
Felixiuss/Python_notes
/Algoritms.py
833
4
4
manatis = dict(lam={'name': 'a', 'age': 1}, lam1={'name': 'b', 'age': 2}, lam2={'name': 'c', 'age': 3}, lam3={'name': 'd', 'age': 4}, lam4={'name': 'e', 'age': 5}, lam5={'name': 'f', 'age': 6}, lam6={'name': 'j', 'age': 7}, ...
20fd5caa304b587c598a6a3b40eccc5ee98c9034
Felixiuss/Python_notes
/Iteratory-Generatory/Molchanov.py
1,161
3.8125
4
# обычная функция def countdown(n): result = [] while n != 0: result.append(n - 1) n -= 1 return result # таже функция но в качестве генератора def gen_countdown(n): while n != 0: yield n - 1 n -= 1 g = gen_countdown(4) try: print(next(g)) print(next(g)) ...
1856b5b8f5c65fd55bc6c7a0f72201cc9c090a9e
seanjib99/pythonproject1
/main.py
240
4.125
4
# every number is given on seperate lines. num1=int(input("enter the first value: ")) num2=int(input("enter the second value:")) num3=int(input("enter the third value:")) sum=num1+num2+num3 print(f"The sum of given three number is {sum}*")
46afcad5deff12ed2cb97eef90a9e3a4d445ae7d
fczj/python-S14
/Day005/day005/正則計算器.py
651
3.671875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 17-8-8 下午4:25 # @Author : xiongzhibiao # @Email : 158349411@qq.com # @File : 正則計算器.py # @Software: PyCharm import re custr = '1 - 2 * ( (60-30 +(40/5) * (9-2*5/3 + 7 /3*99/4*2998 +10 * 568/14 )) - (-4*3)/ (16-3*2) )' class Calculator(): def __ini...
cbe68aac48cc66bbf3f8d170b566e2c72f43e3bb
fczj/python-S14
/Day009/day009/同时启动多线程.py
635
3.671875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 17-8-25 下午3:38 # @Author : xiongzhibiao # @Email : 158349411@qq.com # @File : 同时启动多线程.py # @Software: PyCharm import threading import time def run(n): print("task ",n ) time.sleep(1) print("task done",n,threading.current_thread()) start_tim...
0dfce90d43e19b04ca8d2eb4688cf977f647ae95
neal-o-r/morse
/morse.py
1,918
3.515625
4
from typing import Dict, List, Generator, Set def morse_dict(fname: str) -> Dict: with open(fname) as f: lines = f.read().split("\n")[:-1] split = lambda x: x.split(",") return {m : c for c, m in map(split, lines)} def dictionary(fname: str) -> Set: with open(fname) as f: lines = f.re...
5356500c4992a6f6fc94246a7faa855a431287c2
xbe/qcc
/src/lib/helper.py
2,371
3.625
4
# python3 """Helper functions.""" import itertools import math import numpy as np def to_rad(angle) -> float: """Convert angle (in degree) to radiants.""" return math.pi / 180 * angle def to_deg(rad) -> float: """Convert radiants to angle.""" return rad / math.pi * 180.0 def bitprod(nbits): """Produce...
516dd2d4e102ffc89bfff4a991edbd939e9e37c2
vguillaume8/java_data_structures
/src/test/python/plot_analytics.py
10,286
3.65625
4
# Generate plots with no # connected display / X server import matplotlib as mpl mpl.use('Agg') import matplotlib.pyplot as plt import argparse from functions import * from file_io import read_csv # TODO - Implement python script to fit multiple scatter plots # This one, however will only give the best fit line per s...
abe7b97d29f498e5c759dc692a6b38eb1f515a9d
amangour30/MILPSolver
/input.py
850
3.59375
4
from pulp import * n1 = raw_input("Please enter number of integer variables: ") print "N1: ", n1 n2 = raw_input("Please enter number of continuous variables: ") print "N2: ", n2 print "Please enter the wegihts of the objective function C1 \n" C = [] for i in range(int(n1)): n = raw_input("c %d:"%(i+1)) C.ap...
7c80c110edeba353d600641baa2505ea055b63f1
Wings1016/python-learning-notes
/practise/code/0004.py
629
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import re,string from collections import Counter with open('/Users/herry/Documents/python/text.txt','r') as text: data1 = text.read().replace('\n',' ').replace('\r',' ') # 去除英文标点,string.punctuation包含所有英文符号 for i in string.punctuation: data1 = data1.re...
d625147327d81d423fb77c7c76d20aef772c6135
Fergus98/python_exercises-
/applications/classes.py
278
3.578125
4
class Student: def __init__(self, name, age, _class = "Student"): self.name = name self.age = age self._class = _class def score(self, mscore, escore, sscore): avg = (mscore + escore + sscore) / 3 return avg John = Student("John", "20") print(John.score(5,15,20))
f7baade8d97740c17e42f4938c46c196a2ecc55e
balsa30/domaci06-zbirka02
/str7_zad24.py
419
3.90625
4
""" 24. Napisati metod int najveciNeparniDjelilac(int n) koji vraća najveći neparni pozitivni djelilac broja n. """ n = int(input('Unesite broj: ')) def najveciNeparniDjelilac(n): D = 1 djelilac = 0 while n >= D: if n%D == 0 and D%2 != 0: djelilac = D D = D ...
cb0bb15baf9bbc578ec3879fdd087ae50bf2f7d9
balsa30/domaci06-zbirka02
/str3_zad30.py
789
3.96875
4
""" 30. Dva automobila se kreću po kružnoj staži dužine L u suprotnim smjerovima. Polaze iz iste tačke i kreću se stalnim brzinama v1 i v2. Na kom rastojanju će se naći automobili u trenutku T. Ulaz: U jednom redu zadaju se 4 cijela broja L, v1, v2, T, razdvojeni blankom (1 ≤ L, v1, v2, T ≤ 100). Izlaz: Štampati je...
938bc4623051581e88aba9b022abbeef82c0817e
Djennifer/8dm50-machine-learning
/practicals/code/kNN.py
1,685
3.71875
4
import numpy as np def euclidean_distance(a, b): """calculate euclidean distance between two points a and b""" return np.linalg.norm(a-b) def get_neighbours(X_train, X_test, k): """finds the k amount closest neighbours and returns the indeces and distances of the closest neigbours parameters...
6888404b226e3576dba759731cd409e1233ccc67
zhangdongxuan0227/Practice
/test2.py
406
3.6875
4
#__author__ = 'think' ''' def my_abs(x): if x>=0: return x else: return -x a=int(input("输入数字:")) print (my_abs(a)) ''' # coding = utf-8 '''def get_median(x): x.sort() half = len(x) // 2 return (x[~half]+x[half])/2 s=[1,2,3,4,5] print(get_median(s)) ''' def hel(x,y): if x>=10 an...
b2e66162050f81be43747857e6ece675ab241e9e
tony0411kp/DESKTOP-VOICE-ASSISTANT-a.k.a-F.R.I.D.A.Y-PYTHON-3.8.5-and-PyQt5
/test.py
2,804
4.03125
4
''' else: give_output("dont know this one should i search on internet?") ans = take_input() if "yes" in ans: answer = check_on_wikipedia(quest) if answer!="": return answer elif "no" == ans: ...
ffedf671bb2cbe6bb4ad4b53941f806d690e25be
koilhyuk/Algorithm
/src/baekjoon/bronze/icpc_1_16727.py
296
3.796875
4
P1, S1 = map(int ,input().split()) S2, P2 = map(int, input().split()) P3 = P1+P2 S3 = S1+S2 if P3> S3: print("Persepolis") elif P3 < S3: print("Esteghlal") else: if S1 > P2: print("Esteghlal") elif S1 < P2: print("Persepolis") else: print("Penalty")