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
3af2df1e2785fc87579ae86f465bcaf223c6627c
PaulKitonyi/Python-Practise-Programs
/Q22.py
81
3.59375
4
def squareroot(n): num=0 while num*num<n: num +=1 return num
3990f9350a0aba106a6a7838232d88427172116a
PaulKitonyi/Python-Practise-Programs
/testing_functions/test_cities.py
460
3.546875
4
import unittest from city_functions import city_details class TestCityDetails(unittest.TestCase): def test_city_details(self): testcitydetails = city_details('santiago','chile') self.assertEqual(testcitydetails,'Santiago, Chile') def test_city_details_population(self): testcitydetails...
9bbcaaf745be9fa4593dd73e52cfc6421991f3c6
PaulKitonyi/Python-Practise-Programs
/testing_classes/Survey/survey.py
694
3.828125
4
class AnonymousSurvey(): """A class to collect anonymous answers to a survey Question""" def __init__(self, question): """Store a Question and prepare to store reponses""" self.question = question self.responses = [] def show_question(self): """Display the Question""" ...
b73d22e4ea3551f30ab26f5a89cdc4aac7ed66f3
PaulKitonyi/Python-Practise-Programs
/Q12.py
524
4.03125
4
# Question: # Write a program, which will find all such numbers between 1000 and 3000 # (both included) such that each digit of the number is an even number. # The numbers obtained should be printed in a comma-separated sequence # on a single line. values = [] for i in range(1000, 3001): s = str(i) if ...
46a974a2c8f90592ae25e92e1acd58e6b468bbc3
farbodp/just_codes
/exercises_solutions.py
7,964
4.21875
4
'''-MixUp Given strings a and b, return a single string with a and b separated by a space '<a> <b>', except swap the first 2 chars of each string. e.g. 'mix', 'pod' -> 'pox mid' 'dog', 'dinner' -> 'dig donner' Assume a and b are length 2 or more.''' def mix_up(a, b): return b[:2] + a[2:] + ' ' + a[:2] + b[2...
65bf2ef38e2682fecab3c046a7e343d9ad9b5cee
Chalayyy/challenge_solutions
/escape_pod.py
9,859
3.6875
4
""" The problem: Given a list of entrances, a list of exits (which are disjoint from the entrances), and a matrix indicating the maximum number of individuals that can travel down a hallway each time unit from one room(the matrix row) to another (the matrix column), find the maximum number of individuals that can be s...
c609b30525e3cfb50004bb57bb50efd5daa4f3bd
markcassar/data_analyst
/Project 1/program_files/turnstile_weather_predict_svm.py
5,952
3.796875
4
import numpy as np import pandas as pd from ggplot import * #from sklearn import linear_model #, svm #from sklearn.ensemble import RandomForestClassifier import statsmodels.api as sm #import itertools import matplotlib.pyplot as plt #import operator #import csv def normalize_features(df): """ Normalize the f...
dbb3b5ae73df7d9dae41309f01181eeed824376a
vlad271828/-
/цветок 10.py
225
4.03125
4
import turtle turtle.shape('turtle') def o(n): turtle.left(n) for i in range(1,120): turtle.forward(1) turtle.left(3) turtle.right(n) for h in range(0,360,60): o(h)
b686ef732e4c2be80a6fa65c6f5c5ad39f503665
ingako/MachineLearningKata
/viterbi/constructTransitions.py
1,255
3.578125
4
import numpy as np ## This function constructs tranisition matricies for lowercase characters. # It is assumed that the file 'filename' only contains lowercase characters # and whitespace. ## INPUT # filename is the file containing the text from which we wish to develop a # Markov process. # ## OUTPUT # p is a 26...
c821a3d084e84ec8731bc1b7a3414a26b37e5bf5
JamesLegros/online_courses
/edX/MITx-6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python/Week 1/Problem Set/vowelCount.py
413
3.6875
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 20 15:04:49 2016 @author: jameslegros """ # Assume s is a string of characters s = 'azcbobobegghakl' #Length length = len(s) #String increment i = 0 #Vowel count count = 0 while (length > i): if s[i] == 'a' or s[i] == 'e' or s[i] == 'i' or s[i] == 'o' or s[...
ad36914dfa98a46eedb31e2d48c248ab6c7ea0b9
2019-reu-cmp/assignments-mcgille4
/Day03/sunspots.py
1,464
3.734375
4
# -*- coding: utf-8 -*- """ Created on Tue Jun 4 22:15:32 2019 @author: Emily """ #Read the contents of the file. with open('sunspots.txt', 'r') as f: entire_file = f.read() list_of_data = entire_file.split("\n") #Dictionary not necessary for this application, but useful for other applications. dict_of...
d1ec467f22622f4156419a80c0a4f744a1733560
jossthomas/Enigma-Machine
/components/Enigma_Components.py
5,749
4
4
from string import ascii_uppercase #I'll use the index of letters in this to create the rotors class rotor: """These map letters to reciprocal non identical letters and have the ability to rotate and thereby change the key""" def __init__(self, output_sequence, position, turnover_notches): self.positi...
a0a8ad2bd0e252390dceec9f9f163d013ed6941f
lucaslzl/datacleaner
/cleaner.py
2,373
3.5
4
import pandas as pd """ Class specialized in cleaning files by removing columns """ class DataCleaner: def __init__(self, old_separator=',', new_separator='\t'): self.old_separator = old_separator self.new_separator = new_separator def validate_formatting(self, data_header): try: columns = len(data_head...
6db0d373294a30889bc58af255a044a630b001c2
Ignl94/OOP_Challenge
/person.py
809
3.9375
4
class Person: def __init__(self, name, age, fav_color): self.name = name self.age = age self.fav_color = fav_color def say_hello(self): print(f'Hi, my name is {self.name}') def change_fav_color(self, new_color): self.fav_color = new_color class Swimmer(Person): ...
81f17c765090682ea97cc89b1ab8e078420b6149
PARKINHYO/Algorithm
/python algorithm interview/8장 연결 리스트/Q18. 홀짝 연결 리스트.py
938
3.84375
4
""" fixme https://leetcode.com/problems/odd-even-linked-list/ Q18. 홀짝 연결 리스트 연결 리스트를 홀수 노드 다음에 짝수 노드가 오도록 재구성하라. 공간 복잡도 O(1), 시간 복잡도 O(n)에 풀이하라. 입력 : 1 → 2 → 3 → 4 → 5 → NULL 출력 : 1 → 3 → 5 → 2 → 4 → NULL 입력 : 2 → 1 → 3 → 5 → 6 → 4 → 7 → NULL 출력 : 2 → 3 → 6 → 7 → 1 → 5 → 4 → NULL """ class ListNode: def __...
47c435abe8ff3e753a90c65615d1e9cf9c5e0759
PARKINHYO/Algorithm
/BOJ/2675/2675.py
274
3.625
4
S = int(input()) R = [[x for x in input().split()] for y in range(S)] word="" word2="" word3="" for i in range(S): word = R[i][1] for j in range(len(word)): word2 = word[j]*int(R[i][0]) word3+=word2 print(word3) word3=""
8f8e65c5ddfff031204d5d14b1dc382640fd4842
PARKINHYO/Algorithm
/BOJ/14681/14681.py
382
3.625
4
import sys input = sys.stdin.readline class Solution: def section(self, x: int, y: int): if x > 0: if y > 0: return 1 else: return 4 else: if y > 0: return 2 else: return 3 x =...
ee9b6ec021050ea49e7f49bd70a80872d8e0d7c6
PARKINHYO/Algorithm
/BOJ/4344/4344.py
564
3.578125
4
from sys import stdin if __name__ == '__main__': C = int(stdin.readline()) answers = [] for i in range(0, C): case = list(map(int, stdin.readline().split())) sum = 0 for j in range(1, len(case)): sum += case[j] average = sum / case[0] count = 0 f...
3cd9373974ec8d9e6cf48ae07df009ae08c7467d
PARKINHYO/Algorithm
/python algorithm interview/7장 배열/Q08. 빗물 트래핑.py
1,717
3.828125
4
""" fixme. https://leetcode.com/problems/trapping-rain-water/ fixme. Q08. 빗물 트래핑 fixme. 높이를 입력받아 비 온 후 얼마나 많은 물이 쌓일 수 있는지 계산하라. fixme. Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] fixme. Output: 6 fixme. Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. fixme. In this...
a6be9f5148c961aa5db5db0756ee37aa7288c5c9
PARKINHYO/Algorithm
/BOJ/11651/11651.py
196
3.5
4
N = int(input()) YX = [] for i in range(N): x, y = map(int, input().split()) YX.append([y, x]) YX.sort() for i in range(N): print(YX[i][1], end=" ") print(YX[i][0])
842e5340ebd05a930d99cfca329c1b2561b69717
PARKINHYO/Algorithm
/BOJ/10816/10816.py
642
3.5
4
from typing import List import collections from sys import stdin class Solution: def numberCard2(self, N: int, cards: List[int], M: int, problems: List[int]) -> List[int]: answer = [] counter = collections.Counter(cards) for problem in problems: if problem in counter: ...
96f8cc0fb564055d1f19450dac272a0831d2d698
PARKINHYO/Algorithm
/python algorithm interview/8장 연결 리스트/Q16. 두 수의 덧셈.py
1,775
3.546875
4
""" fixme. https://leetcode.com/problems/reverse-linked-list/ Q16. 두 수의 덧셈 역순으로 저장된 연결 리스트의 숫자를 더하라. 입력 (2 → 4 → 3) + (5 → 6 → 4) 출력 7 → 0 → 8 """ from typing import List class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def reverseList(self, head: L...
5996622953fc825a749142f8261eeb22764ba0cd
PARKINHYO/Algorithm
/BOJ/1427/1427.py
131
3.828125
4
number = [int(i) for i in input()] number.sort() number.reverse() for i in range(len(number)): print(number[i], end="")
284cfbf93ef9d67e6b1dc89d7aebb6b32b65462a
PARKINHYO/Algorithm
/python algorithm interview/8장 연결 리스트/Q15. 역순 연결 리스트.py
974
3.78125
4
""" fixme https://leetcode.com/problems/reverse-linked-list/ Q15. 역순 연결 리스트 연결 리스트를 뒤집어라. 입력 : 1 → 2 → 3 → 4 → 5 → NULL 출력 : 5 → 4 → 3 → 2 → 1 → NULL """ class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def reverseListRecur(self, head...
f47742566b3032e9bb543eec8ec45e556e2478e5
PARKINHYO/Algorithm
/BOJ/2588/2588번.py
219
3.515625
4
def myfunc(a, b, b2): if b2 == 0: print(a*b) return print(a * (b2 % 10)) myfunc(a, b, b2//10) if __name__ == '__main__': n1 = int(input()) n2 = int(input()) myfunc(n1, n2, n2)
e2598f39a718b6908ae87bf5cf46f91329ba7891
karan6181/AStarSearchAlgorithm
/src/heuristic.py
6,292
3.921875
4
""" File: heuristic.py Language: Python 3.5.1 Author: Aravindh Kuppusamy (axk8776@g.rit.edu) Deepak Sharma (ds5930@g.rit.edu) Karan Jariwala (kkj1811@g.rit.edu) Description: Various heuristic functions that returns the heuristic distance from one state to the goal state. """ import copy im...
8d7e16afde1e254e84e849e79bd96ab82d7cf733
torreskatherine/08-course-grader
/course_grader.py
595
3.609375
4
def course_grader(test_scores): test_avg = sum(test_scores)/len(test_scores) if test_avg >= 70 and min(test_scores) > 50: return("pass") elif test_avg < 70 or min(test_scores) <= 50: return("fail") def main(): print(course_grader([100,75,45])) # "fail" print(course_grader([...
bd697ef5acedaf9c3bbc127dfde88c7d4fd0feea
ottocode/archives
/seniorproject/docs/grammer/arrangeterminals.py
3,376
3.65625
4
### Arrange terminals of grammar # ======================================================================== # # Convert my text-representation of the grammer into a data-structure that # can be used in a program # # The format will be: # G = [[symbol0, [p0], [p1], [p2]], # [symbol1, [p0],...
91a33d5e596304be7ad9a9191b240672981b6259
sherkhancrs/codeSignal
/arrayChange.py
266
3.578125
4
def arrayChange(inputArray): count = 0; for i in range(len(inputArray)-1): if inputArray[i+1]<=inputArray[i]: while inputArray[i+1]<=inputArray[i]: inputArray[i+1]+=1 count+=1 return count print(arrayChange([-1000, 0, -2, 0]))
3ce244af7bb3acd2caee5a6813f35a27a7bf775e
LambdAurora/algoprog1
/ch3/tp3_graph.py
2,331
3.609375
4
import graph from random import randrange def black_left_column(width, height, length): for y in range(height): for x in range(width): if x < length: graph.plot(y, x) def black_rectangle(x1, x2, y1, y2): for y in range(y1, y2): for x in range(x1, x2): ...
6d63273b82815d33226d51ddf224e22434bbaded
WalterVives/Project_Euler
/4_largest_palindrome_product.py
975
4.15625
4
""" From: projecteuler.net Problem ID: 4 Author: Walter Vives GitHub: https://github.com/WalterVives Problem: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers...
8b70e1a09f0fbb6a6027b3f510bf408719c2176c
mikesamuel/randos
/pyparsepy/ops.py
7,691
3.90625
4
""" Defines operators for python, and an operator precedence function. """ from lex import Token BRACKET_PAIRS = { '(': ')', '[': ']', '{': '}', '>>>': '<<<', } OPEN_BRACKETS = tuple(BRACKET_PAIRS.keys()) CLOSE_BRACKETS = tuple(BRACKET_PAIRS.values()) INFIX = 'INFIX' POSTFIX = 'POSTFIX' PREFI...
2d97dd0bbf8811c639f5847dc792800a7f974207
zspann/cssi-prework-string-lab
/invitation.py
1,083
3.78125
4
### Challenge 1 - Percy Replacement: def percy_replacer(string_about_percy): return string_about_percy.replace("Percy", "Ron") ### Challenge 2 - String Interpolation: def weasley_invitation(name,day,date,month): return "The family of {first_name} Weasley proudly invite you to celebrate their graduation from H...
1283dcd95c34498969dcd8cba8029f6217ae1180
larryzju/zoj
/3519.py
495
3.5625
4
#!/usr/bin/env python def who_is_the_smartest_man( caocao, peoples ): peoples = sorted( peoples ) skipped = 0 for i in range( len(peoples) ): if caocao < peoples[i]: caocao += 2 else: skipped += 1 caocao += skipped print caocao try: while True: ...
01d0a4d96799d6c687dbd71fac774d8eff7823be
J-Farish24/OOP-Exercises
/RetailItemClass.py
641
3.515625
4
#Create Retail Item class class RetailItem: #Intialize object with data attributes def __init__(self, descr, inv, price): self.__description = descr self.__units = inv self.__price = price #Mutator methods def set_descr(self, descr): self.__description = descr de...
d77fbc93d265064a7094d64f1c8f0e4f8408ec4d
Genskill2/02-bootcamp-estimate-pi-mkarth1k
/estimate.py
1,840
3.53125
4
import math import unittest import random def wallis(n): pi = 0.0 for i in range(1, n): x = 4 * (i ** 2) y = x - 1 z = float(x) / float(y) if (i == 1): pi = z else: pi *= z pi *= 2 return pi class TestWallis(unittest.TestCase): def ...
74914ed8c197d826a7c557c8a1fcd3c8e3c805aa
aryanirani6/ICS4U-Classwork
/example.py
866
4.5625
5
""" create a text file with word on a number of lines 1. open the text file and print out 'f.read()'. What does it look like? 2. use a for loop to print out each line individually. 'for line in f:' 3. print our words only with "m", or some other specific letter. """ # with open("Some_file.txt", 'r') as f: # print(f.re...
6798074572ee5e82a5da113a6ace75b4670ae00c
aryanirani6/ICS4U-Classwork
/classes/classes2.py
2,179
4.375
4
""" name: str cost: int nutrition: int """ class Food: """ Food class Attributes: name (str): name of food cost (int): cost of food nutrition (int): how nutritious it is """ def __init__(self, name: str, cost: int, nutrition: int): """ Create a Food object. Arg...
b4544106396d01246d77056efea9318d93c2e703
Waqas-Ali-Azhar/programming_practice
/leetcode/merge-two-binary-trees.py
2,810
3.984375
4
#https://leetcode.com/problems/merge-two-binary-trees/description/ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None from collections import deque class Solution(object): def mergeTrees(self, t1,...
59b42a9927270598dd784b7c9d2da1de69bb3d28
Waqas-Ali-Azhar/programming_practice
/codejam-2018/c.py
440
3.609375
4
# Incorrect def make_rectangle(A): board = [ ['.' for i in range(1001)] for j in range(1001) ] print("{} {}".format(2, 2)) count = 3 i = 1 j = 1 while i > 0 and j > 0: line = raw_input() i = int(line.split(' ')[0]) j = int(line.split(' ')[1]) print("2 {}".format(count % A)...
5ca14ce2e84e1375c7b3198b6e4a4661d97f3d08
Waqas-Ali-Azhar/programming_practice
/leetcode/middle-of-the-linked-list.py
434
3.78125
4
# https://leetcode.com/problems/middle-of-the-linked-list/description/ # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def middleNode(self, head): first = head second = head while second an...
8028b7aa23465443d7966084002034b4b8f22934
Waqas-Ali-Azhar/programming_practice
/leetcode/path-sum-iii.py
985
3.71875
4
# https://leetcode.com/problems/path-sum-iii/description/ # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None from collections import deque class Solution: def pathSum(self, root, sum): """ ...
c97104bba975c895bb153b100344ba8da1cd169a
Waqas-Ali-Azhar/programming_practice
/leetcode/keyboard-row.py
623
3.578125
4
#https://leetcode.com/problems/keyboard-row/ class Solution(object): def findWords(self, words): keyboard = ["qwertyuiop", "asdfghjkl", "zxcvbnm"] op = [] for word in words: if (word == ""): op.append(word) else: valid = 1 ...
9655d39628d7f2f93f9b77c9d9732af8ffc84bc4
Waqas-Ali-Azhar/programming_practice
/leetcode/average-of-levels-in-binary-tree.py
1,080
3.6875
4
# https://leetcode.com/problems/average-of-levels-in-binary-tree/description/ # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None from collections import deque from statistics import mean class Solution: d...
7416e1c946d17374332e7e4ebabb09eb159aaa97
GribaHub/Python
/exercise15.py
967
4.5
4
# https://www.practicepython.org/ # PRACTICE PYTHON # Beginner Python exercises # Write a program (using functions!) that asks the user for a long string containing multiple words. # Print back to the user the same string, except with the words in backwards order. # clear shell def cls(): print(50 * "\n"...
c7d358369e2cebfb0bb62b58f6e3affc637675cc
GribaHub/Python
/exercise08.py
2,137
4.09375
4
# https://www.practicepython.org/ # PRACTICE PYTHON # Beginner Python exercises # Rock Paper Scissors # Make a two-player Rock-Paper-Scissors game. # Hint: Ask for player plays (using input), compare them, print out a message of congratulations to the winner, and ask if the players want to start a new game. #...
2c34d6968fe8ad668b7c8d443de19b381d45cba9
GribaHub/Python
/exercise18.py
2,915
3.96875
4
# https://www.practicepython.org/ # PRACTICE PYTHON # Beginner Python exercises # Create a program that will play the “cows and bulls” game with the user. The game works like this: # Randomly generate a 4-digit number. Ask the user to guess a 4-digit number. # For every digit that the user guessed correctly in...
dca9c5f3548711b16c7736adc0588fff766c95a1
kirubakaran28/Python-codes
/valid palindrome.py
359
4.15625
4
import re def isPalindrome(s): s = s.lower() #removes anything that is not a alphabet or number s = re.sub('[^a-z0-9]','',s) #checks for palindrome if s == s[::-1]: return True else: return False s = str(input("Enter ...
97a07ff8610f9950da31b1891698fd8b4514b1aa
agchen92/CIAfactbook
/CIAfactbook.py
2,209
4.125
4
#This project, I will be working with the data from the CIA World #Factbook, which is a compendium of statistics about all of the #countries on Earth. This Factbook contains demographic information #and can serve as an excellent way to practice SQL queries in #conjunction with the capabilities of Python. import pandas ...
e1eba3ab225876a640cbe819447de603c0ff7727
lu-jeremy/Python
/tkin/classquiz.py
7,576
3.703125
4
import tkinter # quiz of five, show results at end class quiz(): def __init__(self): self.root = tkinter.Tk() self.root.title('quiz') self.frame1 = tkinter.Frame(self.root) self.frame2 = tkinter.Frame(self.root) self.frame3 = tkinter.Frame(self.root) self.frame4 = tki...
b6f7f8d847619f22f33a7ce8b620eee712de2d20
lu-jeremy/Python
/tkin/tkinterset1part7.py
1,887
3.59375
4
import tkinter from tkinter import messagebox import random #images root = tkinter.Tk() root.title('3') #root.geometry('400x400') heads_img = tkinter.PhotoImage(file = "heads_coin.gif") """ panel = tkinter.Label(root, image = img) panel.pack(side = "bottom", fill = "both", expand = "yes") """ tails_img = tkinter.Ph...
34a62cc6c91a41b745d0096fd13e365a43614131
lu-jeremy/Python
/opencvcode/changingcolorspaces.py
1,413
3.546875
4
import cv2 #more efficient way of storing the information of rows and columns;store images import numpy as np cap = cv2.VideoCapture(0) while(1): #frame (stored in frame) and whether it was successful or not (stored in underscore variable) _, frame = cap.read() # Convert BGR to HSV (hue saturated value)...
beb8400199329bb65c1b2dc92824cb15e68070a9
lu-jeremy/Python
/python_exercises/Basic/youngwonksfibonacci.py
443
3.734375
4
def fibbonaci(n): if n==0: return [0] if n==1: return [0,1] numbers=[0,1] count=2 while count<n: numbers.append(numbers[count-2]+numbers[count-1]) print(numbers[count-2]+numbers[count-1]) count=count+1 return numbers var=fibbonaci(20) print(var) def fib(n...
955cf5b2dc8d55bfb665114eca05da3438f3fa06
yogi-katewa/Core-Python-Training
/Exercises/Daxita/FlowControl/reverse.py
552
3.6875
4
# string = raw_input("Enter list: ") # list1 = list(string) # temp = list1[0] # list1[0] = list1[-1] # list1[-1] = temp # print "".join(list1[::-1]) n=input("How much number you want enter in 1st list: ") list1=[] for i in range(0,n): a=raw_input("Enter element of 1st list: ") list1.append(a) # list1 = ["abcd...
da6be4168e77e38aaa9e59515443bbaf9fa2c6ed
yogi-katewa/Core-Python-Training
/Exercises/Urvi/Flow and Control/p2.py
166
3.65625
4
name= input("Enter name:") print (name) m=list(name) n=m[0] #print (n) #print (m) x=len(m) for i in range(1,x): if(m[i]==n): m[i]='$' print ("".join(m))
34cf749145c20342b57bb30aaae55fbee8e00fc8
yogi-katewa/Core-Python-Training
/Exercises/Deepak/Class and Object/p5.py
395
3.6875
4
class Student: def __init__(self): self.final = [] self.final = "".join(x for x in input("Enter Data : ")).split() self.final1 = [] #print (self.final) def print_data(self): for i in range(0,len(self.final)-1,2): self.final1.append([self.final[i],self.final[i...
cf7b552198679afbf41302a57fb3d1f7abe82cd2
yogi-katewa/Core-Python-Training
/Exercises/Daxita/Collection&iterator/anagrams.py
187
4.0625
4
s = str(input('Enter string:')) word=sorted(s) alternatives = (list(str(ar) for ar in input('Enter string: ').split())) for a in alternatives: if word == sorted(a): print (a)
770d009101a59d9c5d18661e88a25be0c6a28a4f
yogi-katewa/Core-Python-Training
/Exercises/Daxita/Class & Object/circle.py
448
3.96875
4
import math class Circle: def __init__(self,radius): self.radius=radius def area(self,radius): self.radius=radius a=math.pi*self.radius**2 return a def parimeter(self,radius): self.radius=radius p=2*math.pi*self.radius return p r=int(input('Enter the radius of circle: ')) c=Circle(r) area=c.area(r) pr...
dbb2e9c586952161a0dbfc60a5fc79908440938f
yogi-katewa/Core-Python-Training
/Exercises/Daxita/FlowControl/paramgram.py
296
3.734375
4
flist=[] str1=raw_input("Enter any sentence for find paramgram or not..") str2=str1.split(' ') print str2 str3=''.join(str2) print str3 str4=list(str3) print str4 for i in str4: if i not in flist: flist.append(i) print flist l=len(flist) if l == 26: print "pangram" else: print "not pangram"
f1673b7cdc71e508b92e646451d85a7202455c62
yogi-katewa/Core-Python-Training
/Exercises/Urvi/class and Object/parent.py
342
3.90625
4
from abc import ABCMeta, abstractmethod class Polygone: __metaclass__ = ABCMeta def __init__(self): self.n = int(input("Enter the number of sides")) self.list_size = [int(a) for a in input('Enter size of sides: ').split()] @abstractmethod def compute_Area(self): """Abstract met...
4fc94027ff82cdb4e33ecb1d5a14d6a98b00de28
kevinaloys/Kpython
/WebAnalytics/Prediction.py
1,363
4.09375
4
# Prediction # Every week the number of unique visitors grows with 7% compared to the previous week. # Giving an integer number N representing the number of unique visitors at the end of this week and an integer number W # Your task is to # write a function that prints to the standard output (stdout) the number...
45848f3c302f10ff1eb1e48363f4564253f02aa5
kevinaloys/Kpython
/make_even_index_less_than_odd.py
502
4.28125
4
# Change an array, such that the indices of even numbers is less than that of odd numbers, # Algorithnms Midterm 2 test question def even_index(array): index = [] for i in range(len(array)): if(array[i]%2==1): index.append(i) #Append the index of odd number to the end of the list 'index' else: index.i...
bf94c8922a49d0e1c39bd4b7d0a1155c49dff54c
kevinaloys/Kpython
/k_largest.py
463
4.1875
4
# Finding the k largest number in an array # This is the Bubble Sort Variation # Will be posting selection sort variation soon.. def k_largest(k,array): for i in range(0,len(array)-1): for j in range(0,len(array)-1): if (array[j] < array[j+1]): temp = array[j+1] array[j+1] = array[j] array[j] = temp...
c7e52c8a090a63d1d7de0a9993f663e993710bb5
kevinaloys/Kpython
/WebAnalytics/Growth.py
873
4.03125
4
#coding: utf-8 # Growth # Given two integer numbers d1 and d2 representing the unique visitors on a website on the first and second day since launch # Your task is to # write a function that prints to the standard output (stdout) the word: # "Increase" if the number of unique visitors is higher or at lea...
73a55e71d28e290517f5a9e73d99052473d03f52
talhaibnmahmud/Codeforces
/Python/In Search of an Easy Problem.py
237
3.5
4
"""Codeforces problem 1030A "In Search of an Easy Problem" """ if __name__ == "__main__": n = int(input()) answers = [int(x) for x in input().split()] if any(answers): print("HARD") else: print("EASY")
e25033a3260e03a93fdc9824780b942919d17393
talhaibnmahmud/Codeforces
/Python/Hulk.py
343
3.828125
4
"""Codeforces problem 705A - Hulk """ if __name__ == "__main__": n = int(input()) FIRST_PHRASE = "I hate that " SECOND_PHRASE = "I love that " result = "" for i in range(1, n + 1): if i % 2 == 1: result += FIRST_PHRASE else: result += SECOND_PHRASE pr...
848895db1c5682788f09bd4902eb0c0e0d1b514c
AnnaVitry/python
/calculator.py
3,121
3.953125
4
#!/usr/bin/env python3 from tkinter import * import math window = Tk() calc_input = "" result = 0 def input_key(value): global calc_input if is_number(value) == False and float(result_text.get()) != 0: calc_input = result_text.get() calc_input += value calc_input_text.set(calc_input) def equa...
e6b0c382b6e3772efccebbb9fb4bf52641e1e5c4
Yogessh3/Product-Companies
/delete_middle.py
1,021
3.875
4
class Node: def __init__(self,data): self.data=data self.head=None self.next=None class LinkedList: def __init__(self): self.head=None def insert(self,data): if(self.head is None): new_node=Node(data) self.head=new_node else: new_node=...
900c930e7e598329b21b3d329e117e6e394a005b
SarinSwift/Graph-Challenges
/challenge_5.py
4,801
4.15625
4
import sys class Vertex: def __init__(self, v_name): self.name = v_name self.neighbors = {} # key: neigbor vertex object, value: weight of connecting edge self.parent = None def add_neighbor(self, v, w=0): '''Given input is already a vertex object. v: the conne...
d23398d61caee4d5b105ef6846c7b04adb8988c6
dschradick/Python-Toolbox
/NLP.py
8,767
3.578125
4
########## NATURAL LANGUAGE PROCESSING #### Reguläre Ausdrücke # split, findall, search, match: # => siehe Regex.py import re my_string = "Dies ist der erste Satz! Ist das lustig? Denke schon. Sind das 4 Sätze? Oder wieviele Worte?" # Satzenden finden sentence_endings = "[.?!]" print(re.split(sentence_endings, my...
54111ed1eb39ed206b8d14b320f99888f2dba378
Environmental-Informatics/python-learning-the-basics-brucewong23
/wang2846_assignment-01/wang2846_Exercise_3.3.py
3,545
3.609375
4
#################### # Header # Jan. 17 2020 # Shizhang Wang # 0027521360 # the commented parts are different trials # trial 1: 2 mins, trial 2: 8 mins, trial 3: more than I want to admit.. # more details in in-line comments ########## Trial 3 ############ def print_twice(x): print(x, end=' ') ...
a8f50b8321af1c44645978eceb1d4dd2061d22fe
IreneLopezLujan/Fork_List-Exercises
/List Exercises/find_missing_&_additional_values_in_2_lists.py
420
4.25
4
'''Write a Python program to find missing and additional values in two lists.''' list_1 = ['a','b','c','d','e','f'] list_2 = ['d','e','f','g','h'] missing_values_in_list_2 = [i for i in list_1 if i not in list_2] additional_values_in_list_2 = [i for i in list_2 if i not in list_1] print("Missing values in list 2: "+str...
975acb3772e411de687fe70e3f202841b38fb9d7
IreneLopezLujan/Fork_List-Exercises
/List Exercises/retrurn_length_of_longest_word_in_given_sentence.py
396
4.375
4
'''Write a Python function that takes a list of words and returns the length of the longest one. ''' def longest_word(sentence): words = sentence.split() length_words = [len(i) for i in words] return words[length_words.index(max(length_words))] sentence = input("Enter a sentence: ") print("Longest word: "...
d0abab61584a1e26db983ed8b3e2d227b25fd98b
IreneLopezLujan/Fork_List-Exercises
/List Exercises/make_set_of_list.py
367
4.0625
4
'''Write a Python function that takes a list and returns a new list with unique elements of the first list.''' num_list = [1,2,2,2,3,3,4,4,4,4,5,5,5,5,5] set(num_list) # is se set ban raha h list nahei ban rahi '''for making list''' unique_elements = [] for i in num_list: if i not in unique_elements: un...
3404cfd776b2e315c91ebb8b816e89a86c8105ea
IreneLopezLujan/Fork_List-Exercises
/List Exercises/find_smallest_item_in_a_list.py
169
4.09375
4
'''Write a Python program to get the smallest number from a list''' def smallest_item(items): return(min(items)) items = [2,4,5,8,3,0] print(smallest_item(items))
a00774543825bd9d420247b97688a7ac0c7cfeca
IreneLopezLujan/Fork_List-Exercises
/List Exercises/find_maximum_occurring_chars_in_given_str.py
499
3.921875
4
'''Write a Python program to find the maximum occurring character in a given string.''' string = input("Enter an string: ") chars = [] count = [] for i in string: if i not in chars: chars.append(i) for i in chars: n = 0 for j in list(string): if i == j: n+= 1 count.append(...
9130b28e64a5df4d24b46871593c865b2d5223a3
aatarifi/ud120-projects
/svm/svm_author_id.py
2,006
3.625
4
# coding: utf-8 # !/usr/bin/python """ This is the code to accompany the Lesson 2 (SVM) mini-project. Use a SVM to identify emails from the Enron corpus by their authors: Sara has label 0 Chris has label 1 """ import sys from time import time sys.path.append("../tools/") from email_preprocess i...
cac1cd414b24faec5a590d2855c847c3230de769
aadankan/Cwiczenia
/frame.py
358
3.515625
4
from tkinter import * from PIL import ImageTk, Image root = Tk() root.title('Hi!') root.iconbitmap(r'C:\Users\aadan\Desktop\2.ico') frame = LabelFrame(root, padx=50, pady=50) frame.pack(padx=10, pady=10) b = Button(frame, text="Don't click me!") b2 = Button(frame, text="... or here!") b.grid(row=0, column=0) b2.grid...
022fa12e7245d3d42f206df2ccc062185df6146c
MaciejNessel/algorithms
/graphs/alg_kruskal.py
918
3.796875
4
# Implementation of Kruskal algorithm class Node: def __init__(self, val): self.val = val self.rank = 0 self.parent = self def find(x): if x != x.parent: x.parent = find(x.parent) return x.parent def union(x,y): x = find(x) y = find(y) if x == y: retu...
72da947d4566bf7079103ade6adb65fdfa13a06f
MaciejNessel/algorithms
/sort/quick_sort.py
2,170
3.796875
4
# QuickSort (partition Hoare): def partition_hoare(array, low, high): pivot = array[low] (i, j) = (low - 1, high + 1) while True: while True: i = i + 1 if array[i] >= pivot: break while True: j = j - 1 if array[j] <= pivot: ...
2792529dbdd4db606fb737815d68411593c9e185
MaciejNessel/algorithms
/graphs/dfs.py
1,360
3.515625
4
#Implementation of DFS def dfs_arr(graph): def dfs_visit_arr(g, u): print(u, end=' ') nonlocal time time += 1 visited[u] = True for v in g[u]: if not visited[v]: parent[v] = u dfs_visit_arr(g, v) time += 1 time = 0 ...
a2780f68141a881296b02d60fe576a3f5d7a230b
sagarkrkv/Search-Algorithms
/solver16.py
6,318
3.75
4
import sys import heapq ''' This program may cost about 10 seconds to get the result, so please wait for a while. Our heuristic function is calculate the distance position from goal board firstly. For example: [[1, 14, 3, 4], row1 => (0, 0) (0, -1) (0, 0) (0, 0) [8, 2, 6, 7...
6379eb42726147b4875e8e682f2f8e9097789ad6
sarahchen6/112-Term-Project
/mazeGenerationAndSolution.py
6,356
3.59375
4
######################################## # Ho Ho Home: the Santa Maze Game # (mazeGenerationAndSolution.py) # By: Sarah Chen (sarahc2) ######################################## # Maze Generation & Solution ######################################## import random def generateMazeDict(n): mazeDict = {} las...
b9c3b310c900b5a03a4d8c6439e4b42041fee544
disconnect3d/python-ee-labs
/lab1/wc.py
1,292
3.921875
4
"""Word count (wc) unix like program. Usage: wc <file> wc -m | --chars <file> wc -l | --lines <file> Options: -h --help Show this screen. -m --chars Print the character counts. -l --lines Print the newline counts. """ import sys import os from docopt import docopt args = docopt(__doc__) input_f...
b390e256007cc94eef51ba9ef6d9986e156816b3
disconnect3d/python-ee-labs
/lab2/tests/test_player_keyboard_input.py
847
3.53125
4
import unittest import mock import player_keyboard_input PlayerKeyboardInput = player_keyboard_input.PlayerKeyboardInput class TestPlayerKeyboardInput(unittest.TestCase): def setUp(self): self.player = PlayerKeyboardInput('x') self.player._board = mock.MagicMock() def test_make_move_proper...
8df7f9a787d95033855b58f28bd082d7a363e793
SiriShortcutboi/Clown
/ChatBot-1024.py
1,652
4.21875
4
# Holden Anderson #ChatBot-1024 #10-21 # Start the Conversation name = input("What is your name?") print("Hi " + name + ", nice to meet you. I am Chatbot-1024.") # ask about a favorite sport sport = input("What is your favorite sport? ") if (sport == "football") or (sport == "Football"): # respond to football wit...
a3ceed91cd041af6743133cd050e11229d7fbc26
deasymaharani/Grok-Learning
/C7-ITERATION/while loop.py
456
4.09375
4
def mul_table(num,N): n=0 while n<N: result = (n+1)*num print_result = str(n+1) + " * " + str(num)+ " = "+ str(result) n = n+1 print(print_result) num=input("Enter the number for 'num': ") N=input("Enter the number for 'N': ") if not num.isdigit() or not N.isdigit()...
7eafcff44500a06c7cee060805b3195c65a3c349
deasymaharani/Grok-Learning
/C12 - FILES/sorting csv records.py
512
3.609375
4
import csv def sort_records(csv_filename, new_filename): #read from csv fp = open(csv_filename) data = csv.reader(fp) header = next(data) header_list = [header] #extract and sort the data data2 = list(data) content = data2[:] sorted_content = sorted(content) sorted_content = head...
38285c6e09c248116895cff82f9bec44d891c0ed
ShashyChowdary/LearnPython2
/Code/BigNum.py
245
4.03125
4
a = int(input("Enter a number : ")) b = int(input("Enter a number : ")) c = int(input("Enter a number : ")) if a>=b and a>=c : print("big is :", a) elif b>=c and b>=a: print("Big number is :", b) else : print("Big is ", c)
413cd58b70651c1bdc6083ca453da78fc8cc32ae
yousef19-meet/YL1-201718
/lab_5/lab_5.py
851
3.8125
4
##########################################1 ##from turtle import * ## ##class Square (Turtle): ## def __init__(self,size): ## Turtle.__init__(self) ## ## self.shapesize(size) ## self.shape("square") ## ##S1= Square(10) ##########################################2 ##from turtle import *...
724db8d86b1faae414d95ba84596a37d95f26f7d
MOON-CLJ/learning_cpp
/zju_py/1002.py
1,434
3.5625
4
import sys def can_place_if(maps, x, y, count): if maps[x][y] == 'X': return False # x for x1 in range(x - 1, -1, -1) + range(x + 1, count): if maps[x1][y] == 'M': return False if maps[x1][y] == 'X': break # y for y1 in range(y - 1, -1, -1) + range(...
5b479e8d4d1aff29a8009449fccd77c3044eb1b9
RobertLeonhardt/FallingBlocks
/main.py
1,918
3.765625
4
""" main.py Falling Blocks Algorithm Study @date: 2019-11-10 @author: Robert Leonhardt <mail@4px.io> """ # Imports import sys, pygame from FallingBlocks import FallingBlocks # Init pygame pygame.init() # Define window WINDOW_HEIGHT = 600 WINDOW_WIDTH = 300 WINDOW_TITLE = "Falling Bloc...
4ec31a32886dbd4b465ae1716b8536e5172cf96d
pnuggz/kickstart-2020
/b/main.py
750
3.5625
4
# ALWAYS NECESSARY t = 0 # number of cases t_i = 0 # case number # GLOBAL ARRAY BASED ON THE CASE n = 0 # number of houses a = [] # house prices array b = 0 # budget # WORKING VARIABLES def read_file(): # DEFINE GLOBALS HERE # READ THE LINES FOR EACH CASE line_1 = input() line_2 = input() # SPLIT LINES BY SP...
f81cfce6f8e5e4e01086df9ef455e9f73f047a34
Mo-na-rh/python_homework
/hw1/8.py
177
4.03125
4
# functions for recursion # numbers of Fibonacchi n = int(input("n = ")) def fib(n): if n in (1, 2): return 1 return fib(n - 1) + fib(n - 2) print(fib(n))
0ecb379e9f534c7774c93e31acecb41ee4d93e41
lxndrvn/python-4th-tw-mentors-life-oop-overload_mentors_life
/mentor.py
1,514
3.75
4
import os import csv from person import Person from student import Student class Mentor(Person): def __init__(self, first_name, last_name, year_of_birth, gender, energy_level, happiness_level, nickname, soft_skill_level): super().__init__(first_name, last_name, year_of_birth, gender, energy_level, happine...
9d9fcd5f8d6b2879a7e0e92e351eadc404aff631
meggangreen/advent-code-2018
/files/day-24.py
9,883
3.515625
4
""" Notes side < army < group < unit, effective power side = immune sys or infection unit: - hit points: amount of damage withstood -- health - attack damage: amount of damage dealt -- damage - attack type: eg radiation, fire, cold, slashing, etc -- weapon - initiative: at...
2b4cb4a8810cce0e75d888f062410ef2bbda76fd
ishtiaque06/next_blue_bus
/pyScripts/csv_parser.py
1,728
3.671875
4
#This file parses a csv file which has multiple titles without commas followed by #multiple lines of comma-separated values and outputs them into separate csv files # Then writes these files into the corresponding days' CSV's. import os.path import csv def parser(): current_dir = os.path.dirname(__file__) #O...
a88db08f69102367f18f6b6b279db83ebd8e82a5
mikebohdan/CGApp
/lab5/app/figure.py
2,999
3.5
4
from math import cos, sin import numpy as np class Point: def __init__(self, x=0, y=0, z=0): self.x = x * 10 self.y = y * 10 self.z = z * 10 def to_vector(self=None): return np.matrix([self.x, self.y, self.z, 1]) class Line: def __init__(self, from_p, to_p): self.f...
25e208529299adf682217e85c0d03136b69958a0
mikebohdan/CGApp
/lab3/app/curve.py
647
3.515625
4
from app.point import Point class Curve: def __init__(self, fpoint, tpoint, hpoint): self.fpoint = fpoint self.tpoint = tpoint self.hpoint = hpoint def __iter__(self): return self._curve_iterator() def _curve_iterator(self): for i in range(0, 101, 5): ...
8c7c2fe69ae3c8c279ddba7bbadee11bd04b5296
idastambuk/shtrikaona-koda
/python/zadatak2.py
225
3.890625
4
"""Napiši skriptu koja od korisnika traži unos tri broja i javlja koji je od tih brojeva najveći.""" a=[] while len (a) < 3: x= int(raw_input("Upisi broj: ")) a.append(x) print "najveći broj je", max(a)