blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
0f6df05329f3437b4f18be0c124ef8cbb6b2a1ea | Dilstom/intro_py | /ex/classes/app.py | 236 | 3.5625 | 4 | from Student1 import Student # from 'file' import 'Class'
# creating object with an actual student
studentA = Student("Jim", "Business", 3.1, False)
studentB = Student("Pam", "Art", 3.1, True)
print(studentA.gpa)
print(studentB.name) |
1375d1ed9c05998807de77f0f45228e2df507dfd | Dilstom/intro_py | /ex/forLoop.py | 206 | 3.828125 | 4 | friends = ["Ab", "Be", "Ce", "De"]
# for index in range(len(friends)):
# print(index)
for index in range(5):
if index == 0:
print('the first Iteration')
else:
print('the rest') |
2e901f4a81e19532eb82ca1f8910d5357b000b7e | Deepaklal123/Python | /Chapter_02/prac_q_02_Operators.py | 663 | 4.25 | 4 | #Author: Deepak Lal
#University:Sukkur IBA University
a=3
b=4
#Arthmetic operators
print("The sum of 3+4 is ", 3+4)
print("The sum of 3-4 is ", 3-4)
print("The sum of 3*4 is ", 3*4)
print("The sum of 3/4 is ", 3/4)
# Assignment operators
a=32
a+=2 #a=a+2
print(a) # a=34
#Comparison Operators
... |
202441e2f47c91633210963115d8c1647ae92a57 | shenjinrong0901/python_study | /data_structures_and_algorithms/tree/树的遍历/TreeTraversals.py | 1,338 | 3.703125 | 4 | def preorder(tree):
if tree:
print(tree.getRoolVal())
preorder(tree.getLeftChild())
preorder(tree.getRightChild())
#将前序遍历算法实现为外部函数
def preorder(self):
print(self.key)
if self.leftChild:
self.leftChild.preorder()
if self.rightChild:
self.rightChild.preorder()
def... |
33318e76eeb6efabf48e6487d504d547b3ffe2b4 | Piotr17x/pyth | /wd 4/zad6.py | 996 | 3.5 | 4 | import sys
class slowa:
slowo1=""
slowo2=""
def __init__(self, slowo1, slowo2):
self.slowo1=slowo1
self.slowo2=slowo2
def sprawdz_czy_palindrom(self):
if self.slowo1==self.slowo1[::-1]:
return "jest to palindrom"
else:
return "to nie jes... |
dcf49a4b85ece6254681ffa3f894c8924336598a | Imperial-iGEM/Django-DNABOT | /django_dnabot_app/dna_bot/mplates.py | 473 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu May 30 17:05:37 2019
@author: mh2210
"""
def final_well(sample_number):
"""Determines well containing the final sample from sample number.
"""
letter = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
final_well_column = sample_number // 8 + \
(1 if samp... |
b0c2cca44ef5734d69b7c7b9622043e31c848ce6 | tetchel/Bin-Packing-Analysis | /impl/bin_pack.py | 9,855 | 3.8125 | 4 | import math
from timeit import default_timer as timer
from copy import deepcopy
from binary_tree import BinaryTree
class Bin:
CAPACITY = 1
def __init__(self, name):
# Items contains a list of (name, weight) tuples representing items packed into this bin
self.items = []
sel... |
9cc0d065743245c3e1ec9601abbcd35b0e6d9e48 | mrselukar/Edabit-Challenge | /calculator.py | 257 | 4.09375 | 4 | x = float(input ("enter first number: "))
a = input ("enter operation:")
y = float(input ("enter second number: "))
if a == "+":
result = (x+y)
if a == "-":
result = (x-y)
if a == "*":
result = (x*y)
if a == "/":
result = (x/y)
print(result) |
90b7821a67d13e48c5c297cbc09268d2c8461194 | Arent128/npc | /npc/parser.py | 6,293 | 3.578125 | 4 | """
Parse character files into Character objects
The main entry point is get_characters, which creates a list of characters. To
parse a single file, use parse_character instead.
"""
import re
import itertools
from os import path, walk
from .character import Character
VALID_EXTENSIONS = ('.nwod', '.dnd3', '.dfrpg')
"... |
b5a04b6bbbb214ef4685a96d361146e1ab834459 | abhishek155/assignment-10 | /assignment 10.py | 1,498 | 3.671875 | 4 | # ques 1
class Animal():
def animal_attribute(self):
print("save lion")
class Lion(Animal):
print('lion ')
tig=Lion()
tig.animal_attribute()
# ques 2
#output is given as following:
#print a.f() : A
#print b.f() : B
# ques 3
class Cop():
def __init__(self,name,age,work,experience,designation):
... |
7d0365632c2068e97fc523665d16d95387880f3f | wiolaSzczepanik/Alghorithmic_exercises | /function_1.py | 686 | 4.28125 | 4 | """Define a function max() that takes two numbers as arguments and returns the largest of them. Use the if-then-else
construct available in Python. (It is true that Python has the max() function built in, but writing it yourself is
nevertheless a good exercise.)"""
def _max(a,b):
if a > b:
return a
els... |
81fa1ea9cca65aaf984e3fa3550c3cfe724e4813 | OkomoJacob/Spatial-Analysis-Studios | /1.CurrentWeather/main.py | 3,230 | 4.0625 | 4 | # import the necessary libraries
from tkinter import *
from tkinter import Label
from tkinter import Button
import requests as re
# Create a function that will help extract,open, read,and display the current weather condition from servers
def weather():
# This city variable will extract the name of the city input... |
53ac9c91390ccd5696221749826689dbb28ffb35 | sofilaulia/Lab-python | /main.py/lab04.py | 1,591 | 3.765625 | 4 | # DDP LAB-4
# Nama: SOFIL MUNA AULIA
# NIM: 0110120115
# SOAL 1 - Mencetak nama
# Tuliskan program untuk Soal 1 di bawah ini
#program akan mencetak pesan ke layar
print("SOAL 1 - Mencetak nama\n")
#program meminta masukan pengguna
nama=input("Masukan sebuah nama: ")
#program menghitung panjang string
s= len(nama)
... |
b63ee6d465a8dbd23147f34d87ea2125f005aef6 | OliveiraFabioPereirade/introducao_python | /aula8_lambda.py | 1,018 | 4.4375 | 4 | # lambda é uma fução anônima que utiliza um código mais reduzido que os métodos
# reescrita do contador_letras no formato lambda
contador_letras = lambda lista: [len(x) for x in lista]
# | |
# | +-------> retorna uma lista de quantidade de letras de cada palavra ... |
4da7cfc58bb8d0ffa69d9ef706f3dcf26ceba487 | OliveiraFabioPereirade/introducao_python | /aula4.py | 1,809 | 3.75 | 4 | # for x in range(100): # causa execução de 0 a 99
# print(x)
# for x in range(90, 100): # causa execução de 90 a 99
# print(x)
# a = int(input('Entre com um número: '))
# div = 0
# for x in range (1, a + 1): # vai executar de 1 até o valor de a
# resto = a % x
# print(a, resto)
# if resto == 0:
... |
cbd9b7e66293d358a1845c6f72e992a9222c4221 | BS-98/TestPython | /Chapter_III.py | 743 | 4.125 | 4 | def check_numbers(number):
number = str(number)
num_prev = 0
nb = 0
digits = []
rep = False
for num in number:
if int(num) < int(num_prev):
rep = True
break
if num == num_prev:
digits.append... |
79aa6a2020738b523b84ad22aa79036df8c7a90d | JorgeCapo23/Mi-primera-wea | /mini_reto.py | 220 | 3.765625 | 4 |
try:
numero_1 = int(input("dame un numero"))
numero_2 = int(input("dame otro numero"))
except:
print("tan pelotudo sos que no sabes poner un numero")
else:
print("la suma es " + str(numero_1 + numero_2)) |
19c8d25f6d162f021e3f1da8491fe41a6b2dad5b | LissanKoirala/Games-Python | /Fork_Game/main.py | 4,960 | 3.515625 | 4 | # Creator : Lissan Koirala
# Date of Creation : 27/11/2019
# Importing all the libraries that is needed
import tkinter as tk
import random
from tkinter import messagebox
import os
# Defining the wins
def win():
if n1["text"]=="N":
if n2["text"]=="E":
if n3["text"]=="P":
... |
3b13fa6e49c7ab664ae342e16fe65ebfa230caa2 | s4kibs4mi/Project-Euler | /sum of digits of 2^1000.py | 114 | 3.796875 | 4 | number=2**1000
digit_sum=0
while(number>0):
digit=number%10
number=number/10
digit_sum+=digit
print digit_sum
|
ed49fad762a7de7d4b0aad737902ac317b6c5e4f | isaacschaal/SkipList | /SkipList.py | 8,932 | 4.28125 | 4 | import random
import math
class _SkipNode(object):
"""
This class implements the SkipNode,
which is used in the SkipList class.
"""
def __init__(self, key = None, level = 0):
self.key = key
# A list that stores the next key at each level
self.next = [None]*level
... |
35022a2ebbfb017e5aa4dc1b3abe8fc821b4dce8 | v2tamprateep/RLSim | /MDP.py | 1,936 | 3.546875 | 4 | import sys
import random
import utilities
class MDP:
"""
MDP is a dictionary of dictionaries. The outer dictionary maps each action to
an inner dictionary. The inner dictionary maps each action to the probability
of that action occuring. So, MDP[a][a'] = P(a'|a).
"""
def __init__(... |
1e178d20d8c577dacd00fd03071b63f33734104b | kodywilson/lp3thw | /hard_way/ex9.py | 311 | 3.875 | 4 | days = "Mon Tue Wed Thu Fri Sat Sun"
months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"
print("Here are the days:", days)
print("Here are the months:", months)
print("""
There's something going on here with the three double qoutes.
We can type anything we want. It even saves my
blank lines and such.
""") |
6042fe87737538d7737fd10793e45165b60bfa5f | ThachBryant/Algorithms | /OptimalTask.py | 286 | 3.6875 | 4 | # we want to find a optimal way to assign task to workers, assuming each worker
#must take two tasks and each take a fixed amount of time
#want the time it takes to complete all tasks to be minimized.
A = [6, 3, 2, 7,5,5]
A = sorted(A)
for i in range(len(A)//2):
print(A[i], A[~i])
|
00c8a2c5d3ee4ce90b12f6b98e38737db2442c9e | bnchrch/Simple-Work-Tracker | /timer.py | 4,967 | 4.09375 | 4 | import time
import datetime
import sys
import os.path
def print_to_file(start, stop, time_worked, work_text, work_log):
"""
This function formulates the line in the text file for the time chunk of work that was just performed
"""
today = datetime.date.today()
record = ' || %.2f || %.2f || %.4f ho... |
66dc03b5b404d32fb280adcbb42e2dc64d9427cf | hongkailiu/test-all | /trunk/test-python/script/my_list.py | 989 | 4.40625 | 4 | #!/usr/bin/python
my_list = ['word', 786, 2.23, 'john', 70.2]
tiny_list = [123, 'john']
print my_list # Prints complete list
print my_list[0] # Prints first element of the list
print my_list[1:3] # Prints elements starting from 2nd till 3rd
print my_list[2:] # Prints elements starting from 3rd... |
90015c09d1f9a58368766a26d79b42283b723587 | MaartenGr/Reviewer | /Reviewer/tfidf.py | 6,653 | 3.578125 | 4 | import json
import numpy as np
import pandas as pd
from sklearn.feature_extraction.text import CountVectorizer
class TFIDF:
"""
Generate a class-based TF-IDF score for each movie. In other words,
it will generate the most important words for a single movie compared
to all other movies.
C-TF-IDF c... |
53af99a3d4023022a838383e768a5865673dea17 | Bonfim-luiz/Introducao_Ciencia_Computacao_Python_Parte_1_Coursera | /Semana_2/Sem2_Ex2_Media.py | 256 | 3.796875 | 4 | nota1=int(input("Digite a primeira nota: "))
nota2=int(input("Digite a segunda nota: "))
nota3=int(input("Digite a terceira nota: "))
nota4=int(input("Digite a quarta nota: "))
media=(nota1+nota2+nota3+nota4)/4
print("A média aritmética é",media)
|
8e0b1a402283386c79c16ca8079e2e021355e104 | Bonfim-luiz/Introducao_Ciencia_Computacao_Python_Parte_1_Coursera | /Semana_4/Sem4_Ex1_Fatorial.py | 255 | 3.84375 | 4 | entrada=int(input("Digite o valor de n: "))
n=1
fatorial=1
indicador=True
while n<=entrada and indicador:
if n == entrada:
fatorial=fatorial*n
indicador=False
else:
fatorial=fatorial*n
n=n+1
print(fatorial)
|
7890ec33071686f3145380658c6732c84741cee0 | Bonfim-luiz/Introducao_Ciencia_Computacao_Python_Parte_1_Coursera | /Semana_4/Sem4_Ex0_Soma_digitos.py | 247 | 4.09375 | 4 | numero=int(input("Digite um número inteiro: "))
soma=0
while numero//10 >= 0:
resto = numero%10
soma = soma + resto
if numero == 0:
numero=-1
else:
numero = numero//10
print(soma)
|
c51f4fa22a882d43e35986a6d1886e27268ef5e3 | RahulChakraborty/TextProcessing | /TestPython.py | 431 | 3.9375 | 4 | list = [1,2,3,4]
tup = ('Rahul','Chakraborty','New Jersy')
tinydict = {'name': 'john','code':6734, 'dept': 'sales'}
print tinydict.keys()
print tinydict.values()
def printInfo(arg, *varargs):
print arg
for var in varargs:
print var
return
printInfo(10)
printInfo(20,30,40)
#Python Lambda
sum = l... |
15b30af20ccd97800d9e77eca505c7e3f63f8e94 | eminik/Intro-to-Data-Science | /Lesson_3/lesson3_gradient_descent.py | 1,824 | 4.375 | 4 | import numpy
import pandas
def compute_cost(features, values, theta):
"""
Compute the cost of a list of parameters, theta, given a list of features
(input data points) and values (output data points).
"""
m = len(values)
sum_of_square_errors = numpy.square(numpy.dot(features, theta) -... |
984dd0c5a27e17c38cc264d3641b8297e9f0793c | claudezyx/competitive-programming- | /CountMeetingRoom.py | 1,039 | 4.0625 | 4 | """Question: You have been given log files data of a company for the past 5 year which contains information
about meetings that happened in the company. The log file has the following format meetingid : starttime,
endtime where starttime and endtime are unix timestamps. Figure out how many meeting rooms must exist
at ... |
f032555af993ff89a72d9097bb2e5c90bd110fe3 | GabyRebound/algoritmos_de_busqueda | /matrizAdyacencia/controller/helpersVectProb.py | 5,154 | 3.59375 | 4 | #!/usr/bin/python3
# coding: utf-8
import math
from collections import OrderedDict
# funcion que nos permite leer de un archivo el Diccionario
def readDict(file):
data = {}
f = open(file, encoding='utf-8')
c = 0
for line in f:
c += 1
data[f'D{c}'] = line.strip()
return data
# fun... |
e3f404c89c08961da2399866a1c4d87986bc1320 | satya7289/Compter-Science-Stuffs | /ALGO/DP/FibonacciModified/main.py | 244 | 3.828125 | 4 |
def fibonacciModified(t1, t2, n):
dp = [0 for i in range(n+1)]
dp[0], dp[1] = t1, t2
for i in range(2,n+1):
dp[i] = dp[i-2] + (dp[i-1] * dp[i-1])
# return nth value
return dp[n-1]
print(fibonacciModified(0, 1, 5)) |
ea0172e1ad4f94bc4b5318b348c7106094f1e32f | Anechka2021/Anna_Marshall_Python-1 | /Lesson 1-1.py | 225 | 3.640625 | 4 | name = input("Enter your name: ")
print("Hi!", name)
age = input("Enter your age: ")
print("You are so young,", name)
or_pass= "1234"
password = input ("Enter your password:")
if password == or_pass:
print("Ok")
|
06b1c67025b103941ce247b6b77dc730210f1b4c | SHUKLA123/Leetcode-Problems-Solution | /leetcode 409.py | 664 | 3.5625 | 4 | # 409. Longest Palindrome
# Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.
# This is case sensitive, for example "Aa" is not considered a palindrome here.
# Runtime: 28 ms, faster than 83.64%
s = "abccccdd"
def longest... |
634878f31a0ba907eb5f17717ba2df9d2027747c | SHUKLA123/Leetcode-Problems-Solution | /leetcode 240.py | 620 | 3.84375 | 4 | # Problem id : 240. Problem title : Search a 2D Matrix II Difficulty : medium
#Write an efficient algorithm that searches for a value in an m x n matrix.
#This matrix has the following properties:
# Solution : 2-d matrix is given we have to each row contain target or not if not in any row return False else return T... |
bf8a23c35b43479dbeb78911da6a1f6de658ff59 | SHUKLA123/Leetcode-Problems-Solution | /349.py | 309 | 3.59375 | 4 | def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
a = set(nums1)
b = set(nums2)
l = []
if len(a)<=len(b):
for i in a:
if i in b:
l.append(i)
else:
for i in b:
if i in a:
l.append(i)
return l |
b1aa5232462f97ae35c1fcc8cea12c4c87c706e7 | SHUKLA123/Leetcode-Problems-Solution | /tree/112.py | 875 | 3.859375 | 4 | # Problem Id : 112, Problem Title Path Sum
# Tags : Tree , DFS
# Level : Easy
# Given a binary tree and a sum, determine if the tree has a root-to-leaf path
# such that adding up all the values along the path equals the given sum.
# Input : root = [5,4,8,11,null,13,4,7,2,null,null,null,1] , Sum = 22
# Output : True... |
3dc80174e557b1292bcc0e6e3177d9722e286f37 | SHUKLA123/Leetcode-Problems-Solution | /tree/1022.py | 1,164 | 3.890625 | 4 | # Problem Id : 1022, Problem Title : Sum of Root To Leaf Binary Numbers
# Tags : Tree
# Level : Easy
# Given a binary tree, each node has value 0 or 1. Each root-to-leaf path represents a binary number starting with the most significant bit. For example, if the path is 0 -> 1 -> 1 -> 0 -> 1, then this could repre... |
c3b813aafd099f949fc98c2c7edf2e0069f12fdb | SHUKLA123/Leetcode-Problems-Solution | /tree/872.py | 822 | 3.734375 | 4 | # Problem Id : 872, Problem Title : Leaf-Similar Trees
# Tags : Tree , DFS
# Level : Easy
#Given a binary tree, return the sum of values of its deepest leaves.
# Input: root = [3,5,1,6,2,9,8,null,null,7,4]
# Output: True
def leafSimilar(root1, root2):
A, P = [], []
def dfs(N): # mene traverse kiya har ek pa... |
a6a171dff8b79185197709ea739a3e82fdd5d42e | RizwanRumi/python_Learning | /obj_life_cycle.py | 202 | 3.734375 | 4 | ## Definition
class Add:
## Initialization
def __init__(self,a,b):
self.a = a
self.b = b
def add(self):
return self.a + self.b
obj = Add(3,4)
##Access
print(obj.add())
|
a2b71299410c3adacde8388fc796b5a7b4545949 | RizwanRumi/python_Learning | /OOP/constructor_overloading.py | 1,074 | 4.28125 | 4 | # If multiple __init__ methods are written for the same class,
# then the latest one overwrites all the previous constructors.
class example:
def __init__(self):
print("One")
def __init__(self):
print("Two")
def __init__(self):
print("Three")
e = example()
print('''
Solution: C... |
30d60dbb7d8fcd1bb431136eef96efee66eb1738 | RizwanRumi/python_Learning | /python-3-playlist/string_format.py | 249 | 4.0625 | 4 | num1 = 3.1415665
num2 = 40.235415
#PREVIOUS
# print('num 1 is ', num1,' and num 2 is', num2)
#Format method
print('num 1 is {0:.3f} and num 2 is {1:.3f}'.format(num1,num2)
)
#USING F-STRINGS
print(f'num 1 is {num1:.4f} and num 2 is {num2:.4f}')
|
68f46ac6f6f4015079bd6440a38a2fe3b43906bd | RizwanRumi/python_Learning | /function_test.py | 768 | 4.65625 | 5 |
"""
default arguments example for *args, **kwargs in python
"""
print("args for single value: \n")
def student1(name, age, marks):
print("name: ", name)
print("age: ", age)
print("marks: ", marks)
student1('Tom', 22, 85)
print("\n*args for multiple values und result shows by tuple: \n")
def student2(... |
cce08443f11505a6cd0c4762acd62111b90f9f13 | NorthcoteHS/10MCOD-Thomas-MCSHANE | /modules/u3_organisationAndReources/naming/HelloUser.py | 233 | 3.625 | 4 | """
Prog: HelloUser.py
Name: Tom
Date: 2018/03/12
Desc: Says hello to the user.
"""
# Ask user for their name and welcome them
name = input('What is your name? ')
print('Hello ' + name + ', I am Computer! Nice to meet you.')
|
8b52f37ecc18fd39709afc3454516a434a795d63 | NorthcoteHS/10MCOD-Thomas-MCSHANE | /user/helloworld.py | 3,239 | 4.15625 | 4 | """
Program: Helloworld.py
Name: Thomas Mcshane
Date: 22-02-2018
Desc: Ask user about their day
"""
name = input('What is your name? ' )
print(name)
# Ask what users name is
print('Hello' + " " + name + '! My name is Thomas!')
print('1. good')
print('2. bad')
print('3. ok')
print('4. great!')
print('... |
9f4907be954861fa190047848ac4ea73391d6087 | BambooFlower/Simple-Scripts | /Code/RotatingSquare.py | 1,644 | 3.6875 | 4 | # Rotating square made using pygame
import pygame as py
# define constants
WIDTH = 500
HEIGHT = 500
FPS = 30
# define colors
BLACK = (0 , 0 , 0)
GREEN = (0 , 255 , 0)
# initialize pygame and create screen
py.init()
screen = py.display.set_mode((WIDTH , HEIGHT))
clock = py.time.Clock()
rot ... |
faa61a394193cb511a2c950a27b93c261c1ccfb1 | akhipavi/python | /calss.py | 539 | 3.875 | 4 | class Person:
def __init__(self,name,age,gender,height):
self.name=name
self.Age= age
self.gender=gender
self.height=height
def eat(self):
print("person is eating")
def walk(self):
print("person is walkinng")
def getName(self):
return self.nam... |
f45c5441ea211a448089063aa711dc1839422364 | Giulianini/image-alterations-detector | /image_alterations_detector/app/utils/general_utils.py | 302 | 3.640625 | 4 | from tkinter import messagebox
def show_message_box(message, msg_type):
if msg_type == 'warning':
messagebox.showwarning(message=message)
elif msg_type == 'error':
messagebox.showerror(message=message)
elif msg_type == 'info':
messagebox.showinfo(message=message)
|
fa5a0415c56c4dafc9d54484b7af048c738c1a4a | joyrahman/python_workdir | /quickFind.py | 986 | 3.515625 | 4 | class QuickFind:
#constructor to initialize the array
id = []
def __init__(self,N):
for i in range(N):
self.id.append(i)
#print (self.id[i])
#this method verifies whether p and q already connected or not
def connected(self,p,q):
if(self.id[p]==self.id[q]):
return 0
else :
return 1
#this metho... |
9ec2933d112a5a1b3a4de337c389e3b459776cce | joyrahman/python_workdir | /square.py | 220 | 3.859375 | 4 | class Square:
def area(self):
return self.side * self.side
def __init__(self,side=4):
self.side = side
sq = Square(5)
area = sq.area()
sq2 = Square()
area2 = sq2.area()
print area, area2
|
c62ed6af1745191afebf5572ba3f3d97ecb3a158 | gotlaufs/nixie_clock | /Hardware/LTSpice/Over_Current_Protection/CalculateResistors.py | 1,727 | 3.78125 | 4 | #!/usr/bin/env python
# CalculateResistors.py
#
# Use this to calculate resistors for non-inerting op-amp comparator circuit
# with hysteresis.
#
# Input: R1, OpAmp output voltage max/min, Higher and Lower threshold voltages.
# Output: R2, Reference voltage Vref.
#
#
# Roberts Gotlaufs
# 28.03.2017
def get_float(p... |
67dd8500f4c1706b5f5efa289caae68e42ef8a12 | proggga/patterns | /decorator/tests/test_decorator.py | 5,935 | 3.53125 | 4 | """Test Unit class, and then decorator"""
import unittest
import mock
from decorator.buff_curse_decorator import BuffCurseUnitDecorator
from decorator.unit import Unit
from decorator.buffs.heal_on_move import HealOnMoveBuff
from decorator.buffs.zombie import ZombieBuff
from decorator.curses.damage_before_attack impo... |
654ab12f9f9fff456cd58909b1825f288ef2ad72 | prakhyathjain/Machine-Learning-Lab-17CSL76 | /Find_S/finds.py | 1,018 | 3.96875 | 4 | """
Implement and demonstrate the FIND-S algorithm for finding the most specific hypothesis based on a given set of training data samples
Read the training data from a .CSV file
"""
import pandas as pd
# load the csv
df = pd.read_csv("enjoysport.csv")
# save shape
rows = df.shape[0]
cols = df.shape[1]
# init most... |
7a58a893dab1bbdd82d10f7aa7a8a65d82e8b724 | rob93c/RomRoamer | /RomRoamer.py | 1,258 | 3.609375 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
from pynput.keyboard import Key, Controller
from time import sleep
"""
RomRoamer: automatically wander playing with
a GBC/GBA/NDS rom (E.G. to hatch
eggs in Pokémon games or level up
a Pokémon left at the Day Care).
"""
class RomRoamer:
def __... |
b3256bd6b1ebcad3eee132a4f8e88417dad6b9c2 | Brad-Davidson/it3038c-scripts | /Projects/Project_1.py | 1,206 | 4.09375 | 4 | #Project 1: Water Reminder
#Name: Bradley Davidson
#Date: 2/21/21
from win10toast import ToastNotifier
import time
toaster = ToastNotifier() #notification library
def water_timer(interval):
try: # The try/catch block in this case is used to break out of the while loop
while True:
#sleep first ... |
c151d994c5e7eeb07ebf388c0aea09d6cbae643b | manaskumarpradhan/iNeuron | /program1.py | 359 | 3.796875 | 4 | def div7mult5(lowernum=2000,uppernum=3201):
for i in range(lowernum,uppernum):
#check if i is multiplicative of 5
n = i
while (n>0):
n=n-5
#check if i is divisiable by 7 and not multiplicative of 5
if (i%7==0) & (n!=0):
print(i,end=',')
if _... |
15b1f4a58744397aa4f683a5514882d9598e8156 | julianny-favinha/mc886-machine-learning | /linear-regression/examples/sklearnexample.py | 2,875 | 3.6875 | 4 | import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from sklearn import datasets, linear_model
from sklearn.metrics import mean_squared_error
# Load the diabetes dataset
diabetes = datasets.load_diabetes()
# Print the diabetes dimension
#print("Diabetes dataset dimensions:", diabetes.data.shape)
#... |
2a092c1f85ac275aa79640612b7138fe678e5937 | jahick/pythonSamples | /newmyinfo.py | 649 | 4.15625 | 4 | import re
isNameValid = False
while isNameValid == False:
name = str(input("Enter your name..."));
regex = r"[0-9]";
match = re.search(regex,name,re.MULTILINE);
if match != None:
print("Invalid name. Name cannot contain numbers.");
else:
isNameValid = True;
isAgeValid = False;
... |
cf38bc3478199015468385aeb33e22852681f373 | jahick/pythonSamples | /average_withTestPrints.py | 595 | 3.96875 | 4 | from functools import reduce
import math
file = input("Enter input file name: ")
f = open(file,'r')
numStringList = f.readlines()
f.close()
numString = ""
for eachStringItem in numStringList:
numString = numString + eachStringItem
numList = numString.split()
numList = list(map(float,numList))
addition =... |
ff04e8a78be5ed02f03bf21035fd0bec3949fcec | goosen78/simple-data-structures-algorithms-python | /insertion_sort.py | 1,332 | 4.4375 | 4 | #!/usr/bin/env python3
"""
Insertion Sort Script
"""
def insertion_sort(L):
"""
Sorts a list in increasing order. Because of lists are mutable
this function does not have to return something.
This algorithm uses insertion sort.
@param L: a list (in general unsorted)
"""
# a l... |
2281278a010ff6adecab5f9c277cbef5c731e1c7 | goosen78/simple-data-structures-algorithms-python | /quick_sort.py | 1,912 | 4.625 | 5 | #!/usr/bin/env python3
"""
Quick Sort Script
"""
def quick_sort(L):
"""
Sorts a list in increasing order. Because of lists are mutable
this function does not have to return something.
This algorithm uses quick sort.
@param L: a list (in general unsorted)
"""
def partiti... |
2986c29a5db0dd7a1e2d2a2517676e96601ac69d | Lewis-Cole/Poker-Solver | /poker_solver/comparison.py | 4,204 | 3.578125 | 4 | """Contains comparison functions."""
import itertools
from .rules import ranks, suits
from .hand import Hand
def compare_ranges(IP_range: list, OOP_range: list, board: list) -> dict:
"""Returns equities of each holding in IP_range vs OOP_range on board"""
# accounting for range blocked by board
IP_rang... |
745abd06ac5c4cca557c84ffa20fcab7a61235ea | winsonyeap94/ils_qlearning | /src/02b_qlearning_epsilon.py | 5,047 | 3.5625 | 4 | """
Continuing from our earlier example from 02_qlearning.py, we find that our model isn't really learning. It either
does not reach the top, or only reaches after a long time (large number of episodes).
As an Agent learns an environment, it moves from "exploration" to "exploitation." Right now, our model is greedy ... |
0b285d7eeb21b39eea7a398eb095995722f98e9a | jeanmizero/Coursera-Python | /week_1/format.py | 1,065 | 3.640625 | 4 | # # floating formatting follows " {value:width.precision f}"
# result = 100/777
# print(result)
# print("The result was {r:1.3f}".format(r=result))
# # f string
# name = "John"
# print(f'Hello, his name is {name}')
# # List suport indexing and slicing
# my_list = [1, 2, 3, 4]
# # add element end
# my_list.append(6)
# ... |
db1dae8d2abdc113fa675456aa3f9b7f5ac7e59d | TobiasKooijman/van-input-naar-output | /Stokbrood_2.py | 702 | 3.765625 | 4 | # Inputs
Aantal_Stokbrood = input('geef het aantal stokbroden ')
Stokbrood = input('geef de prijs van de stokbroden ')
Aantal_Croissant = input('geef het aantal croissants ')
Croissant = input('geef de prijs van de croissants ')
# Value Numbers:
Totaal_Stokbrood = int(Stokbrood) * int(Aantal_Stokbrood)
Totaal_Croiss... |
be03f036a98e0eb6db7587adb5d9b21db3b3545d | Tujiperti1/t | /mechanize.py | 4,593 | 3.59375 | 4 | <title>All hail mecanize: A powerful python library</title>
<link>http://www.security.securethelock.com/?p=221</link>
<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
<guid isPermaLink="false">http://security.securethelock.com/?p=221</guid>
<description></description>
<content:encoded><![CDATA[
In th... |
52c44f90984ab6937ab7f64145e125fff2d4af86 | daniilzelekson/programming-2021-19fpl | /queue_/queue_.py | 1,681 | 4.09375 | 4 | """
Programming for linguists
Implementation of the data structure "Queue"
"""
from typing import Iterable
# pylint: disable=invalid-name
class Queue_:
"""
Queue Data Structure
"""
def __init__(self, data: Iterable = (), max_size_queue: int = float("inf")):
self.max_size_queue = max_size_qu... |
238ee924d715a063f37de773ee8b5952cde97f75 | AryusG/Turtle-Crossing-Game | /car_manager.py | 1,106 | 3.78125 | 4 | from turtle import Turtle
import random
COLORS = ["red", "orange", "yellow", "green", "blue", "purple"]
# STARTING_MOVE_DISTANCE = 5
# MOVE_INCREMENT = 10
class CarManager:
def __init__(self):
self.all_cars = []
self.starting_move_distance = 5
self.move_increment = 5
def create_car(se... |
d7c313c800a094375b44a03ea875571bd73453d4 | Haruna245/HarunaRepo | /p3(1).py | 230 | 3.859375 | 4 | name_str = "fibonacci sequence"
# name_str refers to the name of the string #
def sq(n):
# n refers to the number of item you want to print #
for i in range(n):
print(name_str[i],end='')
p_view = sq(10)
|
0b7da0f05f7947a2a0cfd744469e9a41dbf60fb3 | max7patek/MathEnvironment | /src/Main.py | 1,657 | 4.25 | 4 | from Environment import Environment
def main():
env = Environment()
instructions(env)
while True:
print()
out = env.run(keys = ('stop',))
if out == 'stop':
print('Goodbye')
break
print(out)
def instructions(env):
print("\
Input an expression t... |
4d7ff89e5e2c4151b8454ad243a6fd73da53aefd | AlejandroToledo15a/Python | /4_Funciones.py | 3,872 | 4.40625 | 4 | """
FUNCIONES.
Las funciones son formas de separar la lógica en piezas sin tener que ejecutarlas linea a
linea, y además permitir reutilizar partes del código que se repitan.
"""
#%%
def saludar():
print('Hola mundo')
saludar()
#%%
def saludar(nombre):
print(f'Hola {nombre}, cómo estás?')
saludar('A... |
4c14d973cc237b29f0a9891562c3f5259553c7d9 | moevm/gui-1h2018-25 | /logic/deck.py | 1,782 | 3.921875 | 4 | from random import shuffle
class Suits:
HEARTS = "Hearts"
DIAMONDS = "Diamonds"
CLUBS = "Clubs"
SPADES = "Spades"
SUITS = (HEARTS, DIAMONDS, CLUBS, SPADES)
symbols = {Suits.SPADES: u'♠', Suits.HEARTS: u'♥', Suits.DIAMONDS: u'♦', Suits.CLUBS: u'♣'}
class Card(object):
def __ini... |
6a0d52e1955702e8104ca9aebe08992162bd3a71 | Jarvis7923/artificial-intelligence-projects | /hw/hw3/others/wht/prj3/Settings.py | 1,792 | 3.9375 | 4 | import random
from enum import Enum
from Cell import *
class PuzzleType(Enum):
"""
It defines whether the type of the puzzle is easy or evil
"""
easy = 0
evil = 1
class Order:
def __init__(self, board):
"""
This class defines the predefined order of the assignment sequence.
... |
befc073dabf79f81f785bc4c4f21d8e882537cf5 | ssyed04/Pacman | /Pacman/Pacman/pathfinder.py | 8,724 | 3.515625 | 4 | #pathfinder.py
from pprint import *
mazeList = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1],
[1, 0, 0, 0, 0, 0, 'F',... |
020bfae2ea34763082fa4b8f4ba00df1790c417e | sbalajiv/learning_python | /flatten_dictionary/flatten_dict.py | 1,082 | 4.53125 | 5 | """
Write a function to flatten a nested dictionary. Namespace the keys with a period.
For example, given the following dictionary:
{
"key": 3,
"foo": {
"a": 5,
"bar": {
"baz": 8
}
}
}
it should become:
{
"key": 3,
"foo.a": 5,
"foo.bar.baz": 8
}
You can a... |
80eb225e6f743c3b3712870651f17490763e2af6 | Bobo199/Metin2 | /Renewal-Dead-Packet-master/V2/2.Client/root/localeinfo.py | 304 | 3.6875 | 4 | #Add
def SecondToMS(time):
if time < 60:
return "%d%s" % (time, SECOND)
second = int(time % 60)
minute = int((time / 60) % 60)
text = ""
if minute > 0:
text += str(minute) + MINUTE
if minute > 0:
text += " "
if second > 0:
text += str(second) + SECOND
return text |
7a0b15385ccb2c39ae2bbe78c903ada1f300daeb | npovey/aws | /backup_AWS_S3/Restore.py | 2,597 | 3.90625 | 4 |
# File name: Restore.py
# Example: nps-MacBook-Air-2:Desktop np$ python3 program3/Restore.py text2
# Program always restores from "npovey2" bucket on AWS
# Type in any directory name to back up
# The restore recursive function was taken from
# https://stackoverflow.com/questions/31918960/boto3-to-download-all-files-f... |
c6bd7a5f7d2b1028709b606552b5842130fdf10a | imrajashish/python-prog | /covid19.py | 463 | 4.25 | 4 | #Write a Python program that iterate over elements repeating each as many times as its count.
from collections import Counter
c = Counter(p=4, q=2, r=0, s=-2)
print(list(c.elements()))
#Write a Python program to find the most common elements and their counts of a specified text.
from collections import Counter
s = 'lk... |
ab6bddf681c43cd15f02c602f6bc6633105e6eda | imrajashish/python-prog | /datastr.py | 419 | 3.8125 | 4 | #Write a Python program to convert a float to ratio.
from fractions import Fraction
value = 4.2
print(Fraction(value).limit_denominator())
# Write a Python program to generate a series of unique random numbers.
import random
choices = list(range(100))
random.shuffle(choices)
print(choices.pop())
while choices:
if ... |
2fd36405361803c31921c600c3a4bb1ec7fba9be | imrajashish/python-prog | /data str1.py | 1,022 | 4.34375 | 4 | #Write a Python program to iterate over an enum class and display individual member and their value.
from enum import Enum
class country(Enum):
Afganistan = 10
japan = 12
india = 232
odisha = 21
Bihar = 121
for data in country:
print('{:15} = {}'.format(data.name, data.value))
#Write a Python pr... |
769091ba7d1aab81235bf0be58f093231a33d23c | imrajashish/python-prog | /list_string.py | 556 | 4.5 | 4 | #Write a Python program to create a list taking alternate elements from a given list.
def alternate_elements(list_data):
result=[]
for item in list_data[::2]:
result.append(item)
return result
colors = ["red", "black", "white", "green", "orange"]
print("Original list:")
print(colors)
print("List w... |
173626ec636aa4269aa59fecc071d3b54e661675 | imrajashish/python-prog | /JSON.py | 554 | 4.0625 | 4 | #Write a Python program to convert JSON data to Python object.
import json
json_obj = '{ "Name":"David", "Class":"I", "Age":6 }'
python_obj = json.loads(json_obj)
print("\nJSON data:")
print(python_obj)
print("\nName: ",python_obj["Name"])
print("Class: ",python_obj["Class"])
print("Age: ",python_obj["Age"])
#Write ... |
a93ff0540141079d7041264c14ed71e57a82695a | imrajashish/python-prog | /Backtracking.py | 330 | 3.96875 | 4 | #Creat all the binery string with n bits.Assume A[0..n-1] is an array of size n.
def appendAtFront(x,L):
return [x + element for element in L]
def bitStrings(n):
if n == 0: return[]
if n == 1: return[]
else:
return(appendAtFront("0",bitStrings(n-1))+appendAtFront("1",bitStrings(n-1)))
print(bitS... |
32bcfddf98d8869ea6e7b3148ca5acb0db453b6f | imrajashish/python-prog | /Exercise5.py | 977 | 4.03125 | 4 | #Write a Python program to create the combinations of 3 digit combo.
numbers = []
for num in range(100):
num = str(num).zfill(3)
print(num)
numbers.append(num)
#Write a Python program to count the number of each character of a given text of a text file.
'''import collections
import pprint
file_input = input('File... |
9eb1f104babc8c7a142743b3d4ada7cefcd6e8ae | fgirardi/SourcePython | /diversos/ExampleRegx.py | 207 | 3.71875 | 4 | import re
match = re.search('([a-z]+)\s([a-z])', 'Guilherme Orlando Girardi')
if match:
print("[{0}]".format(match.group(0)))
print("[{0}]".format(match.group(1)))
print("[{0}]".format(match.group(2)))
else:
print('sad')
|
a5987de42b8a0e1149e328c59d8dca745b73bc6c | brianchun16/PythonPractices | /Quiz/quiz2_1_for_loop.py | 119 | 3.796875 | 4 | word = 'Welcome!'
# string is also a "list of characters" and can be directly taken from
for w in word:
print(w)
|
e692643945466ad1f0527bbecadb49c63261d688 | brianchun16/PythonPractices | /Lecture06/practice06_list_mutable.py | 290 | 3.8125 | 4 | techs = ['MIT', 'Caltech']
ivys = ['Harvard', 'Yale', 'Brown']
univs = [techs, ivys]
univs1 = [['MIT', 'Caltech'], ['Harvard', 'Yale', 'Brown']]
print 'univs =', univs
print univs == univs1
techs.append('Princeton')
print 'univs =', univs
print 'univs1 =', univs1
print univs == univs1
|
ab09bcc93a8e747d6e9dc2da1e96163f2d63fd4a | brianchun16/PythonPractices | /Lecture04/practice2_for.py | 170 | 4.0625 | 4 | #ex) 9 multiply using 'for' loop
for i in range(2, 10):
print("=======================")
for j in range(1, 10):
print(str(i) + ' * ' + str(j) + " = " + str((i * j))) |
4458ab8f6f4abd43d66484da106f3648b4da03fe | brianchun16/PythonPractices | /Lecture09/person.py | 457 | 3.8125 | 4 | class Person(object):
def __init__(self):
self.name = ""
self.bday = ""
self.height = 0
# def set_something creates function for adding specific values
def set_name(self, name):
self.name = name
def set_bday(self, bday):
self.bday = bday
def set_height(self, height):
self.height = height
#combine... |
efa1a2324e7d7cc7b0e52ff0f36674a4e73084cd | brianchun16/PythonPractices | /Lecture02/Practice3.py | 220 | 3.765625 | 4 | current_year = 2017
my_birth_year = 2000
my_age = current_year - my_birth_year
if my_age < 8:
print("byebye")
elif my_age < 20:
print("bye")
print(" ")
else:
print("Continue")
print(" playing")
print("done")
|
559b330d0a2839570edee711e70af70b1ee5fe73 | ricksu/LeetCodeS | /88. Merge Sorted Array.py | 683 | 3.578125 | 4 | class Solution(object):
def merge(self, nums1, m, nums2, n):
"""
:type nums1: List[int]
:type m: int
:type nums2: List[int]
:type n: int
:rtype: void Do not return anything, modify nums1 in-place instead.
"""
m, n, t = m -1, n - 1, m + n - 1
while m >= 0 and n >= 0:
... |
12dcb041575c1f56017c0375e6e898b12f76a52b | cyliang1113/python-demo | /leolab/pythondemo/encoding/demo02.py | 393 | 3.84375 | 4 | # coding: utf-8
str1 = u"中国"
print(str1)
print(type(str1))
print(len(str1))
print("=================================")
str2 = "中国"
print(str2)
print(type(str2))
print(len(str2))
print("=================================")
# print(type(str2.decode('utf-8')))
# print(len(str2.decode('utf-8')))
print("===============... |
c2c5e5a18267595bc3396e0081de3297e4068daf | chandiwalaaadhar/DataStructuresAndAlgo | /trees.py | 788 | 3.5 | 4 | class BinaryTreeNode():
def __init__(self, data, left=None, right=None):
self.data=data
self.left=left
self.right=right
class BinaryTree(object):
def __init__(self, root=None):
self.root=root
def preorder(self, root):
if (root is None):
return
prin... |
ba5a2e8068babbe0c00bf428394a1a8e72a15534 | thamyresmfs/trabalho-extra | /facil.PY | 180 | 3.734375 | 4 | p = input("informe o preço")
print(p)
d = input("informe o desconto")
print(d)
vf = (float (p) * float(d))/100
print((p),"reais, com",(d),"%","de desconto, deu",(vf),"reais.")
|
6d30afad451781d2544f69fe7cecc07f632716d7 | mamemilk/acrc | /プログラミングコンテストチャレンジブック_秋葉,他/src/2-1-2_02_arc031_b.py | 1,218 | 3.53125 | 4 | # https://atcoder.jp/contests/arc031/tasks/arc031_2
# 埋めるマスは結局全探索になってしまった.
# - DFSなので,マスによってはすぐ終わる.特に埋め立て地からスタートするのでDFS関数はすぐに抜ける.
# - 10x10マスで小さい
# ということで,全探索でもなんとかなった.
A = []
W = 10
H = 10
for h in range(H):
yoko = list(input())
A.append(yoko)
def dfs(y,x,M):
M[y][x] = '.'
for (ny, nx) in [(y... |
f817a3fa2bf68d417eabb8675fc088424db7d24d | mamemilk/acrc | /C言語による計算の理論/src/comp.py | 5,906 | 3.703125 | 4 | pair_map = {}
def pair(x, y):
global pair_map
z = (x+y)*(x+y+1)//2 + x + 1
pair_map[z] = (x,y)
return z
# Left, Rightの探索の部分だけ早くすれば、現実時間に終わるかと思ったが、結局Pairでメモ化しないと終わらなかった。
def fast_left_right(z):
if z == 0:
return(0,0)
if z in pair_map.keys():
return pair_map[z]
n = 0
wh... |
d2a686c97efa2927839f07b0595b3b1d5abd626e | nikhilgurram97/CS490PythonFall2017 | /PythonLab2/task3.py | 4,409 | 3.890625 | 4 | class Student: #first class
def __init__(self, name, id, country, password=None): #using init function
self.studentname=name
self.studentid=id
self.studentcountry=country
self.__studentpassword=password ... |
4aa086c89319bf65f89b235ad579cd2f63632e18 | nikhilgurram97/CS490PythonFall2017 | /PythonLab2/task2.py | 300 | 3.6875 | 4 | a=input("Enter the limit value n: ")
b={}
for i in range(1,int(a)+1): #for adding values into dictionary, loop is used
b[i]=i*i #keys and values updated accordingly(square value of keys is updated to value)
print (b) #dictionary is printed |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.