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 |
|---|---|---|---|---|---|---|
23ce65dc8e50e30045618ac6514ec174dd470e53 | UskovaKate/Coursework | /2-я часть/3.py | 630 | 4.125 | 4 | #Создать прямоугольную матрицу A, имеющую N строк и M столбцов со случайными элементами.
#Найти наименьший элемент столбца матрицы A, для которого сумма абсолютных значений элементов максимальна.
import numpy as np
N = 6
M = 2
A = np.random.randint(low=-4, high=9, size=(N, M))
print("Матрица:\r\n{}".format(A))
sum =... |
290f471ddd312bbc70a62082ff334b20ae88f0e0 | UskovaKate/Coursework | /2-я часть/2.py | 588 | 4.15625 | 4 | #Создать прямоугольную матрицу A, имеющую N строк и M столбцов со случайными элементами.
#Найти наибольшее значение среди средних значений для каждой строки матрицы.
import numpy as np
N = 6
M = 2
A = np.random.randint(low=-4, high=9, size=(N, M))
print("Матрица:\r\n{}".format(A))
Average = A.mean(axis=1)
index = Av... |
0a75fc19434bdcc3823f690a609d3a4cdc8191eb | AnonymousRandomPerson/TreeSearch | /screen.py | 12,673 | 3.6875 | 4 | # coding: utf-8
from tkinter import *
from data import *
class Screen:
"""The main GUI screen."""
def __init__(self):
"""Initializes the screen elements."""
self.error = None
self.trainer = None
self.secondTrainer = None
self.battleType = None
self.pokemonEntr... |
14b447b5220101496b51e727c164734c27347d19 | algrhythms/ituym-18 | /competition/mafya/mafya.py | 976 | 3.546875 | 4 | """
Created by mbenlioglu on 1/20/2018
"""
def select(num_list):
left, right = 0, len(num_list) - 1
while right - left + 1 > 2:
is_popped = False
for i in xrange(0, len(num_list)/2):
if num_list[i] == num_list[-(i+1)]:
continue
is_popped = True
... |
4d7da8b58cc3cdc091bbba3787cbfff5076c1952 | sidharth08singh/PythonCodingChallenges | /Coding/Src/Q3_ArrayPairSum.py | 1,030 | 3.75 | 4 | #Approach 0: Quadratic Time - Consider all pairs possible using 2 for loops.
#Approach 1: Using Hash Tables.
#Approach 2: Using Dynamic Programming.
class algorithm:
def ArrayPairSum(self, arr, sum):
dict = {}
for i in arr:
if (dict.__contains__(i)):
dict[i] = dict[i] + 1... |
693164df3516d43f5c4bede5717a9c9012f46566 | sidharth08singh/PythonCodingChallenges | /Coding/Src/Essentials/SearchImpl.py | 534 | 3.828125 | 4 | #returns index of the element if found, else returns -1.
class SearchImpl:
def BinSearch(self, arr, searchItem):
low,high = 0, len(arr)-1
arr = sorted(arr)
print arr
while(low <= high):
mid = (low + high)/2
if(arr[mid] == searchItem):
return mi... |
8e18a8d881e2cf08fdf5416bc8059470a1f99df1 | sidharth08singh/PythonCodingChallenges | /Coding/Src/Q20_RecursionStringRev.py | 496 | 4.09375 | 4 | def reverseStringRecursively(str):
if str is "":
return str
else:
return str[-1] + reverseStringRecursively(str[:-1]) #str[:-1] is the entire string barring last character.
#str = "a"
#print reverseStringRecursively(str)
def reverseListRecursively(list):
if len(list) is 0:
retur... |
5032c42c2d6803f7c431807affd6f1aee05ac96f | Niangelina/HackerRank-Challenge | /Data Structures/Stacks/01. Maximum element/maximum-element.py | 802 | 3.828125 | 4 | # sumber link test https://www.hackerrank.com/challenges/maximum-element/problem
def max_find(stack_arr) :
value_maxx = 0
for i in range(len(stack_arr)) :
if value_maxx < stack_arr[i] :
value_maxx = stack_arr[i]
return value_maxx
N = int(input())
stack = []
value_max = 0
for i... |
f700ed3e5efcd3470e429b116d9d645d248c209a | decagonhq/intro-to-python-CoderHal | /divide.py | 251 | 3.90625 | 4 | def divide(number1, number2, floor = True):
try:
if floor == True:
return round(number1/number2)
else:
return number1/number2
except TypeError:
raise TypeError("Values must be integers")
|
9cb67d39a7c80bcae371ef5dccf1da672aced2b2 | duarte15/ListaDicionario | /Questão-3.py | 1,704 | 3.875 | 4 | produtos={}
def cadastrarProduto(produtos, produto, preco):
produtos[produto]=preco
def exibirProdutos(listProdutos):
for x in listProdutos:
print("produto: ",x," preco: ",produtos[x])
def removerProduto(produtos, produto):
del produtos[produto]
print(produtos)
def exibirBaratoProduto(prod... |
98d85c501fa10e00c9d92135e2967cc1c244b34e | rischimart/hathellon | /test/arithmetic/simple_math.py | 117 | 3.546875 | 4 |
a = 1
b = 3
print a + b
print a / b
#c = 8
d = 9
print (a + (b / (c + d))) / (d + c * (a + b))
#print (c + e) / e
|
9619792fc3078bcb9195dec0cdc7340cb45ac053 | thomas-mauran/pong | /Pong.py | 4,127 | 3.515625 | 4 | import turtle
import os
import math
import random
cursor_size = 20
player_height = 60
player_width = 20
court_width = 1000
court_height = 600
#screen
wn = turtle.Screen()
wn.title("PingPangPong")
wn.bgcolor("black")
wn.setup(width = 1.0, height = 1.0)
#bordure
bordure = turtle.Turtle()
bordure.penup()
bordure.colo... |
8d2988e0ff185532ae7ce5d444d09eae0b9a0794 | sebi5361/micropython | /ports/gprs_a9/modules/blink.py | 238 | 3.5 | 4 | import machine
import time
def blink(interval):
print("blink")
led = machine.Pin(27, machine.Pin.OUT, 0)
value = 1
while True:
led.value(value)
time.sleep(interval)
value = 0 if (value==1) else 1
|
da28fd136dda915e73ecafd7a8c1be3ed7c12a16 | sauravtom/testing123 | /classes.py | 747 | 3.875 | 4 |
class Foo:
pass
class Pokemon:
'this class has information about pokemons'
def __init__(self, pokemon_name,pokemon_cp,pokemon_type):
self.pokemon_name = pokemon_name
self.pokemon_cp = pokemon_cp
self.pokemon_type = pokemon_type
self.__foo = 'private variable'
def displayInfo(self):
print self.__foo
... |
de96cc585410c8356590a971bd86505045a03f9e | azrlzhao/password-safty-check- | /check_password.py | 1,724 | 4.125 | 4 |
#Password security check code
#
# Low-level password requirements:
# 1. The password is composed of simple numbers or letters
# 2. The password length is less than or equal to 8 digits
#
# Intermediate password requirements:
# 1. The password must consist of numbers, letters or special characters (only: ~!@#$%... |
6d29f88cd286e41a0806119081e0e196d9a32745 | yanhan-si/intermediatePython | /advancedPython/codeStype/basicOOP.py | 641 | 3.765625 | 4 | class Cat():
def __init__(self, name, age, isIndoor=True):
self.name = name
self.age = age
self.isIndoor = isIndoor
def speak(self):
print(f'{self.name} says, "purrrrrr"')
def __repr__(self):
return self.name
class Dog():
def __init__(self, name, age, breed):
... |
80967f08e13137ec5c6a76efc56ef35b2ea8a548 | wanguinjoka/Password-Locker-Python | /password_locker.py | 5,963 | 4.0625 | 4 | import pyperclip
from user import User
from user import Credentials
def create_user(username,password):
'''
function that creates a new user to the app
'''
new_user = User(username,password)
return new_user
def save_user(user):
'''
function to save a user
'''
user.save_user()
def ... |
fc799de273c4518112db73912c14d86fb0fa3e71 | imajunryou/advent_of_code_2018 | /day_1/frequency.py | 2,706 | 3.671875 | 4 | import argparse
import os
import sys
import profile
from typing import List, Tuple
from oset import oset
def parse_frequency(frequency):
result = 0
try:
result = int(frequency)
except ValueError:
pass
return result
def update_frequency(frequency: 'oset', next_frequency: int) -> 'Tupl... |
c786e729fcdfaf2afb31be9f20d6f1adc3e20016 | karahan-sahin/information-retrival-projects | /Trie Dictionary/query.py | 965 | 3.734375 | 4 | import pickle
import json
import HelperClass
# Read query
query = input("Enter input: ")
# Load inverted index
_inverted_index = open("inverted_index.json", "r")
inverted_index = json.loads(_inverted_index.read())
# Load Trie
_dictionary = open("trie.pickle","rb")
dictionary = pickle.loads(_dictionary.read())
ids =... |
b9f0a7554874afea441a4b3d4610c8b269baa963 | white-hat-vaibhs/python | /python8b.py | 199 | 3.71875 | 4 | age = raw_input ("how old are you ?")
gender = raw_input("Male or female ?")
weight = raw_input("What is your weight")
print "So , you're %r old %r and your weight is %r " %(age,gender,weight)
|
ab7b5ff8e907d45ef3cfbec2bb611ada3b68058d | daninick/test | /word_count.py | 1,318 | 4.375 | 4 | import re
filename = input('''
This program returns the words in a .txt file and their count in it.
Enter a .txt file name: ''')
f = open(filename, 'r')
# Read the file and convert it to a string
text = f.read()
# Ignore the empty lines
text = text.replace('\n', ' ')
# All words in the text are separated by spac... |
cbdc6f451ebc612c8ea377d91504ae26d1e42c26 | ShruthiJaisimha/Neural-Networks | /Neural Network Projects with Python Part1.py | 4,188 | 3.625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
cd C:\Shruthi\Udemy_Course_Mine\Neural-Network-Projects-with-Python-master
# In[2]:
conda env create -f environment.yml
# In[3]:
conda activate neural-network-projects-python
# In[5]:
cd C:\Shruthi\Udemy_Course_Mine\Neural-Network-Projects-with-Python-master... |
43361106ef6c75c9bcbf0b420f72c002b2cf41f8 | paulwongx/freecodecamp | /python_scientific_computing/shape_calculator.py | 1,559 | 3.84375 | 4 | class Rectangle:
def __init__(self, width, height):
self.width = width
self.height = height
def set_width(self, width):
self.width = width
def set_height(self, height):
self.height = height
def get_area(self):
return self.width * self.height
... |
d18a54553d5aa9b68992f6b404bfec62c8c355da | gayathrig269/Linked-List-1 | /remove_nth_node.py | 1,029 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
TC : O(N) as we traverse through the list
SC : O(1) as no extra space used
"""
# Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def removeNthFromEnd(self, head: ... |
faae9023f7340cdb2df5bbe6ddb9f64c4624cd72 | pero5ar/FER.HMO | /reparse.py | 2,263 | 3.53125 | 4 | import argparse
import csv
from typing import Tuple, Dict, Set, List, Deque
class Variables:
def __init__(self):
self.student_activity_dict: Dict[Tuple[str, str], dict] = {}
# Parse:
def parse_arguments():
parse = argparse.ArgumentParser(
description='',
formatter_class=argparse.Raw... |
a7bda31db86212ad8bc83fbc2df3d3da476a04d6 | deepaksood619/Projects | /parking_lot/python-parking-lot-problem-object-oriented/Level.py | 1,260 | 3.734375 | 4 | '''
Created on 2014-11-29
@author: ouyangsiqi
'''
class Level:
'''
The class is the levels of the parking lot
'''
__levelId = 0
__spaces = []
__spaceCount = 0
def __init__(self, spacesOfEachLevel, levelId):
'''
Constructor
'''
self.__levelId = levelId
... |
c38e0d609c3414396e23f7ae50b2bf4695477eb6 | rrotilio/MBA539Python | /p20.py | 482 | 4.15625 | 4 | validInt = False
def doRepeat (str1,int1):
i = 0
while (i < int1):
print(str1)
i = i + 1
print("I like to repeat things.")
varStr = str(input("What do you want me to repeat?: "))
while not validInt:
try:
varInt = int(input("How many times should I repeat it?: "))
if(varInt < 0):
print("I can't repeat ... |
0209d972709a7ce195d634309cf9669117f2f590 | rrotilio/MBA539Python | /p15.py | 132 | 3.90625 | 4 | import math
rad = 6
volume = ((4/3) * math.pi * math.pow(rad,3))
print ("The volume of a sphere with radius",rad,"is",volume,".") |
b5cfbbe439edc01c32af743742bb4b002af88a2d | YG15/DataHack2019 | /src/functions/read_csv_skipping_rows.py | 1,262 | 3.515625 | 4 | import numpy as np
import pandas as pd
def read_csv_skipping_rows(csv_path, skip_ratio):
# Read every Nth line of a csv file.
# For example to read very 10th line, run read_csv_skipping_roxws('my_file.csv',10)
def file_len(fname):
with open(fname) as f:
for i, l in enum... |
69fd01e6ecb6054410b706ece3fdc4e8a42e28be | tompsherman/cspt19long | /Clothing.py | 369 | 3.703125 | 4 | from product import Product
# allows inheritance
#syntax for inheritance class:
class Clothing(Product):
def __init__(self, name, price, color):
#reference the init from product using the super() keyword
super().__init__(name, price)
self.color = color
def __str__(self):
re... |
8b4f11d3fdea093efafc8fc13eb9809d49916bf2 | tompsherman/cspt19long | /graphs/social.py | 6,185 | 3.703125 | 4 | from random import shuffle, randint
from queue import Queue
import time
import random
class User:
def __init__(self, name):
self.name = name
class SocialGraph:
def __init__(self):
self.last_id = 0
self.users = {} # nodes
self.friendships = {} # edges
def add_friendship... |
1cb744029eccad963be49a5aed49fc9e2cabb6fa | vikashpatty/Data-Science-Learnings | /a3/Python_for_Data_Science_L1_Hands_ON_Part-9.py | 1,466 | 3.609375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[2]:
'''
12.Suppose that you want to perform a hypothesis test to help determine whether the correlation between tree girth and tree volume is statistically significant.
Perform a two-sided test of the Pearson's product moment correlation between tree girth and volume at t... |
3fff1efacf1a2e1984ba17f2f13b0ee5dfe1e44d | salemandreus/hackerranks | /python-named-tuples.py | 1,839 | 3.703125 | 4 | from collections import namedtuple
from textwrap import dedent
Student = namedtuple('Student', 'ID, MARKS, NAME, CLASS' )
def parse_input(lines):
""" WIP """
Student = namedtuple('Student', lines[0])
student1 = Student(lines[1])
return student1
def get_average(*args):
""" WIP"""
pass
#... |
8a74241633816ba8560ebeab7444a04e73a67eff | ReemShalaata/Algorithmic-Toolbox-Coursera-MySolutions | /weeks/week2_algorithmic_warmup/2_last_digit_of_fibonacci_number/My Solution.py | 256 | 3.75 | 4 | def get_fibonacci_last_digit_naive(n):
array=[None]*(n+1)
array[0]=0
array[1]=1
for i in range(2,n+1):
array[i]=(int(array[i-1])+int(array[i-2])%10)
return array[n]%10
n = int(input())
print(get_fibonacci_last_digit_naive(n))
|
49cbdcca9a926486d55b162b742da5e2ae0f739d | ganesh-k13/CI-19853-NumPy-Codecov | /main.py | 305 | 4.03125 | 4 | import sys
from myapp.app import multiply_by_two, divide_by_two
def main():
num = int(input("Insert a number: "))
print("The double of %d is %d" % (num, multiply_by_two(num)))
print("The half of %d is %d" % (num, divide_by_two(num)))
sys.exit(0)
if __name__ == "__main__":
main()
|
e980766914cf9153198477df7dd653db9c3636d1 | Gorgious56/MazeGenerator | /maze_generator/maze/algorithm/algorithms/maze_algorithm.py | 2,740 | 3.609375 | 4 | """
Base Maze Algorithm Class
Inherit from this class to extend or create a custom algorithm
"""
from random import (
seed,
random,
shuffle,
choice, # Keep this
randrange, # Keep this
choices, # Keep this
)
from maze_generator.maze.constants import grid_logic as cst
from maze_generator.maze... |
e17b831b1c9c94f59bf63fa4723c0d10625040ff | mariazverina/adventofcode2018 | /day14.py | 1,563 | 3.5 | 4 | class Scoreboard:
def __init__(self):
self.e1 = 0
self.e2 = 1
self.scores = [3, 7]
def tick(self):
s = self.scores[self.e1] + self.scores[self.e2]
if s >= 10:
self.scores.append(1)
self.scores.append(s % 10)
self.e1 += 1 + self.scores[self.e1]... |
5271a42743aff92f0d0cfe191e78177c6113204c | aidanprk/passwordsqlite | /script.py | 2,048 | 3.828125 | 4 | import sqlite3
import random
#Functions
def new_user(name, password):
#creates a new user under table: users
conn = sqlite3.connect('userdata.dp')
c = conn.cursor()
c.execute('select max(id) from users;')
id = c.fetchone()[0]
if id == None:
u_id = 1
else:
u_id = id + 1
n = name
p = password
c.execut... |
bae61db7f2e00224041131b55e86283c4945fd22 | Gevorg102/Lesson_git_1 | /Lesson_3.py | 1,407 | 3.53125 | 4 | """
a = int(input('greq tiv: '))
res = a % 2 == 0
print( res)
"""
'''
people = int(input('qani mard petq e lini: '))
groups = int(input('qani mard ka xmbum?: '))
groups = people // groups
balance = people % groups
print('registered people _', balance, people, '\ngroups _ ', groups, '\nBalance_', balance)
'''
'''
tob... |
7db9bd8d181b425cdf09f356b0b893f1d11c6a35 | Marie-Burns22/data_structures_practice | /LinkedInAlgorithms/recursion.py | 599 | 4.0625 | 4 | def countdown(x):
if x == 0:
print("Done!")
return
else:
print(x, "...")
countdown(x -1)
print("foo")
# countdown(5)
def power(num, pwr):
if pwr == 0:
return 1
else:
return num * power(num, pwr-1)
def factorial(num):
if num == 0:
ret... |
48416b5038ce6e132853010a0b677216ec10e68f | P-Muench/Thesis_Source | /Datastructures/Ability.py | 810 | 3.625 | 4 | class Ability:
_dummy = None
def __init__(self, name: str, cost: float, resource: float):
"""
Initializes an ability by a name, its cost and a resource requirement. Resource req. must be positive and <= 1
:param name:
:param cost:
:param resource:
"""
as... |
856f36bd79f0866552aa760bd9cea652ee4cfdbb | dwzukowski/PythonDojo | /funwithfunctions.py | 2,051 | 4.625 | 5 | def multiply(list, num):
newList = []
for val in list:
newList.append(val*num)
return newList
#we declare a function called layered_multiples which takes one parameter arr
def layered_multiples(arr):
#we declare a variable called new_array which is an empty list
new_array = []
#we insta... |
a03dbd25a62938ef0ed68df80d0df1df9983125e | dwzukowski/PythonDojo | /comparingArrays.py | 1,379 | 4.3125 | 4 | #we declare a function called compareArrays which takes two parameters, list one and list two
def compareArrays(list_one, list_two):
#we delcare a variable answer which is string
answer = ""
#we compare the lengths of teh two lists; if they are not equal the list cannot be the same
if len(list_one) != l... |
d1f1d9a4d2a03bab8643fb8c00c5dcccf7b1462a | dwzukowski/PythonDojo | /classesIntroBike.py | 2,318 | 4.75 | 5 | #we declare a class called bike
class Bike(object):
#we set some instance variables; the miles variable will start at zero for every instance of this class
def __init__(self, price, max_speed):
self.price = price
self.max_speed = max_speed
self.miles = 0
#we declare a method called ... |
7654c068f8136a957fd0f17a00f00c130c0af639 | dwzukowski/PythonDojo | /typeList.py | 1,091 | 4.34375 | 4 | #we declare a function called typeList that takes one paramater, list
def typeList(list):
newStr = ""
sum = 0
#instantiate a for loop
for i in range(0,len(list)):
if isinstance(list[i], int):
sum+=list[i]
elif isinstance(list[i], float):
sum+=list[i]
... |
6fbb373a288803178c264b97addaad5a9cdc09ad | LuisDiazUgena/raspberry-pi-2 | /ras(pi)2-commander/ras(pi)2-commander.py | 928 | 3.96875 | 4 | from Tkinter import *
def doNothing():
print ("Ok, I'm going to do nothing")
root = Tk()
root.title("Ras(pi)2 Commander")
#create menu item 1
mainMenu = Menu(root)
root.config(menu=mainMenu) #Make Tkinter know that mainMenu is actually a menu
root.minsize(width=600, height=200)
root.maxsize(width=780,height=460)
... |
57f5457382402636cae650efcb5d427d7c1c94e7 | didierbaczynski/IntroPython | /exo6.py | 217 | 3.53125 | 4 | dividedBy7=[]
dividedBy5=[]
for i in range(1500,2700):
if (i%7)==0 :
dividedBy7.append(i)
if (i%5)==0 :
dividedBy5.append(i)
print ('divided by 5',dividedBy5)
print ('divided by 7',dividedBy7)
|
8080cda6c3b68a6660f702ea12c4ccdba1835058 | AkankshaSharma00/Python_Code | /primeComposite.py | 203 | 4.09375 | 4 | num=input("Enter number to be checked :");
number=int(num);
for i in range(2, number):
if(number%i==0):
print("Entered number is not prime.");
break
else:
print("Enetered number is prime."); |
9959480252814e93b6977549ba443613bd7ecb47 | akharkhalis/leetcode | /venv/easy/Leetcode_Number of Steps to Reduce a Number to Zero.py | 308 | 4.03125 | 4 |
def numberOfSteps(num):
step = 0
while num !=0:
if (num % 2 ) == 0:
num = num / 2
step += 1
print ( 'Even', num)
if (num % 2) != 0:
num = num - 1
print ( 'odd', num)
step += 1
print (step)
numberOfSteps(123) |
1bdd101dac13cd8cdec4bedfc3d55a95f2eac041 | EduardoZortea18/PythonExercises | /ex005.py | 132 | 3.78125 | 4 | number = int(input('Type a number: '))
print('number {} ancestor {} and successor {}'.format(number, (number - 1), (number + 1))) |
79099a159afe949fe52a38c380382fe35135ae83 | EduardoZortea18/PythonExercises | /ex003.py | 146 | 4.15625 | 4 | n1 = int(input('Type a number:' ))
n2 = int(input('Type another number: '))
sum = n1 + n2
print('sum between {} and {} is {}!'.format(n1,n2,sum)) |
9b9c1fc50ec7de95e4a841f0ae7127678f242e35 | EduardoZortea18/PythonExercises | /ex008.py | 305 | 4.125 | 4 | distance = int(input('Type some distance in meters: '))
print('The distance of {} meters is equal to: \n'
'{}km \n'
'{}hm \n'
'{}dam \n'
'{}dm \n'
'{}cm \n'
'{}mm \n'.format(distance, distance/1000, distance/100, distance/10, distance*10, distance*100, distance*1000)) |
e1cafcff6fd6f27ef097004e5b9b8b2f92bcd093 | ppo223/Leetkou | /9_huiwen.py | 756 | 3.9375 | 4 | # -*- coding:utf-8 -*-
#一行代码搞定:将数字转换成字符列表,切片方法搞定
#return True if str(x) == str(x)[::-1] else False
class Solution:
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""
# for i in x_list[-1::-1]:
# for j in x_list[-1::-1]:
# if i... |
2a499608c62583eb9cdc1911d3157fddca69af0b | gruxic/Ping-Pong | /ball.py | 788 | 3.640625 | 4 | from turtle import Turtle
import random
class Ball(Turtle):
def __init__(self):
super().__init__()
self.shape("circle")
self.color("white")
self.penup()
self.goto(random.randint(-100,150),random.randint(-100,150))
self.x_move=10
self.y_move=10
... |
808e0dbf4601a5fb7f3d98d290c8bdafaf061c23 | arya200/Arya-s-Coding-Projects | /week4-lab4b/program4.py | 823 | 3.75 | 4 | # By submitting this assignment, I agree to the following:
# “Aggies do not lie, cheat, or steal, or tolerate those who do”
# “I have not given or received any unauthorized aid on this assignment”
#
# Name: Arya Ramchandani
# Section: 021
# Assignment: lab4b-4
# Date: 23/9/18
... |
3db9dea2cfaf2ae9e1da9dc11d2245754c1ba46e | arya200/Arya-s-Coding-Projects | /week11 - lab11b/Activity 2/activity2.py | 866 | 3.5 | 4 | # By submitting this assignment, all team members agree to the following:
# “Aggies do not lie, cheat, or steal, or tolerate those who do”
# “We have not given or received any unauthorized aid on this assignment”
#
# Names: Arya Ramchandani 627007018
#
# Section: 021
# Assignment: Lab08b - ... |
e296d96835246505ca3a0c096565f4f201885c40 | arya200/Arya-s-Coding-Projects | /week 3 - lab3a/Activity 2/Team 1 - Connor and Alvin/Birthdays.py | 1,179 | 3.65625 | 4 | # By submitting this assignment, I agree to the following:
# “Aggies do not lie, cheat, or steal, or tolerate those who do”
# “I have not given or received any unauthorized aid on this assignment”
#
# Names: Connor Tisdel 627004745
# Alvin Yolanda Ewaldo 227008703
# Section: 021
... |
b47b5ef9e2dca30a397c20b3c88575ca0bca2415 | arya200/Arya-s-Coding-Projects | /week6-6b/Real_Activity_1.py | 5,359 | 4.25 | 4 | # By submitting this assignment, I agree to the following:
# “Aggies do not lie, cheat, or steal, or tolerate those who do”
# “I have not given or received any unauthorized aid on this assignment”
#
# Name: Arya Ramchandani
# Section: 021
# Assignment: lab6b-1
# Date: 10/3/18
... |
1c8656166b6eb0fa1340556a144c0991a7089f7c | abhinavmanocha/PythonDatabase | /hashingDatabase.py | 1,513 | 3.796875 | 4 | #Importing pymysql and bcrypt.
#Remember to run 'pip install bcrypt' to download/install that package.
import bcrypt
import pymysql
#def methodName(methodParameters): is how you define a method in Python.
#HashMyPassword accepts a string paramter password, and generates a salt/hashes it using the bcrypt password... |
149379e3b20f4102a5757633d20c7760f3731f32 | DarthVi/hpcscripts | /multinode/FileFeatureReader/featurereaders.py | 1,817 | 3.5 | 4 | from __future__ import annotations
from abc import ABC, abstractmethod
from io import TextIOWrapper
import re
from typing import List
class IFeatureReader(ABC):
@abstractmethod
def getFeatures(self, file: TextIOWrapper):
pass
@abstractmethod
def getNFeatures(self, file: TextIOWrapper, n: int)... |
f1b4a00553d384d23fd357d217e0544bc5730e92 | kristianmirabile/Practice | /functionshw.py | 1,628 | 4 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
def lesser_of_two_evens(a,b):
if a%2 == 0 and b%2 == 0:
if a > b:
return b
else:
return a
elif a%2 != 0 or b%2 != 0:
if a > b:
return a
else:
return b
# In[162]:
lesser_of_two_ev... |
eeb0ea4d1a45da5ff359d640b7fa6571250352bd | ashirwad08/dsp | /python/advanced_python_csv.py | 586 | 3.625 | 4 | # this function is called from advanced_python_regex.py
def emails2CSV(emailList):
"""Receive a list of emails and write to a csv file"""
import csv
#insert extra newline characters in list
#for i in range(len(emailList)):
# emailList[i]=emailList[i]+'\n'
try:
with open("emails.csv","w") as csvfil... |
ecbfc9777b18f6c1cbe8b07bf4a09e403ded5246 | 19h61a0507/python-programming-lab | /pat4.py | 111 | 3.640625 | 4 | for i in range(0,4):
for j in range(0,i+1):
print(2**i,end=" ")
i=i-1
print("\n")
|
8e662865c92c45a66ab05eb834ac525f87863c30 | 19h61a0507/python-programming-lab | /strpalindrome1.py | 205 | 4.375 | 4 | def palindrome(string):
if(string==string[::-1]):
print("The string is a palindrome")
else:
print("Not a palindrome")
string=input("enter the string")
palindrome(string)
|
ed1729658e62ec071a59d39f7ff09f84ad872a9a | raghu192/Python_Practice | /Sum_of_Two_Numbers.py | 88 | 4 | 4 | num1=int(input('enter num1: '))
num2=int(input('enter num2: '))
sum=num1+num2
print(sum) |
f6f5900a38d2912d506580a029b30b4d306c6b00 | raghu192/Python_Practice | /Fabino_check.py | 226 | 3.859375 | 4 | n=int(input())
i=0
j=1
mark=False
while (i+j)<=n:
k=i+j
if k==n:
mark=True
i=j
j=k
i+j
if mark:
print(" N is part of fabonosisi series")
else:
print(" N is not a part of fabonosisi series")
|
a632df7db09bd77e95beb747808c47962db9c5ec | raghu192/Python_Practice | /printing_square_pattern.py | 277 | 3.765625 | 4 | n = int(input()) # n0.0f .rows
i = 1 # row counter
while i <= n:
j = 1 # coloumn counter
while j <= n:
print(n, end='') #end with empty character with no automatic enter
j = j + 1 #incrementing coloumn
print()
i = i + 1 #incrementing row
|
8e69697f64acac4e3a71c8c16f340e1aeb428a0c | newshackaz/sensorkit | /putting_it_together/led/led.py | 547 | 3.953125 | 4 | # this library lets you control the pins
import RPi.GPIO as GPIO
# this library will let us pause the program
from time import sleep
# set the Pi to use BCM numbering, not "physical" numbering
GPIO.setmode(GPIO.BCM)
# this pin will power the led
POWER_PIN = 17
# set up the pin to output power
GPIO.setup(POWER_PIN, G... |
e9b02f4f59ac85cccc16fc1fa572bb67ec270e92 | ahsansaif47/Python-Basic | /Sequences and basic searching in python.py | 474 | 3.984375 | 4 |
## Sequences and basic searching in python..
## Sequnece concatination..
a = [0,1,2,3,4]
b = [5,6,7,8]
## C sequence is the concatination of a and b
c = a + b
print("Result of concatination is: ", c)
## Note: You can't concainate 2 differant datatypes..
## Use of in keyword..
string = input("Your string to s... |
f5463dc235ca4d9c5e8c79d1775ab06896fb18e1 | achen8124/COVID-Flask-App | /app/checkAvailability.py | 11,552 | 3.6875 | 4 | import requests
import string
def get_vacc_page( state ):
""" This function requests the vaccine spotter page
and reads in the input as a dictionary
"""
vax_url = f"https://www.vaccinespotter.org/api/v0/states/{state}.json"
result = requests.get(vax_url)
if result.status_code == 200:
... |
9814dcb2ed11faa27cb9cdba90a32be40b73eb31 | Fazii/Python | /zadania5/5.2.py | 3,790 | 3.84375 | 4 | import math
import unittest
def add_frac(frac1, frac2):
tmpfrac1 = frac1[1]
frac1[0] = frac1[0] * frac2[1]
frac1[1] = tmpfrac1 * frac2[1]
frac2[0] = frac2[0] * tmpfrac1
frac2[1] = frac1[1]
a = frac1[0] + frac2[0]
b = frac1[1]
gcd = math.gcd(a, b)
if gcd != 1:
a /= gcd
... |
9d27dddce5f8598ecb5131286c682cd70fb2281d | Fazii/Python | /zadania6/6.5.py | 4,102 | 3.71875 | 4 | import unittest
from math import gcd
class Frac:
def __init__(self, x=0, y=1):
self.x = int(x)
self.y = int(y)
def __str__(self):
if self.y == 1:
return str(self.x)
else:
return str(self.x) + '/' + str(self.y)
def __repr__(self):
return "Fr... |
1e98064b41d815433eb3309ddff99f721c1f5f7c | Fazii/Python | /zadania4/4.6.py | 303 | 3.5 | 4 | def sum_seq(sequence):
s = 0
for i in range(len(sequence)):
if isinstance(sequence[i], (list, tuple)):
s += sum_seq(sequence[i])
else:
s += sequence[i]
return s
sequence = [(0), 1, [2, 3], (4, 5), [(6, 7), 8], ([9, 10], 11)]
print(sum_seq(sequence)) |
bdb456492eb7c89a11f0528f2fa631e76f353031 | peiyong-addwater/2018SM2 | /2018SM2Y1/COMP90038/quizFiveSort.py | 2,748 | 4.28125 | 4 | def insertionSort(arr):
assignment = 0
# Traverse through 1 to len(arr)
for i in range(1, len(arr)):
key = arr[i]
assignment = assignment +1
# Move elements of arr[0..i-1], that are
# greater than key, to one position ahead
# of their current position
j = ... |
9b0d9f2fdcba4f3842b72f7e654557ccaad516d5 | moritz2104/LPTHW | /ex13.py | 547 | 3.5625 | 4 | from sys import argv
# script, first, second, third = argv
# print "The script is called:", script
# print "Your first variable is:", first
# print "Your second variable is:", second
# print "Your third variable is:", third
script, first, second = argv
third = raw_input("Your third variable is:")
fourth = raw_input... |
bf82972f95c7449118b9c622e1be975f0bec9592 | moritz2104/LPTHW | /ex33.py | 1,391 | 3.921875 | 4 | # i = 0
# numbers = []
# print '\n',i
# print numbers
# while i < 5:
# print "\nAt the top of the loop i is %d" % i
# numbers.append(i)
# print "Now i = i + 1 is being done."
# i += 1
# print "At the bottom of the loop i is %d" % i
# print "Numbers now: ", numbers
# print "\nThe numbers: "
# for num in numb... |
2113e0f5ecdfabd6c6758fd5989e5b69a7529d3d | moritz2104/LPTHW | /ex07.py | 717 | 4.125 | 4 | print "Mary had a little lamb." # output a string
print "Its fleece was white as %s." % 'snow' # outputs a string with a format string --> wie geht das in python 3 ???
print "And everywhere Mary went."
print "." * 10 # what'd that do?
print "_" * 80 # what'd that do? Na ist doch klar!
end1 = "C"
end2 = "H"
end3 = "E"... |
0678cf3d363346dd002c9b9d805eeecc920714aa | Link-/pyboiler | /pyboiler/pyboiler.py | 2,532 | 3.671875 | 4 | #!/usr/bin/python
# @version: alpha-0.3.0 | python 2.7.x
# -
# @desc: PyBoiler is a simple python script
# that creates the basic folder/file structure
# for simple python projects.
# -
import argparse
from distutils.util import strtobool
import codecs
import json
import os
DEFAULT_FOLDER_STRUCTURE = [
{'folder': '... |
4adf181e01e9210052bacd734f4394e46b7f9dab | goto456/data-structures-and-algorithm | /python/quick_sort.py | 1,175 | 4 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
#########################################################################
# File Name: quick_sort.py
# Author: Wang Biwen
# mail: wangbiwen88@126.com
# Created Time: 2016.06.07
#########################################################################
import random
def part... |
0247990dba4132946a9b3deec8ac7e13670740b0 | mayurandhare13/Data-Structure | /miscellaneous/ListOfList.py | 630 | 3.890625 | 4 | # return a new sorted merged list from K sorted lists, each with size N.
import heapq
def merge(lists):
merged_list = []
heap = [(lst[0], i, 0) for i, lst in enumerate(lists) if lst]
heapq.heapify(heap)
while(heap):
val, list_ind, element_ind = heapq.heappop(heap)
merged_list.append(... |
2da1c86ca2b108bff9190215a78f842d86db5efd | mayurandhare13/Data-Structure | /Daily Coding Practice/JobScheduler.py | 429 | 3.875 | 4 | """
This problem was asked by Apple.
Implement a job scheduler which takes in a function f and an integer n, and calls f after n milliseconds.
"""
from threading import Thread
import time
def exe_fun(f, n):
time.sleep(n)
f()
def some_fun(name):
print("\t Hey {}".format(name))
job = Thread(target=exe_fun... |
a7d410c227ad41694e6f8f653996fb5a5f179308 | at-vo/Networks | /CS3305/asn3/4d.py | 1,085 | 3.96875 | 4 | def Merge(A,p,q,r):
# general merge algorithm definitions
n1= q-p+1
n2= r-q
L = []
R = []
for i in range(n1+1):
L.append( A[p+i-1])
for i in range(n1+1):
R[i] = A[q+i]
L[n1+1] = float('inf')
L[n2+1] = float('inf')
i = 0
j = 0
check = false # add check for inversion ... |
994ce50841ef8b99f62fccdbf8cb3ea40fd233d9 | andrewoleeschool/project-euler | /p0101.py | 2,164 | 4.03125 | 4 | # If we are presented with the first k terms of a sequence it is impossible to say with certainty the value of the next term, as there are infinitely many polynomial functions that can model the sequence.
# As an example, let us consider the sequence of cube numbers. This is defined by the generating function, un = n3... |
509be2822b907ee6a0853c70ee2be104b5d24396 | crazywiden/Leetcode_daily_submit | /Widen/LC1192_Critical_Connections_in_a_Network.py | 2,239 | 3.75 | 4 | """
1192. Critical Connections in a Network
There are n servers numbered from 0 to n-1 connected by undirected server-to-server connections forming a network where connections[i] = [a, b] represents a connection between servers a and b. Any server can reach any other server directly or indirectly through the network.
... |
9b1f7b2a6b5cf52bd6406563714300f1e32d1f3d | crazywiden/Leetcode_daily_submit | /Widen/LC543_Diameter_of Binary_Tree.py | 1,564 | 4.25 | 4 | """
543. Diameter of Binary Tree
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root.
Example:
Given a binary tree
1
/ \
... |
6484f844b8844f4ac1e280dc5eedffd222212768 | crazywiden/Leetcode_daily_submit | /Widen/LC358_Rearrange_String_k_Distance_Apart.py | 3,199 | 3.75 | 4 | """
LC358. Rearrange String k Distance Apart
Given a non-empty string s and an integer k, rearrange the string such that the same characters are at least distance k from each other.
All input strings are given in lowercase letters. If it is not possible to rearrange the string, return an empty string "".
Example 1:
... |
83163acd94774048c6ed331b41da1d5bb8a904ca | crazywiden/Leetcode_daily_submit | /Widen/LC376_Wiggle_Subsequence.py | 1,871 | 4.25 | 4 | """
A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a wiggle sequence.
For example, [1,7,4,9,2,... |
da035ee9b9b9b09d6cc0fdca73a7ea8f87af8d70 | crazywiden/Leetcode_daily_submit | /Widen/LC289_Game_of_Life.py | 2,365 | 3.625 | 4 | """
289. Game of Life
According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."
Given a board with m by n cells, each cell has an initial state live (1) or dead (0). Each cell interacts with its eight ne... |
b80cd93c287501d752cfa6d1a2765a98129b2fab | crazywiden/Leetcode_daily_submit | /Widen/LC411_Minimum_Unique_Word_Abbreviation.py | 8,483 | 3.90625 | 4 | """
LC411 Minimum Unique word abbreviation
A string such as "word" contains the following abbreviations:
["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r1", "3d", "w3", "4"]
Given a target string and a set of strings in a dictionary, find an abbreviation of this target s... |
628f8ab619e1460c897cdacfb238dd69b0cb94eb | crazywiden/Leetcode_daily_submit | /Widen/LC394_Decode_String.py | 1,811 | 4.15625 | 4 | """
394. Decode String
Given an encoded string, return its decoded string.
The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer.
You may assume that the input string is always valid; No extra ... |
8f18ff973848c4229277829462435a099e7a361e | crazywiden/Leetcode_daily_submit | /Widen/LC996_Number_of_Squareful_Arrays.py | 2,360 | 3.90625 | 4 | """
996. Number of Squareful Arrays
Given an array A of non-negative integers, the array is squareful if for every pair of adjacent elements, their sum is a perfect square.
Return the number of permutations of A that are squareful. Two permutations A1 and A2 differ if and only if there is some index i such that A1[i]... |
a447a7d99834885c1dde548f83dd0924627834ed | crazywiden/Leetcode_daily_submit | /Widen/LC79_Word_Search.py | 2,112 | 3.953125 | 4 | """
79. Word Search
Given a 2D board and a word, find if the word exists in the grid.
The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once.
Example:
board =
[
['A','B','C'... |
a953d20e0094da3a509afd7ae9a8cda33aeee6cf | crazywiden/Leetcode_daily_submit | /Widen/LC408_Valid_Word_Abbreviation.py | 2,325 | 4.1875 | 4 | """
408. Valid Word Abbreviation
Given a non-empty string s and an abbreviation abbr, return whether the string matches with the given abbreviation.
A string such as "word" contains only the following valid abbreviations:
["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r... |
4b9b2b4d43d5a3c7e26e7dd93afd23343c9c20c0 | crazywiden/Leetcode_daily_submit | /Widen/LC739_Daily_Temperatures.py | 1,190 | 4.03125 | 4 | """
LC739 daily temperature
Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead.
For example, given the list of temperatures T = [73, 74, ... |
3babf3a7f130e20a9b46c08c8586a771fb7b6137 | crazywiden/Leetcode_daily_submit | /Widen/LC822_Card_Flipping_Game.py | 2,635 | 3.859375 | 4 | """
LC822 -- Card Flip Game
On a table are N cards, with a positive integer printed on the front and back of each card (possibly different).
We flip any number of cards, and after we choose one card.
If the number X on the back of the chosen card is not on the front of any card, then this number X is good.
What is ... |
ea6058dcb399a23cdb7a23dd51d9a029a774c357 | crazywiden/Leetcode_daily_submit | /Widen/LC529_Minesweeper.py | 2,875 | 4 | 4 | """
529. Minesweeper
Let's play the minesweeper game (Wikipedia, online game)!
You are given a 2D char matrix representing the game board. 'M' represents an unrevealed mine, 'E' represents an unrevealed empty square, 'B' represents a revealed blank square that has no adjacent (above, below, left, right, and all 4 diag... |
a7ae2ed4c28ec523a71aa8dfefad790fe72d071b | crazywiden/Leetcode_daily_submit | /Widen/LC829_Consecutive_Numbers_Sum.py | 955 | 3.65625 | 4 | """
LC829
Given a positive integer N, how many ways can we write it as a sum of consecutive positive integers?
Example 1:
Input: 5
Output: 2
Explanation: 5 = 5 = 2 + 3
Example 2:
Input: 9
Output: 3
Explanation: 9 = 9 = 4 + 5 = 2 + 3 + 4
Example 3:
Input: 15
Output: 4
Explanation: 15 = 15 = 8 + 7 = 4 + 5 + 6 = 1 + 2... |
a1ae4727135642dbe136ccc98b78f58887fbe3c0 | crazywiden/Leetcode_daily_submit | /Widen/LC1110_Delete_Nodes_And_Return_Forest.py | 1,667 | 3.921875 | 4 | """
1110. Delete Nodes And Return Forest
Given the root of a binary tree, each node in the tree has a distinct value.
After deleting all nodes with a value in to_delete, we are left with a forest (a disjoint union of trees).
Return the roots of the trees in the remaining forest. You may return the result in any orde... |
1bf26a8906ab31d1cff7058a92135dd0ae82edd8 | crazywiden/Leetcode_daily_submit | /Widen/LC1087_Brace_Expansion.py | 1,937 | 4.0625 | 4 | """
LC 1087 -- Brace Expansion
A string S represents a list of words.
Each letter in the word has 1 or more options.
If there is one option, the letter is represented as is.
If there is more than one option, then curly braces delimit the options.
For example, "{a,b,c}" represents options ["a", "b", "c"].
For ex... |
674ab5706ff27def6de4ed18f621ee684e701693 | crazywiden/Leetcode_daily_submit | /Widen/LC218_The_Skyline_Problem.py | 4,048 | 3.671875 | 4 | """
218. The Skyline Problem
"""
# sweep line + hash heap implementation
# Runtime: 172 ms, faster than 30.06% of Python3 online submissions for The Skyline Problem.
# Memory Usage: 18.5 MB, less than 10.00% of Python3 online submissions for The Skyline Problem.
class HashHeap:
def __init__(self, desc=False... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.