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
7ff4fb5902c8cf03d28e3eaa35bdb0233f07b1ac
No-Life-King/school_stuff
/CSC 131 - Intro to CS/lab4_5-8.py
215
4
4
import math # a function that takes the argument of a radius and returns the area of the corresponding circle def areaOfCircle(r): return math.pi*math.pow(r, 2) # for testing purposes #print(areaOfCircle(5))
067860b9c4e832f265c689f03c9571075a337de0
No-Life-King/school_stuff
/CSC 231 - Data Structures/Homework 7/compareSort.py
1,372
3.5
4
import random, time import bubbleSort, insertionSort, mergeSort, quickSort, selectionSort, shellSort import sys sys.setrecursionlimit(100000) # print("N \t Bubble \t Select \t Insert \t Shell \t Merge \t Quick") print("N \t Shell \t Merge \t Quick") for n in range(10000, 100001, 10000): mylist = [] for ...
1df7d1245fc8c4359b7c08ece9c99c52efef58a5
No-Life-King/school_stuff
/CSC 231 - Data Structures/BigO_Practice.py
2,216
3.96875
4
__author__ = 'guinnc' ''' For use in Lab 3. ''' import time, random, math def mystery1(n): '''What is it's big O?''' sum = 0 for i in range(0, 10): sum += n return sum def mystery2(n): '''What is it's big O?''' sum = 0 for i in range(0, n): sum += i return sum def my...
9ffcff7ababc693ba6560973f1b056a3cfd44e83
No-Life-King/school_stuff
/CSC 380 - Design and Analysis of Algorithms/username_generator/functions.py
454
3.546875
4
def get_password_list(): password_file = open("source_lists/14.3M_passwords.txt", "r", encoding="latin1") password_list = [] for password in password_file: valid = True for char in password: if 126 < ord(char) < 160: valid = False break n...
bac6da4bfd43ed7f5b24f51ddedfb6a30e438cb2
No-Life-King/school_stuff
/CSC 131 - Intro to CS/lab10_2.py
1,498
3.734375
4
teams_file = open('teams.txt', 'r') teams = [] points = [0]*20 for team in teams_file: teams.append(team.strip()) games_file = open('games.txt', 'r') for match in games_file: clubs, score = match.strip().split(' , ') team1, team2 = clubs.strip().split(' - ') team1 = team1.split(' . ') te...
e7321f7d238fc5bb149511e9e3e25d7b7d6a2529
Sidharth4032/CSCI-1100
/Labs/Lab 10/example_program.py
3,269
3.765625
4
import random import time """ This is the skeleton to demonstrate how to put Lab 10 together. It provides an example to show the use of doctest. Note the function, addone(x) presented below has an additional 4 lines after the normal function description. The lines beginning with '>>>' indicate e...
1e76a6ef9f58ce4dbd29319268e7338c2f721ce7
Sidharth4032/CSCI-1100
/HW/HW07/ole.py
4,158
3.71875
4
def found(dictionary,word): if word in dictionary: return True else: return False def drop(dictionary,word): matches = set() for i in range(len(word)): drop = word[:i] + word[i+1:] if drop in dictionary: matches.add(drop) matches = list(matches) ...
2b3a274fe0d982324a9f7e020970733c1d7d93e2
Sidharth4032/CSCI-1100
/Lecture Exercises/Lecture_08/problem_2.py
552
4.0625
4
values = [ 14, 10, 8, 19, 7, 13 ] new_value1 = int(input("Enter a value: ")) print(new_value1) values.append(new_value1) new_value2 = int(input("Enter another value: ")) print(new_value2) values.insert(2, new_value2) print(values[3],values[-1]) difference = max(values) - min(values) print("Difference: {}".format(di...
661a6eb2633010c8de62cf4be0d27d45cdee40a2
Sidharth4032/CSCI-1100
/HW/HW03/hw3Part3.py
3,045
4.40625
4
''' The purpose of this code is to track the position and power level of a Pikachu as a user enters ten commands that directs the Pikachu to take certain actions. At the end of the code, printed is the final position and power level of the Pikachu, a list of all the commands entered, and a sorted list of all the comman...
ce8951ba0ee86c50d590a626b5e42a9f85494ba6
Sidharth4032/CSCI-1100
/Lecture Exercises/Lecture_10/problem_4.py
336
3.515625
4
co2_levels = [ 320.03, 322.16, 328.07, 333.91, 341.47, \ 348.92, 357.29, 363.77, 371.51, 382.47, 392.95 ] p = float(input("Enter the fraction: ")) print(p) for x in range(len(co2_levels)): co2_levels[x] = co2_levels[x]*(1+p) print('First: {:.2f}'.format(co2_levels[0])) print('Last: {:.2f}'.format(...
65c80a1aa0437f30ac3b1d8fadffad335da8deb3
zhengyscn/go-slides
/reboot/lesson6/scripts/oop3.py
1,018
4.21875
4
'''程序猿 ''' class Programmer(object): # 局部变量, 所有方法均可以直接访问,无需实例化. monkey = 'Play Computer' # 构造函数 def __init__(self, name, age, height): self.name = name # 可以公开访问 self._age = age # 类的私有属性,是编程规范的约束而非Python语法的越苏 self.__height = height # 对外伪私有属性 # 方法 def ge...
3825434744b2d460770cc4a01aadc0928ebf9012
yawsonsamuel320/Logic-Puzzles-with-Code
/The Three Gods.py
3,255
4.28125
4
from random import * # (The Three Alien Gods Logic Puzzle) # The following Logic Puzzle can be found on Ted-Ed: https://www.youtube.com/watch?v=LKvjIsyYng8&vl=en # The Puzzle Conditions # (Condition 1) # Unknown meanings of Ozo and Ulu # Ozo is either True or False x = choice([True, False]) alien_language = {x:...
f7419e7c536b0ca378aa983fda947b212bdc5498
gmerticariu/streamlit-apps
/tutorials/app.py
1,381
3.921875
4
import streamlit as st # To make things easier later, we're also importing numpy and pandas for # working with sample data. import numpy as np import pandas as pd st.title("my first app") st.write("here's our first dataframe") df = pd.DataFrame({ "first": [1,2,3,4], "second": [10 * x for x in [1,2,3,...
5e7801126c7cb04b5aadd168890a0a805b28c2dd
chantelprows/bioinformatics-algorithms
/venv/Lib/CS 418/Part 5/suffixArray.py
277
3.734375
4
from functools import cmp_to_key def suffixArray(text): cmp = lambda i, j: \ [1, -1][text[i] < text[j]] if text[i] != text[j] \ else cmp(i + 1, j + 1) return sorted(range(len(text)), key = cmp_to_key(cmp)) # print(suffixArray('AATCGGGTTCAATCGGGGT$'))
cdd1d8d47b77a07d5397e191b50475b204e62bd7
RinatGumarov/Code-metrics
/thirdParty/PythonParser/helloo.py
670
3.5
4
import os import math as algebra import time, bs4 import a as hello class A: a = 10 def print_number(self, a): for x in range(1, 5): while (a > 3): print(a) x = 5 a = x + 2 b = q + 5 + s for q in range(1, 5): b + 2 print(a)...
259f11820d403abfd022a319693f15bf0e17156f
nandhinipandurangan11/CIS40_Chapter3_Assignment
/CIS40_Nandhini_Pandurangan_P3_3.py
1,478
4.1875
4
# CIS40: Chapter 3 Assignment: P3.3: Nandhini Pandurangan # This program uses a function to solve problem 3.3 # P3.3: Write a program that reads an integer and prints how many digits # the number has, by checking whether the number >= 10, >= 100 and so on. # (Assume that all integers are less than 10 billion) >> 10 bi...
fb79a0b5ba94f9f3fb97179b85448e8270e19c05
divyadeep1/Internship_at_IITk
/graph_formation/walls_to_graph.py
1,859
3.765625
4
""" Converts walls, provided in json format, to a graph (adjacency list representation). """ import json def make_graph_from_1d_walls(file_name): path_to_input_file = "./json/Make graph/" path_to_output_file = "./json/To extrude/" _walls = "_walls" dot_json = ".json" with open(path_to_input_file+file_name+_w...
c6f2dd94451ab8a2877335b133e1a4b8b0e5c838
betyonfire/gwcexamples
/python/scramble.py
475
4.21875
4
import random print "Welcome to Word Scramble!\n\n" print "Try unscrambling these letters to make an english word.\n" words = ["apple", "banana", "peach", "apricot"] while True: word = random.choice(words) letters = list(word) random.shuffle(letters) scramble = ''.join(letters) print "Scrambled: %s" % s...
0280e779c668237fe909104f7fc7cbbdb420bd8b
AlehAkbashev/MYPT_practise
/4_lab/2_task.py
3,178
3.5625
4
from math import * import pygame from pygame.draw import * def main(x, y): sky(x, y) water(x, y) bird(2*x/3, 0.2*y, 50, 0) bird(0.1*x, 0.005*y, 50, 15) bird(0.1*x, 0.3*y, 50, -15) seagull(3*x/7, 0.75*y, 3*x/4) fish() pass def sky(x, y): rect(screen, DARK_BLUE, [0, 0, x, 0.1*y]) ...
f5be1bc6340012b3b3052e8f6a45df116a1c2d5c
Zahidsqldba07/CodeSignal-solutions-2
/Arcade/Intro/growingPlant.py
1,072
4.53125
5
def growingPlant(upSpeed, downSpeed, desiredHeight): import itertools for i in itertools.count(): if upSpeed >= desiredHeight: return 1 elif i*upSpeed - (i-1)*downSpeed >= desiredHeight: return i '''Caring for a plant can be hard work, but since you tend to i...
172dfb2db723fe86341307a6b391b8592075de71
Zahidsqldba07/CodeSignal-solutions-2
/The Core/Well of Integration/69.houseOfCats.py
745
4.03125
4
def houseOfCats(legs): result = [] for people in range(50): for cats in range(20): if people*2 + cats*4 == legs: result.append(people) return result '''There are some people and cats in a house. You are given the number of legs they have all together. Your task is t...
194084ba00f6b20e68dfd1af50a162e9b032de10
Zahidsqldba07/CodeSignal-solutions-2
/Arcade/Intro/arrayMaximalAdjacentDifference.py
440
3.859375
4
def arrayMaximalAdjacentDifference(inputArray): new = [] n = len(inputArray) for i in range(1, n): dif = abs(inputArray[i] - inputArray[i-1]) new.append(dif) return sorted(new)[-1] '''Given an array of integers, find the maximal absolute difference between any two of its adjacent el...
7eb8c26e89deb1a57753ee4f48facd693ede15cc
John-Moisha/Hillel_ITP_Python_16_09
/OLD_HOME_WORK/HW_9/New_HW_-_9.py
3,770
3.703125
4
from dateutil.parser import parse path = "../Files/authors.txt" # Дан файл authors.txt # Все пункты сделать как отдельные функции(можно создавать дополнительные вспомагательные функции) # 1) написать функцию, которая считывает данные из этого файла, # возвращая список строк в которых есть полная дата и указание на че...
17b85a690befcc87379b5dd3d1f99bf42f77099b
John-Moisha/Hillel_ITP_Python_16_09
/Lesson - 1.py
367
4.28125
4
# num = 5 hi = "Hello, World!" # print (num, type(num)) # print (hi, type (hi)) # print (hi, num) # f_number = 0.6 # print(f_number, type(f_number)) print(2 + 3 * 4) print(2 ** 3) #степень print('2' + '3') print(hi * 3) print(10 / 2) #флоат print(10 // 2) #целое print(11 // 2) print(-11 // 2) print(11 % 2) #остато...
4c932396f7abc88249f6356b8fb30367544327f8
xiongdawei/National-Hoilday-HW
/HW 科学绘图.py
4,440
3.65625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Oct 1 20:00:46 2018 @author: davidxiong """ import time import random import matplotlib.pyplot as plt import numpy as np def listt(x): listtt = [] while x>0: listtt.append(random.randint(0,100000)) x-=1 return listtt # s...
9eaf450a14920198179d4242709157521d16747b
maet3608/minimal-pytest-project
/mymath/calculator.py
914
3.6875
4
def add(a, b): """Return sum of a and b >>> add(1,2) 3 """ return a + b def mult(a, b): """Return product of a and b""" return a * b # no test for this line def div(a, b): """Return a divided by b and Raise exception for b==0""" if not b: raise ValueError("Cannot divide...
d29af428bc63d5c98715b2a16b028cf544b8dbfe
da-the-dev/M3C
/main/mac/chestgen_gui.py
3,059
3.609375
4
from Tkinter import * ######################################## def start(): root = Tk() root.title("Chest prefiller") # When slot selected: def selected(event, frame): frame.configure(bg="yellow") # When slot deselected: def deselected(event, frame): frame.configure...
66bf7413af4127c557af084f90f6c97afe522d61
jemi-droid/Speech-Recognition
/speech_recognition/first.py
874
3.640625
4
#The following example shows a stepwise approach to analyze #an audio signal, using Python, which is stored in a file. #The frequency of this audio signal is 44,100 HZ. import numpy as np import matplotlib.pyplot as plt from scipy.io import wavfile frequency_sampling, audio_signal = wavfile.read("/Users/jem...
2091212aa9ca309d51b0e0c82ad6ead5c11e33cd
wduan2/learning
/python/math/btc.py
870
4.09375
4
#!/usr/bin/env python3 def convert(num, mod): import re if mod == 't' and re.search(r'^[0-1]+$', num): return __to_10(num) elif mod == 'b' and re.search(r'^[0-9]+$', num): return __to_2(num) else: print(f"Invalid number format: {num} for mod: {mod}") def __to_10(num): re...
b5b5224678df9f4b9769ca52e87ec135a51a08fb
vlthomas11/Module7
/fun_with_collections/sort_and_search_arrays.py
289
3.90625
4
def search_array(a_array,item): a = sort_array(a_array) if item in a: return a.index(item) else: return -1 def sort_array(a_array): sortedarray = sorted(a_array) return sortedarray if __name__ == '__main__': print(search_array([3,5,10,6,15],6))
39d755ef97d3b7013ce86fcd3aeec3a5da4ff0c2
pola68/wbn
/5-fullScape-mainPage/other/read_my_sqlite.py
685
3.71875
4
import sqlite3 #Opening SQLite Connection sqlite_connection = sqlite3.connect('database.db'); c = sqlite_connection.cursor() file = open("michaltest.txt","w") #Manipulating SQLite DB c.execute("SELECT * from main_audit") rows = c.fetchall() for row in rows: print("Date: %s\nCorp Name: %s\nClientID: %s\nClientName: ...
e9d449cdf605e7b548770edbfc9276df1a87f935
OmkarD7/Python-Basics
/10_set.py
1,304
3.9375
4
#sets number_set = {5, 2, 6, 4, 8} print(number_set) #error- TypeError: unhashable type: 'list' #mixed_type = {4,5,6,[7,8,9]} # #list cannot be item in a set but tuple can be used as an item in set mixed_type = {4, 5, 6, 7, (55, 44, 33)} print(mixed_type) #converting list into set number_list = [4, 5, 7, 8, 8, 9] num...
a288cdf0c28d593175e59f2e8fdff0a2c26cd98f
OmkarD7/Python-Basics
/22_assignment.py
766
4.28125
4
from functools import reduce #find the sum of squares of all numbers less than 10 numbers = [5, 6, 11, 12] sum = reduce(lambda a,b:a+b, map(lambda a:a*a, filter(lambda n: n <= 10, numbers))) print("sum of squares of all numbers which are less than 10: ",sum) #other way without using lambda def fun1(a, b): return a...
f1e22ac3a77bcfd1d09ecdc289a5fcef686ce578
OmkarD7/Python-Basics
/29_threads.py
491
3.765625
4
import threading import time def callMeForEachThread(threadname, delay): counter = 0 while counter <=10: print("Thread Name: ",threadname, " with counter value: " ,counter) time.sleep(delay) counter += 1 thread1 = threading.Thread(target=callMeForEachThread, args=("Thread1", 1)) thread...
451e7436970f2ce96aa15bc70e3627d2b5ed8580
rmetcalf9/python_Testing_Utilities
/tests/test_assertMultiLineStringsEqual.py
4,343
3.625
4
import unittest import python_Testing_Utilities as undertest str1Name="str1" str2Name="str2" class test_assertMultiLineStringsEqual(unittest.TestCase): def test_emptyStrings(self): self.assertEqual(undertest.areMultiLinesStringsEqual("","",str1Name, str2Name),None) def test_passNone(self): self.assertEq...
00334f1a45d775728ef7b2c1e97b99e250a42947
ChrisDancel/head_first_design_patterns_python
/chapters/chapter_4/pizza.py
1,114
3.765625
4
from abc import ABC, abstractmethod from utils import pizza_inventory as pi class SimplePizzaFactory: def createPizza(self, type): pizza_selector = {'cheese': pi.CheesePizza(), 'pepperoni': pi.PepperoniPizza(), 'clam': pi.ClamPizza(), ...
bee62f3a8acd5778268e4dc0bd2948ba88920036
aabritt/twitter
/twitterinfluence.py
5,767
3.75
4
import tweepy # To consume Twitter's API import pandas as pd # To handle data import numpy as np # For number computing from textblob import TextBlob import re consumer_key = "rAezDfgG3lYjfbww4ez2NXbmi" consumer_secret = "6kV4MSWE92V3Bt9wiiYPyjHGLZCnRjVTWhusyEz60aYg4f2bYn" access_token = "10706...
401db0d1c9fa07f71bdfdc93700097dc2a5fcecc
dimliakop/demo_algorithms
/tests/linkedlist/impl/tests/test_queue.py
1,827
3.6875
4
from unittest import TestCase from src.linkedlist.impl.queue import Queue # TODO : implement the Queue class UtilsTestCase(TestCase): def test_create_empty_queue(self): queue = Queue() self.assertEqual('', str(queue)) # def test_create_queue_from_content(self): # queue = Queue(5, 8, 9...
93180b5bc9b9f8454c6a453be0ea359cd5336694
dansmoliik/Malware-graph-detection
/graph_and_web/Cycle.py
821
3.609375
4
class Cycle: def __init__(self, node_ls): self.node_ls = node_ls self.count = 1 self.rpr = "" for node_name in self.node_ls: self.rpr += str(node_name) + " > " self.rpr += str(self.node_ls[0]) def __repr__(self): rpr_temp = ''.join(("Cycle -...
709a63ba721c447fad84ff309e45adc0774d29f5
egosk/codewars
/ML - Iris flower - Scikit/Iris flower - ML - basic exercises.py
1,849
4.125
4
# ML exercises from https://www.w3resource.com/machine-learning/scikit-learn/iris/index.php import pandas as pd import matplotlib.pyplot as plt import numpy as np from scipy import sparse # 1. Write a Python program to load the iris data from a given csv file into a dataframe and print the shape of the # data, type o...
da877bb35d8f3728d2bf91305c8b30e46819b30c
egosk/codewars
/print directory contents.py
606
4.15625
4
""" This function takes the name of a directory and prints out the paths files within that directory as well as any files contained in contained directories. This function is similar to os.walk. Please don't use os.walk in your answer. We are interested in your ability to work with nested structures. """ import os d...
0e426f3f0eb6d3b48102c5e381ba52675211e7f0
skynyrd/python2-teaching-materials
/simple concepts/10.if-elif-else.py
126
4.09375
4
x = 5 y = 5 if x > y: print "x is greater than y" elif y > x: print "y is greater than x" else: print "x and y are equal!"
0e6fd08e400e55e4439ae2be38def0205f5e04a2
skynyrd/python2-teaching-materials
/simple concepts/20.pin.py
231
3.796875
4
pin = "159753" print "Enter your PIN number" input_pin = raw_input() if input_pin != pin: while input_pin != pin: print "Enter your PIN number" input_pin = raw_input() print "Welcome to your account!"
15a51ef00e0eb07f6d8f0d241ec0b5172b1ca2af
WinstonHou/Phython200817
/0817/math and English.py
347
3.890625
4
math = int(input("數學:")) english = int(input("英文:")) if math >=0 and math<=100 and english >=0 and english<=100: if math>=90 and english>=90: print("有獎品") elif math <60 and english<60: print("你會被懲罰") elif math<60 or english<60: print("再加油") else: print("error")
6f1fcce196f029880ba7f261b0d41506da530c93
RivicVisuals/harvard-cs50
/pset7/houses/import.py
955
3.9375
4
import csv from sys import exit, argv import cs50 # check argv if len(argv) != 2: print("Usage: python import.py <input.csv>") exit(1) # reset database open("students.db", "w").close() db = cs50.SQL("sqlite:///students.db") # create tables db.execute("CREATE TABLE students (id INTEGER PRIMARY KEY AUTOINCREME...
916eed004f905fd8cb945b2704374a2209a656a6
lisa-mo/python-advanced
/test/scr.py
1,539
3.984375
4
# def is_int(str): # try: # int(str) # return True # except ValueError: # return False # a = '-123' # print(is_int(a)) # print(a) import math def enter_coefficients(): while True: try: a1, a2, b1, b2, c1, c2 = input("Please enter coefficients for the equation 'a...
5132436157529abb27e60a3e1fc5b63bb9e2554c
IsmailTitas1815/Data-Structure
/codeforces/705A.py
597
3.8125
4
n = int(input()) for i in range(1,n+1): if n == 1: print("I hate it",end="") elif n%2!=0: if i==1: print("I hate that",end="") elif n==i: print(" I hate it", end="") elif i%2!=0: print(" I hate that",end="") else: print(" I...
b397adb67e8f120ec1d8b4aa66752ac5b1f86d67
IsmailTitas1815/Data-Structure
/LinkedList/singlyMainFile.py
3,300
4.0625
4
class Node: def __init__(self,data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def listLength(self): currentNode = self.head count = 1 while currentNode.next is not None: count+=1 currentN...
975946bf640c92ccc1b73c986fe49c7bb863e74b
IsmailTitas1815/Data-Structure
/codeforces/1283B.py
291
3.609375
4
testcase = int(input()) for i in range(testcase): a,b = list(map(int, input().split())) prothome_dimu = (a//b)*b baki = a - prothome_dimu half = b//2 if baki >= half: total = (prothome_dimu) + half print(total) else: print(prothome_dimu+baki)
b082c41d8abcb8f9f8036156384a3c3a2dde05cb
IsmailTitas1815/Data-Structure
/contest/Raif contest/C.py
211
3.765625
4
for i in range(int(input())): str = input() str = str.replace("AB","") str = str.replace("AB","") str = str.replace("BB","") if len(str)>0: print(len(str)) else: print(0)
de27ee7fd30f5b1e358471fedbc170344b3daa6a
IsmailTitas1815/Data-Structure
/contest/676 div 2/B.py
126
3.640625
4
for i in range(int(input())): n = int(input()) li = [] for j in range(n): li.append(input()) print(li)
d35fa14baf405d07f20063d0cba478a20f46775c
IsmailTitas1815/Data-Structure
/codeforces/41A.py
94
3.875
4
str1 = input() str2 = input() if (str1[::-1]) == str2: print("YES") else: print("NO")
16ecb4dd64655cd7257ddab9e6dc21cdf57d4349
IsmailTitas1815/Data-Structure
/Hack codingblocks/math/2.py
157
3.9375
4
n = int(input()) f = True for i in range(2,n): if n%i==0: f = False break if f == True: print("Prime") else: print("Not Prime")
70ac9c6c7755b358e013ed124ad001ad3d508487
robinharris/python3_files
/sensor_app/Menu1Class.py
1,106
3.953125
4
''' Handles the top level menu ''' import os class Menu1: ''' Displays a top level menu and accepts user choice. Validates input and initiates chosen action ''' def __init__(self): self.choice = None def displayMenu1(self): while True: try: print(''' ...
577d8af43864e1e8005264c4389be49f32949733
victorhvn/Reto-18
/Test_gun.py
1,289
3.671875
4
from unittest import TestCase from main import Gun import sys sys.tracebacklimit = 0 class Test_my_Gun(TestCase): def setUp(self): print(self._testMethodDoc) self.my_gun = Gun(100) def test_is_Lock_gun(self): """Test, is lock my gun?""" msg = "Error with function isLock" ...
0474a050995fe4341a072499aeb18112e7d426df
benallard/advent
/2020/day19.py
1,239
3.53125
4
#! /usr/bin/env python import sys check = False rules = {} def valid(input, nr): rule = rules[nr] if isinstance(rule, str): if input.startswith(rule): yield len(rule) else: for choice in rule: yield from valid_seq(input, choice) def valid_seq(input, nrs): # ...
a1e352dc16a4f27a5497def59a6c74d68b0fad79
shrilakshmishastry/VtuquestionPaperSolution
/division.py
241
3.5
4
def Solve(n,m): try: q = n//m r = n%m print("quotient",q) print("reminder",r) except Exception as e: print(e) n = int(input("enter neumarator")) m = int(input("enter denominator")) Solve(n,m)
a6e8db03e85425c507cff306f16675647489a423
shrilakshmishastry/VtuquestionPaperSolution
/concate_and_compare_2_string.py
177
4.25
4
str1 = input("enter first string") str2 = input("enter second string") print("String after concate:"+str1+str2) print("string compare","equal" if str1 == str2 else "Not equal")
ff801d7d43f14d222a8539e0b2ba1ebbd093ed42
shrilakshmishastry/VtuquestionPaperSolution
/search_line.py
106
3.625
4
import re str1 = open("from.txt") for i in str1: if(re.search("^F..m:*",i)): print(i)
3d2d9a0325f9581916bcdafb8f3db64ca1084804
gbalabanov/Hack_BG_101
/Week1/final_round/is_an_bn.py
169
4
4
def is_an_bn(word): return (word[:len(word)//2] == 'a'*(len(word)//2) and word[len(word)//2::] == 'b'*(len(word)//2)) a=input("Enter word: ") print(is_an_bn(a))
ecf5766f2688bd468b6f0f9ff95f39ffb47cffe5
gbalabanov/Hack_BG_101
/Week1/warm_up/fact_digits_task4.py
261
3.984375
4
def factorial(a): fact=1 for x in range(1,a+1): fact*=x return fact def fact_digits(n): currentDigit=0 fib=1 sum=0 while n: currentDigit=n%10 sum+=factorial(currentDigit) n//=10 return sum n=int(input("Enter n:")) print(int(fact_digits(n)))
be9fb44ff6f3177bc7b0564a3751396cfed22756
gbalabanov/Hack_BG_101
/Week1/final_round/magic_square.py
1,204
3.828125
4
def equal_diagonals(matrix): sum1 = 0 sum2 = 0 for x in range(0, len(matrix)): sum1 += matrix[x][x] sum2 += matrix[x][(len(matrix) - 1) - x] return sum1 == sum2 def euqal_cols(matrix): colSums = [] for i in range(0, len(matrix)): for j in range(0, len(matrix)): ...
5791ed774640c4f55a6495741e5d7a2f181b8a7d
gbalabanov/Hack_BG_101
/Week2/2-Files/sum_numbers.py
237
3.515625
4
import sys def sum_numbers(): list_nums = [] filename = sys.argv[1] myfile = open(filename, "r") list_nums = myfile.read().split(" ") print(list_nums) return sum(int(x) for x in list_nums) print(sum_numbers())
f0c640ec86971fe2d02ff454be5bee15e7433c01
gbalabanov/Hack_BG_101
/Week1/the_real_deal/substrings_in_string.py
275
4.15625
4
def count_substring(main,sub): count=0 iterator=main.find(sub) while(iterator != -1): count+=1 iterator=main.find(sub,iterator+len(sub)) return count a=(input("Enter string: ")) b=(input("Enter substring: ")) print(count_substring(a,b));
5b62472566352691430cedeb66a570ad81786b78
ws2823147532/algorithm008-class01
/Week_03/[47]全排列 II.py
2,941
3.890625
4
# 给定一个可包含重复数字的序列,返回所有不重复的全排列。 # # 示例: # # 输入: [1,1,2] # 输出: # [ # [1,1,2], # [1,2,1], # [2,1,1] # ] # Related Topics 回溯算法 # 思考一下,为什么造成了重复,如何在搜索之前就判断这一支会产生重复,从而“剪枝”。<br /> # 利用有序数组的特性(就和之前做15. 三数之和那样):连续两个一样的值那么他后续的排列肯定是和前一个值的排列是一样的<br /><br /> # 但是这道题,需要我们慎重使用这个特性,因为还需要满足一个条件:判重的同时,还要保证当前所处的level,即前后两个值level...
cc5199300bd11fff3e9a3bf846491d4d5fbc3e82
ws2823147532/algorithm008-class01
/Week_03/[70]爬楼梯.py
1,363
3.609375
4
# 假设你正在爬楼梯。需要 n 阶你才能到达楼顶。 # # 每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢? # # 注意:给定 n 是一个正整数。 # # 示例 1: # # 输入: 2 # 输出: 2 # 解释: 有两种方法可以爬到楼顶。 # 1. 1 阶 + 1 阶 # 2. 2 阶 # # 示例 2: # # 输入: 3 # 输出: 3 # 解释: 有三种方法可以爬到楼顶。 # 1. 1 阶 + 1 阶 + 1 阶 # 2. 1 阶 + 2 阶 # 3. 2 阶 + 1 阶 # # Related Topics 动态规划 # leetcode submit region be...
0381026e5a58d2e5ee586c7917742850fb567382
ws2823147532/algorithm008-class01
/Week_02/[111]二叉树的最小深度.py
1,415
3.875
4
# 给定一个二叉树,找出其最大深度。 # # 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。 # # 说明: 叶子节点是指没有子节点的节点。 # # 示例: # 给定二叉树 [3,9,20,null,null,15,7], # # 3 # / \ # 9 20 # / \ # 15 7 # # 返回它的最大深度 3 。 # Related Topics 树 深度优先搜索 # leetcode submit region begin(Prohibit modification and deletion) # Definition for a binary tree no...
a10cc744d5683123a2444267eb4471b17e8b5f65
ws2823147532/algorithm008-class01
/Week_04/[367]有效的完全平方数.py
1,068
3.6875
4
# 给定一个正整数 num,编写一个函数,如果 num 是一个完全平方数,则返回 True,否则返回 False。 # # 说明:不要使用任何内置的库函数,如 sqrt。 # # 示例 1: # # 输入:16 # 输出:True # # 示例 2: # # 输入:14 # 输出:False # # Related Topics 数学 二分查找 # leetcode submit region begin(Prohibit modification and deletion) class Solution: def isPerfectSquare1(self, num: int) -> bool: ...
e8a6326206339e3105928a5f6787b1e2f68aa457
thisIsCamelCasingRule/friendly-lamp
/testUnitest.py
353
3.609375
4
import unittest import geometry import geometry2 class PlaneTestCase(unittest.TestCase): def test_point_input(self): m = geometry2.enter_the_point_2() self.assertEqual(type(m), list) # def test_find_third_point(self): # m = geometry2.find_third_point() if __name__ ==...
68dbddf0e256b1627b1323f0c4d5821ba41fa0f5
adityaagungp/hackerrank-10days-of-stats
/day5/day5-poisson.py
245
3.796875
4
import math def factorial(n): if n <= 1: return 1 else: return n * factorial(n-1) mean = float(input()) k = int(input()) # Poisson distribution pd = ((mean ** k) * (math.e ** -mean)) / factorial(k) print(round(pd, 3))
56e9dcbd6d786d884101ea056ea28239d17b83be
ardhi12/python_fundamental
/args_kwargs.py
386
3.53125
4
# args adalah argument yang lebih dari 1. simbolnya adalah * def printData(*args): for name in args: print(name) printData('ardhi', 'wahyu', 'yudhi') # kwargs adalah keyword argument yang lebih dari 1. simbol ** def printData2(**kwargs): for key, value in kwargs.items(): print(key + ' -> '...
d2978810e5037bb31174766b5974cd305d1f1653
ardhi12/python_fundamental
/for_anak_ayam.py
226
3.953125
4
N = int(input("Masukan jumlah anak ayam = ")) print("Anak ayam turunlah " + str(N)) if N > 1: for i in range(N - 1, 0, -1): print("Mati satu tinggallah " + str(i)) # terminate print("Mati satu tinggal induknya")
84f5ecdcd7c7eac1930cf37d18c73da7e6913860
ardhi12/python_fundamental
/Soal 2.py
1,141
3.96875
4
# Program BeratAtlit # Menerima berat badan atlit # KAMUS # bb : int # kelas : str # ALGORITMA print("-- Range Berat Badan --") print("45 - 50 Kg : Kelas A") print("51 - 55 Kg : Kelas B") print("56 - 60 Kg : Kelas C") print("61 - 65 Kg : Kelas D") print("66 - 70 Kg : Kelas E") print("< 70 Kg : Kelas F") print("> 45 K...
32c61b44184273a3fbe7bebc31accd5aac259087
ProjetPython/OutOfSyria
/choix.py
3,288
3.53125
4
from contour import * from amir import * import time def choix1(amir): print("Aujourd'hui, c'est le grand jour. J'ai réveillé ma famille à 5h du matin afin de m'enfuir.") print("J'ai pris mon téléphone et des vivres. Il me reste de la place pour un objet") print() print("1) Prendre une batterie") print("2) Prendre...
bba4afe60725da9c2ff1bb7027e5e27cbb6e5945
p4radoks/yeni
/14Fonskiyon.py
493
3.53125
4
def asd(x): return x+15 print(asd(5)) #Def ile fonskiyon oluşturuyoruz. fonksiyondaki değeri sonradan belirlemek için bekletiyoruz. Printde fonskiyonun ne yapacağını yazıyoruz. def fonskiyon(): #inputla x'i çekiyoruz. x=input("x'in değerini yazın:") return pow(int(x),4)+3*int(x)+25...
05e987cfc13439ef27bd2abf673d7af6361e707f
rhasan33/aioplate
/src/base/pagination.py
1,148
3.609375
4
class Pagination: def __init__(self, total_pages, page, count, page_size): self._total_pages = total_pages self._page = page self._count = count self._page_size = page_size @property def _next(self): """ Calculating the next page for pagination return...
9bf4ca3e93a56a9c93858c4e83af3bd571f25fd8
quantum-iob/AtCoder
/ABC/A.py
59
3.8125
4
s = input() print('er' if s[len(s)-2::] == 'er' else 'ist')
2dde630523a5bff44665719c769c762e29f2e235
lawrizy/implementation_linked_list
/linked_listv2.py
791
3.96875
4
class Node(): def __init__(self,data=None,next=None): self.data = data self.next = next class LinkedList(): def __init__(self): self.head = Node() def __str__(self): iter = self.head return_str = str(self.head.data)+'-->' while iter.next is not None: ...
96f3e4cdac485c100cbfdfa32d57000e82abc3ee
JayHull/tdd-workshop
/prime_numbers/prime_pytest.py
471
3.609375
4
""" Prime Numbers Kata https://en.wikipedia.org/wiki/Prime_number A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself. 1 is an exception and is not considered a prime. Write a function that takes a number and returns True if it's a prime. """ import sy...
1824c7b87b9ffa4ad858fe0edce7718d182cfc48
juannvictor/Python-2020
/Comandos2.py
756
3.8125
4
import pandas as pd import numpy as np d = {'a':[1,2,np.nan], 'b':[5, np.nan, np.nan], 'c':[1,2,3]} print(d) df = pd.DataFrame(d) print(df) print("\n") print(df.dropna()) #por valor padrão, exclui linhas inteiras que possuem valores vazios print("\n") print(df.dropna(thresh=2)) #só vai excluir linhas q...
088f07aec3fa090ff61b70376bf6e2f169f2241a
Bhumi248/finding_Squareroot_in_python
/squareroot.py
351
4.1875
4
#importing pakage import math print "enter the number u want to squreroot" a=int(input("a:")) #for finding square root there is defuslt function sqrt() which can be accessible by math module print" square_root=",math.sqrt(a) #finding square root without use of math module like:x**.5 print "squareroot usin...
6828a07e52227ddc03f22bb767737eadbdc1d7db
yogabbagabb/PythonProjects
/KLambC1/P4.py
533
3.75
4
''' Created on May 3, 2015 @author: ahanagrawal ''' class approximate(): def __init__ (self,iterations): self.iterations = iterations self.sum = 0 def approx (self): for iter in range(0, self.iterations, 1): self.sum += (-1)^(iter)* (1/(1+2*iter)...
0e2cc054d1a6e57370f17c577fb04ef9bb0a48f6
yogabbagabb/PythonProjects
/NewChapter1_KLamb/PokemonGame/MoveEntry.py
559
3.734375
4
''' Created on Oct 18, 2015 @author: ahanagrawal ''' class MoveEntry (object): def __init__(self, **kwargs): self.__dict__.update(kwargs) def getPoint(self): return self.points def getMove(self): return self.move def str (self): return "Move " + str(...
8f958eef385efefce083e461b9c69953aaa4b244
yogabbagabb/PythonProjects
/OperationsA/MyFunctions/GoldenSearch.py
2,330
3.859375
4
''' Created on Dec 17, 2015 @author: ahanagrawal Accepts a user-provided function that returns one output for every one input. Finds either the minimum or maximum of the function, depending on the choice of the boolean parameter findMin, between the parameters a and b. a and b must contain a minimum between them. T...
e839846f07194e40114a71ec6065e21c6e267b54
KleKlai/python_basics
/strings.py
2,302
3.8125
4
def string_Upper(string): string = str(string).upper() return string def string_Lower(string): string = str(string).lower() return string def string_Length(string): return len(string) def string_Concat(string1,string2): return str(string1)+", "+str(string2) def string_Int_Str(num): num = str(num) return num...
bc86a46866746546fd9cb85c8215d0f170d93431
rubiruchi/Game-Theory-Final-Project
/mazes.py
8,933
3.765625
4
import numpy as np import random WIDTH = 9 HEIGHT = 6 ACTIONS = { 0: (0, 1), 1: (0, -1), 2: (1, 0), 3: (-1, 0) } PENALTY = -2 REWARD_GOAL = 100 REWARD_MOVE = -0.1 ALL_POSITIONS = [(x, y) for x in range(WIDTH) for y in range(HEIGHT)] class Maze: def __init__(self, start, goal, obstacles): ...
d5bce7e6afd1696358a28263721a849b1c9ae52b
Himske/Neural_Networks_from_Scratch
/chapter_4/relu_activation.py
1,128
3.984375
4
import numpy as np import nnfs from nnfs.datasets import spiral_data nnfs.init() class Layer_Dense: def __init__(self, n_inputs, n_neurons): 'Initialize weights and biases' self.weights = 0.01 * np.random.randn(n_inputs, n_neurons) self.biases = np.zeros((1, n_neurons)) def forward(...
e301db9b96bd14bedd6b282638bb0d1782a8980b
jennychiou/Class_RA
/HW/7107029022_1023_RAhomework.py
5,333
3.546875
4
# coding: utf-8 # In[1]: import pandas as pd import numpy as np import seaborn as sns import matplotlib.pyplot as plt # In[2]: #匯入資料 data = pd.read_csv('data/electricity.csv') # In[3]: # 針對用電量設定類別 def get_consumption_category(wt): if wt < 200: return 1 elif 200 < wt < 400: return 2 ...
934889b87b29901d7bb41049fb59729c092d5bf4
durid-ah/Machine_Learning_Basics
/KNN_implementation/KnnClassifier.py
1,262
3.5
4
import numpy as np class KnnClassifier: def euclidean_distance(self, p1, p2): if p2.ndim == 1: # handle one point dist = (p1 - p2)**2 dist = np.sum(dist) else: # handle multiple points dist = (p1 - p2[:, :])**2 # subtracting p2 points from p1 and s...
0258a0bd76f01a2c212ccbee2299cdf31df41bc3
Emmanuelraj/python_playlist
/lessons/string_format.py
131
3.734375
4
num1=1.000003553 num2=3.001245666 # print(num1,'and num2 is',num2); print('num1 is{0:3f} and num2 is{0:4f}'.format(num1,num2))
29d2518ec61a949413145e39b56f523b2900ca01
Hiuze/python-lesson-07
/3.py
165
3.75
4
#өгөгдсөн тооны цифрүүдийн нийлбэрийг ол. n = int(input("n: ")) i = 0 while n > 0: i += n % 10 n = n // 10 print(i)
ddcec50206d9d5489168c68d234d31cde528742c
abhilash97sharma/python_codes
/Cond_stat.py
359
4.15625
4
is_male = True is_tall = False if is_male: print("You are a male") else: print('You are a female') if is_male and is_tall: print("you are male and tall") elif is_male and not is_tall: print('you are male and not tall') elif not is_male and is_tall: print('you are not male and tall') else: prin...
ebdd28443a4eb602e246e5284e300344ce5cd9bf
nihagopala/PythonAssignments
/day3/MaxInThreeNos.py
700
4.5
4
#-----------------------------------------------------------# #Define a function max_of_three() that takes three numbers as # arguments and returns the largest of them. #-----------------------------------------------------------# def Max_Three(a,y,z): max_3 = 0 if a > y: if a > z: m...
b369116c665c70df576807c8cd7f2a1f7545aae3
nihagopala/PythonAssignments
/day1/10. TranposeOfMatrix.py
374
4.40625
4
#----------------------------------------# #Program to display transpose of a matrix #----------------------------------------# matrix = [[1, 2], [3, 4], [5, 6]] rmatrix = [[0, 0, 0], [0, 0, 0]] for i in range(len(matrix)): for j in range(len(matrix[0])): rmatrix[j...
6bcc913eed3ed4d99c607fb12c0400017b247a9e
nihagopala/PythonAssignments
/day1/15. SetOfOperations.py
545
4.53125
5
#----------------------------------------------------------# #Program to print the result of different set of operations #----------------------------------------------------------# set1 = {0, 2, 4, 6, 8}; set2 = {1, 2, 3, 4, 5}; # set union print("Union of set1 and set2 is",set1 | set2) # set intersection...
3b52c1a2d001dcaf357f3fc4a6bdfa1745b75ef8
coding5211/python_learning
/learn2.23/ds_seq.py
663
4.125
4
""" shoplist=["apple","banana","mango","sai"] str="jackrose" print("itme 0 is",shoplist[0]) print("item 1 is",shoplist[1]) print("item 2 is",shoplist[2]) print("str 0 is",str[0]) print("itme 1 to 3 is",shoplist[1:2]) print("item 1 end is",shoplist[1:] ) print("item 1 to -1 is",shoplist[1:-1]) print("item start to end ...
dfb0c66d3559273ebe23d6f6d544739afd0408c0
maplexuci/Tkinter
/06_frames.py
928
4.0625
4
from tkinter import * from PIL import ImageTk, Image root = Tk() root.title("Add Frame") root.iconbitmap('images/icon.ico') # You need to put something in the frame to display the frame. # the padx and pady in the frame is for the elements inside of the frame, that relative to frame. # the padx and pady in frame.pack...
34beb7b8e07f729b21440c65fdbf65c03ce4691d
JasonChuang0323/Leetcode-Jason
/387. First Unique Character in a String/387.py
499
3.609375
4
# Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. # Examples: # s = "leetcode" # return 0. # s = "loveleetcode", # return 2. class Solution: def firstUniqChar(self, s: str) -> int: d = {} for i in s: if i not in d: ...
87c3c79c856a591362e95918901fd4026031f630
ctbeiser/Evolution
/evolution/traitcard.py
2,149
3.84375
4
from .trait import Trait from functools import total_ordering # Because range is inclusive only on the bottom CARNIVORE_FOOD_VALUE_RANGE = range(-8, 8+1) NORMAL_FOOD_VALUE_RANGE = range(-3, 3+1) @total_ordering class TraitCard: def __init__(self, food_value, trait): """ Represents a Card with a Trait and...
7a99ee6006115c07fd9be9ae5c4f13c987c27a76
bs4/LearnPythontheHardWay
/ex15drill2.py
872
3.765625
4
from sys import argv script, file_name, file_name2 = argv txt = open(file_name) txt2 = open(file_name2) print "This is the name of your file: %r" % file_name print txt.read() print "This is the name of your second file: %r" % file_name2 print txt2.read() txt2 = open(file_name2) print "Now I will return only the fi...