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 |
|---|---|---|---|---|---|---|
e1e3eea7acf0164573e728e17b0013b90678d1e1 | Danielle-Smith/Dunder | /invoice_class.py | 5,297 | 4.375 | 4 | class Invoice:
def greeting(self): # must always put self as the argument in a class
return 'Hi there'
inv_one = Invoice()
print(inv_one.greeting()) # runs as self and saved in a different place in memory than inv_two
inv_two = Invoice()
print(inv_two.greeting()) # runs as self
# ---------------------------... |
6f384b9f9c31765b2c7cb5e22af25202d686deb0 | JusticeLenon/ProjectEuler | /project_euler.py | 456 | 4.1875 | 4 | ''' List all multiples of 3 and 5 from 0 to 10000 and return the sum'''
def if_multiple( nat_number ):
'''Return True if it is a multiple of 3 or 5'''
for i in range(1,10):
if i % 3 == 0 or i % 5 == 0 :
print i, 'True'
else:
print i, 'False
return
def apppend_to_arrray( myarray, ite... |
5c12d55aa03414192edf4c2d0a668ade95eb17ef | ptrkptz/udemy_python | /Python_Course/16_Exercise_Boolean.py | 189 | 3.921875 | 4 | myAge = 44
userAge = int(input("What is your age?"))
if (userAge>myAge):
print("you are older")
elif(userAge==myAge):
print("we are the same age")
else:
print("you are young")
|
c08f06f789fc81a1672e797a41c1d8cc39801864 | ptrkptz/udemy_python | /Python_Course/17_conditionals.py | 841 | 4.125 | 4 | grade1 = float(input ("Type the grade of the first test: "))
grade2 = float(input ("Type the grade of the second test: "))
absenses = int(input ("Type the number of absenses: "))
total_classes = int(input("Type the total number of classes: "))
avg_grade = (grade1 + grade2) /2
attendance = (total_classes - absenses) / ... |
1055f864fb549ae4202482553b16be2c046ff3d6 | ptrkptz/udemy_python | /Python_Course/15_booleans.py | 249 | 4.125 | 4 | num1 = float(input("Type the 1st num:"))
num2 = float(input("Type the 2nd num:"))
if (num1 > num2):
print(num1, " is greater than ", num2)
elif(num1==num2):
print(num1, " is equal to ", num2)
else:
print(num1, " is less than ", num2)
|
8046776610bf62f836ac8b08c19141c8e46845c4 | sandeep-talware/Python-Basic-Learning | /com/org/main/classes_test.py | 537 | 3.9375 | 4 | class Point:
def __init__(self,x,y):
self.x = x
self.y = y
def move(self):
print("Move")
def draw(self):
print("Draw")
Point1 = Point(x=10,y=20)
Point1.draw()
Point1.move()
print(f"x={Point1.x}")
print(f'y={Point1.y}')
class Person:
def __ini... |
0c03544b2b3006a6dcf40b843b865dbb6f49707b | JoeHill/arbitrage | /arbitrage/utils.py | 8,282 | 4.125 | 4 | import re
def comma_delimited_list_indicies(split_sentence):
"""
Determines if the sentence has a list of nouns separated by commas (which throw off pos tagging).
A list of nouns separated by commas is characterized by two or more consecutive words with
trailing commas.
:param list(str) split... |
3632d4d32a82d3b985dc0adea28680827b996020 | cavassani/python_caelum_apostila | /programa2.py | 135 | 3.75 | 4 | nome = input('Digite seu nome:\n')
idade = input('Digite sua idade:\n')
print('Sua idade é {}, e seu nome é {}'.format(idade, nome))
|
d92429eac40bc1f0a40f2f11470915f70d1051e8 | nimisane/algorithmsInPython | /mergesort.py | 821 | 3.625 | 4 | a=[13,0,4,65,3,2]
print("Unsoerted list",a)
def merge(a):
if len(a)>1:
mid=len(a)//2
n=len(a)
l=[]
r=[]
i=0
while(i<=mid-1):
l.append(a[i])
i=i+1
i=mid
while(i<=n-1):
r.append(a[i])
i=i+1
... |
d76c43aa1c903f6b86dc928efc76d546cbdd0d31 | AlexJamesWright/Blackjack | /src/Broadcast.py | 1,910 | 3.796875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 22 20:32:06 2019
@author: ajw1e16
This class will contain all history about a game, easy for every player to see.
"""
import utilityFunctions as ut
class Broadcast(object):
"""
A public class that contains all information available to all... |
f68b546868113761dcfabfbf752e7372e95b681c | antln/File_searcher_app | /play.py | 784 | 3.921875 | 4 | # def factorial(n):
# if n == 1:
# return 1
# return n * factorial(n-1)
#
#
#
#
# print("5!= {:,}, 3!= {:,}, 11! = {:,}".format(
# factorial(5),
# factorial(3),
# factorial(11)
# ))
#
def finbonacci(limit):
nums = []
current = 0
next = 1
while current < limit:
curr... |
c361fb93f8ef7497f3a084f68e93cfbbe762c7d4 | PraneethVasarla/Bitcoin-live-analytics | /Wordcloud.py | 674 | 3.53125 | 4 |
def cloud():
from wordcloud import WordCloud, STOPWORDS
import matplotlib.pyplot as plt
import wikipedia
from PIL import Image
import numpy as np
term="Bitcoin"
def find_term():
title=wikipedia.search(term)[0]
page=wikipedia.page(title)
return page.c... |
02fc220648a39e4fd4e36c7bba81ad8f8b70ed3e | nick3499/generate_random_design_nick3499 | /generate_design_rgb.py | 1,433 | 4.03125 | 4 | #!/usr/bin/env python
'''Generate random colored background design.'''
from random import randrange
def generate_design():
'''Generate random background design.'''
# input instructions
print('\x1b[1;34mEnter hex color\x1b[0m: (example: 50514f) or leave blank')
# hex color code string inputs
hex1 =... |
ee043da04912418552ae76f2b95419814689d586 | freddieaviator/checkpoint_python_fredrik | /question_2.py | 915 | 3.921875 | 4 |
def to_camel_case(text):
try:
text = text.split(" ")
result = ""
for word in text:
result += word.capitalize()
return result
except Exception as e:
return (f"Error: {e}")
print(to_camel_case("hello world"))
print(to_camel_case("My stRiNg"))
print(to_camel_c... |
f4c1a9956ab654b5e6c266a8bf7b48ed8cb8c02d | kamdarkarnavee/CompetitiveCoding | /rolling string.py | 683 | 3.828125 | 4 | def rotate(s, operations):
ls = list(s)
for element in operations:
start_index, end_index, op = element.split(" ")
start_index = int(start_index)
end_index = int(end_index) + 1
for index in range(start_index, end_index):
val = ls[index]
if op == 'L':
... |
1be761d396ca2da2a13d7cc6893a06802d5abd3a | kamdarkarnavee/CompetitiveCoding | /TimeMap.py | 890 | 3.578125 | 4 | class TimeMap:
def __init__(self):
"""
Initialize your data structure here.
"""
self.key_ls = []
self.val_ls = []
self.timestamp_ls = []
def set(self, key: str, value: str, timestamp: int) -> None:
self.key_ls.append(key)
self.val_ls.append(value... |
8bb2e79a1b644db3e49752e6ee2207eeb3e79600 | kamdarkarnavee/CompetitiveCoding | /flatten_dictionary.py | 485 | 3.5625 | 4 | intext = "{'a': 1,'b': {'c': 2, 'd': {'e': 3}}}"
l = []
flag = False
d = dict()
for i in intext:
if i != ' ' and i != "'":
if i == '{':
flag = False
continue
if i == ':':
flag = True
continue
if i == '}' or i == ',':
flag = False... |
f4d951c727641b38c9fa0c87235849af8db8f7db | profthyagu/internship | /int_mod3.py | 14,445 | 4.5625 | 5 | #!/usr/bin/env python
# coding: utf-8
# # String
# Strings can be created simply by enclosing them in ""/''.
# In[1]:
var1='hello'
print (var1)
# * accessing values in Strings:
# To access substrings use brackets for slicing/indexing.
# In[5]:
var1='hello world'
var2="pythonprogramming"
print("var1[0]:",var1... |
974bd609c79503ce9155bd42363598c7b6aa6746 | Leonidas-I/python-powershell | /MIT_Sort.py | 1,789 | 4.03125 | 4 | def bubble_sort(L): #O(n**2) where n is len(L))
swap = False
while not swap: #O(len(L))
print 'bubble_sort: '+ str(L)
swap = True
for i in range(1, len(L)): #O(len(L))
if L[i-1] > L[i]:
swap = False
L[i], L[i-1] = L[i-1], L[i]
def se... |
420b33c0e181ceec758de031b7c19c76b02253ba | Leonidas-I/python-powershell | /TP_Iteration.py | 2,360 | 4.09375 | 4 | import math
def eval_loop(): #eval is built-in function to evaluate a string
while True:
a = raw_input('Type your equation here: ') #Ex: 1 + 2 * 5
if a == 'done':
break
print eval('math.sqrt(25)'), eval('type(math.pi)'), eval(a)
print 'Done'
# eval_loop()
... |
09707029aa485c7726da6f7902568dc5025e3323 | VivekM27/Coding-Bat-Python-Solutions | /Logic-2/lucky_sum.py | 130 | 3.578125 | 4 | # LUCKY_SUM
def lucky_sum(a, b, c):
if a==13: return 0
elif b==13: return a
elif c==13: return a+b
else: return a+b+c |
34c55b5556f3d5adcacdae3d0f87e187cab24a36 | VivekM27/Coding-Bat-Python-Solutions | /List-2/has22.py | 165 | 3.5625 | 4 | # HAS22
def has22(nums):
i = 0
while i<len(nums)-1:
if nums[i] == 2 and nums[i] == nums[i+1]:
return True
break
i += 1
return False |
4de5295d9044f66b9e978ccbe60a8e22c6543719 | VivekM27/Coding-Bat-Python-Solutions | /Logic-2/make_bricks.py | 123 | 3.609375 | 4 | # MAKE_BRICKS
def make_bricks(small, big, goal):
return True if(goal%5 <= small and goal-(big*5) <= small) else False
|
235c0a74de7895b56190f926975d2405ab57a561 | VivekM27/Coding-Bat-Python-Solutions | /List-1/sum2.py | 124 | 3.8125 | 4 | # SUM2
def sum2(nums):
if len(nums) == 0: return 0
elif len(nums)<2: return nums[0]
else: return nums[0] + nums[1] |
8fc2e153b8b176e45c4bcf259dbf7d99ba460860 | VivekM27/Coding-Bat-Python-Solutions | /String-1/non_start.py | 170 | 3.5625 | 4 | # NON_START
def non_start(a, b):
if len(a) == len(b) and len(a)<1: return ''
elif len(a)<1: return b[1:]
elif len(b)<1: return a[1:]
else: return a[1:]+b[1:] |
620ddb829657373b3ab2567441916211f6076800 | VivekM27/Coding-Bat-Python-Solutions | /List-2/count_evens.py | 100 | 3.65625 | 4 | # COUNT_EVENS
def count_evens(nums):
c = 0
for i in nums:
if i%2 == 0: c+=1
return c |
2c1020cdb8ac309f97182d39788dd82f84b26836 | VivekM27/Coding-Bat-Python-Solutions | /String-2/cat_dog.py | 236 | 3.59375 | 4 | # CAT_DOG
def cat_dog(str):
c = count(str, 'cat')
d = count(str, 'dog')
return True if(c==d) else False
def count(str, val):
c = 0;
i = 0
while i<len(str):
if str[i:i+3] == val: c += 1
i += 1
return c |
3b81417cb6f4dc2733c8f38f71026657318b9689 | VivekM27/Coding-Bat-Python-Solutions | /Logic-1/cigar_party.py | 196 | 3.5625 | 4 | # CIGAR_PARTY
def cigar_party(cigars, is_weekend):
if is_weekend == False and (cigars<40 or cigars>60): return False
elif is_weekend == True and cigars<40: return False
else: return True |
c4c59659d42090f07b317e40ee350ffdfbaf6746 | VivekM27/Coding-Bat-Python-Solutions | /List-1/make_ends.py | 111 | 3.625 | 4 | # MAKE_ENDS
def make_ends(nums):
return [nums[0], nums[0]] if len(nums)<2 else [nums[0], nums[len(nums)-1]] |
6730098d0a407d9b4c672923b5e8e21e7e4633d2 | nimus0108/python-projects | /Tri1/dictro.py | 228 | 3.578125 | 4 |
test_dict = {}
test_dict["yankees"] = 80
test_dict["red sox"] = 50
test_dict["blue jays"] = 45
key_lists = list(test_dict.keys())
key_lists.sort()
for team in key_lists:
print(team + " won", test_dict[team], "games.")
|
504b12b8de997337e4c6166ded242ff6d93d14ce | nimus0108/python-projects | /Tri1/anal_scores.py | 535 | 4.25 | 4 | # Su Min Kim
# Analysis Scores
num = input("")
num_list = num.split()
greater = 0
less = 0
def get_mean (num_list):
m = 0
i = 0
x = len(num_list)
for i in range (0, x):
number = int(num_list[i])
m += number
mean = m/x
return mean
for num in num_list:
number = int(num)
... |
a105380fff64a537382bd1d7f749040a0616bea6 | nimus0108/python-projects | /Gui/gui_p5.py | 1,770 | 3.53125 | 4 | # Movie Chooser
import tkinter
class Application(tkinter.Frame):
def __init__(self, master):
super(Application, self).__init__(master)
self.grid()
self.create_widgets()
def create_widgets(self):
tkinter.Label(self, text="Choose your favorite movie types").grid(row=0, column=0,... |
88a0fd2a92efeeedf78414ef26b73d1f7f8e7e1b | anjalikm/Games-in-Python | /pong2.py | 4,422 | 3.765625 | 4 | # Implementation of classic arcade game Pong
import simplegui
import random
# initialize globals - pos and vel encode vertical info for paddles
WIDTH = 600
HEIGHT = 400
BALL_RADIUS = 20
PAD_WIDTH = 8
PAD_HEIGHT = 80
HALF_PAD_WIDTH = PAD_WIDTH / 2
HALF_PAD_HEIGHT = PAD_HEIGHT / 2
LEFT = False
RIGHT = True
paddl... |
b7d9ff81754c3e8ee3e6407b851ae9fd08793b79 | abbirdboy/BackEnd | /revised_testcode.py | 1,772 | 3.921875 | 4 | import collections
import unittest
# Sample 1
initial_list1 = [1, 3, 7, 8, 9, 10, 11] # Here is our initial ordered list
shifted_list1 = [8, 9, 10, 11, 1, 3, 7] # Here is the list after it has been sliced (at index 3) and shifted
# Your function should return `11`
#shiftedlist_max(shifted_list1) #=> '11'
# Sample ... |
22d738bf4737e5e0684ecbf554e432fff66eda3d | jhuang292/mapReduce | /assignment3/inverted_index.py | 663 | 3.6875 | 4 | import MapReduce
import sys
"""
Inverted Index Example in the Simple Python MapReduce Framework
"""
mr = MapReduce.MapReduce()
# =============================
# Do not modify above this line
# Implement the MAP function
def mapper(doc_list):
document_id = doc_list[0]
text = doc_list[1]
tokens = text.spl... |
7cedc2abfe14e5c09a7702d02647b302c37e5e73 | ctec121-spring19/programming-assignment-4-if-structures-jhalnan | /Prob-2/Prob-2.py | 1,557 | 4.0625 | 4 | # Module 3
# Programming Assignment 4
# Prob-2.py
# Joel Halnan
'''
Input - Person's name, hourly wage, hours
Process - Calculate's normal wages, over-time wages, combined wages, taxes withheld, medical insurance withheld, and take home pay.
Output - The employee's name, regular wages, overtime wages, total wag... |
55233391b409d7b914f360fd0ecb9abc4fc02fb6 | Caelink/hackerRank | /python-solutions/grade-round.py | 403 | 3.609375 | 4 | #!/bin/python
import sys
def solve(grades):
for i, grade in enumerate(grades):
if (grade > 37) and ((grade % 5) > 2):
grades[i] += (5 - (grade % 5))
return grades
n = int(raw_input().strip())
grades = []
grades_i = 0
for grades_i in xrange(n):
grades_t = int(raw_input().strip())
... |
102ad14a58323137e018a22cbeb6ab85dfffc360 | zolaneta/variance | /variance.py | 795 | 4.09375 | 4 | import intertools
def factorial(x):
if x==1:
return 1
else:
result = factorial(x -1)* x
return result
number = str(raw_input("What is the number? "))
n = [] # number of elements
for i in number:
if i not in n:
n.append(i)
print n
print i
else:
... |
16866fa0a64a1c3ab345a7448d6a966f5c56b2d3 | Jeremiah-Durano/python-chat-server | /Chat+Server/c.py | 834 | 3.765625 | 4 |
# Echo client program
import socket
HOST = '127.0.0.1' # The remote host
PORT = 50007 # The same port as used by the server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
data = s.recv(80000)
print "please enter your username"
name = raw_input()
nameCommand = ... |
9e077fc421d364d7574bb8e64be5124277f93daf | JianFengY/data_visualization | /chapter15_generating_data/random_walk.py | 1,970 | 3.984375 | 4 | # -*- coding: utf-8 -*-
'''
Created on 2018年1月24日
@author: Jeff Yang
'''
# 将所有可能的选择存储在列表里,并在每次决策时都使用choice()决定使用哪种选择
from random import choice
class RandomWalk():
"""一个生成随机漫步数据的类"""
def __init__(self, num_points=5000): # 随机漫步包含的默认点数设置为5000
"""初始化随机漫步的属性"""
self.num_poin... |
b2f182ed749756c883c72ddc826ad1afef09801e | meanJustin/Algos | /Demos/Searching Algos/Searching Demo.py | 9,501 | 3.8125 | 4 | import random
import time
import math
import sys
# https://www.geeksforgeeks.org/kmp-algorithm-for-pattern-searching/
# Python program for KMP Algorithm
def KMP_Search(pat, txt):
M = len(pat)
N = len(txt)
# create lps[] that will hold the longest prefix suffix
# values for pattern
lps = [... |
c876053f4a23e86dcda291995c5142396ae5709f | meanJustin/Algos | /Demos/MergeSort.py | 1,451 | 4.15625 | 4 | # Python program for implementation of Selection
# Sort
import sys
import time
def mergeSort(arr):
if len(arr) >1:
mid = len(arr)//2 # Finding the mid of the array
L = arr[:mid] # Dividing the array elements
R = arr[mid:] # into 2 halves
mergeSort(L) # Sorting the first ... |
2a184829f4ee49b00587339e9a6719510adb4180 | leroycorentin/csad | /knn.py | 1,006 | 3.5625 | 4 | import pandas as pd
from sklearn.model_selection import train_test_split
import numpy as np
from sklearn.neighbors import KNeighborsClassifier
# Prepare Dataset
# load data
train = pd.read_csv("digit-recognizer/train.csv", dtype = np.float32)
# split data into features(pixels) and labels(numbers from 0 to 9)
targets_... |
55e225c8500dc9ea08f60f856d92b3544fdbd5dc | josauder/kaggle-quora | /network2.py | 5,571 | 3.828125 | 4 | """
network.py
~~~~~~~~~~
A simple Tensorflow implementation of Michael Nielsen's `network.py`
from the excellent online-book 'Neural Networks and Deep Learning'.
The goal is not to write eloquent Tensorflow code, but to keep structure
similar to Michael's implementation, which can be found at:
https://github.com/mnie... |
df77d9c94a8993ed14edb483ef33785491224d26 | mosot624/ProgrammingChallenges | /RecursiveChallegen.py | 668 | 3.796875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Mar 25 10:15:33 2019
@author: Michael
"""
#http://www1.udel.edu/CIS/181/pconrad/05S/examples/recursion/recursion.problems
def changetoString(var,n,counter):
if n == 1:
var = int(var[0])
return var
elif counter == len(var):
var... |
181accc46b0d03467a765e1b6f1fe8949f2799dc | prathapSEDT/pythonnov | /Collections/List/Slicing.py | 481 | 4.1875 | 4 | myList=['a',4,7,2,9,3]
'''
slicing is the concept of cropping sequence of elements
to crop the sequence of elements we need to specify the range in [ ]
synatx: [starting position: length]
here length is optinal, if we wont specify it, the compiler will crop the whole sequence
form the starting position
'''
# from inde... |
8c94185a47805431f457cb157523350c318ba831 | prathapSEDT/pythonnov | /Collections/List/Len.py | 208 | 4.1875 | 4 | '''
This length method is used to get the total length of elements that are available in the given list
'''
myList=['raj','mohan','krish','ram']
''' get the toatal length of a given list'''
print(len(myList)) |
3aee5a7a4a62a9ab4339ff518c5efaa5e0afa539 | prathapSEDT/pythonnov | /looping statements/WhileLoop.py | 244 | 4.1875 | 4 | '''
while loop is called as indefinite loop
like for loop , while loop will not end by its own
in the while we need write a condition to break the loop
'''
''' Print Numbers from 1-50 using while loop '''
i=1
while(i<=50):
print(i)
i+=1 |
8ab26e5acf6edeff0c278b27cfc98a8241110547 | PrakarshBhardwaj/Automate-The-Boring-Stuff | /mapit/mapit.py | 406 | 3.828125 | 4 | #Takes input address in format ___,____,_____ from command line or keyboard
#and maps it on google maps.
import webbrowser
import sys
import pyperclip
if len(sys.argv) > 1:
addlist = sys.argv[1].split(",")
else:
addlist = pyperclip.paste().split(",")
print(addlist)
address = "https://www.google... |
bd488c3585dbf1e3dfd83170624920ba2164ba65 | PrakarshBhardwaj/Automate-The-Boring-Stuff | /APIs/iptracker.py | 570 | 3.53125 | 4 | import json , sys , pprint
import requests
if len(sys.argv) < 2:
print("Usage: python ipstack.py <ip address>")
sys.exit()
url = "http://api.ipstack.com/{}?access_key=your_key".format(sys.argv[1])
response = requests.get(url)
response.raise_for_status()
ipdata = json.loads(response.text)
try:
... |
d1f67412393e9d75f8c8ee956a1a80b3a815e28c | ParkEunSeon/python_lecture | /test.py | 382 | 4.03125 | 4 | print("hello world")
print("***********")
# 언더바를 변수앞에 쓰는 것을 추천하지 않는 이유
# 파이썬 내장변수와 혼동이 생길 수 있으므로(__변수명 : 내장변수)
# 키워드 + 대문자로 시작 추천
# ex) class Cat:
a, b, c = 80, 75, 55
sum = a + b + c
avg = sum/3
print(avg)
if 13%2==0 :
print("짝수")
else :
print("홀수")
|
8ca1246d66dc9398d63d06ea437a1e18b34b0b6e | ParkEunSeon/python_lecture | /list_2.py | 110 | 3.6875 | 4 | numList = [num for num in range(1,6)]
num_even_list = [x for x in numList if x %2 == 0]
print(num_even_list) |
38535106af6a7368434149e06f86fa57ad2390de | EOxServer/eoxserver | /eoxserver/testing/utils.py | 509 | 3.546875 | 4 | def tag(*tags):
"""Decorator to add tags to a test class or method."""
def decorator(obj):
if len(getattr(obj, '__bases__', [])) > 1:
setattr(obj, 'tags', set(tags).union(*[
set(base.tags)
for base in obj.__bases__
if hasattr(base, 'tags')
... |
74095d49c7c1c157eb5aaed88edc31662600440c | wangrui-spiderNet/Python-100examples | /homework01.py | 1,454 | 4.15625 | 4 | # coding=UTF-8
'''
【程序2】
题目:企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高
于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可可提
成7.5%;20万到40万之间时,高于20万元的部分,可提成5%;40万到60万之间时高于
40万元的部分,可提成3%;60万到100万之间时,高于60万元的部分,可提成1.5%,高于
100万元时,超过100万元的部分按1%提成,从键盘输入当月利润I,求应发放奖金总数?
1.程序分析:请利用数轴来分界,定位。注意定义时需把奖金定义成长整型。
2.程序源代码:
'''
... |
782f595dc3f3a06732dce5f59daf9fa570219715 | Sharan1425/Data_structures | /linked_list/program/single_LinkedList.py | 3,848 | 4.09375 | 4 | class Node:
def __init__(self, data=None, next=None):
self.data = data
self.next = next
class LinkedList:
def __init__(self):
self.head = None
# this is reversely data is appending
def insert_at_begning(self, data):
node = Node(data, self.head)
self.head = node... |
3c9f956769ed83aafda8dd95fd619d02f767d8c1 | YuanJiaquan/yaml1 | /may/test.py | 1,109 | 4 | 4 |
# 1.将身边的一个事物抽象出一个类。比如老师、学生、桌子、椅子、苹果、香蕉、枕头、被子或任意物品。
# 1.提供基本属性、基本的方法。
# 2.通过类创建出几个不同的对象。
# 3.打印它们的属性、调用它们的方法。
#
class Any_thing(object):
# def __init__(self):
people1='teacher'
# def __del__(self):
# print('nihao')
def dayin(self):
print(self.people1)
# a=Any_thing()
# print(a.people1)
... |
01bd59c9ab7dc8fe89e8d378b2adc7405bbd5231 | YuanJiaquan/yaml1 | /april1/可变数据类型.py | 2,138 | 3.984375 | 4 | # 1、定义一个列表[1, 2, 3],并将列表中的头尾两个元素对调。对调后为[3, 2, 1]
l1=[1,2,3]
l1[0],l1[2]=l1[2],l1[0]
print(l1)
# 2、定义一个列表,并将列表中的指定位置的两个元素对调。对调第一个和第三个元素
# 列表如下:[23, 65, 19, 90]
# 对调后结果:[19, 65, 23, 90]
l2=[23, 65, 19, 90]
l2[0],l2[2]=l2[2],l2[0]
print(l2)
# 3、对列表[10, 11, 12, 13, 14, 15]
# 翻转,调整后为[15, 14, 13, 12, 11, 10]
l3=[10, 11, 12... |
5952332a73d01fadb8a18062559e58b2d614349b | YuanJiaquan/yaml1 | /may/demo11.py | 7,985 | 3.875 | 4 | # 面向对象:私有的属性,私有的方法 封装,继承,多态,类方法,静态方法
# 私有属性,方法
# 场景:不愿意把对象的方法和属性公开的时候
# 私有属性:不愿意公开属性
# 私有方法:不愿意公开方法
# 定义:属性或者方法的前面 加个__ age=18 __age=18 def open() def __open()
# class Girl:
# def __init__(self,name):
# self.name=name
# # 不要轻易问女孩子的年龄
# self.__age=18
#
# def __desc(self):
# ... |
0486d51253f2368d50ff666e1fc2c8536e1f7370 | isheebo/the-stubborn-ones | /app/sums.py | 244 | 3.78125 | 4 | def recursive_sum(numbers):
total = 0
for index in range(len(numbers)):
if isinstance(numbers[index], list):
total += recursive_sum(numbers[index])
else:
total += numbers[index]
return total
|
80a03270d440466ddcef7742ac878cda32d6ff29 | cheaterdxd/python-practice- | /conlatz_sequence_auto_boring.py | 756 | 3.9375 | 4 | def collazt(num):
if num%2==1:
return num*3 +1
if num%2==0:
return num //2
print '''
==================================================
= THE COLLATZ SEQUENCE GAME - AUTO BORING =
= MADE BY: Le Thanh Tuan No.29 =
================================================== '''
print "Nhap vao so... |
d8995fd36963fd7901e1fdd422cfd612b2a03737 | psnehas/Binary-Search-1 | /SearchInRotatedSortedArray.py | 1,384 | 3.828125 | 4 | # Time complexity: O(log n)
# Space complexity: O(1)
# Did this code successfully run on Leetcode : yes
# Any problem you faced while coding this : had trouble figuring out the logic to identify the sorted half to search
class Solution:
def search(self, nums: List[int], target: int) -> int:
left, right = 0... |
4c2ae4f726e1adcd2d00240d575609e695c4a6b4 | oshin0703/python | /intermediate-1.py | 1,293 | 3.96875 | 4 | #関数・メソッド
def test_func():
print('call test_func')
test_func()
def cal(num_1,num_2,oprn):
if oprn == 1:
print('足し算開始')
print(num_1 + num_2)
elif oprn == 2:
print('引き算開始')
print(num_1 - num_2)
elif oprn == 3:
print('掛け算開始')
print(num_1 * num_2)
elif op... |
cb244df78feae78043793f9ee9f245902e42c01a | khunamir/OpenCV-FCC | /Basics/draw.py | 989 | 3.640625 | 4 | import cv2 as cv
import numpy as np
# Draw a blank page
blank = np.zeros((500, 500, 3), dtype='uint8')
cv.imshow('Blank', blank)
# 1. Draw a image a certain color
blank[150:400, 150:400] = 0,0,255
cv.imshow('Green', blank)
# 2. Draw a rectangle
cv.rectangle(blank, (0,0), (blank.shape[1]//2, blank.shape[0]//2), (0,25... |
6321e1cf2cd31f6b633a123cfe78f12d57bff99d | priyendumori/SMAI-Assignments | /2/q-1-3-1.py | 2,585 | 3.515625 | 4 | #!/usr/bin/env python
# coding: utf-8
# ## q-1-3-1
# #### Implement a model using linear regression to predict the probablity of getting the admit.
# In[1]:
import pandas as pd
from sklearn import preprocessing
from sklearn.linear_model import LinearRegression
import numpy as np
import sklearn as sk
from sklearn.me... |
4b4b89760d2e2394d3e50c67bd5fb06782822004 | anilkumar-01/rise-drop-points | /test.py | 4,523 | 3.546875 | 4 |
cordinates1 = [(1,5,10),(4,6,8),(10,15,10),(11,12,8)]
# Output - [(1,10),(5,8),(6,0),(10,10),(15,0)]
cordinates2 = [(1,10,4),(1,8,6),(1,6,8)]
# Output = [(1,8),(6,6),(8,4),(10,0)]
cordinates3 = [(0,6,2),(5,10,8),(7,8,12)]
# Output - [(0,2), (5,8),(7,12),(8,8) (10,0)]
cordinates4 = [(1, 2, 8), (3, 6, 4), (3, 6... |
9266236293a7e1c49900110e7e408876fcddf99d | VectorSigmaGen1/Basic_Introductory_Python | /Practical 10 - 3rd October 2019/p10p1.py | 1,261 | 4.28125 | 4 | # program to calculate the positive integer square root of a series of entered positive integer
"""
PSEUDOCODE
request input for a positive integer and assign to variable num
print "Please enter the positive integer you wish to calculate the square root of
(Enter a negative integer to exit program): "
... |
13080a3947d52e11797bd399fe8e3e3342dc4091 | VectorSigmaGen1/Basic_Introductory_Python | /Practical 13 - 10th October/p13p5.py | 1,013 | 4.53125 | 5 | # Program to illustrate scoping in Python
# Added extra variables and operations
"""
Pseudocode
DEFINE function 'f' of variable 'x' and variable 'y'
PRINT "In function f:"
Set x = x+1
Set y = y * 2
set z = x-1
PRINT "x is", 'x'
PRINT "y is", 'y'
PRINT "z is", 'z'
RETU... |
7d1038aaa9fe2af8374685ac523187026e58280a | VectorSigmaGen1/Basic_Introductory_Python | /Practical 09 - 3rd October 2019/p9p3.py | 969 | 4.28125 | 4 | # program to calculate the factorial of an entered integer
"""
Pseudocode
Set num = 0
WHILE input >= 0;
Request input
Print "Please enter a positive integer (If you wish to terminate the program, please enter a negative integer): "
run = 1
for i in range(1, input+1, 1)
run = run * i... |
0f1ad4d9a1bb6273f8e442b39f5c3281b4bd7e1a | VectorSigmaGen1/Basic_Introductory_Python | /Practical 07 - 26th Sep 2019/p7p3.py | 619 | 4.34375 | 4 | # program to print the first 50 integers and their squares
# for this program, I've used the first 50 positive integers starting with 0 and ending with 49
'''
print 'This is a program to print the integers 0 to 49 and their squares'
set variable=int(0)
While variable <50
print variable
print variab... |
7a63238e5cb6c4ea552dfa07a6c3f7470c452dfa | VectorSigmaGen1/Basic_Introductory_Python | /Practical 12 - 8th October 2019/p12p2.py | 1,703 | 4.40625 | 4 | # Define the function fibonacci which displays 'a' number of terms of the Fibonacci Sequence
# Program to check if an entered integer is a positive integer and if so to apply the function factorial to produce an answer
"""
Pseudocode
Define function 'fibonacci' of a variable 'a':
IF a > 0
set vari... |
6f859d260c8d4fd41bb03d315defb665e4bc20f2 | VectorSigmaGen1/Basic_Introductory_Python | /Practical 11 - 3rd October 2019/p11p3.py | 1,772 | 4.5 | 4 | # Program to check if an entered integer is a positive integer and if so to display that number of terms from the Fibonacci Sequence
"""
Pseudocode
request the input of an integer and assign it to variable 'length'
print "Please enter the number of terms in the Fibonacci Sequence you would like: "
WHILE leng... |
7fb84f004a36f1ca3e2b6dee6c5c91652c8b46ef | VectorSigmaGen1/Basic_Introductory_Python | /Practical 07 - 26th Sep 2019/p7p4.py | 746 | 4.28125 | 4 | # program to add the first 5000 integers and give an answer
# for this program, I've used the first 5000 positive integers,
# starting with 0 and ending with 4999.
"""
print 'This is a program to add the integers 0 to 4999 and give a total'
set variable=int(0)
set sum=int(0)
While variable <5000
set s... |
a46e1a2da5913c7bfce2ebaa1470e59455bf47c7 | VectorSigmaGen1/Basic_Introductory_Python | /Practical 17 - 15th October 2019/p17p3.py | 1,679 | 4.03125 | 4 | # Program to check if the strings 'cat' and 'dog' appear the same number of times in a user entered string
"""
Pseudocode
request the user to enter a string and assign it to variable 'string'
Print "Please enter a string of text: "
IF 'string' = ""
PRINT "You have entered nothing. The program will now t... |
db540b0084bd73a4f11a39cdadc04c394ad4e7cb | VectorSigmaGen1/Basic_Introductory_Python | /Practical 18 - 17th October 2019/p18p1.py | 1,328 | 4.34375 | 4 | # an iterative version of the isPal function
# Checks whether a supplied string is a palindrome
"""
Pseudocode
DEFINE function 'isPal(s)'
Get the length of 's' and assign it to variable 'length'
IF 'length' <=1
RETURN TRUE
ELSE
set variable 'check' = 0
FOR 'i' in rang... |
c8520d4c44c202e2fbab0794200f716a80ab20c3 | Horuskov/Web-Learning | /Python2/Training/index.py | 1,249 | 3.953125 | 4 | # comment: I believe I can fly
# To import math module:
import math
f_name = "john"
l_name = "ford"
name = f"{f_name} {l_name} {6 + 9}"
viewers = 1000
price = 4.99
unknown = 1 + 8j # a + bi
presence = False
feeling = "strong \nand good"
x = input("x: ")
y = int(x) + 11
if y > 30:
print("Wow.")
... |
a365c2627e66ee8afb11c5148daea2e13aac3e40 | KoichiHirai/AtCoder | /Product.py | 131 | 3.5 | 4 | # https://atcoder.jp/contests/abc086/tasks/abc086_a
a,b = map(int,input().split())
print("Odd") if (a*b)%2 == 1 else print("Even") |
db7a76f10b772ada6fdf40e22e0943d5abee331b | KoichiHirai/AtCoder | /Coffee.py | 165 | 3.640625 | 4 | # https://atcoder.jp/contests/abc160/tasks/abc160_a
s = input()
s_list = list(s)
print("Yes") if s_list[2] == s_list[3] and s_list[4] == s_list[5] else print("No") |
ee8d16d254276c2bd373a0ca8638106be585c81b | KoichiHirai/AtCoder | /ProgrammingEducation.py | 147 | 3.546875 | 4 | # https://atcoder.jp/contests/abc112/tasks/abc112_a
if int(input()) == 1:
print("Hello World")
else:
a,b = int(input()),int(input())
print(a+b)
|
6636284cfa5c7236d2ab3f164203c46d342150cc | KoichiHirai/AtCoder | /AcCepted.py | 354 | 3.8125 | 4 | # https://atcoder.jp/contests/abc104/tasks/abc104_b
s = input()
if s[0] != "A":
print("WA")
exit()
position_C = s.find("C")
if position_C == -1 or position_C == 1 or position_C == len(s)-1:
print("WA")
exit()
s_list = list(s)
s_list.remove("A")
s_list.remove("C")
for i in s_list:
if i.islower() == False:
... |
8780fa7960fe3e92416f38b7a9907a8c0d22b6cd | KoichiHirai/AtCoder | /DoubleHelix.py | 162 | 3.890625 | 4 | # https://atcoder.jp/contests/abc122/tasks/abc122_a
b = input()
if b == "A":
print("T")
elif b == "T":
print("A")
elif b == "C":
print("G")
else:
print("C") |
3044128f6e0560eefdcd78199a89ba615ae8bbfb | taun323/hero_vs_dragon1 | /game.py | 1,903 | 4.03125 | 4 | import random
# import random is a simple library that implements the random number generator behavior
# Please read into the variables below the correct numbers. Use try and except to catch error.
# a simple example would be:
# hero_hp = i
# nt(input("how many hp does the hero have?"))
while True:
try:
he... |
0be9fe73a252d0f51c338cd04f464a57be09269a | pq569375378/DJSCC-for-Wireless-Image-Transmission | /Tensorflow_Implementation/BatchMaker.py | 3,645 | 4.4375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Nov 23 22:40:12 2019
@author: Danish
"""
# Create a class that will do the batching for the algorithm
class BatchMaker():
""" This class contains three functions. This class will be an iterator. An iterator in
Python is a class with methods next() and iter... |
bfdacaad653068d62f82e45ace3cb120c33a5572 | Vanshikagarg17/StonePaperScissor-Game | /Rock_Paper_Scissors v1.1.py | 1,039 | 4.25 | 4 | from random import randint
winning=2
#scores
comp=0
p=0
#scores
while p<winning and comp<winning:
rand_num = randint(0,2)
print(f"computer score:{comp} player score:{p}\n")
player = input("Player, make your move: \n").lower()
if player=="quit" or player=="q":
break
if rand_num == 0:
computer = "rock"
elif ... |
6416bbd289069b4ad2208b0db6efe9e78c2cd05b | LuckyTyagi279/Misc | /python/loops_if.py | 481 | 4.1875 | 4 | #!/usr/bin/python
# Loops
# While Loop
while 0 :
Var=0
while Var < 5 :
Var = Var + 1
print Var
print "This is not in the loop!"
# Conditional Statement
# If statement
while 0 :
Var=1
if Var == 2 :
print "Condition is TRUE!"
else :
print "Condition is FALSE!"
while 0 :
Var = 0
while Var <= 100 :
if... |
db9ab8a3074d7fb6487c7a83e9005954993b628f | SusanthiMandalapu/MSC-project | /src/model/detection_model_wrapper.py | 879 | 3.828125 | 4 | """Contains code for abstractions used to simplify interaction with the model"""
class ModelWrapper:
'''Provide a wrapper to the prediction model'''
__model = None
def __init__(self, model = None):
super().__init__()
if model is None:
self.__model = "" #set the model to default
... |
a2bb2fb1bec5647604115acd68b11bac971352b8 | shehancaldera/baxter-project | /baxter-rubiks-algorithm/Old Code/BasicCubeTests.py | 1,738 | 3.75 | 4 | # -*- coding: utf-8 -*-
# example list sent from the vision system
# colours are:
# o = orange
# n = blue
# r = red
# g = green
# w = white
# y = yellow
facevs = ('rnwgrwono', 'nwgyoowyr', 'roygynyyn',
'grwwwgwrg', 'ywngnygny', 'roorgonro')
#... |
b4ced03a7145a4eac713f8a66cc7a1ab0292287a | cristian0497/High-Level-Programming | /0x0B-python-input_output/3-write_file.py | 248 | 3.875 | 4 | #!/usr/bin/python3
"""
Write in file, overwrite if already exists
"""
def write_file(filename="", text=""):
"""
Methon to open, write the file
"""
with open(filename, mode='w', encoding='utf-8') as f:
return f.write(text)
|
ac1b99db91419c6da9a252393d52e56d980060a5 | cristian0497/High-Level-Programming | /0x04-python-more_data_structures/12-roman_to_int.py | 308 | 3.578125 | 4 | #!/usr/bin/python3
def roman_to_int(roman_string):
ret = 0
valores = {
'M': 1000, 'D': 500, 'C': 100, 'L': 50, 'X': 10,
'V': 5, 'I': 1}
if len(roman_string) == 0:
return None
for i in roman_string:
if i in valores:
ret += valores[i]
return ret
|
72a6e60276d0e641e7772c65a2608ea0a6771be9 | s4017050400/david | /time_clock.py | 938 | 3.921875 | 4 | from datetime import date
from datetime import timedelta
today=date.today() #which is like datetime.date(2018,10,3)
one_day=timedelta(days=1) #one day which can be plused
for i in range(1,11):
date1=today+i*one_day
standard=date1.isoformat().translate({ord(c):None for c in '-'})#date.isoformat() is 2018-10-03
p... |
4052149356a34c724a3eb79be5f1726938f633c5 | lingsitu1290/Sales-Report | /sales-report.py | 1,951 | 3.90625 | 4 | """
sales_report.py - Generates sales report showing the total number
of melons each sales person sold.
"""
# #initialize empty lists for salespeople and melons sold
# salespeople = []
# melons_sold = []
# # open the file sales-report.txt into f
# f = open("sales-report.txt")
# #loop over each lin... |
62bae2fb4dd2e703527cedd8f55f649e9677912f | jerry-che/Basic_Python | /Goldbach.py | 1,189 | 4.0625 | 4 | # File: Goldbach.py
# Description: this program takes a user input that is greater than five and returns all even numbers and a sum of two numbers
# Student Name: Jerry Che
# Student UT EID: jc78222
# Course Name: CS 303E
# Unique Number: 51340
# Date Created: 10/10/17
# Date Last Modified:
def is_prime(n): ... |
b4abce09aa38fb0a1d7e01cdc6de0ccadf124bb6 | jerry-che/Basic_Python | /CalculatePI.py | 1,054 | 3.65625 | 4 | # File: CalculatePI.py
# Description: calculates PI given a random throw on the dartboard
# Student Name: Jerry Che
# Student UT EID: jc78222
# Course Name: CS 303E
# Unique Number: 51340
# Date Created: 10/15/17
# Date Last Modified: 10/16/17
import math #imports the libraries the program will be u... |
ea83612e855e0ba340ddef1944efd3c7bc9ca3b3 | AlejandroSantorum/Apuntes_Mat_IngInf | /5_Curso/Estadística_2/Trabajo_Computacional_2/Clasificador.py | 4,133 | 3.84375 | 4 | ################################################################################
# Authors:
# · Alejandro Santorum Varela - alejandro.santorum@estudiante.uam.es
# · Jose Manuel Chacon Aguilera - josem.chacon@estudiante.uam.es
# File: Clasificador.py
# Date: Dec. 23, 2020
# Project: 2nd Computational... |
ca1673da2326e494a8d5c906424d39693cf3b9f6 | AlejandroSantorum/Apuntes_Mat_IngInf | /4_Curso/Proyecto_Sistemas_Informáticos/P1/hello.py | 1,026 | 3.984375 | 4 | #!/usr/bin/python3 -tt
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
# Google's Python Class
# http://code.google.com/edu/languages/google-python-class/
"""A tiny Python program to check that Python is working.
Try running this prog... |
9176b405a1e2bf36da7475b43bc8470864f44aa1 | zacherymoy/cs-module-project-recursive-sorting | /src/sorting/sorting.py | 1,583 | 4.15625 | 4 | # TO-DO: complete the helper function below to merge 2 sorted arrays
def merge(arrA, arrB):
elements = len(arrA) + len(arrB)
merged_arr = [0] * elements
# Your code here
# print("merging",arrA,arrB)
arrA_idx = 0
arrB_idx = 0
idx = 0
while arrA_idx < len(arrA) and arrB_idx < len(arrB):
... |
548179ed09601ab857f5d8deeccb9c5bd1100bf3 | WELLINGWANG/learngit | /python/totalNum.py | 468 | 3.703125 | 4 | house={'ling':{'chair':3,'desk':1,'pot':4},
'jiamin':{'chair':5,'book':18,'cup':20},
'soo':{'car':1,'chair':9,'desk':1}}
def allHouse(houses,item):
numItems=0
for p,i in houses.items():
numItems+=i.get(item,0)
# print(p+str(i.get(item,0)))
return numItems
print('Number of prop... |
008cb017c4b71db023d5ffb8a7aacaeb340cb5bd | ajinzrathod/snapshare | /app.py | 541 | 3.609375 | 4 | from tkinter import Tk, font
class App:
def __init__(self, master: Tk, font_size) -> None:
self.master = master
# Creating a Font object of "TkDefaultFont"
self.defaultFont = font.nametofont("TkDefaultFont")
# Overriding default-font with custom settings
# i.e changing fo... |
e3e37279ff494f91a4dca998542e978cf9b3ae1a | cyril-gao/wheel | /Algorithms/leetcode/Python/max_points_on_a_line.py | 2,120 | 3.859375 | 4 | from typing import List
from fractions import Fraction
'''
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.
Example 1:
Input: [[1,1],[2,2],[3,3]]
Output: 3
'''
def max_points(points: List[List[int]]) -> int:
class KeyType:
def __init__(s... |
79abba1ce58e06c12a4786befa728a359a816087 | cyril-gao/wheel | /Algorithms/leetcode/Python/backtracking/sudoku.py | 3,147 | 4.0625 | 4 | from typing import List
from copy import deepcopy
'''
Write a program to solve a Sudoku puzzle by filling the empty cells.
A sudoku solution must satisfy all of the following rules:
Each of the digits 1-9 must occur exactly once in each row.
Each of the digits 1-9 must occur exactly once in each column.
Ea... |
b429703d5eb72449af30d108412b413e3f3a4588 | Frayn-code/Python-Algorithm | /DataStructure/hashtable/LongestWordinDictionary.py | 552 | 3.875 | 4 | '''
leetcode 720
'''
class Solution:
def longestWord(self, words):
"""
:type words: List[str]
:rtype: str
"""
ans=''
words=set(words)
for word in words:
if len(word)>len(ans) or (len(word)==len(ans) and word<ans):
if all([word[:i] i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.