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 |
|---|---|---|---|---|---|---|
cb73dc9fb4d0ce82f696e03f79b436a86e9308fa | sashkent3/schemes_interpreter | /_sasha.py | 1,158 | 3.71875 | 4 | def calculator(input_string):
return no_scope_calculator(list(map(map_light_int, input_string.split())))
def map_light_int(input_string):
try:
return int(input_string)
except ValueError:
return input_string
def no_scope_calculator(main_list):
symbol_index = 0
while main_list[symb... |
708934baae7b7922bcc17437c73c48c58a076696 | bell-liang/algorithm-for-numerical-analysis | /非线性方程.py | 2,700 | 3.6875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Dec 8 19:46:26 2019
@author: bell liang
"""
# 解非线性方程组之二分法、牛顿法、简化牛顿法、牛顿下山法、重根情形下的牛顿法
import math
def caculate_dichotomy(f, a, b, limit):
y_a = f(a)
x_mid = (a + b) / 2.
y_mid = f(x_mid)
while y_mid != 0 and abs(a - x_mid) > limit:
if y_mid * y_a < 0:... |
37f69445c760dc4e8d83e8dc138e73c0b8a8eb08 | elwerro/predictCreditCardFraudUsingLogisticRegression | /predictCreditCardFraudUsingSciKitLearnLogisticRegression.py | 5,584 | 3.84375 | 4 | #!/usr/bin/env python
# coding: utf-8
# Dependencies
# In[1]:
# https://www.data-blogger.com/2017/06/15/fraud-detection-a-simple-machine-learning-approach/
#install pandas and scikit learn versions in Jupyter notebook for this demo from
#!pip install seaborn==0.9.0
get_ipython().system('pip install pandas==0.19.2 s... |
19da73ec6b8a0094bf9f607eb6102781c6147ed8 | Lchet/TensorFlow_Intro | /Tensorflow_flow.py | 11,894 | 3.625 | 4 | # -*- coding:utf-8 -*-
# @Filename: Tensorflow_flow.py
# Created on: 09/10/21 10:33
# @Author: Luc
import numpy as np
import pandas as pd
import tensorflow as tf
import sys
import matplotlib.pyplot as plt
import datetime
from sklearn.preprocessing import MinMaxScaler, StandardScaler, LabelEncoder
from sklea... |
911ce4c5e924323bafc68f28bbfc4ef3d5db4937 | ShashankRaturi/Python-Projects | /1_Coffee Machine/Main.py | 2,867 | 3.921875 | 4 | def coffeeMachine():
MENU = {
"espresso": {
"ingredients": {
"water": 50,
"coffee": 18,
},
"cost": 1.5,
},
"latte": {
"ingredients": {
"water": 200,
"milk": 150,
... |
557ba821afce273ded46545d7d82c4b5322a1c32 | giokro/Advanced-Python | /Homework1/quadratic-equation-giokro/build/lib/quadratic_equation/Quad.py | 382 | 3.984375 | 4 | from math import sqrt
def Quad(a, b, c):
roots = []
D = (b*b)-(4*a*c)
print("D = ", D)
if D>0:
x1 = (-b + sqrt(D))/(2*a)
x2 = (-b - sqrt(D))/(2*a)
print("x1 =", x1, " x2 =", x2)
roots.append(x1)
roots.append(x2)
return roots
elif D==0:
x = -b/(2*a)
print("x =", x)
roots.append(x)
retu... |
bacf932168b2677a71b83e72afef082ae8445afb | panthercoding/Summer_Lecture7 | /scatter2.py | 387 | 3.90625 | 4 | #Python Libraries
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0,10,30)
y1 = np.sin(x)
y2 = np.cos(x)
#Without Legend
#plt.scatter(x,y1,marker="o",c="red",s=40,alpha=0.5)
#plt.scatter(x,y2,marker="o",c="purple",s=40,alpha=0.5)
#With Legend
#plt.scatter(x,y1,marker="o",c="red",s=40,alpha=0.5)
... |
2a0efd155787e3a2e1087df00a05956b7f0591e6 | Calendis/3d-roller | /Roller.py | 501 | 3.6875 | 4 | class Roller():
"""A point with some methods to do with position"""
def __init__(self, x, y):
super(Roller, self).__init__()
self.x = x
self.y = y
def get_x(self, offset=0):
return self.x+offset
def get_y(self, offset=0):
return self.y+offset
def get_pos(self):
return((self.get_x(), self.get_y()))
... |
722dfbc113161177153ad77d0e9cfd3b5baf25c9 | eruns/gophish | /test_tkinter.py | 3,875 | 4.03125 | 4 | < Object-Oriented Programming | GUI Applications
Jump to navigation
Jump to search
"""This program demonstrates object-oriented Python GUI using tkinter.
Input:
None
Output:
Window canvas
Global variables:
root (tkinter.root): top-level window
canvas (tkinter.canvas): canvas
References:
https:... |
806c2347a9aad5e057bf56e46fc7ca4def3e0a05 | kumawat0008/debug-python | /main.py | 1,044 | 3.6875 | 4 | import time
from timeloop import Timeloop
from datetime import timedelta
import threading
class MyThread(threading.Thread):
pass
def fibonacci(n):
# First Fibonacci number is 0
if n == 1:
return 0
# Second Fibonacci number is 1
elif n == 2:
return 1
else:
return fibon... |
1b081dfc115a840dde956934dbab0ee5f3b41891 | harshaghub/PYTHON | /exercise.py | 457 | 4.15625 | 4 | """Create a list to hold the to-do tasks"""
to_do_list=[]
finished=False
while not finished:
task = input('enter a task for your to-do list. Press <enter> when done: ')
if len(task) == 0:
finished=True
else:
to_do_list.append(task)
print('Task added')
"""Display to-... |
bdbeac2a359480c53f55ecc4cda1a415998cddba | Cochleor/HSE_bioinformatics_2021 | /seminar2/classwork.py | 1,586 | 3.953125 | 4 | '''
Что такое функции
'''
def function_name(x, y):
a = x + y
b = x - y
return a*b
x = 634
y = 2534
result = function_name(5, 6)
print(result)
print(x)
def insertion_sort(x):
for i in range(len(x)):
min_idx = i
for j in range(i + 1, len(x)):
if x[j] < x[min_idx]:
... |
3c5008b1c6d9af8777a8e214e6eebe0d1ead3f2d | KrugerDaniel/PI_202_Blitzkrieg | /Testes de aprendizado/Aprendendo arcade/teste.py | 1,953 | 3.796875 | 4 | """Comentários:
Neste arquivo utilizei para treinar os conceitos básicos de abrir a janela e criar algumas formas
Feito por: Daniel Krüger
"""
# Importando a biblioteca arcade
import arcade
# Definindo constantes da janela
SCREEN_WIDTH = 1200
SCREEN_HEIGHT = 800
SCREEN_TITLE = "Aprendendo"
class Janela(... |
b22ee401bfd88b9173c234e3aeaca434faf451f7 | grunthos81/x | /p1.py | 163 | 3.609375 | 4 | import time
s = time.time()
total = 0
for i in range(1, 1000):
if i % 3 == 0 or i % 5 == 0:
total += i
t = time.time()
print(total, t-s)
|
69f98809cb1ee01b187225aa0e039ad113a650f4 | ciblois/Hello-Python | /6.Learn Python - Free Interactive Python Tutorial - Exercise.py | 1,532 | 3.984375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Mar 18 15:50:54 2020
@author: Cinthya
"""
print("Loop through and print out all even numbers from the numbers list in the same order they are received. Don't print any numbers that come after 237 in the sequence.")
numbers = [
951, 402, 984, 651, 360, 69, 408, 319... |
49fe0610d6f9479cec01f5ec1724df2797b7df59 | sid-jain5/Machine-Learning | /Supervised Algorithms/Regression/Linear-Regression/simple_linear_regression.py | 1,420 | 3.546875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun May 6 20:04:45 2018
@author: siddhant
"""
#Simple linear Regression
#Importing Libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
#Imporing the Dataset
dataset = pd.read_csv('Salary_Data.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[... |
dd16aaaed1ae79c0e3c11defe8c2bbc3d073e8b2 | haiconmeo/test_paracel-_bai2 | /Longest Word in Dictionary.py | 410 | 3.5625 | 4 | class Solution(object):
def longestWord(self, words):
"""
:type words: List[str]
:rtype: str
"""
kq = ""
wordset = set(words)
for word in words:
if len(word) > len(kq) or len(word) == len(kq) and word < kq:
if all(word[:k] in wordse... |
1e503308a39bf605ae491406f4e66c67a562a5b8 | joseck12/blog | /tests/test_user.py | 701 | 3.578125 | 4 | import unittest
from app.models import User
from app import db
#the setup method creates an instances of our user
class UserModelTest(unittest.TestCase):
def setUp(self):
self.new_user = User(username = 'joseck',password = 'qwerty', email = 'jogachi4@gmail.com')
def save_user(self):
db.sessi... |
38e1f1dbc8fdd62d69a72e363c0578a28c528f47 | Hakjun14/Haar_transform | /Haar_transform/pair_diff.py | 203 | 3.578125 | 4 | def pair_Diff(input):
half = int(len(input) / 2)
output = []
i = 0
while i < half :
output.insert(i, (input[2 * i] - input[2 * i + 1]) / 2)
i += 1
return output |
0744ae02f3745c24bfde953f978f68e337a1dec5 | git-kth/Programmers_Practice | /level1/ex20.py | 190 | 3.5625 | 4 | # level1 - x만큼 간격이 있는 n개의 숫자
def solution(x, n):
answer = []
start = x
for _ in range(n):
answer.append(start)
start += x
return answer
|
229194b7a8960adf5443c12072f061e6d83fb70a | ayushsrivast/AIML-CHATBOT | /frontend.py | 2,039 | 3.734375 | 4 | import tkinter as tk
from tkinter import font
import aiml
import os
#to define the height and width of the UI window
HEIGHT = 479
WIDTH = 479
#AIML usage to obtain reply from the bot
kernel = aiml.Kernel()
#to not have to train AIML files everytime we run the program, this if-else statements overpasses the creatio... |
5e1919bbcbdc15946feaf0dc2c5902b0c6b3056c | Kinshuk-Goel/dodge-pygame | /not_working.py | 1,477 | 3.734375 | 4 | # Import module - pygame
import pygame
# Import pygame.locals | Detect hardware input from user:
from pygame.locals import (
K_UP,
K_DOWN,
K_LEFT,
K_RIGHT,
K_ESCAPE,
KEYDOWN,
QUIT,
)
# Define screen width and height
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
# Define a player object by exten... |
eb5e4e87b0f03b23a6a006b0f2a33d7b6a2acf6d | AlexLUdo/HWK1 | /bornyearforewer.py | 366 | 3.859375 | 4 |
while True:
year_of_b = int(input('Дружище, ану-ка, подскажи-ка год рождения Александра Сергеевича Пушкина: '))
if year_of_b == 1799:
print("Слава Богу! Поздравляю! ВЕРНО. :)")
break
print('Нет :(... еще разик попытаемся...') |
06aa33fcc532ee2fc94ace401366b72f6034d19e | StevenJokess/py_leetcode | /142.linked-list-cycle-ii.py | 1,321 | 3.640625 | 4 | # coding=utf-8
'''
version:
Author: StevenJokess https://github.com/StevenJokess
Date: 2020-10-10 16:51:49
LastEditors: StevenJokess https://github.com/StevenJokess
LastEditTime: 2020-10-10 17:20:31
Description:
TODO::
Reference:
https://leetcode.com/problems/linked-list-cycle-ii/discuss/358863/Python-97.29-Faster
ht... |
da473a2ad0508906f8c27aa1a3cd15c8b8da24b7 | StevenJokess/py_leetcode | /15.3-sum.py | 1,501 | 3.59375 | 4 | # coding=utf-8
'''
version:
Author: StevenJokess https://github.com/StevenJokess
Date: 2020-10-10 10:21:05
LastEditors: StevenJokess https://github.com/StevenJokess
LastEditTime: 2020-10-10 11:34:14
Description:
TODO::
Reference:D:\onedrive\leetcode\Python\1.two-sum.py
https://leetcode.com/problems/3sum/discuss/7392/... |
c3ffae5b775ff79b82cefb8de5d43ebba30541a3 | NikhilDusane222/Python | /DataStructurePrograms/hashTable.py | 901 | 3.75 | 4 | #Class Hashtable
class HashTable():
#initialize slot and value if table
def __init__(self):
self.size=11
self.slots=[None]*self.size
#put the element in slot
def put(self,key):
hashValue=key%self.size
if self.slots[hashValue]==None:
self.slots[hashValue]=key
... |
4fa45f63c6bbadc3ab8c3490058f3ac239648957 | NikhilDusane222/Python | /DataStructurePrograms/palindromeChecker.py | 965 | 4.1875 | 4 | #Palindrome checker
#class Dequeue
class Deque:
def __init__(self):
self.items = []
def add_front(self, item):
self.items.append(item)
def add_rear(self, item):
self.items.insert(0, item)
def remove_front(self):
return self.items.pop()
def remove_rear(self):
... |
d11e4e8e0513beabbd3c68e23f2f59926e632887 | mikikop/DI_Bootcamp | /Week_5/day_1/exercises/Ninja/codeninja.py | 1,249 | 3.875 | 4 | class Phone:
"""docstring for Phone"""
def __init__(self, number):
super(Phone, self).__init__()
self.number = number
self.call_history = []
self.messages = []
self.message_dict = {}
def call(self, other_phone):
self.call_history.append(other_phone)
... |
b4eed1eb0fe9593af6778319a54c81bcf5e32e23 | mikikop/DI_Bootcamp | /Week_4/day_3/exercises/XP/codexp.py | 3,853 | 3.90625 | 4 | #Ex1
# keys = ['Ten', 'Twenty', 'Thirty']
# values = [10, 20, 30]
# my_dict = dict(zip(keys,values))
# print(my_dict)
#Ex2
# family = {
# "rick": 43,
# 'beth': 13,
# 'morty': 5,
# 'summer': 8
# }
# cost_pers = 0
# total_cost = 0
# for name,age in family.items():
# if age>=12:
# cost_pers = 15
# total_co... |
f4bd846af010b1782d0e00da64f0fdf4314e93ba | mikikop/DI_Bootcamp | /Week_4/day_3/daily/codedaily.py | 700 | 4.1875 | 4 | choice = input('Do you want to encrypt (e) or decrypt (d)? ')
cypher_text = ''
decypher_text = ''
if choice == 'e' or choice == 'E':
e_message = input('Enter a message you want to encrypt: ')
#encrypt with a shift right of 3
for letter in e_message:
if ord(letter) == 32:
cypher_text += chr(ord(letter))
else:... |
25e86fc49773801757274ede8969c27c68168747 | mikikop/DI_Bootcamp | /Week_4/day_5/exercises/Class/codeclass.py | 1,542 | 4.25 | 4 | # 1 Create a function that has 2 parameters:
# Your age, and your friends age.
# Return the older age
def oldest_age(my_age,friend_age):
if my_age > friend_age:
return my_age
return friend_age
print(oldest_age(34,23))
# 2. Create a function that takes 2 words
# It must return the lenght of the longer... |
f8a4c86612482ab6b3ed6083decef121a856ffc9 | kenmcdowell/02.TexturePainter-ken | /texture_painter.py | 3,684 | 3.6875 | 4 | '''Renders text from a CSV file to textures
and applies them to multiple objects.
Use snippets...
import os, sys; sys.path.append(os.path.dirname(bpy.data.filepath)); import texture_painter
import importlib; importlib.reload(texture_painter); texture_painter.go()
import codecs
codecs.open('backers_10.csv', 'r', 'utf-8... |
fbe8763d022dc8aff2ecfde7da9090fbb3f580d3 | djtorel/Sprint-Challenge--Algorithms | /Short-Answer/exercise_2.py | 626 | 3.78125 | 4 | import math
OPTIMAL_FLOOR = 8
def optimal_breaking_floor(top_floor):
return optimal_floor(top_floor, 0)
def optimal_floor(upper_bound, lower_bound):
if upper_bound == lower_bound:
return upper_bound
half_upper_lower = math.ceil((upper_bound - lower_bound) / 2)
if is_egg_broken(upper_bound ... |
410c41c14b184ad8e24b6d4070825f9043c0a7f8 | hray0903/AutomateTheBoringStuffWithPython | /collatz.py | 220 | 3.5625 | 4 | def collaz():
print("整数を入力してください")
try:
co = int(input())
except ValueError:
pass
if co % 2:
return co * 3 + 1
else:
return co / 2
print(collaz()) |
898087e2ab361e36a323025fdf8cb6da43c3d0f9 | AlexS1981/lup-lessons-ht | /lesson3.1-HT2.py | 31,227 | 3.71875 | 4 | # # 1. У вас есть массив чисел. Напишите три функции, которые вычисляют
# # сумму этих чисел: с for-циклом, с while-циклом, с *рекурсией.
list_id = [1, 10, 2, 9, 3, 8]
# # Скриптом -----------------
def func_sum1(list_a):
print('Скриптом: sum_1 =', sum(list_a[0:])) # Встроенная ф-ция суммирует срез всех эл-... |
d07e90653d51a8a29aff173eff31f7011515889c | LStokes96/Python | /Code/cotd_01.07.py | 256 | 3.65625 | 4 | def oddSquare(odd_list):
for x in range (len(odd_list)):
if odd_list[x] % 2 == 0:
odd_list[x] = odd_list[x]
else:
odd_list[x] = odd_list[x] * odd_list[x]
return odd_list
print(oddSquare([1,2,3,4,5,6,7,8,9])) |
aff2134f2e4a76a59dc2d99184a548e17f290de0 | LStokes96/Python | /Code/teams.py | 945 | 4.28125 | 4 | #Create a Python file which does the following:
#Opens a new text file called "teams.txt" and adds the names of 5 sports teams.
#Reads and displays the names of the 1st and 4th team in the file.
#Create a new Python file which does the following:
#Edits your "teams.txt" file so that the top line is replaced with "This ... |
4845d004d2ae905a010115cf02d57b1397ba3009 | LStokes96/Python | /Code/cotd_09.06.py | 253 | 3.5625 | 4 | def alpha(word_list):
list = word_list.split(',')
sorted_list = sorted(list, key=str.lower)
string1 = ""
for i in sorted_list:
string1 += i + ","
return string1
word_list = "this,About,could,Zoo,jUMP"
print(alpha(word_list)) |
40b176d3e7abfe685472e7db13f3fbca9c2ae12c | LStokes96/Python | /Code/cotd_10.06.py | 292 | 4 | 4 | def zip(string1,string2):
list1 = list(string1)
list2 = list(string2)
i = 0
while i < len(list1):
n = 0
while n < len(list2):
list2.insert(n,list1[i])
i += 1
n += 2
return ''.join(list2)
print(zip("String","Fridge"))
|
ed8db7aa2814d11a1dc93b4b31835fcaa44e34f4 | fatinnabila00/BestFlight | /Word_Frequency.py | 13,662 | 3.890625 | 4 | # HK article 1
with open('hongkong1.txt', 'r') as f:
p = f.read() # p contains contents of entire file
# logic to compute word counts follows here...
words = p.split()
wordCount = len(words)
print("Hong Kong article 1 - The total word count is:", wordCount)
# HK article 2
with open('h... |
dc0065ff5fbd355e069942bf51f4c1232d471031 | pratishthasingh1/Phanalytics | /qualifyingoffer.py | 1,157 | 3.5625 | 4 | #import dependencies
import bs4, requests
#using requests library, we can get the URL
url = 'https://questionnaire-148920.appspot.com/swe/data.html'
res = requests.get(url)
# using html.parser we can now look for the class of 'player-salary' to use the relevant data
soup = bs4.BeautifulSoup(res.text, 'html.parser')... |
34ebb9c67e57141525a493cc326c3dfd63a0d2e1 | cnspaulding/PFB_problemsets | /Python4PS/ps4q10.py | 299 | 3.859375 | 4 | #!/usr/bin/env python3
import sys
start = int(sys.argv[1])
end = int(sys.argv[2])
#num = start
while start <= end:
if start%2==0:
print(start)
start += 1
#this way is not fully working.
#numbers= range(start,end)
#for number in numbers:
# print(number)
# num += 1
#(num[number1:number2])
|
2123524241ccf23da580a2026ce7594c7c8cd824 | cnspaulding/PFB_problemsets | /Python8PS/ps8q1.py | 1,422 | 3.546875 | 4 | #!/usr/bin/env python3
import re
A_count=0
T_count=0
G_count=0
C_count=0
fasta_dict = {}
fasta_file = open('Python_08.fasta', 'r')
#open file, save gene name in one list and seq in another.
for line in fasta_file:
line=line.rstrip()
#sees lines that start with >, pulls then out, removes the >m and splits the nam... |
94221ad83e62335bd12d6a19bd6fed007946e346 | BrunoDeNadaiSarnaglia/CSAir | /Route.py | 873 | 3.96875 | 4 | __author__ = 'Bruno'
class Route():
def __init__(self, code_of_cities, distance):
"""
initiates values for self
:param code_of_cities: list containing the TWO cities of this route
:param distance: distance of the route
:return:
"""
self.code_of_cities = code... |
5e1e5c71e31e84bba5f0c0e71c1af971603e9915 | BrunoDeNadaiSarnaglia/CSAir | /text_interface.py | 8,103 | 3.734375 | 4 | # from Statistics import longest_flight_in_the_network
import webbrowser
from Statistics import longest_flight_in_the_network, shortest_flight_in_the_network, average_distance_of_all_flights, \
biggest_city_served_by_CSAir, smallest_city_served_by_CSAir, average_population_of_all_cities, \
cities_by_continent_s... |
f40dabb9150299f4706d861b67d3f50311e7adf5 | Tyler-Applegate/numpy-pandas-visualization-exercises | /numpy_exercises.py | 9,412 | 4.03125 | 4 | # Exercises
# In your numpy-pandas-visualization-exercises repo, create a file named numpy_exercises.py for this exercise.
import numpy as np
# Use the following code for the questions below:
a = np.array([4, 10, 12, 23, -2, -1, 0, 0, 0, -6, 3, -7])
# How many negative numbers are there?
len(a[a<0])
# 4 negative n... |
899edd865eeb5c82631921f19621f426031184f5 | dave31415/brunodb | /brunodb/csv_writer.py | 300 | 3.515625 | 4 | from csv import DictWriter
def write_csv(filename, stream):
fp = open(filename, 'w')
first = next(stream)
fieldnames = list(first.keys())
writer = DictWriter(fp, fieldnames=fieldnames)
writer.writeheader()
writer.writerows(stream)
fp.close()
|
dc0f41022beddc6d683760a6d33f3f7db0861160 | shengxu1/hockey_game | /util.py | 6,186 | 3.609375 | 4 |
import pygame
import math
import settings
from enum import Enum
class Side(Enum):
LEFT = "left"
RIGHT = "right"
class Circle(object):
# (x, y) is coordinate of the circle center, r is radius
def __init__(self, x, y, r):
self.x = x
self.y = y
self.r = r
class Point(object):
def __init__(self, ... |
8c39c56759039bf5bcacd3b2e7d9f8245997e39e | gavinsykes/project-euler | /problem_14/problem_14.py | 1,407 | 3.65625 | 4 | import argparse
import sys
sys.path.append('/home/gavin/project-euler')
import pyfuncs
challenge = 'Which starting number, under {}, produces the longest chain in the Collatz problem?'
parser = argparse.ArgumentParser(description = 'Which starting number, under x, produces the longest chain in the Collatz problem?')... |
2f28be5c8f041f83e137ff0494b4ee86b1c61c7b | gavinsykes/project-euler | /problem_15/problem_15.py | 1,519 | 3.625 | 4 | import argparse
import sys
sys.path.append('/home/gavin/Documents/Git Repositories/project-euler')
import pyfuncs
challenge = 'Starting in the top left corner of a 2x2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.\n\nHow many such routes are there thro... |
149e6802e0f3ab8a6caa08dd3b87a074cd584ab0 | bugos/algo | /Facebook Hackercup/2017 Qualification/progress_pie.py | 722 | 3.515625 | 4 | '''
|C| BugOS
https://www.facebook.com/hackercup/problem/1254819954559001/'''
import math, fileinput
cycleX = cycleY = cycleRadius = 50
def getColour(progress, X, Y):
X -= cycleX #axes on the center of the cycle(50, 50)
Y -= cycleY
inCircle = cycleRadius**2 >= X**2 + Y**2
atan = math.atan2(Y, X)
if atan < 0:... |
a11bc3f4daaceb44efb680bb6d4e76f82d175942 | manas-verma/MasterMind | /MasterMind.py | 2,525 | 3.703125 | 4 | from random import random
import argparse
import sys
def main(*args):
parser = argparse.ArgumentParser(description="Play Mastermind")
parser.add_argument('-a', '--attempts', type=int,
help='the number of attempts', default=20)
parser.add_argument('-c', '--code', type=str,
... |
5b5889f06217a4af1af9f0859b1a3ce1fbb46663 | NyleSiddiqui/MNIST-Neural-Network-From-Scratch | /venv/activations.py | 2,038 | 3.59375 | 4 | import numpy as np
class Softmax:
# Forward pass
def forward(self, inputs):
# Remember input values
self.inputs = inputs
# get unnormalized probabilities
exp_values = np.exp(inputs - np.max(inputs, axis=1, keepdims=True))
# normalize them for each sample
probabili... |
0af05405f63c01f50206600ba77829913d52dc36 | i-me/Python2014 | /10.11.py | 244 | 3.703125 | 4 | #-*- Coding:iso8859-15 -*-
phrase="Bonjour je suis à la recherche d'un chien nommé Garis"
mot=""
chaine=[""]
i=0
for c in phrase:
if c==" " or c=="":
chaine.append("")
i+=1
else:
chaine[i]+=c
print(chaine)
|
86147b41f8b500838cad374d1e28784af9d35bf5 | i-me/Python2014 | /12.5.py | 1,179 | 3.71875 | 4 | import math
class Cercle(object):
"Cercles de taille variés"
def __init__(self, rayon=1):
self.rayon=rayon
def surface(self):
self.surface=math.pi*(self.rayon**2)
return(self.surface)
def affiche(self, donnee):
return(round(donnee,2))
class Cylindre(Cercle):
"Cylindre... |
91cc72e0ce3c586c3390eba1621c5558430ae9c9 | i-me/Python2014 | /exemple_codecompact.py | 716 | 3.546875 | 4 | from tkinter import *
fen1= Tk()
#création de widgets Label(), Entry() et Checkbutton():
Label(fen1, text='Premier champ:').grid(sticky=E)
Label(fen1, text='Deuxième:').grid(sticky=E)
Label(fen1, text='Troisième:').grid(sticky=E)
entr1=Entry(fen1)
entr2 = Entry(fen1)
entr3=Entry(fen1)
entr1.grid(row=0, column=1)
ent... |
d1de30c06684bace8d77a5bf23e8286fd74866b2 | FL9661/Chap1-FL9661 | /Chap2-FL9661/Chap2-4.py | 1,639 | 3.84375 | 4 | print ("!!! Chapter 2.4 Variables !!!", "\n")
print ("2.4.1.6 - Variables - data-shaped boxes")
print ("a = 3.0")
print ("b = 4.0")
print ("c = (a ** 2 + b ** 2) ** 0.5)")
# ("c = ((\"a = 3.0 x 3.0\") + (\"b = 4.0 x 4.0\")) ** 0.5)")
# ("c = (9.0 + 16.0) ** 0.5")
# ("c = 25.0 ** 0.5")
print ("print (\"c =\", c)", "\... |
58d75067e577cf4abaafc6e369db8da6cf8e7df1 | FL9661/Chap1-FL9661 | /Chap3-FL9661/FL9661-Chap3-3.py | 2,254 | 4.5 | 4 | # F Lyness
# Date 23 Sept 2021
# Lab 3.4.1.6: the basics of lists #
# Task: use a list to print a series of numbers
hat_numbers = [1,2,3,4,5]
#list containing each number value known as an element
print ('There once was a hat. The hat contained no rabbit, but a list of five numbers: ', hat_numbers [0], hat_numbers [... |
0a303f610ef622fca25bb99eca67ff0f337241c7 | varma-shivani98/Python- | /python9.py | 298 | 3.625 | 4 | seq='AATTTGGGCCTGTAGCGTAGCCAAAGGGTACGTTAATGCCTGATCGT'
print(seq)
mRNA=' '
for i in seq:
if i=='A':
j='T'
elif i=='T':
j='U'
elif i=='G':
j='C'
elif i=='C':
j='G'
else:
print("It is not a base")
mRNA=mRNA+j
print(mRNA)
|
59155d5c560e507962407ef6f9763040148c0b9c | Ackerize/Codeforces | /339A.py | 143 | 3.640625 | 4 | s = input().split('+')
s.sort()
for i in range(len(s)):
if i < len(s) - 1:
print(s[i]+"+", end='')
else:
print(s[i])
|
6c68a4b129524de39ef050160decd697dfec5a86 | sigrunjm/Maximum-number | /maxnumb.py | 471 | 4.4375 | 4 |
num_int = int(input("Input a number: ")) # Do not change this line
# Fill in the missing code
#1. Get input from the user
#2. if number form user is not negative print out the largest positive number
#3. Stop if user inputs negative number
max_int = 0
while num_int > 0:
if num_int > max_int:
max_int = ... |
17fb418fa226818b770c2f55a7538a7017482253 | viktornham/LearningPy | /a2q4.py | 506 | 4 | 4 |
first1=ord(input("Starting letter: "))
first2=ord(input("Ending letter: "))
second1=int(input("Starting number: "))
second2=int(input("Ending number: "))
third1=ord(input("Starting letter: "))
third2=ord(input("Starting number: "))
counter=0
for S in range(first1, first2+1):
for M in range(secon... |
81200bbbead105b87af0c042f60b952969649c77 | yaseenshaik/python-101 | /loops_and_iterations.py | 512 | 3.859375 | 4 | nums = [1, 2, 3, 4, 5]
for num in nums:
print(num)
# break and continue
for num in nums:
if num < 3:
continue
elif num == 3:
print('Ayy')
break
print(num)
# range from 0 to x use range(x+1)
for i in range(10):
print(i)
# range from x to y use range x, y+1
for i in range... |
28962e9e8aaa5fb3ce7f67f8b4109c426fed0f65 | yaseenshaik/python-101 | /ints_floats.py | 539 | 4.15625 | 4 | int_ex = 2
float_ex = 3.14
print(type(float_ex))
# Float/normal division
print(3 / 2) # 1.5
# Floor division
print(3 // 2) # gives 1
# Exponent
print(3 ** 2) # 9
# Modulus
print(3 % 2) # 1
# priorities - order of operations
print(3 + 2 * 4) # 11
# increment
int_ex += 1
print(int_ex)
# round (takes a... |
f71f3456cb9340aed7a812774b6b4b2b0aa598f2 | hunter717177/Hunter-Python-Tutorial | /queue.py | 583 | 4.03125 | 4 | """Create Queue class"""
class Queue:
"""Creates Queue Class"""
def __init__(self):
self.store = {}
self.min = 0
self.max = 0
def enqueue(self, value):
"""adds to queue"""
self.store[self.max] = value
self.max += 1
def dequeue(self):
"""returns ... |
dae861a719ced79a05da501c28302a2452395924 | abercrombiedj2/week_01_revision | /lists_task.py | 493 | 4.4375 | 4 | # 1. Create an empty list called `task_list`
task_list = []
# 2. Add a few `str` elements, representing some everyday tasks e.g. 'Make Dinner'
task_list.append("Make my bed")
task_list.append("Go for a run")
task_list.append("Cook some breakfast")
task_list.append("Study for class")
# 3. Print out `task_list`
print(t... |
e828a19b351bf5f2daf60318dab482645e025253 | tslator/arlobot_tx2 | /arlobot_common/src/common/motion.py | 5,151 | 3.578125 | 4 | import math
from transforms import calc_vel_inc, normalize_vector
def uni2diff(v, w, L, R):
"""
Convert unicyle to differential
:param v: Linear velocity
:param w: Angular velocity
:param L: Wheel base (or track) width
:param R: Wheel radius
:return: left/right velocity
"""
#print... |
f63237832bed176ae6cd6f4e0c2613a23819d5e4 | krishnaml/mastering-python-for-data-science | /ch04 - Making sense of data through advance visualization.py | 8,515 | 3.59375 | 4 |
# coding: utf-8
# # Making sense of data through advance visualization
# In[3]:
get_ipython().magic(u'matplotlib inline')
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import pandas.tools.rplot as rplot
# ## Controlling the line properties of a chart
# Let create a simple line chart
# ... |
cf9c299e7a278696d6cd010bc578103e2f39bc06 | Marsel931Z/hiperskill | /banking.py | 5,669 | 3.65625 | 4 | import random
import sqlite3
conn = sqlite3.connect('./card.s3db')
cur = conn.cursor()
cur.execute('drop table card')
cur.execute("""CREATE TABLE IF NOT EXISTS card (
id INTEGER PRIMARY KEY AUTOINCREMENT,
number TEXT,
pin TEXT,
balance INTEGER DEFAULT 0);""")
conn.commit()
class Menu... |
67f78c3fe9c99730b1cf6c0057b70120b9ff7edc | augfranco/EP2 | /inspermon.py | 1,812 | 3.578125 | 4 | import random
import json
with open("Inspermon.json") as arquivo:
lista_de_inspermon = json.load(arquivo)
t=0
print("Inspèrmon")
nome_personagem = input("Comece seu jogo escolhendo o nome de seu personagem: ")
passeie_durma = input("{}, você deseja: Passear(P) Dormir(D) Ver o insperdéx(I) ".format(nome_persona... |
4453699ee5736e5e3179e08fed78f6909b839c3e | AlifArifin/Seleksi-2018 | /Tugas1/src/scrapper.py | 7,413 | 3.5 | 4 | from bs4 import BeautifulSoup
from urllib.request import urlopen
import json
import re
import time
import pandas
# to check whether url is a fauna/flora page or not
def isFloraFauna(url) :
try :
page = urlopen(url).read()
soup = BeautifulSoup(page, 'html.parser')
# every flora and fauna ha... |
3e4c56259b4210e77a830b4c837bc9eee4f88fe3 | nanyangeva/COMP7702_AI | /assignment1/node.py | 9,434 | 3.59375 | 4 | class Node():
def __init__(self, state, parent=None, action=None, depth=0):
self.state = state # a board
self.parent = parent # parent node, a NODE! not just a matrix.
self.action = action # The one that led to this node (useful for retracing purpose)
self.depth = depth # depth o... |
eddfe3460290adb0f33c23ae338aad9fa9281967 | chibeze01/SRPN | /SRPN.py | 12,006 | 3.53125 | 4 | operand = list() # this is the number stack
operator_buffer = list() # this is called a buffer not a stack becaue it hold one value for less than 0.5 seconds at any given time
operator = ['d','-','+','*','/','%', '^'] # this is the precedence order with d[0] at the buttom and powers at the top[6]
r = [ 1804289383,8... |
7c8a2160987dcb024b5c1f2efdbd7ec22e5c4b92 | DxfAndCxx/upplay | /helper/poker.py | 1,322 | 3.5 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import random
"""
suit - 牌面花色:
['h', 'hearts', 'd', 'diamonds', 's', 'spades', 'c', 'clubs']
值对应红桃,方块,黑桃,梅花, 'h', 'd', 's', 'c' 是缩略写法
point - 牌面点数:
['A', 2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'O', 'JOKER']
"""
__joker__ = 'JOKER'
__poi... |
2691f81983049181cc695deea83cb647dddd60f3 | hmcc/spam-classifier | /tools/extract_email_text.py | 1,004 | 3.75 | 4 | from email import message_from_file
from sys import stdin
def get_payload(msg):
"""
Get the payload from the Message.
email.message.Message.get_payload will be a list of Message objects when
is_multipart() is True, or a string when is_multipart() is False
https://docs.python.org/3.4/library/email... |
a430e9bb28ae56dfe1309b2debbfff29b73a41b8 | milincjoshi/Python_100 | /95.py | 217 | 4.40625 | 4 | '''
Question:
Please write a program which prints all permutations of [1,2,3]
Hints:
Use itertools.permutations() to get permutations of list.
'''
import itertools
l = [1,2,3]
print tuple(itertools.permutations(l)) |
5daa554fffa4995e9848498756de6209a8903f48 | milincjoshi/Python_100 | /17.py | 585 | 3.6875 | 4 | '''
Question:
Write a program that computes the net amount of a bank account
based a transaction log from console input. The transaction log format is shown as following:
D 100
W 200
D means deposit while W means withdrawal.
Suppose the following input is supplied to the program:
D 300
D 300
W 200
D 100
Then, the outp... |
105e0f1338a0bc64a7a30c241caea5289b106c01 | milincjoshi/Python_100 | /60.py | 173 | 4.21875 | 4 | '''
Question:
Print a unicode string "hello world".
Hints:
Use u'strings' format to define unicode string.
'''
y = "hello world"
x = y.decode("utf-8")
print x
print type(x) |
fac3f0586e4c82f66a35d23b3ec09640da8dab44 | milincjoshi/Python_100 | /53.py | 682 | 4.6875 | 5 | '''
Define a class named Shape and its subclass Square.
The Square class has an init function which takes a length as argument.
Both classes have a area function which can print the area of the shape
where Shape's area is 0 by default.
Hints:
To override a method in super class, we can define a method with the
sa... |
1f8f77de56148b8522764286979777cf86b2c421 | milincjoshi/Python_100 | /82.py | 190 | 4.21875 | 4 | '''
Question:
Please write a program to shuffle and print the list [3,6,7,8].
Hints:
Use shuffle() function to shuffle a list.
'''
import random
lii = [3,6,7,8]
random.shuffle(lii)
print lii |
2822a1bdf75dc41600d2551378b7c533316e6a86 | milincjoshi/Python_100 | /45.py | 318 | 4.25 | 4 | '''
Question:
Write a program which can map() to make a list whose elements are square of elements in [1,2,3,4,5,6,7,8,9,10].
Hints:
Use map() to generate a list.
Use lambda to define anonymous functions.
'''
#print map([x for x in range(1,11)], lambda x : x**2)
print map( lambda x : x**2,[x for x in range(1,11)]) |
bc2efffa5e46d51c508b6afa2f5deda322a77765 | milincjoshi/Python_100 | /28.py | 247 | 4.15625 | 4 | '''
Question:
Define a function that can receive two integral numbers in string form and compute their sum and then print it in console.
Hints:
Use int() to convert a string to integer.
'''
def sum(a,b):
return int(a)+int(b)
print sum("2","4") |
e0b5da0e50ff42c29d43e572809b1dc0a095ff0d | milincjoshi/Python_100 | /20.py | 417 | 3.765625 | 4 | '''
Question:
Define a class with a generator which can iterate the numbers, which are divisible by 7, between a given range 0 and n.
Hints:
Consider use yield
'''
class X(object):
def divisible_by_7(self,n):
i = 0
while(i<=n):
if i%7 ==0:
yield i
i+=1
obj_x = X()
gen_7 = obj_x.divisible_by_7(70)
for e... |
e8fe10fdb158f9074de9dec9118f47684f58198a | muskanmahajan37/Easy-ML-and-DL | /Introduction-to-Python-Programming/Session2/source code/2-1/2-1-10.py | 216 | 4 | 4 | salary = {'John': 30000, 'Jane': 50000, 'Paul': 45000, 'Elizabeth': 70000, 'Seth': 10000}
keys = salary.keys()
for key in keys:
if salary[key] >= 50000:
print('{}\'s salary is: '.format(key), salary[key]) |
0cb915387181af778563cc00d48f16af6a170c9d | muskanmahajan37/Easy-ML-and-DL | /Introduction-to-text-mining-with-Python/source code/Session2/2-1-4.py | 2,293 | 3.796875 | 4 | # 텍스트 분석을 위해 nltk 모듈을 불러온다
import nltk
# nltk 모듈에서 Stopwords를 직접 불러온다
from nltk.corpus import stopwords
# 영어의 stopwords를 불러와 변수에 저장한다
stopWords = stopwords.words('english')
# 전처리하고자 하는 문장을 String 변수로 저장한다
sent1 = 'My only regret in life is that I did not drink more wine.'
sent2 = 'I drink to make other people more in... |
f833d59166982175d25aa08d0b7bdadcba58c809 | muskanmahajan37/Easy-ML-and-DL | /Machine-learning-toolkits-with-python/Optimization methods (first-order vs second-order)/source code/adam-optimizer.py | 764 | 3.640625 | 4 | import numpy as np
from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.neural_network import MLPClassifier
from sklearn.metrics import accuracy_score
data = datasets.load_digits()
X_data = data.images # load X_data
y_data = data.target # load y_data
X_data = X_data.re... |
6bdcf40d90b523cef0e34f896eed3ba60a4d7ddc | XavierElon/ftp-client | /CLIENT/ftclient.py | 4,708 | 4.03125 | 4 | #!/bin/python
# Name: Xavier Hollingsworth
# Date: 08/11/19
# Course: CS372
# Assignment: Project 2
# Sources: https://topidesta.files.wordpress.com/2015/10/ptyhon-network-engginering-english-version.pdf
# https://www.geeksforgeeks.org/socket-programming-python/
# http://stackoverflow.com/questions/24196932/how-can-i... |
bfaa73e0cb5cb771e04f0db61768aa4828eb0af9 | DikshitaPoojari/prac | /demo_cal.py | 1,510 | 3.609375 | 4 | import logging
import employ_demo
# Debug : These are used to give Detailed information, typically of interest only when diagnosing problems.
# Info : These are used to Confirm that things are working as expected
# Warning : These are used an indication that something unexpected happened, or indicative of some problem... |
0a7628cb4a380ebc447933fb1b66f53e3ab812f6 | WillyWilsen/KU1102-Praktikum-Pengenalan-Komputasi | /src/Tugas Praktikum/P02_16520145_01.py | 1,475 | 3.578125 | 4 | # Nama : Willy Wilsen
# NIM : 16520145
# Tanggal : 4 November 2020
# Deskripsi : Membuat program yang menampilkan kelipatan dari A, B, dan C
# KAMUS
# N : int
# a : int
# b : int
# c : int
# x : int
# Asumsikan N > 0 dan a, b , c > 0
# ALGORITMA
N = int(input("Masukkan nilai N: ")) # input N
a = int(input("Masukkan ... |
be17f41dc92527bd72866c7d42f826103d3b568f | WillyWilsen/KU1102-Praktikum-Pengenalan-Komputasi | /src/Tugas Pendahuluan/H02_16520145_01.py | 246 | 3.5 | 4 | # Nama : Willy Wilsen
# NIM : 16520145
# Tanggal : 1 November 2020
# Deskripsi : Membuat program yang menuliskan 1 sampai N dalam satu baris
# KAMUS
# N : int
# ALGORITMA
N = int(input("Masukkan N: "))
for i in range(1, N+1):
print(i, end = " ")
|
cfe2ad41654190fd76887e32563f2a31a42f5c61 | WillyWilsen/KU1102-Praktikum-Pengenalan-Komputasi | /src/Tugas Pendahuluan/H02_16520145_03.py | 492 | 3.75 | 4 | # Nama : Willy Wilsen
# NIM : 16520145
# Tanggal : 1 November 2020
# Deskripsi : Membuat program yang menentukan apakah X adalah bilangan prima
# KAMUS
# X : int (Asumsikan X bilangan asli)
# Prima : boolean
# ALGORITMA
X = int(input("Masukkan X: "))
Prima = True
for i in range(2,X):
if X % i == 0: # untuk mencar... |
bba22536e57f8ef4f91e70cfd228d54606c729bd | ThePeziBear/MyPythonLibrary | /For Beginners/Monte_Carlo_find_Pi.py | 480 | 3.8125 | 4 | import random
def estimate_pi():
INTERVAL = int(input())
points_in_circle = 0
points_in_square = 0
for i in range(INTERVAL):
x = random.uniform(0, 1)
y = random.uniform(0, 1)
distance = x * x + y * y
if distance <= 1:
points_in_circle = points_in_circle + 1... |
8c114e901a5c8b295442b5ade7ad2a91ac454855 | ThePeziBear/MyPythonLibrary | /Visualizing_Python/Matplotlib/line_chart_Matplotlib.py | 511 | 3.546875 | 4 | import matplotlib.pyplot as plt
years = [1950, 1960, 1970, 1980, 1990, 2000, 2010]
gdp = [300.2, 543.3, 1075.9, 2862.5, 5979.6, 10289.7, 14958.3]
# erstelle Linienchart. years = x-Achse= years, y-Achse = GDP, marker = Dartellung der Punkte als kreise, linestyle = durchgehend
plt.plot(years, gdp, color='blue', marker=... |
8028b6b281c144db6db1248a98dc13186cf6bc66 | ThePeziBear/MyPythonLibrary | /For Beginners/prime_number_generator.py | 364 | 3.75 | 4 | def prim():
primelist = []
n_1 = 0
n_2 = int(input())
print("Prime numbers between", n_1, "and", n_2, "are:")
for x in [*range(n_1, n_2), 1]:
if x > 1:
for i in [*range(2, x, 1)]:
if (x % i) == 0:
break
else:
primel... |
bfedb2d9cc9bb2cf5482f516a0933d38f5c1de56 | KenyStev/Metodos_Numericos_2doParcial | /NexeR's code/Interpolacion_Lagrange.py | 526 | 3.546875 | 4 | #INTERPOLACION DE LAGRANGE
n = input('Ingrese numero de Puntos: ')
xList = []
yList = []
for i in range(n):
x = input('Inserte X' + str(i) + ': ')
y = input('Inserte Y' + str(i) + ': ')
xList.append(x)
yList.append(y)
m = input('Ingrese n: ')
x = input('Ingrese x buscado: ')
for p in range(m):
y =... |
ae9a4dde4a29d611ecdfce0668d69940d0bda0cf | MLaddU/pdsnd_github | /bikeshare_LaddMoravek.py | 9,385 | 4.3125 | 4 | import time
import csv
import pandas as pd
import numpy as np
CITY_DATA = { 'chicago': 'chicago.csv',
'new york city': 'new_york_city.csv',
'washington': 'washington.csv' }
def get_filters():
"""
Asks user to specify a city, month, and day to analyze.
Returns:
(str) ci... |
f6ddca04ca979ad4db6aa2f9fcb18845c7a06cef | ravi-bhardwaj/person-address-api-client | /personapi_options.py | 338 | 3.9375 | 4 | options = {
1: "Add Person",
2: "Edit Person",
3: "Delete Person",
4: "Add Address to person",
5: "Edit Address",
6: "Delete Address",
7: "Count Number of Persons",
8: "List Persons",
9: "Exit"
}
def display_options():
for option in options:
print(str(option) + " :: " +... |
6159c66af2c4d2388f15f2487b4df6e2013db632 | jijiglobe/softdev-hw | /memoize/fib.py | 387 | 3.734375 | 4 | def fib(n):
memo = []
x = 0
while x<n+1:
memo.append(-1)
x+=1
return fibInner(n,memo)
def fibInner(n, memo):
# print memo
if n<2:
memo[n] = n
return memo[n]
elif memo[n] > -1:
return memo[n]
else:
memo[n] = fibInner(n-1,memo) + fibInner(n-2... |
a0376e17bd52e1967ee0718755b5e5bce2913048 | saisravan25/Python-script-on-Real-time-Website-Login-AccountCreation-Scenario- | /login_captcha.py | 427 | 3.6875 | 4 | import random
def captcha():
ops = ['+', '-', '//', '*']
num1 = random.randint(1, 20)
num2 = random.randint(1, 20)
random_operation = random.choice(ops)
print("Captcha : ", num1, random_operation, num2)
maths = eval(str(num1) + random_operation + (str(num2)))
Answer = int(input("... |
e95d429da8c1244e407913413e549ed08316bf59 | LMIGUE/Github-mas-ejercicios-py | /classCircle.py | 717 | 4.25 | 4 | class Circle:
def __init__ (self, radius):
self.radius = radius
def circumference(self):
pi = 3.14
circumferenceValue = pi * self.radius * 2
return circumferenceValue
def printCircumference (self):
myCircumference = self.circumference()
print ("Circumference of a circ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.