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 |
|---|---|---|---|---|---|---|
2120c40bf9636bc245bc60ff55a8f55aab16d034 | viviyanti/PBO | /PBO_18099/Latihan_7.3.Str.py | 238 | 3.515625 | 4 | class Mahasiswa :
def __init__(self, nama, kelas):
self.nama = nama
self.kelas = kelas
def __str__(self):
return f"nama {self.nama}, kelas : {self.kelas}"
c=Mahasiswa("vivi", 45)
print(c) |
d0fec4e684b774cbc4b07cce6c7d7bacfa6681ca | shortma1/Coyote | /day6.py | 615 | 4.25 | 4 | # # functions
# print("Hello") # print() is a function
# num_char = len("Hello") # len() is also a function
# print(num_char)
# def my_function(): # def defines function, my_function() is the name of the function, and : finished the function definition
# print("Hello")
# print("Bye")
# my_function() # to... |
427bd2da94bf86f9df5637fd1723ad23b7569561 | posenberg/LPTHW | /ex18.py | 470 | 4.03125 | 4 |
def print_two(*args):
#this one is like your scripts with argv
# to use *args means you take all the arguments in a function as place them as a list.
arg1, arg2 = args
print "arg1: %r, arg2: %r" % (arg1, arg2)
def print_two_again(arg1, arg2):
print "arg1: %r, arg2: %r" % (arg1, arg2)
def print_one(arg1):
print... |
d2748867ecdaa65218c7ffecaf74fbaec0149789 | Vitaee/Python-Basic-Projects-5 | /BinarytoHexadecimal.py | 1,387 | 4.34375 | 4 | print("Welcome to the Binary/Hexadecimal Converter App\n")
a = int(input("Compute binary and hexadecimal values up to the following decimal number: "))
decimal = list(range(1, a+1)) #a+1 dedik çünkü range fonksiyonu son sayıyı almıyor.
binary = []
hexadecimal = []
for i in decimal: #for döngüsü oluşturarak decimal bin... |
b889e8d371d274cafd4d4b438e8ca14031bcec2d | Tomer9000/wog | /wog/CurrencyRouletteGame.py | 2,655 | 3.5625 | 4 | import requests
import random
from inputimeout import inputimeout, TimeoutOccurred
from .Game import Game
class CurrencyRouletteGame(Game):
"""
This class returns True if the user replies correctly on the value
(generated between 1-100) from USD to ILS, else it returns False.
"""
def __init__(self... |
c2fae8e508097b01e00fabcf36bf2ab16e3454e8 | manojputhalapattu/python | /finally.py | 254 | 3.765625 | 4 | a=2;
b=0;
try:
print("resource opend")
print(a/b)
except Exception:
print("cant divide by zero")
finally:
print("resource closed")
#here the finally block will be executed irrespectvie of the try and the catch blockes
|
dd34bfdc0e37c06062fa8bdf015c1c32107de3a1 | manojputhalapattu/python | /addition_array.py | 162 | 3.828125 | 4 | from array import *
arr1=array('i',[3,4,5])
arr2=array('i',[4,5,6])
arr3=array('i',[])
for i in range(len(arr1)):
arr3=arr1[i]+arr2[i]
print(arr3)
|
c4b72e0ddfd79cf6906d3c1d86274a0773f45e48 | manojputhalapattu/python | /su.py | 160 | 3.59375 | 4 | def add():
c=a+b
print(c)
def sub(a,b):
c=a-b
print(c)
def mul(a,b):
c=a*b
print(c)
def divide(a,b):
c=a/b
print(c)
|
5c62b7146932456135082c0bad224897534858c5 | manojputhalapattu/python | /super_keyword.py | 470 | 3.859375 | 4 | class a():
def __init__(self):
print("init in a ")
def feture1(self):
print("feature 1 working")
class b(a):
def __init__(self):
super().__init__()
print("init in b")
b1=b()# object creation for class b
# here syper keyword helps to invoke the __init__ in both cla... |
ef9d283b2808fbbd592e6a9dc8edfdff4cb54ce3 | manojputhalapattu/python | /quizquestion1.py | 110 | 3.625 | 4 |
i=1
for i in range(1,100):
if i%3==0 and i%5==0:
continue
print(i)
i=i+1
|
e21849adeecdea5a8ef379a9b4aa05088cab4b5b | piluvr/Python | /Assignment.py | 1,180 | 3.640625 | 4 | # your code goes here
fName = input("What is your first name? ")
lName = input("What is your last name?")
ID = int(input("Student ID: "))
n=1
inputclasses = []
roomnums=[]
print("*************************************************")
print("* *")
print("*\t" + lName + ", " + f... |
a08f76a2e3ccc91b0e0ebae2c191fd09f7c43063 | piluvr/Python | /max.py | 233 | 4.125 | 4 | # your code goes here
nums =[]
input1 = int(input("Enter a number: "))
input2 = int(input("Enter a number: "))
input3 = int(input("Enter a number: "))
nums.append(input1)
nums.append(input2)
nums.append(input3)
print(str(max(nums)))
|
6a8762e28635efdd5a7a84d3ceb234128144c043 | InsaneDhina/books_scraping | /menu.py | 1,021 | 3.9375 | 4 | from app import books
USERCHOICE = """
enter b to see best books
enter c to see cheapest books
enter n to see next available book on the catalogue
enter q to quit
"""
def print_best_books():
best_books = sorted(books, key=lambda x: x.rating * -1)[:10]
for book in best_books:
print(book)
... |
725d88dc4e383962d85965ffbbf65e77c74f6134 | yugan3/Python | /week 10 test.py | 936 | 3.71875 | 4 | #1. 无空隙回声输出
a = input("")
a = a.replace(" ","")
print(a)
#2. 文件关键行数
f = open(‘latex.log’, 'r', encoding='utf-8')
s = 0
f = set(f.readlines())
f = list(f)
for i in f:
s = s + 1
print(s)
#3. 字典翻转输出
s = input()
try:
dict_1 = eval(s)
if isinstance(dict_1, dict):
dict_2 = dict(zip(di... |
d8c92e58919689ff644004479aad9cbae61218e2 | shanjiang1994/LeetCode_for_DataScience | /Solutions/Array/88.Merge Sorted Array.py | 2,809 | 4.34375 | 4 |
'''
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.
Note:
The number of elements initialized in nums1 and nums2 are m and n respectively.
You may assume that nums1 has enough space (size that is equal to m + n) to hold additional elements from nums2.
Example:
Input:
nums... |
92b23cdfa9a34ba5230c0353dbc1958a63a38658 | Skryvvara/DS1-Soullevel-Calculator | /soullevelcalc.py | 1,287 | 4.1875 | 4 | # returns cost of the given level
# when level = 12 the returned cost is from level 11 -> 12
def get_level_cost(level: int) -> int:
return int(round((0.02 * pow(level, 3)) + (3.06 * pow(level, 2)) + (105.6 * level) - 895, 0))
# returns the amount of possible levelups
# takes the current level and the amount of hel... |
2d0f3c35b0bffedb1f4fbeb1e8dfc4b67efbfd97 | brahmcapoor/terminal-xkcd | /xkcd_menu.py | 2,058 | 3.84375 | 4 | import xkcd_comic
import os
def num_find(database):
number_comics = str(len(database) + 1)
number = int(
input(
"Comic number? The most recent comic is number " +
number_comics +
". "))
comic = None
for entry in database:
if entry[0] == number:
... |
cf79d548cfb65bb4ea3073cd0d1723981cea1400 | sydoruk89/math_series | /math_series/series.py | 1,177 | 4.1875 | 4 | def fibonacci(n):
"""
The function return the nth value in the fibonacci series.
Args:
n (int): integer
"""
if n >= 0:
if n < 2:
return n
else:
return fibonacci(n - 1) + fibonacci(n - 2)
else:
return 'Please provide a positive number'
... |
7b96413c200c18d0febbdd018dd54b3eb022eaa5 | mazhar-h/sorting-algorithms | /python/merge_sort.py | 1,284 | 3.703125 | 4 | import sort_tools
import copy
def merge(data, low, middle, high):
data_a = []
data_b = []
len_a = middle - low + 1
len_b = high - middle
i = 0 # track data_a
j = 0 # track data_b
k = low # track original data set
for idx in range(middle - low + 1):
data_a.append(data[low + ... |
940f7e850a7c42ee749bb2204ad65742d4b4f474 | mazhar-h/sorting-algorithms | /python/insertion_sort.py | 532 | 3.765625 | 4 | import copy
import sort_tools
def insertion_sort(data, n):
for i in range(1, n):
temp = data[i]; # create hole
#slide greater elements down
j = i
while j > 0 and data[j-1] > temp:
data[j] = data[j-1]
j -= 1
data[j] = temp
@sort_tools.timeit... |
03362f86c83d15b377824bc47722ceb4204a2031 | Bia10/WOW-Bot | /Utility.py | 268 | 3.671875 | 4 | # -*- coding: utf-8 -*-
import string
def str2hex(s):
out = ""
for c in s:
out += ("%2x"%(int(ord(c)))).upper().replace(" ","0")
return out
def hex2str(s):
out = ""
i = 0
while i < len(s):
out += chr(int(s[i]+s[i+1],16)&255)
i += 2
return out |
377fc2b3e0471bf7e093138ade92549b0b3e1aef | bigWaitForItOh/Classic-Problems | /substring_sum/python/substring.py | 607 | 4.03125 | 4 | ###############################################################################################
#A number is given in the form of a string and we are supposed to find the sum of all its substrings (which are also numbers)
#example: 16 = 16 + 1 + 6 = 23
#example: 123 = 123 + 1 + 2 + 3 + 12 + 23 = 164
###################... |
ee01557ce1c11cdcb394712d8312e1b3732e2441 | bigWaitForItOh/Classic-Problems | /n_queens/python/n_queens.py | 1,401 | 3.671875 | 4 | ###############################################################################################################################
#Solves the N Queens Problem using Backtracking & Recursion
#Input: Number N
#Output: a List of N Lists, representing an NxN grid. 0 represents no queen at that spot, 1 otherwise.
############... |
5f00c818bf58ae0788f8a8b1ae0c5b8863f29c2d | bigWaitForItOh/Classic-Problems | /knapsack/fractional/python/fractional_knapsack.py | 1,198 | 4.09375 | 4 | ##################################################################################################################
#Fractional Knapsack Greedy Algorithm
#Time Complexity: O(nlog(n))
#Yields the optimal value that can be retrieved, needs to be modified to include weight-item information
#################################... |
e920c9632e1409b7d5835a145d4461d8ca042b41 | bigWaitForItOh/Classic-Problems | /apple_table/python/apple_table_dp.py | 1,443 | 4.0625 | 4 | ############################################################################################################################
#Dynamic Programming Implementation of the Apple Table Problem
#
#A table composed of N x M cells, each having a certain quantity of apples, is given. You start from the upper-left corner.
#At e... |
a48243f3ddee2603d67d7ab46315b3ad32b3d953 | ErickGualteros/Tareas | /Tarea2.py | 1,740 | 3.6875 | 4 | from math import fabs, pi#Paquetes
import matplotlib.pyplot as plt
import numpy as np
print("Area y Perimetro de un circulo y un Cuadrado")
y1=float(input('Ingrese el valor de y1: '))
x1=float(input('Ingrese el valor de x1: '))
y2=float(input('Ingrese el valor de y2: '))
x2=float(input('Ingrese el valor de x2: '... |
a84a393c64046586442bbda297197535d3b13c93 | antonkhelou/SIS | /sis/views/utils.py | 7,043 | 3.515625 | 4 | from PIL import Image
import sys
def nn_resample_image(image_path, pxl_box_width, pxl_box_height):
"""
Function which pixelates an image by averaging out pixel values in blobs of
pxl_box_width * pxl_box_height in dimensions.
Returns a PIL Image object.
"""
image = Image.open(image_path)
i... |
cf94fd180711f6301bdc646841904f5f37cb3417 | mrJeppard/NeighborCompare | /NeighborCompare/tests/test_identity.py | 2,072 | 3.875 | 4 | """A starting point for unit tests."""
from unittest import TestCase
import utils4testing as utils
from NeighborCompare.neighborplot import NeighborPlot
class Testings(TestCase):
"""Place holder running test class."""
def test_identity(self):
"""Same coords should come up with a comparison score of ... |
a2a2157555c17486a38855892ebbea00a41bf766 | ShawnT21/The_Box | /dungeon_adventure.py | 2,490 | 4.09375 | 4 | from sys import exit
def get_hurt(message, severity):
"""
A simple function that determines damage of mc based on severity level.
Parameters:
(String) message: message explaining how the mc got hurt.
(int) severity: the severity level of how bad the damage inflicted is.
"""
if severity == 1... |
828d38d0d0d6de4b7a412b3d2f9e01d14cda7d46 | Nicola-B/Object-Oriented-Programming | /Farm Simulation/Farm_simulation_Fields_main_programe.py | 6,950 | 3.65625 | 4 | #Nicola Batty
#13/07/2015
#Farm simulation Fields main programe
from Farm_simulation_Fields import *
def auro_grow(field, days):
#grow the field auromatically over x days
for day in range(days):
light = random.randint(1,10)
food = random.randint(1,100)
water = random.randint... |
344af6744412fee8ca812b99af2166e732e73450 | Nicola-B/Object-Oriented-Programming | /Farm Simulation/Farm_Simulation_Crops_Main_Program.py | 2,656 | 3.5625 | 4 | #Nicola Batty
#12/06/2015
#Farm Simulation Crops Main Program
import random
from Farm_simulation_Crop import *
from Farm_simulation_Crop_Wheat import *
from Farm_simulation_Crop_Potato import *
def auto_grow(crop, days):
for day in range(days):
light = random.randint(1,10)
water = r... |
9ec5c7564fb1cb22aff412378b83d21e66afd07d | arpita-lataye14/NESTED_LIST | /duplicate2.py | 345 | 3.796875 | 4 | # it will be show the numbers how many which time repeat.
# how many number repeat in a list.
n = [19, 17, 12, 17, 17, 18, 10, 17, 14, 12, 19, 17, 12, 13, 11]
a=[]
b=[]
i=0
while i<len(n):
if n[i]in n:
if n[i] not in a:
a.append(n[i])
else:
b.append(n[i])
i=i+1
print(b,'b... |
0816c1aab19db7d937bcf5716be56fa2789e122b | arpita-lataye14/NESTED_LIST | /prime.py | 290 | 3.8125 | 4 | a=[20,30,3,7,23,1,9,97,25,5]
i=0
while i<len(a):
if a[i]%2!=0 and a[i]%3!=0 and a[i]%5!=0:
print('it is a prime number:',a[i])
elif a[i]==2 or a[i]==3 or a[i]==5:
print('it is a prime number:',a[i])
else:
print('it is not a prime number:',a[i])
i=i+1 |
06312f780b6376cf5c558253d1f7b88e8c259cfd | Harathi-2021/Python | /vote.py | 123 | 4.09375 | 4 | age=int(input("Enter the age"))
if age>=18:
print("your Eligible to vote")
else:
print("your not Eligible to vote") |
efff0ca716cd75b2b45cf31b48798a218e8f8af5 | Harathi-2021/Python | /calculator.py | 417 | 3.921875 | 4 | choice=int(input("Enter the choice number 1:addtion 2:subtraction 3:multiplication 4:division"))
a=int(input("Enter the number"))
b=int(input("enter the number"))
if choice==1:
c=a+b
print("Result=",c)
elif choice==2:
c=a-b
print("Result=",c)
elif choice==3:
c=a*b
print("Result=",c)
elif choice=... |
42e693cfc1eecc95ba53f95916924cc2a272db74 | Harathi-2021/Python | /cal pr.py | 492 | 3.9375 | 4 | choice = int(input("Enter the choice number"))
if choice>=1 and choice<=4:
print("Enter two numbers")
num1=int(input())
num2=int(input())
if choice==1:
opr=num1+num2
print("Result=",opr)
elif choice==2:
opr=num1-num2
print("Result=",opr)
elif choice==3:
opr=num... |
3dcf5b339aa3b3fbb7de454ade1e99dcb87a93c5 | rcarlsson/adventofcode | /2018/02/aoc_02a.py | 745 | 3.765625 | 4 | import sys
from string import ascii_lowercase
def solve_line(line):
twos = 0
threes = 0
for c in ascii_lowercase :
if line.count(c) == 2:
twos = 1
elif line.count(c) == 3:
threes = 1
if twos == 1 and threes == 1:
break
return (twos, threes)
... |
d2eb3a7eea093b0cbc356d67e07b1b13c0b5eb9c | panwoo1/Algorithm | /sorting/insertion_sort.py | 341 | 3.796875 | 4 | # 가장 작은 수부터 차례대로 찾는 방식(큰 수부터 찾을 수도 있음)
def insertion_sort(A, n):
for i in range(1, n):
j = i - 1
while(j >= 0 and A[j] > A[j+1]):
A[j], A[j+1] = A[j+1], A[j]
j = j - 1
A = [12, 4, 9, 10, 21, 3, 8, 0, 7, 9, 6]
insertion_sort(A, len(A))
print(A)
|
64d2f5d6a3805f834f4e6af840e42ce530192667 | panwoo1/Algorithm | /algo_time/fibo.py | 228 | 3.796875 | 4 | def fibo(n):
if(n < 2):
return 1
a = 1
b = 1
c = a + b
while (n >= 2):
c = a + b
a = b
b = c
n -= 1
return c
# n을 입력받은 후
# fibo(n) 호출!
# 리턴값을 출력함
n = int(input())
print(fibo(n)) |
5421eb966d983f912a942f45de512c1ac20b6707 | ranajoy-dutta/TechGig | /30-Day-Challenge/Day29_Comparison_Between_Diagonals.py | 438 | 3.609375 | 4 | def main():
row, col = map(int,input().split())
mat = []
for i in range(row):
mat.append(list(map(int,input().split())))
d1,d2,forward,backward = 0,0,0,col-1
for i in range(row):
d1 += mat[i][forward]
forward += 1
d2 += mat[i][backward]
backward -= 1
if d1... |
f6f6685357d3c03bf35d024a675e130bc9557747 | andrewdhan/Intro-Python | /src/days-2-4-adv/player.py | 1,163 | 3.6875 | 4 | # Write a class to hold player information, e.g. what room they are in
# currently.
from item import Item
class Player:
def __init__(self,name,location, inventory = []):
self.name = name
self.location = location
self.inventory = inventory
def try_move(self, direction):
d = direction + "_to"
next_move = g... |
2e0db88ce42668e0b3e259c0ccf644b9e1f52ae3 | hachiroku-86/heron | /Maths algo/Factorielle.py | 129 | 3.875 | 4 | def factorielle():
y=1
x=int(input("Saisissez un nombre : "))
for i in range(1,x+1):
y=y*i
print(y)
|
d47947b2dcec568ac083bf018cd52f5cbcb9df0c | hachiroku-86/heron | /Maths algo/Diviseur.py | 312 | 3.71875 | 4 | def divisor(n):
diviseurs=[]
for i in range (1,n+1):
if n%i==0:
diviseurs.append(i)
return diviseurs
def estPremier(n):
if len (divisor(n))==2:
return 1
else:
return -1
def plusPetitPremier(m):
while estPremier(m) != 1:
m=m+1
return m
|
b26754b318f3bbbf326d047fd9918f9550a64ff4 | Tagima/IoT_AccessControl | /Host/Face_recognition/cnn.py | 2,340 | 3.578125 | 4 | from torch.autograd import Variable
import torch.nn.functional as F
import torch
import torch.optim as optim
class SimpleCNN(torch.nn.Module):
# Our batch shape for input x is (3, 32, 32)
def __init__(self):
super(SimpleCNN, self).__init__()
# Input channels = 3, output channels = 18
... |
a6d3c1ca23a5bd361624d85a32f401c22d399e28 | JackFurby/kontakt | /trie.py | 3,071 | 3.609375 | 4 | # https://github.com/JackFurby/trie/blob/master/trie.py
import glob
import errno
import pickle
class Node:
"""Node object for trie."""
# children contains links to other nodes
# data contains word if node is the end of a word
# end indicates if the current node is the end of a word
def __init__(self, end=False,... |
b5327d632a6f19e66a924e7805affe2c550a82f5 | gunwoongPark/Algorithms-and-Troubleshooting | /작은 과제/10-3(Knapsack).py | 508 | 3.609375 | 4 | def Knapsack(C, w, v, K):
n = len(w)
for idx in range(1, n+1):
for weight in range(1, C+1):
if(w[idx-1] > weight):
K[idx][weight] = K[idx-1][weight]
else :
K[idx][weight] = max(K[idx-1][weight], (K[idx-1][weight-w[idx-1]] + v[idx-1]))
return ... |
c4a79bd887f8b46e2e9e40469326658426341196 | tarasingh85/TSA_railways | /TSA_railway.py | 1,402 | 3.90625 | 4 | # satnam shri waheguru
print()
print("-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_WELCOME TO T.S.A RAILWAYS-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_")
print()
class Train:
seats=[1,2,3,4,5,6,7,8,9,10]
def __init__(self, name, fare ):
self.name=name
self.fare=fare
def displayStatus(self):
print... |
283c326932fc0de929cff8b3e32ed6ee0f7f1de1 | ak042/sql | /sqlb.py | 356 | 3.84375 | 4 | # INSERT Command
# import the sqlite3 lib
import sqlite3
# create the conn
conn = sqlite3.connect("new.db")
# get a cursor obj
cursor = conn.cursor()
# insert data
cursor.execute("INSERT INTO population VALUES('New York City', 'NY', 8200000)")
cursor.execute("INSERT INTO population VALUES('San Francisco', 'CA', 8... |
ab9575276120e3dd8ca84d40b104cc5493dbd987 | anshdholakia/Python_Projects | /Email_collector.py | 1,005 | 3.609375 | 4 | import re
str='''
Random Lists
Phone Numbers
Passwords
URLs
Fake Names
Credit Cards
SEARCH
MENU
Random Email Addresses:
RERUNOPTIONS
esbeck@sbcglobal.net
thaljef@msn.com
fbriere@comcast.net
manuals@aol.com
ryanshaw@me.com
nasarius@live.com
miturria@me.com
animats@att.net
keiji@att.net
gerlo@... |
20b4c3e37a696af6c0fb8c585e2293a3ea3d0a6e | anshdholakia/Python_Projects | /w3r ex on math.py | 22,382 | 4.03125 | 4 | # Write a Python program to convert degree to radian.
# import math
# def func(d):
# return math.radians(float(d))
# print(func(15))
# Write a Python program to calculate the area of a trapezium
# def func(a,b,h):
# return 1/2*h*(a+b)
# print(func(6,5,5))
# Write a Python program to calculate t... |
3791fb46c3a675eb2512d1596ae93a38623b4568 | anshdholakia/Python_Projects | /OOPS9.py | 923 | 3.625 | 4 | # class Dad:
# basketball=1
#
#
# class Son(Dad):
# dance=1
# def isdance(self):
# return f"Yes I dance {self.dance} number of times"
#
# class Grandson(Son):
#
#
# dance=6
#
# def isdance(self):
#
# return f"Dancer " \
# f"Yes I dance ballet {self.dance... |
94e9bebee541b227fee0713a50ef389e0089f1bf | anshdholakia/Python_Projects | /setters and property_decorators.py | 1,179 | 4.21875 | 4 | class Employee:
def __init__(self,fname,lname):
self.fname=fname
self.lname=lname
# self.email=f"{self.fname}.{self.lname}@gamil.com"
def explain(self):
return f" This Employee is {self.fname} {self.lname}"
@property
def email(self):
if self.fname==No... |
38dc95db1a37dafe46b126aaf292a19a592b4c71 | anshdholakia/Python_Projects | /file reading.py | 497 | 3.609375 | 4 | # f = open("ansh2.txt", "a") # for creaitng a file as well as writing multiple lines
# a=f.write("Ansh is a good boy\n")
# print(a) # number if characters that are written will be printed
# f.close()
# f = open("ansh2.txt", "w") #for creating a new file and for writing A line
# f.write("Ansh is a good boy\n")
#... |
aaba774ca1cb7bf525ee5f7912a663c39972f16b | anshdholakia/Python_Projects | /sets.py | 469 | 4 | 4 | s=set([1, 2, 3, 4])
#print(type(s))
#set1=set(s)
#print(set1)
s.add(1)
#s.union({1,2,3,5}) # this statment does not do anything as it only specifies the union but does not implement it
#It only implements when it is STORED IN ANOTHER SET such as s1
#s1= s.union({1,2,3,5})
#s1= s.intersection({1,3,4,5,6})
#prin... |
05f69fe60523a80c10d761c87101c4175a7b7742 | anshdholakia/Python_Projects | /OOPS1.py | 276 | 3.546875 | 4 | # object oriented programming
# Classes- Template
# Object- Instance of class
# DRY- Do not repeat yourself
class Student:
pass
ansh=Student() # deriving object from class
harry=Student()
ansh.name="ansh"
ansh.std=12
ansh.section=1
print(ansh.section) |
45521599af6d990c059840b0f1b70c9d3c482c6f | anshdholakia/Python_Projects | /map_filter.py | 1,387 | 4.21875 | 4 | # numbers=["1","2","3"]
#
# # for i in range(len(numbers)): # not suitable every-time to use a for loop
# # numbers[i]=int(numbers[i])
#
# # using a map function
# numbers=list(map(int,numbers))
#
#
# numbers[2]=numbers[2]+5
#
# print(numbers[2])
# def sq(a):
# return a*a
# num=[1,2,124,4,5,5,12... |
f6eda7e1687d6d775ca2398caf93b6a9b7c60321 | boehmrya/pythonAutomation | /httpsReplace/httpsReplace.py | 431 | 3.5625 | 4 |
'''
Replace http with https in a file
Output results to a new file
'''
import re
# open text file
textFile = open('sample.txt', 'r')
# string of text
fileContents = textFile.read()
# phone number regex
httpRegex = re.compile('http:')
httpsString = httpRegex.sub('https:', fileContents)
# write results to new file
o... |
6c465540793c7d032822d027ff5e58837b8fcf31 | lovaraju987/Python | /learning concepts and practising/basics/sep,end,flash.py | 443 | 4.15625 | 4 | ''' sep, end, flash'''
print('slfhs',2,'shalds',end = ' ') # by default print statement ends with \n(newline).so, this 'end' is used to change to ending of the print statement when we required it
print('sfjsaa',3,'hissa')
print('sfjsaa',2,'hissa',sep = ' ') # by default multiple statemnets in one print without any s... |
bb3fc582bab80a20014ba7aadb17ebe04015b05c | lovaraju987/Python | /learning concepts and practising/sending emails with python/sending_emails.py | 1,547 | 3.921875 | 4 | # sending email with python smtplib library
# steps to send email
# step 1 - import 'smtplib'
# step 2 - if you want send suject also with email, then import "MIMEMultipart" from "email.mime.multipart" and also import "MIMEText" from email.mime.text
# step 3 - stor sender email and password into varaible
# step 4... |
51914f2b2254144749521afd365a991f884ecbdc | lovaraju987/Python | /learning concepts and practising/Mutltithreading/multithreading-1.py | 3,965 | 4.40625 | 4 | ''' Multithreading '''
'''
multithreading is a way acheiving multitasking. In multithreading the concept of threads is used.
we need to import 'threadidng' API to implement multithreading in python
'''
''' Index :_
What is Multitasking in Python?
Types of MUlittasking?
What is thread?
How to achieve Multithreadin... |
3ae45e7a4702d8ebc37ea34864cb21b23137b0fa | lovaraju987/Python | /learning concepts and practising/Strings & Variables/string_methods.py | 3,783 | 4.59375 | 5 | ''' String Methods'''
str1 = 'geeksforgeeks is for geeks'
str2 = 'geeks'
#find()
print(str1.find(str2,2)) # It searches the given string where it is found in another string from starting index
#rfind()
print((str1.rfind(str2,0))) # It also searches the given string where it is found in another string. but it runs th... |
8c415215dc989769c0bf39d52e477c494effb0f5 | erYash15/Social-Media-Friend-Recommendation | /making_friends.py | 1,315 | 3.71875 | 4 | import random
import sqlite3
import pickle
linked_list_representation = []
# Data is set limited to 1000 points to avoid generating similar data.
while 1:
n_size = int(input("Please select size of database between 100 and 1000: "))
# Check limits
if n_size >= 100 and n_size <= 1000 :
... |
58c64fbd66f26227720cb1d167a8b270e8d903d0 | JuankaMendez/IA | /Ejercicio 2.py | 1,170 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Feb 14 00:54:05 2018
@author: lox_j
"""
"""
PROGRAMA PARA CALCULAR LA DESCIACION ESTANDAR Y VARIANZA
"""
from math import pow, sqrt
restar = list()
elevar = list()
def sumatoria(datos):
sumatoria = float(sum(datos))
return sumator... |
44452b0968689f60e90c5460baa132efeba063ab | PaulaSena/Python | /script-python/teste01.py | 123 | 3.640625 | 4 | nome=input('Qual é o seu nome?')
idade=input('Qual é sua idade?')
peso=input('Qual é seu peso?')
print(nome,idade,peso)
|
c60cfc2ece72bcdd7dd155c8b3fea9afdfd0039c | hgbritten/pythonisms | /pythonisms/pythonisms.py | 701 | 3.5 | 4 | from ll import LinkedList
from functools import wraps
from time import sleep
def procrastinate(func):
@wraps(func)
def wrapper(*args, **kwargs):
sleep(3)
return func(*args, **kwargs)
return wrapper
@procrastinate
def say(txt, salutation="Dear Sir or Madam"):
print(salutation + ", " ... |
3d0b0ef5e94ef8a8883f5a253c6ec2938253223b | wenlisong/coding-everyday | /Tree/subtree.py | 1,116 | 3.890625 | 4 | # coding=utf-8
# 输入两棵二叉树A,B,判断B是不是A的子结构。(ps:我们约定空树不是任意一个树的子结构)
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
# 1.Find the root node with same value
# 2.Check if pRoot2 is the subtree of pRoot1
# 2.1. Yes: return True
... |
158b0c4b80643315260f6410573beb939424e7da | wenlisong/coding-everyday | /leetcode/FirstMissingPositive.py | 711 | 3.765625 | 4 | # Given an unsorted integer array, find the smallest missing positive integer.
class Solution:
def firstMissingPositive(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
numdict = {}
n = len(nums) + 1
while nums:
num = nums.pop()
... |
e2713e94106957557ec5830cc9fab319dbaa0cfe | wenlisong/coding-everyday | /leetcode/MajorityElement.py | 835 | 3.734375 | 4 | # Given an array of size n, find the majority element.
# The majority element is the element that appears more than ⌊ n/2 ⌋ times.
# You may assume that the array is non-empty and the majority element always exist in the array.
class Solution:
def majorityElement(self, nums):
count = 0
majority = ... |
5957a506338a628123be73ec5c188fdfa4ed9c96 | wenlisong/coding-everyday | /LinkedList/lastKthNode.py | 837 | 3.578125 | 4 | # -*- coding:utf-8 -*-
# 输入一个链表,输出该链表中倒数第k个结点。
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def FindKthToTail(self, head, k):
if k <1:
return None
cur = head
next = head
for i in range(k - 1):
if ne... |
00750f8a2a6aa281bb6ba755bb3f6eb9985c4e85 | wenlisong/coding-everyday | /BitManipulation/NumberOfOneBits.py | 957 | 3.75 | 4 | # Write a function that takes an unsigned integer and returns the number of '1' bits
# it has (also known as the Hamming weight).
class Solution(object):
def hammingWeight(self, n):
"""
:type n: int
:rtype: int
"""
res = 0
while n > 0:
res += n&1
... |
6665ebd6516b719a754bc13ff88882a610ae8690 | samdallas/advent-of-code-2020 | /day_3.py | 569 | 3.5625 | 4 | #!/usr/bin/python
import csv
array_in = []
with open('./input.csv') as csvfile:
myreader = csv.reader(csvfile, delimiter=' ')
for row in myreader:
array_in.append(row[0])
def tree_count(x_jump, y_jump):
n_trees = 0
x_pos = 0
y_pos = 0
row_len = len(array_in[0])
while y_pos < len(array_in):
if ar... |
d549c26bd4698d56c915cccafad36204a835b7b4 | flxdot/project-carlos-on-edge | /Auxiliary.py | 5,850 | 3.671875 | 4 | #!/usr/bin/python
import os
import abc
import time
import logging
import logging.handlers
from threading import Thread, Event, Lock
class Timer(Thread):
"""The Timer is used to perform periodic tasks."""
def __init__(self, name: str, period: [float, int]):
"""
:param name: (mandatory, string... |
5733608db00de58d07cd64754e9592302e8e7dd6 | badri-venkat/Computational-Geometry-Algorithms | /PolygonHelper.py | 849 | 4.21875 | 4 | def inputPolygon(numberOfPoints):
polygonArray = []
print(
"Enter the points in cyclic order. Each point is represented by space-separated coordinates."
)
i=0
while i<numberOfPoints + 1:
x, y = map(int, input().split())
polygonArray.append(tuple([x, y]))
i+=1
if i... |
533d56ce5d372bfc972e3b9aa9d525f8c451f39e | Jooakim/adventofcode | /2016/day03/day03.py | 828 | 3.546875 | 4 | def checkSides(x,y,z):
return x+y>z and x+z>y and y+z>x
with open('input.txt') as f:
inp = f.readlines()
valid = 0
for row in inp:
x = row.split()
if (checkSides(int(x[0]),int(x[1]),int(x[2]))):
valid += 1
print valid
valid = 0
stored = []
a = []
... |
8878d61b57abe24e8f25332203496686cba0fd70 | simonwangao/Pickle_Gomoku_Agent | /threat_space_search.py | 35,853 | 3.9375 | 4 | from random import choice, shuffle
from copy import deepcopy
import utils
# This AI will decide a move based on the following order of steps:
# (0) -> If AI can win this turn, AI does so
# (1) -> Check for opponent's threats and prevent them (the straight_four
# threat cannot be prevented so we will not check f... |
471875926007c11aa4084b4f555b1f544b2aaaec | kradical/ProjectEuler | /p15.py | 706 | 3.75 | 4 | # Starting in the top left corner of a 2×2 grid, and
# only being able to move to the right and
# down, there are exactly 6 routes to the bottom
# right corner.
# How many such routes are there through a 20×20 grid?
# will be the 21st central binomial coefficient
#(2*21)!/21!
import math
def main():
number = mat... |
85d97c3d438e50790e7c2b29e60bb3dd46ccefdb | kradical/ProjectEuler | /p6.py | 634 | 3.828125 | 4 | # The sum of the squares of the first ten natural numbers is,
# 1^2 + 2^2 + ... + 10^2 = 385
# The square of the sum of the first ten natural numbers is,
# (1 + 2 + ... + 10)^2 = 552 = 3025
# Hence the difference between the sum of the squares of the
# first ten natural numbers and the square of the sum is
# 3025 − 385... |
e01e7b007f7041fccc232fc3e9ab9ecacb44dec4 | kradical/ProjectEuler | /p9.py | 467 | 4.15625 | 4 | # A Pythagorean triplet is a set of three
# natural numbers, a < b < c, for which,
# a2 + b2 = c2
# For example, 32 + 42 = 9 + 16 = 25 = 52.
# There exists exactly one Pythagorean triplet
# for which a + b + c = 1000.
# Find the product abc.
def test():
for a in range(1, 333):
for b in range(1000-a):
... |
3c61058b4721164d3a0b4252786d7b747f674510 | iFocusing/StreamingEventCompliance | /client/simulate_stream_event/client_logging.py | 9,853 | 3.734375 | 4 | import logging
from . import config
from pythonlangutil.overload import Overload, signature
import os
class ClientLogging:
"""
Description:
This class does the formatting of client side log before sending it to the logging system.
This class takes different arguments provided by the user a... |
2e7eec6459410eacf6968bd97ffb05ca03a4368a | mcode36/Python-Challenge | /P4/P4.py | 677 | 3.640625 | 4 | input_file = "sample1.txt"
INPF = open(input_file,"r")
line_count = 0
word_count = 0
char_array = []
for i in range (0,26):
char_array.append(0)
def char_cnt(v):
global char_array
text = v.lower()
for i in range (0, len(text)):
k = ord(text[i]) - 97
if k >= 0 and k <... |
92f25ef490208864ef74cc6c70392f7be9191aca | prasertcbs/calc | /area.py | 880 | 3.96875 | 4 | import math
def rectangle(w, h):
return w * h
def square(side):
"""calculate square area
Args:
side (float): side length
Returns:
float: area of square
"""
return side ** 2
def triangle(b, h):
"""[summary]
Args:
b ([type]): [description]
h ([type... |
4ecc881e7dcb2590682843e82b15cb498b41f304 | RiptideStar/Web-Crawler-Class | /BeautifulSoup包的解释.py | 3,595 | 3.5625 | 4 | # 什么是BeautifulSoup4?
# '''
# BS4: 将复杂的HTML文档转换成一个复杂的树形结构,每个节点都是Python对象,所欲对象可以归纳为4种:
# - Tag
# - NavigableString
# - BeautifulSoup
# - Comment
# '''
from bs4 import BeautifulSoup
f = open('./baidu.html', 'rb') # 以rb模式打开文件
html = f.read() # 读取文件到html变量
bs = BeautifulSoup(html, 'html.parser') # 使用BS... |
dff8542b895f9bd5b1b9d594346ef6bceec5ba97 | tobyt99/pythoncolt | /mileage.py | 166 | 4.09375 | 4 | print ("how many kms did you do today>")
today = float(input())
miles = today/1.6093
miles = round(miles, 2)
print(f"{today} kms is equal to {miles} miles GREAT JOB") |
6d471e7019a0653852e8f84c63d2af095c22ca81 | tobyt99/pythoncolt | /guessing.py | 467 | 4.03125 | 4 | import random
from random import randint
game = "y"
while game == "y":
num = randint(1, 10)
guess = int(input("guess a number between 1 - 10: "))
while guess != num:
if num > guess:
state = "too low"
else:
state = "too high"
print(f"sorry {state}")
... |
3fde84bd29962741121856cc2ba0016be0459bfd | CucchiettiNicola/PythonProgramsCucchietti | /Python3/TurtleInput.py | 843 | 3.984375 | 4 | import turtle as t
spostamento = 1
moltiplicatore = 100
t.speed(0)
t.color("green", "red")
while True:
print("\ninserire:\nf per andare avanti\nr per girare a destra\nl per girare a sinistra\nb per andare indietro\nstop per fermare il programma\n |\n\ /")
k = input()
if k == "f":
t.fo... |
732c172fbce4e4cac32875feb880b5e1c6ac59f4 | CucchiettiNicola/PythonProgramsCucchietti | /Compiti-Sistemi/Es32/Es32.py | 1,475 | 4.75 | 5 | the_count = [1,2,3,4,5]
fruits = ['apples', 'oranges', 'pears', 'apricots']
change = [1, 'pennies', 2, 'dimes', 3, 'quartiers']
# this first kind of for-loop goes trough a list
for number in the_count:
print(f"This is count {number}")
# same as above
for fruit in fruits:
print(f"A fruit of type: {fruit}")
#... |
498246113e0c33826b2efc992baaaf49136b6be4 | CucchiettiNicola/PythonProgramsCucchietti | /Compiti-Sistemi/Es17/Es17.py | 1,490 | 3.765625 | 4 | from sys import argv
from os.path import exists
script, from_file, to_file = argv
print(f"Copying from {from_file} to {to_file}...")
# we could these two on one line, how?
# > Yes, but we have problem closing the file.
# indata = open(from_file, "rb").read()
in_file = open(from_file, "rb")
indata = in_file.read()
... |
1f19ee1ef63dd717f68bce4ac0587b27a0ce2d9c | PierreBeylard/debugging_calculatrice_programme | /calculatrice/calculatrice.py | 2,940 | 3.921875 | 4 | def ask_user(sentence = "Saisir un chiffre"): # do_something == modification of function name
choice = input(f"{sentence}\n>")
return choice
def numbers_caption (number):
list_numbers = []
while number.isdigit():
# supression of if condition
list_numbers.append(int(number))
nu... |
7a3d95745712c736e8819193b93de05f4f12375a | GwangrokBaek/Algorithm-challenge | /Bronze_IV/compare_two_numbers.py | 173 | 3.53125 | 4 | #
# Author : Kwangrok Baek (zester926@gmail.com)
# URL : https://www.acmicpc.net/problem/1330
#
a, b = map(int, input().split())
print('>') if a > b else print('<') if a < b else print('==')
|
d72e0f3c43f4da52ff2010ed12e19fb093eeb05e | Jtaylorapps/Python-Algorithm-Practice | /makeItZero.py | 2,902 | 3.59375 | 4 | # Print two arrays with equal sums if they exist in O(n*log(n)) time
def make_it_zero(input_array):
arr = sorted(input_array) # O(n*log(n))
n = len(arr) - 1
# Last element
counter1 = arr[n]
# Second to last element
counter2 = arr[n - 1]
# Create the two arrays
sum1 = [counter1]
su... |
3635084135919453e1a9e4119fdbe1925781e557 | Jtaylorapps/Python-Algorithm-Practice | /splitBuckets.py | 1,753 | 4.0625 | 4 | import sys
# Splits array of int from input text file into given number of buckets (subsets).
# The buckets will be ordered and the goal is for buckets to be of minimum size.
# Outputs the created buckets to a text file.
# Verify the input and output command line arguments exist
if len(sys.argv) != 3:
print("Erro... |
781e35187cfc218d047510831e9d2293efc7633a | yangnianbing/leetcode | /227.basic-calculator-ii.py | 892 | 3.703125 | 4 | #
# @lc app=leetcode id=227 lang=python3
#
# [227] Basic Calculator II
#
# https://leetcode.com/problems/basic-calculator-ii/description/
#
# algorithms
# Medium (32.19%)
# Total Accepted: 91.3K
# Total Submissions: 283.6K
# Testcase Example: '"3+2*2"'
#
# Implement a basic calculator to evaluate a simple expressio... |
5ad55be984df4e1b2ff07f26f50871c8f0f9117b | pchoengtawee/NLP | /NLTK/Text_Mining/Text_mining_2.py | 9,069 | 3.765625 | 4 | # %%%%%%%%%%%%% Natural Language Processing %%%%%%%%%%%%%
# %%%%%%%%%%%%% Authors %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Dr. Martin Hagan----->Email: mhagan@okstate.edu
# Dr. Amir Jafari------>Email: amir.h.jafari@okstate.edu
# %%%%%%%%%%%%% Date:
# V1 11 - 8 - 2017
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%... |
8092939f7159d6b69d707d91b2d55c79415bb42d | AyushDubey-maker/Imp-Questions-Algorithms | /Random-Password-Generator.py | 971 | 4 | 4 | import string
import random
# Through below code we can import all lower/upper ascii letters
if __name__=='__main__':
s1=string.ascii_lowercase
s2=string.ascii_uppercase
s3=string.digits # all digits from 0-9
s4=string.punctuation
# This code block checks that the user inserts only int... |
f360eca7901975834a2aaab40f6392ad42f5e68d | soundgarden134/depth-search-sudoku | /venv/classes.py | 4,628 | 3.515625 | 4 | import numpy as np
import copy
class Sudoku:
matrix = [[]]
def __init__(self, mat):
self.matrix = mat
def is_final_state(self):
for i in range(9):
for j in range(9):
if self.matrix[i][j] == 0:
return False
return True
def chec... |
b83ee6a6fefa793d1622e987b51d3ff4b68d71d2 | r-matthew-cline/MachineLearning-Assignment-01 | /main.py | 11,144 | 4.1875 | 4 | ###################################################################
##
## Machine Learning Assignment 1
## Regression Fundamentals
##
## @author: Matthew Cline
##
###################################################################
import pandas as pd
import math
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3... |
811b81a34ff3c9aaeb94200544dc53ace9f5a83b | Gauravsahadev/Udemy-Python3-BootCamp-Practice-Problems | /Colour.py | 254 | 4.09375 | 4 | print("Enter a colour of your choice")
colour=input()
if colour=="blue":
print("You're Awesome!!")
elif colour=="red":
print("Danger -X-")
elif colour=="green":
print("Nature Lover!")
elif colour=="white":
print("Peace!")
else:
print("You monster!") |
bc08c385b2bd8509caced55c5b5aaf18da1b117e | Gauravsahadev/Udemy-Python3-BootCamp-Practice-Problems | /Dictionary/playlist.py | 844 | 3.828125 | 4 | # Playlist to display songs and overall duration of all songs.
#adding the playlist in dictionary
playlist=dict(title="gaana.com",
author="gaurav sahadev",
totalSongs="5",
songs=[{"title":"Turn it off","artist":"Culture abuse","duration":3.37},
{"title":"Lovely","artist":"billie eilish","duration":3.50},
{"title"... |
b0dfa1327acc7c44cf0c80db63aa3a2afb2dc23f | Gauravsahadev/Udemy-Python3-BootCamp-Practice-Problems | /Dictionary/two_lists.py | 201 | 4.21875 | 4 | list1 = ["CA", "NJ", "RI"]
list2 = ["California", "New Jersey", "Rhode Island"]
answer={list1[i]:list2[i] for i in range(3)}
print(answer)
#method second
answer2=dict(zip(list1,list2))
print(answer2) |
c88714d6e90c12d04af7dafa591f2b2d7e03e6ae | Gauravsahadev/Udemy-Python3-BootCamp-Practice-Problems | /Functions/math.py | 482 | 4.03125 | 4 | # A simple program to do math calculations
def add(num1, num2):
pass
return num1+num2
def subtract(num1, num2):
pass
return num1-num2
def multiply(num1, num2):
pass
return num2*num1
def divide(num1, num2):
pass
return num1/num2
def math(num1, num2, fn=add):
return fn(num1, nu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.