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 |
|---|---|---|---|---|---|---|
aeac895dad717d9fc41db5c468b9697c6bfba078 | alviz/test1 | /exercise5.py | 357 | 3.53125 | 4 | from random import randrange
# a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
# b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
a = [randrange(1,100) for x in range(1,randrange(10,40))]
b = [randrange(1,100) for x in range(1,randrange(10,40))]
c = set()
print(a)
print(b)
for item in a:
if item in b:
c.add(ite... |
f4f80473d83b197f7745831b1ad7c507d00d76a3 | kishu9/Breast-Cancer-Prediction- | /Main File.py | 12,444 | 3.78125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
#import libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
# In[2]:
data = pd.read_csv('data.csv')
data.head()
# In[3]:
data.shape #Count the number of rows and columns in the data file
# In[4]:
... |
a0dfbc3c044cd81a040f9d533dee4c61e5a6645f | tw9ntyseven/Programming | /Practice/05/Python/my.py | 183 | 3.625 | 4 | print('Введите x0')
x0 = int(input())
print('Введите v0')
v0 = int(input())
print('Введите t')
t = int(input())
g = 9.8
res = x0 + v0 * t - g*t*t/2;
print(res)
|
47d063a3b69dc3809ef5ebe73191f67ba08676fc | tw9ntyseven/Programming | /Practice/33/Python/my.py | 526 | 3.9375 | 4 | def sort(array):
for i in range(1, len(array)):
key = array[i]
j = i - 1
while j >= 0 and key < array[j]:
array[j + 1] = array[j]
j -= 1
array[j + 1] = key
def create(length, base, step):
if length < 0:
return None
array = [base]
for i... |
630f0524689ad8135b24ccb5704fb1001c4728cc | BeppeMarnell/TeamProjectMAIR | /src/Rules.py | 9,334 | 3.96875 | 4 | class Rules:
"""
1 cheap, good food busy True 1 a cheap restaurant with good food is busy
2 spanish long time True 1 Spanish restaurants serve extensive dinners
that take a long time to finish
3 busy ... |
a8116f9e6c47d80691b22dd024a4f0243663c961 | xuchenxing/MyLeetcode | /junior/levelOrderBottom.py | 1,644 | 3.703125 | 4 | '''
给定一个二叉树,返回其节点值自底向上的层次遍历。 (即按从叶子节点所在层到根节点所在的层,逐层从左向右遍历)
例如:
给定二叉树 [3,9,20,null,null,15,7],
3
/ \
9 20
/ \
15 7
返回其自底向上的层次遍历为:
[
[15,7],
[9,20],
[3]
]
'''
#Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
... |
55e1c43c5751d93276f05e2af46bb55e36fa1674 | Psianturi/lomba_kurakura | /Kurakura_Race.py | 857 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Dec 3 11:35:40 2018
@author: Posma
"""
#!/bin/python3
from turtle import Turtle
from random import randint
iren = Turtle()
iren.color('red')
iren.shape('turtle')
iren.penup()
iren.goto(-160,100)
iren.pendown()
kanaya = Turtle()
kanaya.color('yellow')
... |
a9bc65f94c7d6d17b0dff0ba6d0e703283c759fc | solankeganesh777/Python-Basics-for-data-science-project | /Python basics/Write File in Python.py | 1,092 | 3.953125 | 4 | #File Handling in Python
#Writing File
with open('/resources/data/Example2.txt',"w") as wfile:
wfile.write("This is first line written")
wfile.write("This is second line written")
#check if file is written
with open('/resources/data/Example2.txt',"r") as rfile:
print(rfile.read())
#By setting the... |
eb7d6522bdc0ed9b1a9a6533d84528f0bb27f78e | solankeganesh777/Python-Basics-for-data-science-project | /Matplotlib/Plotting.py | 458 | 4.15625 | 4 | # Matplotlib Plotting
#Plotting X and Y points
x=np.array([1,4,5,7])
y=np.array([5,3,9,5])
plt.plot(x,y)
plt.show()
print("\n")
#Plotting without line
x=np.array([1,4,5,7])
y=np.array([5,3,9,5])
plt.plot(x,y,'o')
plt.show()
print("\n")
# Multiple points
x=np.array([1,6,4,2,5,7])
y=np.array([5,3,8,9,3,5])
plt.plot(x,... |
184889fc0fe4e276c1c691da0de1a702c4a35e34 | solankeganesh777/Python-Basics-for-data-science-project | /Other/DateTime.py | 746 | 3.875 | 4 | #Python DateTime
import datetime
print(dir(datetime))
print(datetime.datetime.today())
print(datetime.datetime.now().year)
print(datetime.datetime.today().strftime("%Y"))
print(datetime.datetime.today().strftime("%B"))
print(datetime.datetime.today().strftime("%m"))
print("\n")
#Creating Date objects
import datet... |
f38dcb8559ab8e18e3b5215d549e9193427061cc | solankeganesh777/Python-Basics-for-data-science-project | /Python basics/Iterator.py | 666 | 4.21875 | 4 | #Python Iterators
list=[1,2,3,4,5,6,7,8]
myit=iter(list)
print(next(myit))
print(next(myit))
print(type(myit))
print("\n")
name="Ganesh"
myit=iter(name)
print(next(myit))
print(next(myit))
print(type(next(myit)))
print(next(myit))
print(next(myit))
print(next(myit))
print("\n")
#Creation of iterator
class MyNumbers... |
c2098b9962a5a22afd6f02a3e08966866f7f2836 | bhanuchandrika/pylearn | /string-reverese-words.py | 160 | 4.03125 | 4 |
# Reverse any random sentence - only the word positions
sentence = input("Enter a sentence - ")
sentence = sentence.split()
print(' '.join(sentence[::-1]))
|
804af53c087acedbf1b6d0cdb8770ba4f099b105 | bhanuchandrika/pylearn | /array-pop-vs-remove.py | 533 | 3.9375 | 4 | import array as arr
a=arr.array('d', [11,22,44,55,33,77,66,99,2345,1122,34])
print(f"a.pop(1) takes the index of the element in the array and prints the array element that has been removed - {a.pop(1)}")
print(f"The array now - {a}")
print(f"a.pop(9) prints the array element that has been removed - {a.pop(9)}")
print(f... |
1eb9716c4733ea4f9d69c3b59f34d116d27734d2 | trndnd/Computing-Homework | /Making_Database_Table.py | 239 | 3.609375 | 4 | import sqlite3,os
db = sqlite3.connect("Movies.db")
cursor = db.cursor()
cursor.execute("CREATE TABLE Movies(Movie_Name text,release_Date text,genre text,rating text)")
db.commit()
db.close()
print("Database \"Movies\" has been created!") |
b8785ff53eb0e7fda2200ec7f882501b45c86564 | WeDias/RespPPZ | /WesleyDiasIV.py | 2,624 | 3.703125 | 4 | # Wesley Dias (1º Semestre ADS-B), Lista IV
# Exercício 1a (Obs.: Não foi usado a função max ou min, o que torna este exercício válido — hahaha :D )
from random import randint
numeros = []
for c in range(0, 10):
numeros.append(randint(1, 100))
print(f'Lista sorteada: {numeros}')
numeros.sort()
print(f'O menor núm... |
e14a0f9e9f2b24d368839224f678fd96dbbb4c50 | keqiliu/LearnPython | /learn_the_hard_way/ex24_more_practice.py | 758 | 3.75 | 4 | print("Some practice")
print('You\'d need to know \'bout escapes with \\ that do:')
print('\n newlines and \t tabs.')
poem = """
\tI'm so tired
\n\t\t and sleepy
"""
print("-----------")
print(poem)
print("-----------")
five = 10 - 5
print(f"This should be five: {five}")
def secret_formula(started):
jelly_bena... |
3f8bfc90d69ac3c98ead04e15ff383573bb16d86 | keqiliu/LearnPython | /reach_to_21_game/game.py | 1,366 | 4.03125 | 4 | # the cute game
import random
def get_add_number(current_num):
if current_num % 3 == 2:
return 1
elif current_num % 3 == 1:
return 2
else:
return random.randint(1, 2)
if __name__ == '__main__':
print('\n{game_name:-^40}'.format(game_name='let\'s play a game'))
print('star... |
a1ee204c11742a25916a587c05d3caea3e6ffae0 | keqiliu/LearnPython | /learn_the_hard_way/ex37_symbol_review.py | 701 | 3.703125 | 4 | # assert
# (ensure something is true)
assert False, "error!"
# del
# (delete from dictionary)
X = {"a": 1, "c": 2}
del X["c"]
# except
try:
a = 1 / 0
except ZeroDivisionError as e:
print(e)
# exec
# (run a string as python)
exec('print("Testing exec")')
# finally
# (do this no matter what!)
# global
# ... |
3ccfa41042db2bb4e0868549c1a4f58522e4fed1 | faruqfadhil/hackerrank-practice | /warm-up-challenge/repeated-string.py | 907 | 3.8125 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the repeatedString function below.
def repeatedString(s, n):
constan = 'a'
index_constan = []
karakter = list(s)
panjang = len(karakter)
for i in range(panjang):
if(karakter[i]==constan):
index_c... |
8abed6121ee7847b3d076fa7c555db089ec3f483 | wajdm/ICS3UR-5-05-Python | /addressing_mails.py | 1,866 | 4.46875 | 4 | # !/usr/bin/env python3
# Created by: Wajd Mariam
# Created on: December 2019
# This program formats the mailing address using given input.
def format_address(first_name, last_name, street_add, city,
province, postal_code, apt_number=None):
# returns formatted mailing address
if apt_numbe... |
3c1c2c953ba874b11a15ad86f6a6e0bce020f8f2 | gauri05/Assignment4 | /Assignment4_1.py | 276 | 3.921875 | 4 | def main():
print("program which contains one lambda function which accepts one parameter and return power of two")
num = input("Enter the number:")
ans = lambda num: 2 ** int(num)
ret = ans(num)
print("Ans::", ret)
if __name__ == "__main__":
main()
|
197a3f0ba78195e2c48d4e66890fbac50f384828 | 563213341/git-example | /example/vol5/5.8-5.11.py | 949 | 3.859375 | 4 |
a=['1','d','r','t','5'] #5.8已完成
for p in a:
if p=='5':
print('baba')
else:
print('dadi')'''
'''
a=[] #5.9已完成
if a:
for p in a:
if p=='5':
print('baba')
else:
print('dadi')
else:
print('no')
'''... |
3abdc080bd022cb4e5bb4ee2fdabfc47d8d8d4de | 563213341/git-example | /example/vol7/7.4-7.7.py | 720 | 3.65625 | 4 | '''
while True:
t=input('请输入配料:') #7.4,7.7已完成
if t=='quit':
break
else:
print('俺们会在披萨中添加 '+t+' 这种配料')'''
p='3岁以下免费,3-12岁10刀,12岁以上15刀'
p+='\n根据观众的不同年龄收取不同的票价,请输入您的年龄:'
'''
while True:
t=input(p) #7.5已完成
if t== 'quit':
brea... |
182e04713fff2e4cd0ff10b0be433ea4042ba585 | DorameEthan/DorameEthan.github.io | /TEST.py | 330 | 3.59375 | 4 | import turtle, random
window = turtle.Screen()
window.bgcolor ('black')
t = turtle.Turtle ()
t.color('cyan')
t.pensize (0.2)
t.shape('turtle')
t.speed (-10)
x = 2
y = 1
z = 1
print (y)
while 1==1:
z=(z+1)
t.forward (20)
t.right (x)
x=(1.1*(x/z)-z)
while x > 259:
x=x-360
p... |
d66c3b61672cd06e46d8271c28a4c3b0a4fc6b50 | richiebeeth/alg.geneticos | /cadena.py | 611 | 3.796875 | 4 | import math
max=5;
min=1;
presicion=0.001;
# CONVERTIR UN BINARIO A UN DECIMAL
cadena=(input('INTRODUCE UN BINARIO:'))
cadena1=len(cadena)
decimal=int(cadena, base=2)
print("TU NUMERO EN DECIMAL ES:")
print(decimal)
# CONVERTIR UN DECIMAL A UN BINARIO
# CONVERTIR A UN NUMERO REAL
real = min + (decimal * ((max - min... |
7755b9f7f631963d2ead7db18c8b503d9aeb38c9 | MonoDeSpella/OrangeBelt | /orangeBelt.py | 4,444 | 4 | 4 | #here is a gallows game!
import random
word_list = ['math', 'literature', 'history', 'programming', 'csharp', 'onelove', 'python']
#function that gets random word from list above (:D)
def get_word():
word = random.choice(word_list)
return word.upper()
# getting current level
def display_hangman(... |
f8e1503fd120b1d24d370f929ca6b3cdab0d40e9 | windyIsMe/leetcode | /python/p94.py | 948 | 3.75 | 4 | from treenode import TreeNode
class Solution:
def inorderTraversal(self, root: TreeNode):
res = []
self.traverse(res, root)
return res
def inorderTraversalIterative(self, root: TreeNode):
stack = []
res = []
cur = root
while cur or stack:
whi... |
7f05e5e75bd40365e95a6fc3ab5152a201ac32e3 | windyIsMe/leetcode | /python/p95.py | 891 | 3.90625 | 4 | from treenode import TreeNode
class Solution:
def generateTrees(self, n: int) -> [TreeNode]:
if n == 0:
return []
return self.generateTree(1, n)
def generateTree(self, start, end):
nodeList = []
if start > end:
nodeList.append(None)
else:
... |
e5bccdc081667ac60817f79f9470b8e1628206ba | mrwindowsSDE/mycode | /flowchart/flowchart.py | 1,269 | 3.671875 | 4 | #!/usr/bin/env python3
import sys
EDGES = {"0": ["1", "2", "3"], "2": ["4"], "3": ["4"], "4": ["5", "6"],
"6": ["7"], "7": ["8", "9"], "8": ["10"], "9": ["10"], "10": ["11", "12"],
"12": ["13"], "13": ["14"]}
RESPONSE_TO_ANSWER = {"0": "0", "2": "4", "3": "4", "6": "7", "8": "10", "9": "10", "12": "13"}
QUESTIONS = ... |
1e08d804eb6fa2fc41810c3bf897af8cde83bb34 | ksgifford/data-structures | /src/new_deque.py | 1,636 | 3.984375 | 4 | """Defines data structure for implementing a deque."""
# -*- coding: utf-8 -*-
from dbl_linked_list import DblLinkedList
class Deque(object):
"""Establish class for deque. Methods composed from dbl_linked_list."""
def __init__(self, seq=None):
"""Initialize deque."""
self._deque = DblLinkedLi... |
69e0f1689d1e282e76b4c7966112fb5767100f3e | cmurphy/euler | /p20.py | 178 | 3.78125 | 4 | from math import factorial
def sum_factorial(n):
number = str(factorial(n))
sum = 0
for c in number:
sum += int(c)
return sum
print sum_factorial(100)
|
d48ea8d84a101e730681b83f7b6ce32d28ed78f3 | eager7/python_study | /algorithm/tree/BinarySearchTree.py | 2,756 | 3.796875 | 4 | #!/usr/bin/python
# -*- coding:utf-8 -*-
import sys
__metaclass__ = type
__author__ = 'changtao.pan'
class BinarySearchTree():
def __init__(self, key):
self.key = key
self.left = None
self.right = None
self.parent = None
self.degree = 1
def query(self, key):
if... |
d848e63cea08ab5ef809bacfca1109dc2159a2ec | eager7/python_study | /algorithm/bubble.py | 743 | 3.828125 | 4 | #!/usr/bin/python
# -*- coding:utf-8 -*-
__author__ = 'changtao.pan'
__metaclass__ = type
import pickle
import numpy as np
def bubble(mlist):
print 'bubble method'
length = len(mlist)
for index in xrange(length):
for i in xrange(length - index - 1):
if mlist[index] < mlist[i+index+1]:
... |
a3861d6826190c7a1e6ad3d21f38d37786ac229d | HamzaErrifai/Search_V2_beta | /classes/History.py | 794 | 3.546875 | 4 | import os
from .Shortcut import Shortcut
class History(Shortcut):
def __init__(self):
self.saveFile = "save/history.json"
super().__init__("History", self.saveFile)
def clear(self):
f = open(self.saveFile, 'w')
f.close()
os.system('cls')
return True
def add... |
92176384ecb7886c74672b1a920854fbb58ae74a | InjiChoi/algorithm_study | /탐색기반설계/3506.py | 190 | 3.515625 | 4 | # 블럭 채우기 1 (Small)
num = int(input())
def block(n):
if n==1:
return 1
elif n==2:
return 2
else:
return block(n-1)+block(n-2)
print(block(num)) |
9b480a692d239a50c5f9e4acc9a44d8d360e5706 | InjiChoi/algorithm_study | /재귀함수/1904.py | 375 | 3.5625 | 4 | # 두 수 사이의 홀수 출력하기
a, b = map(int, input().split())
def odd_print(small_n, large_n):
if small_n > large_n :
return
elif large_n % 2 != 0: # 홀수일 때 출력
odd_print(small_n, large_n-1)
print(large_n)
else: # 짝수이면 하나 감소시키고 넘어가기
odd_print(small_n, large_n-1)
odd_print(a,b)
|
ac566079a1f0b1c8b05a921253df65872f4d2201 | tryingtokeepup/Sorting | /src/iterative_sorting/iterative_sorting.py | 1,387 | 4.34375 | 4 | # TO-DO: Complete the selection_sort() function below
def swapping_helper(index_a, index_b, arr):
# cool_dude = array
temp = arr[index_a]
arr[index_a] = arr[index_b]
arr[index_b] = temp
return arr
def selection_sort(arr):
# loop through n-1 elements
for i in range(0, len(arr) - 1):
... |
9a718e4a71ef9f2a19f9decc472d6fba57a5cb51 | czwartaoslpoj/book-review-project | /templates/house_hunting.py | 736 | 4.1875 | 4 | //calculating how many months I need to save the money fo portion_down_payment
total_cost = int(input("The cost of your dream house: "))
portion_down_payment = total_cost/4
current_savings = 0
annual_salary= int(input("Your annual salary: "))
portion_saved = float(input("Portion of your salary to save as a decim... |
5cc063e8e37864b19eeea77e38fc75e41d4d1b66 | jtmorgan/ds4ux | /bpdata/residential_permits_by_month.py | 1,881 | 3.609375 | 4 | import csv
import encoding_fix
import json
from operator import itemgetter
import requests
# load in the JSON file we created with download_building_permit_data.py
with open("data/residential_permits_2010-2016.json") as json_infile:
bp_api_data = json.load(json_infile)
json_infile.close()
# create an empty di... |
704faceb9b6e51c0cd86561097f5ccb6b4d6250d | jtmorgan/ds4ux | /notifications/bgt-traffic/bike_and_ped_idea3.py | 448 | 3.625 | 4 | """
Which hour during November 11, 2015 saw the most overall traffic?
"""
import bgt_traffic
nov_11 = bgt_traffic.traffic.get('11/11/2015')
busiest_hour = ""
most_traffic = 0
for h_key, h_val in nov_11.items():
traffic = h_val['total']
if traffic > most_traffic:
busiest_hour = h_key
most_tr... |
62f17df24279f5c2798d5bee3a2ba1ba134f9d0e | jtmorgan/ds4ux | /notifications/notifications_dictread.py | 1,527 | 3.921875 | 4 | import csv
"""
There are 8 types of notification that a user can receive
- someone @mentioned you in a discussion
- someone left you a message on your user page
- someone reverted one of your edits
- someone changed your userrights
- someone sent you an email
- someone thanked you for your edit
- someone reviewed an a... |
0873f14dd28ae5b6eb3a241ca7a9cd5e307866b4 | mhmadwrekat/data-structures-and-algorithms-2 | /python/code_challenges/graph/graph.py | 2,612 | 3.703125 | 4 | #Lab 35
from collections import deque
class Vertex():
def __init__(self,key):
self.key = key
def __str__(self):
return str(self.key)
class Queue():
def __init__(self):
self.dq = deque()
def enqueue(self,value):
self.dq.appendleft(value)
def dequeue(self):
return self.dq.pop()
... |
a4b6ecf87ffbb31a664228dd3e3d9ab2a10773c9 | mhmadwrekat/data-structures-and-algorithms-2 | /python/code_challenges/insertion-sort/test-insertion-sort.py | 384 | 3.5625 | 4 | from insertion-sort.insertion-sort import insertion_sort
def test_insertion_sort():
assert insertion_sort([8,4,23,42,16,15]) == [4,8,15,16,23,42]
# Reverse-sorted
assert insertion_sort([20,18,12,8,5,-2]) == [-2,5,8,12,18,20]
# Few uniques
assert insertion_sort([5,12,7,5,5,7]) == [5,5,5,7,7,12]
# Nearly-sor... |
8b17daddcc3b675217299aefae792f7dbf1c47bb | PepSalehi/DeepLearning | /assignment2/code/assignment1 code/mnist.py | 10,594 | 3.890625 | 4 | # preactlayer[] -- pre-activation layer before sigmoid
# postactlayer[] -- layer to store post-activation results after sigmoid
# outputlayer[] -- output layer which applies softmax to the last postactlayer
import numpy as np
import os
import copy
from loader import loaddata
import matplotlib.pyplot as plt
import cs... |
b8377d7a3b05caccd7c4ecd15a65ebf2bc5769b7 | jhstarr/Find_Contacts_at_Companies | /find_contacts_at_companies_fn.py | 6,809 | 3.765625 | 4 | # Jeff Starr, 3 July, 2018
# This is a program that takes two input csv files and returns two output
# files.
# One input file contains a list of target companies. One input file
# contains a list of contacts at companies. One output file contains a list of
# all contacts who work at companies that appear to match... |
490edff95bfcfdb21aab4b7ff19b3f1e7f00596f | yerishA0/Tarea-02 | /auto.py | 385 | 3.734375 | 4 | #encoding: UTF-8
# Autor: yerish valdes A01375755
# Descripcion: calcular una velocidad
# A partir de aquí escribe tu programa
velocidad=int(input("velocidad:"))
tiempo= 500/velocidad
distancia1=velocidad * 6
distancia2=velocidad * 10
print ("distancia despues de 6h: ",distancia1,"km")
print ("distancia despues de 1... |
2783f7fee050c5beb094b7b89d3983cced4ea591 | pratikgchaudhari/python-demo | /inputs/rental_car.py | 635 | 4.0625 | 4 | cars = {'1':'Figo','2':'Swift','3':'Scorpio','4':'Mercedes'}
print('--------------------------------------------------------------')
print('Welcome to Zoomcar!')
print('--------------------------------------------------------------')
print('Which of following cars would you like to rent:')
print(' 1: Figo')
print(' 2... |
42197c180b52480cc3db26a67fbdfedf2a788dfc | pratikgchaudhari/python-demo | /strings/stripping_spaces.py | 288 | 3.90625 | 4 | name = "\n\t Elon Musk \n\t"
print('Original name: ' + name)
print('Name after stripping whitespace on it\'s left: ' + name.lstrip())
print('Name after stripping whitespace on it\'s right: ' + name.rstrip())
print('Name after stripping whitespace on it\'s left and right: ' + name.strip()) |
9adbdfe40268bc18ab18d343a9ada685b39459e4 | CelineGuilbert/Moocs-Python | /Dataquest/Step 1: Python Introduction :: 8 Customizing Functions and Debugging Errors.py | 3,647 | 4.1875 | 4 | #improve our spell checker 'voir feuille functions.py
#Recall that our spell checker works by:
#Reading in a file of correctly spelled words, tokenizing it into a list, and assigning it to the variable vocabulary
#Reading in, cleaning, and tokenizing the text we want to spell check
#Comparing each word (token) in the ... |
9a60f8b0ef84713babe9b194f1040349f1251d3e | CelineGuilbert/Moocs-Python | /Dataquest/Step 2: Analysis with Pandas :: 6 Series and DF.py | 5,052 | 4.0625 | 4 | ##http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.html#pandas.Series
##1. Data structures
#The three key data structures in pandas are:
#Series objects (collections of values)
#DataFrames (collections of Series objects)
#Panels (collections of DataFrame objects)
#https://github.com/fivethir... |
e6251adf10b62e774dd938fb21ca138a0063d78e | CelineGuilbert/Moocs-Python | /Dataquest/Step 2: Analysis with Pandas :: 1 Getting_starting_with_numpy.py | 6,703 | 4.40625 | 4 | #NumPy is much easier to work with than lists of lists, because:
#It's easy to perform computations on data.
#Data indexing and slicing is faster and easier.
#We can convert data types quickly.
#Overall, NumPy makes working with data in Python much more efficient. It's widely used for this reason, especially for mac... |
f2af3e7b5026178157da485a65286a83e5e2a7f9 | dogpi/StudyMatplotlib | /01.UsageGuide/figure_simple.py | 210 | 3.640625 | 4 | import matplotlib.pyplot as plt
import numpy as np
x = np.arange(0,10,0.1)
y = np.sin(x)
fig,ax = plt.subplots(num="sin")
ax.plot(x,y,marker="*",color=(1,0,0),linestyle="dashed")
ax.set_title("sin")
plt.show() |
f47c60ed65e11daf92f68098ef12a81962d2d88a | ZmeiBaktMailybekov/full-progs | /подготовкаКконтр1.py | 172 | 3.609375 | 4 | i =0
while i <= 11:
from random import randint
x = randint (1, 10)
y = randint (1, 10)
if x > y:
print x - y
elif x < y:
print x + y
elif x == y:
print x * y
|
25645792928bc7f35f63fc2e31cee3c10ab4e3e6 | sandycamilo/minimax | /minmax.py | 4,712 | 3.703125 | 4 | from sys import maxsize #pick maxsize of an integer - using value to represent infinity
# +1 = human
# -1 = computer
#generate tree of all possible moves
#each position or node of a tree holds a heuristic value - + / -
#algorithm starts from bottom of tree, decides best move and removes all the bad moves
#goal... |
2dcae6d542ce64bde8d741c322b8661141c7ed3a | duffyw99/sean_tutorials | /weatherwall/weatherwall.py | 1,272 | 3.71875 | 4 | import json
import requests
## api key is free, sent via email when you submit a request
## Details at: https://openweathermap.org/appid
api_key='replace_with_your_api_key'
zip_code = '32252'
## prepare api url string
api_url = f'http://api.openweathermap.org/data/2.5/weather?appid={api_key}&zip={zip_code}'
## subm... |
e1a42bb8d1b00666fe1a9d2022d116fc879630eb | markellisdev/bangazon-orientationExercises1-6 | /bangazon.py | 2,605 | 4.15625 | 4 | class Department(object):
"""Parent class for all departments
Methods: __init__, get_name, get_supervisor
"""
def __init__(self, name, supervisor, employee_count):
self.name = name
self.supervisor = supervisor
self.size = employee_count
def get_name(self):
"""Retur... |
530c03355fbb85c4dec09a8e14b64b528d371359 | siddharthchd/Errors_and_Exception_Handling | /exception_handling.py | 275 | 4.0625 | 4 | def add(n1,n2):
print(n1 + n2)
number1 = 10
number2 = input("Enter number : ")
try:
# Attempt to run code that may have an error
#add(number1, number2)
result = 10 + 10
except:
print("You aren't adding correctly")
else:
print("Something went wrong")
|
1d5c0f96330d39c5f3f88897de62797445d9963a | zhufangxin/learn-python3 | /money_challenge/money_challenge v1.0.py | 456 | 3.90625 | 4 | """
功能:52周存钱计划
week saving total
1 10 10
2 20 30
3 30 60
4 40 100
...
"""
def main():
week = 1
saving_money = 10
total_money = 0
while week <= 52:
total_money += saving_money
print('第{}周,存钱{}元,总共存钱{}元'.format(week, saving_money, total_mo... |
55f4e852fd8e90f8e3ab507f22a881a4a1e63181 | zhufangxin/learn-python3 | /Fractal_tree/fractal_tree.py | 825 | 4.28125 | 4 | """
递归 绘制分形树
"""
import turtle
def draw_branch(branch_length):
"""
绘制分形树
"""
if branch_length > 5:
# 绘制右侧树枝
turtle.forward(branch_length)
print('向前', branch_length)
turtle.right(20)
print('向右20度')
draw_branch(branch_length - 15)
... |
0f5d1d9f2eb8149d8d0906016f40ddb7dc9f1605 | zhufangxin/learn-python3 | /pwd_strength/pwd_strength v5.0.py | 2,272 | 3.625 | 4 | """
功能:定义一个password的工具类
版本:V5.0
知识点:面向对象编程
"""
class PasswordTool:
"""
密码工具类
"""
def __init__(self, password): # 外部传入password
# 类的属性
self.password = password # 将外部属性传递给本身
self.strength_level = 0
# 类的方法
def process_password(self):
# 1.密码长度是... |
39dbe193950a26b470874de4c343cf45fc2cd892 | zhufangxin/learn-python3 | /Exchange/currency_converter v4.0.py | 721 | 4.09375 | 4 | # -*- coding: utf-8 -*-
"""
功能:汇率转换
版本: V4.0
新增功能: 函数应用 计算转换后金额
"""
def convert_currency(im, rate):
"""
汇率兑换函数
"""
return im * rate
USD_VS_RMB = 6.77 # 固定值的命名用大写
currency_inp_value = input('请输入带单位的货币金额(退出程序请输入Q):')
unit = currency_inp_value[-3:]
if unit == 'CNY':
exchange_rate ... |
b47910013603691bce074cfb81edb5ecf480f863 | Kay-Towner/homework | /week6 LAB.py | 9,945 | 4.03125 | 4 | """Written by Kay Towner"""
"""2/17/21"""
##2
##1. What is a compound statement in Python, and
##what does the syntax of a compound statement looklike?
##
#compound statements are groups of statements, for, if, else ect.
#they general are formated with indentations and sepereated
#by colons on each line.
... |
d58e07624b8ee730f409317d54883ced7daeb9c8 | dhruvmahajan123/expenditure_tracker_python | /database.py | 1,727 | 3.796875 | 4 | import sqlite3 as db
def init(name):
conn=db.connect(("{xyz}.db").format(xyz=name,))
cur=conn.cursor()
sql = '''
create table if not exists credit(
date string,
title string,
amount number
)
'''
sql2 = '''
create table if not exists debit(
date string,
title string,
... |
baae9ce539c308fd6f1bbe6d1afbcc6c3b5143d6 | TraceTschidaUT/cs313e | /War.py | 10,234 | 3.78125 | 4 | # File: Dice.py
# Description: A game of war simulator
# Student's Name: Trace Tschida
# Student's UT EID: TRT729
# Course Name: CS 313E
# Unique Number: 51465
#
# Date Created: 9/24/2017
# Date Last Modified: 9/26/2017
import random
class Deck():
# initialize
def __init__(self):
# hold th... |
ebcdd0cc836b5940b69b999f24b67020a97960e3 | wpram45/DataStructuresInPython | /Bst.py | 1,100 | 3.59375 | 4 | class BinarySearchTree:
veri=None
sag=None
sol=None
def ekle(root,veri):
head=root
if root is None:
root=BinarySearchTree()
root.veri=veri
root.sag=None
root.sol=None
return root
if root.veri < veri:
if root.sag is None:
... |
affc5419e543c5ab4ba2da8e53cb43e7f40318f6 | oomaer/ICT-CS101 | /sumofn_Numbers.py | 248 | 3.96875 | 4 | runs = True
ncount = 0
sum = 0
while runs:
num = int(input('Enter number '))
if num == 0:
runs = False
else :
sum = num + sum
ncount -=-1
print(ncount, ' numbers are typed and ', sum, ' is their sum')
|
681d4c5a1a07bde39277c8b7275e426a2477685f | oomaer/ICT-CS101 | /sinx cosx.py | 125 | 3.796875 | 4 | import math
x = eval(input('Enter any number '))
formula = math.pow(math.sin(x), 2) + pow(math.cos(x), 2)
print(formula)
|
cbcd10c7aac7e87637c9d42c93ccf440780b9a52 | oomaer/ICT-CS101 | /sincossni.py | 183 | 3.546875 | 4 | import math
x = eval(input('Enter any number '))
sol1 = (2/(math.sin(x))) - (math.cos(x)/math.sin(x))
sol2 = math.sin(x) / math.cos(x)
print(sol1 , " = " , sol2, " Hence Proved!") |
9eea9265e1ace539b7498d06a98811dc189c3578 | strawwhat/diary | /programming-three/three134.py | 2,269 | 4.125 | 4 | #!/usr/bin/python
# *-*coding:utf-8 *-*
"示例3-9 page134 redirect.py 重定向流到python对象"
"""
file-like objects that save standard output in a string and provide
standard input text a string ; redirect runs a passed-in function
with its output and input streams reset to these file-like class objects
类似文件的对象,用于在字符串中保存标准输出并提供... |
3a579f9d96a69d694b51b84fea5f8b05ec4a0464 | MrDeshaies/NOT-projecteuler.net | /euler_081_083_matrix.py | 1,338 | 3.59375 | 4 | # common matrix functions for 081, 082 and 083
from dijkstra import Node
def load_matrix_from_file(filename):
matrix = []
f = open(filename, "r")
for line in f:
matrix.append([int(x) for x in line.strip().split(",")])
f.close()
return matrix
def node_at(nd,x,y,value):
key = "{},{}"... |
07947dfb1fb9ef0e548759556298fa5429270d4f | MrDeshaies/NOT-projecteuler.net | /side_projects/product_digit_sum.py | 290 | 3.734375 | 4 | # a * b = c., where 0 < a,b < 100.
# Are there values of a for which all c have the same digital sum?
def digital_sum(number):
return sum([int(i) for i in str(number)])
for a in range(1,10000):
if all([digital_sum(a*b) == digital_sum(a) for b in range(1,a+1)]):
print(a)
|
65c7a433bdb9c75f8fab7a66cdb6599650f4083b | MrDeshaies/NOT-projecteuler.net | /euler_035.py | 1,087 | 3.75 | 4 | # The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719,
# are themselves prime.
#
# There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97.
#
# How many circular primes are there below one million?
from euler import isPrime
# if the... |
1248cb15ba3973b73fc52e0244fc34e2f01d9b7f | MrDeshaies/NOT-projecteuler.net | /euler_040.py | 790 | 3.59375 | 4 | # Champernowne
# An irrational decimal fraction is created by concatenating the positive integers:
#
# 0.123456789101112131415161718192021...
#
# It can be seen that the 12th digit of the fractional part is 1.
#
# If dn represents the nth digit of the fractional part, find the value of the following expression.
#
... |
fc7d23a25399b3519f1dcdde07cdf8e56a339a6a | MrDeshaies/NOT-projecteuler.net | /euler_031.py | 1,185 | 3.578125 | 4 | # In England the currency is made up of pound, £, and pence, p,
# and there are eight coins in general circulation:
#
# 1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p).
# It is possible to make £2 in the following way:
#
# 1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + 3×1p
#
# How many different ways can £2 be made using an... |
5152ceac7f81c2e6864f20714d31011d9c17f947 | MrDeshaies/NOT-projecteuler.net | /euler_092.py | 1,521 | 3.921875 | 4 | # Project Euler 92
# A number chain is created by continuously adding the square of the digits in a number to form
# a new number until it has been seen before.
#
# For example,
# 44 → 32 → 13 → 10 → 1 → 1
# 85 → 89 → 145 → 42 → 20 → 4 → 16 → 37 → 58 → 89
#
# Therefore any chain that arrives at 1 or 89 will become s... |
2ef6276eec928acd8c0866e7e41f5b44fe4f1e5d | MrDeshaies/NOT-projecteuler.net | /euler_066.py | 3,555 | 3.5 | 4 | # Euler 66
# Consider quadratic Diophantine equations of the form:
# x^2 – Dy^2 = 1
#
# For example, when D=13, the minimal solution in x is 6492 – 13×1802 = 1.
#
# It can be assumed that there are no solutions in positive integers when D is square.
#
# By finding minimal solutions in x for D = {2, 3, 5, 6, 7}, we obta... |
24f6feeda30f66fddf433d9d4c0cd388b6509763 | MrDeshaies/NOT-projecteuler.net | /euler_042.py | 1,597 | 4.125 | 4 | # The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1);
# so the first ten triangle numbers are:
#
# 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
#
# By converting each letter in a word to a number corresponding to its alphabetical position and
# adding these values we form a word value. For examp... |
542759df80baa3bdc951931364e72aea52226305 | amitkumar-panchal/ChQuestiions | /python/q01/Contiguous.py | 1,558 | 4.28125 | 4 | """
Fiels: _items is a list of items
_size is number of items that can be stored
"""
## Contiguous(S) produces contiguous memory of size s
## and initializes all entries to None.
## Requires: s is positive
class Contiguous:
def __init__(self, s):
self._items = []
self._size = s;
for ... |
145c6f255a638abb668cb9d4afb88b3831aadb92 | SoumyaSreedhar/Binary-Search-2 | /Min_sortedArray.py | 944 | 3.5625 | 4 | #153. Find Minimum in Rotated Sorted Array
#Time Complexity: O(log n)
#sapce Complexity : O(1)
class Solution:
def findMin(self, nums: List[int]) -> int:
if(nums == None or len(nums) == 0):
return -1
low = 0
high = len(nums) - 1
while(low<=high):... |
e95d206cd35c1d6187464e3ccbeafc8cb9d33f7f | the-0r10n/3kh0.github.io | /python/main.py | 386 | 4.0625 | 4 | # My first time using python.
#
# Thank you https://www.w3schools.com
# I learned from there, very helpful stuff.
#
if 5 > 2:
print("Five is greater than two btw!")
x = 5
y = "This is y"
z = 69420
print(x)
print(y)
print(z)
a = str(3)
b = int(3)
c = float(3)
print(a)
print(b)
print(c)
e = "Python is "
f = "awe... |
164e6ece6af8f27d2f6154414be81e602fc2c53b | Anushadsilva/python_practice | /List/list.pg5.py | 489 | 4.21875 | 4 | '''Write a Python program to extract specified size of strings from a give list of string values. Go to the editor
Original list:
['Python', 'list', 'exercises', 'practice', 'solution']
length of the string to extract:
8 '''
#Solution:
if __name__ == '__main__':
list1 = ['Python', 'list', 'exercises', 'practice', 's... |
1830fad14cd2a6cc01e23b3edda6b8e6194df6af | Anushadsilva/python_practice | /Functions/func_pg7.py | 341 | 3.921875 | 4 | #Write a Python function that takes a list and returns a new list with unique elements of the first list.
def my_rtn():
my_list = [1,2,3,3,3,3,4,5]
nw_list = []
for x in my_list:
if not x in nw_list:
nw_list.append(x)
return nw_list
if __name__ == '__main__':
nw_lst = my_rtn()... |
33493606a7c784467d5a56d20ee49df3f50cfdf8 | Anushadsilva/python_practice | /Sets/set_py10.py | 163 | 3.890625 | 4 | #Write a Python program to remove all elements from a given set.
if __name__ == '__main__':
set_x = set([1, 2, "hello", 9])
set_x.clear()
print(set_x) |
e6e3fecae85caf717dd594e94096a717e9cd16b4 | Anushadsilva/python_practice | /dictionary/dict_py6.py | 575 | 4.125 | 4 |
'''Write a Python program to count the frequency in a given dictionary.
Original Dictionary:
{'V': 10, 'VI': 10, 'VII': 40, 'VIII': 20, 'IX': 70, 'X': 80, 'XI': 40, 'XII': 20}
Count the frequency of the said dictionary:
Counter({10: 2, 40: 2, 20: 2, 70: 1, 80: 1})'''
#Solution
if __name__ == '__main__':
dict1 = ... |
d68786a9942542808767b47b11919d0f7f7eaa6a | Anushadsilva/python_practice | /Functions/func_pg3.py | 305 | 4.28125 | 4 | #Write a Python function to find the Max of three numbers
def mx(x,y,z):
return max(x,y,z)
if __name__ == '__main__':
a = int(input("Enter the first number"))
b = int(input("Enter the second number"))
c =int(input("Enter the third number"))
print("max of the given numbers is: ", mx(a,b,c))
|
d48b459a1b24001717169e114eb786e1cddf3e73 | HoangQuyla/hangman | /test.py | 2,971 | 4.0625 | 4 | import unittest
import main
class TestGame(unittest.TestCase):
#TEST UNIT INPUT IN LOWER CASE RETURN TRUE
def test_input(self):
result = main.hang('the sky is blue')
self.assertTrue(result)
#TEST UNIT INPUT RETURN FALSE BECAUSE THE WORD IS NOT IN LOWER CASE
def test_input... |
d65cff9692ed861eb48f5dfed7774226c621e41f | james-norcross/PE_P45_TriPentHexNumbers | /PE_P45.py | 719 | 3.71875 | 4 | ## Author: James Norcross
## Date 2/19/15
## Finds the first Triangular of index greater than 285 which is also
## Pentagonal and Hexagonl
import math
def isPentagonal(num):
n = (math.sqrt((24 * num) + 1) + 1)/6
if(n == int(n)):
return True
else:
return False
def getTriangleNumber(n):
... |
696dd183216393e16af61aaf9bb6e67d1613611d | KHilse/python-hangman | /hangman.py | 2,979 | 3.671875 | 4 | import random
# Print Intro and Instructions
print("*** HANGMAN ***")
print("\nGuess letters one at a time and try to solve the phrase!")
print("Enter '1' to attempt to solve")
# Define hangman images
hangman = [
" _____\n \ |\n \ |\n \|\n |\n |\n_________",
" _____\n O \ |\n \ |\n ... |
44e534dfab096d6dd2c3e479aebc4ce298fb8c58 | RennoRis/uas2 | /package/Pembayaran.py | 3,098 | 3.609375 | 4 | def spp() :
bulan = int(input("\n\t Jumlah bulan yang di bayar = "))
bulan = float(bulan)
total = 350000 * bulan
print("***************************************")
print("\tTotal bayar spp Rp. 350.000 " , bulan ," = Rp. ",total)
def uas() :
matkul = int(input("\n\t Jumlah mata kuliah = "))
ma... |
c53cdb4bfe94ea9c7e6e73aeaf6037bf23a8d78f | josegerar/ciscocourse | /practica_modulo/module.py | 1,516 | 4.0625 | 4 | # module.py
# !/usr/bin/env python3
""" module.py - an example of Python module """
__counter = 0
def suml(list):
global __counter
__counter += 1
sum = 0
for el in list:
sum += el
return sum
def prodl(list):
global __counter
__counter += 1
prod = 1
for el in list:
... |
d17acec1e56841be1c5c924b26cbd8727aea60c8 | VroomFondell/pythonCode | /MadLib.py | 1,705 | 3.796875 | 4 | # Derek Sleeper, HW1, build sample one, 4/5/16
# This program will run the user through one MadLib
# style word game one time.
# The original story was this:
# The wombat crept through my living room.
# It stopped suddenly to listen.
# Just then, a beligierent Yokel came bursting onto the scene!
# "Where is my collect... |
579d6046604626afd901e8885bcce6de1a8fb09c | SinghReena/TeachPython3 | /SayNamesMultipleTimes.py | 591 | 4.21875 | 4 | # SayNamesMultipleTimes.py - lets everybody print their name on the screen
# Ask the user for their name
name = input("Can I know your name please: ")
# Keep printing names until we want to quit
while name != "":
# Print their name 35 times
for x in range(35):
# Print their name followed by a spa... |
a965fd20a0bada940bc4638e58e27ce20852b4d4 | michelpf/desafios | /strings/string_justify.py | 5,856 | 4.21875 | 4 | import traceback
def truncate_clean(text, init, max_char_line_m, text_justified, max_char_line, justification=False):
'''
Function to truncate a given text when the boundary end is a space character.
:param str text:
Text value.
:param str init:
Init index, position to start the analysi... |
e388787af733180e18e76ae6e51edb20d1149ef6 | ChandlerMoeller/FibonacciAlgorithmComparison | /Fibonacci.py | 2,331 | 3.8125 | 4 | import sys
import time
sys.setrecursionlimit(10000)
FibCounter = 0
DynamicFibCounter = 0
Table = {}
OptDynamicFibCounter = 0
OptDynamicFibCache = 0
def Fibonacci(value):
global FibCounter
if value is 1:
return 1
elif value is 0:
return 0
else:
FibCounter += 1
return(Fibonacci(value-1) + Fibonacci(value... |
8d492a9376bac8507bc05db338f6e28a72d690a0 | LaurentVeyssier/Show-me-the-data-structures | /problem3.py | 7,114 | 3.734375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Dec 14 02:28:57 2020
@author: lveys
"""
import sys
from collections import Counter
import random
# class for tree node structure
class Node:
def __init__(self, freq, char = None):
self.freq = freq
self.char = char
self.left = None... |
e8112fe27041e5a43c6d569cd8f473a347fb576e | gougoudata/vaspgrid | /enterfi.py | 246 | 3.65625 | 4 | import sys, os
def enterfi(prompt=""):
while True:
filename = raw_input(prompt+"\t").strip()
if os.path.exists(filename):
break
else:
print "File does not exist. Try again:"
return filename
|
8b290bbce3375044b8b46b0c9ec06d705264fce4 | farinfallah/Python-for-Beginners | /Week2/guessNumber.py | 291 | 3.5 | 4 | #Farinaz Fallahpour
import random
flag = True
start = 1
end = 99
while flag:
guess = random.randint(start, end)
print(guess)
bkm = input()
if bkm == 'k':
end = guess
elif bkm == 'b':
start = guess
elif bkm == 'd':
flag = False
print("You win!")
|
d2c261da77f2afa56af0af04d80c6b3df946b3e7 | farinfallah/Python-for-Beginners | /Week3/isPalindrome.py | 310 | 3.984375 | 4 | #Farinaz Fallahpour
def isPalindrome(x):
x = x.lower()
length = len(x) // 2
count = 0
while count < length:
if x[-1-count] != x[count]:
return False
count +=1
return True
string = input()
if isPalindrome(string):
print("palindrome")
else:
print("not palindrome"... |
d9dc4fcb508630233d402b3025e4ab08a8235a7f | farinfallah/Python-for-Beginners | /Week5/source.py | 3,153 | 3.875 | 4 | #Farinaz Fallahpour
import csv
from statistics import mean
import collections
def calculate_averages(input_file_name, output_file_name):
with open(output_file_name, 'w') as writefile:
with open(input_file_name, 'r') as readfile:
lines = csv.reader(readfile)
for line in lines:
... |
dbc2b1cda44f300702613c1a2f5f39987e65b9df | SiddhantBhardwaj2018/ISTA-130- | /pig.py | 3,666 | 4.09375 | 4 | '''
Author: Sriharsha Madhira
Collab: Siddhant Bhardwaj
Date: Today
Class: ISTA 130
Section Leader: Erica Cohen
Description:
The given program is a 2 player game of pig. the players roll a
dice and get values between 1 and 6. Ech player starts with a score of 0
and each dice roll other than 1 is added to the players'... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.