blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
d7573b68907ce1f0c608bee9c15a2e016e581acf
shenyuanwu/python-learning
/question.py
682
4.4375
4
print("What is your favorite fruit: jackfruit, grape, or blueberry?") user_input = input() while user_input.lower().strip("'.,!?") != "jackfruit" and user_input.lower().strip("'.,!?") != "grape" and user_input.lower().strip("'.,!?") != "blueberry": print("That is not a real fruit! Please choose either jack...
5ac9597399aa00ed7f5bc5178b8d2139c88fc4a6
gayaniindunil/Image_classification
/predictor.py
1,823
3.6875
4
''' this is the predict class which is written to predict images using the cifar10_cnn model ''' import numpy as np import os import cv2 import matplotlib.pyplot as plt from keras.models import load_model from keras.preprocessing.image import ImageDataGenerator model = load_model('zoo/model/model1.h5') model.co...
c73c82274fdcb7c1e7bd79548db7decc6bb72f9c
ymli1997/deeplearning-notes
/numerical/symbol-compute/01-create-symbol.py
1,098
3.640625
4
#coding:utf-8 ''' 创建符号 ''' import sympy sympy.init_printing() from sympy import I, pi, oo x = sympy.Symbol('x') # x的类型还未确定 print('x is real:',x.is_real) # 创建实数符号 y = sympy.Symbol('y',real=True) print('y is real:',y.is_real) # 创建虚数符号 z = sympy.Symbol('z',imaginary = True) print('z is real:',z.is_real) # 创建正数和负数符号 g...
979c1d073edce97863376a8aec4b9d9664ba7ff8
UWPCE-PythonCert-ClassRepos/Self_Paced-Online
/students/terrance_jones/lesson2/fizzbuzz.py
422
4.21875
4
def fizzbuzz(): ''' Fizzbuzz prints fizz for numbers divisible by 3, prints buzz for numbers divisible by 5 and prints fizzbuzz for numbers divisible by 3 and 5. All others it prints the number''' for i in range(100): if i == 0: print() elif(i%3 == 0 and i%5!=0): print("Fizz") elif(i%5== 0 and i%3!...
bfb7bdfd7c95ce2452785d07e15f11103a993833
worklifesg/Deep-Learning-Specialization
/Deep Neural Networks with PyTorch/Module1/Lab1_1DTensors_Part2.py
3,248
3.765625
4
# Fundamental concepts of Tensors - Index/Slicing and Functions #Import libraries import torch import numpy as np import pandas as pd import matplotlib.pyplot as plt #---------------------Indexing and Slicing --------------------------- #indexing on tensors index_tensor=torch.tensor([0,1,2,3,4]) with open('Lab1_T...
519fe7a0fd178336399b40cb3c47e85e7f3564dd
pythonsolidity/python-workshops
/Workshop1-2/Matplotlib/matplotlib.py
585
3.640625
4
#!/usr/bin/env python # coding: utf-8 # # Matplotlib # Matplotlib is an amazing visualization library in Python for 2D plots of arrays. # In[ ]: import matplotlib.pyplot as plt # ### Plotting an array # In[ ]: x = [10,20,30] y = [3,2,1] plt.plot(x,y) # ### Bar Plot # In[ ]: plt.bar(x,y) # ### Scatter ...
48c843a3bb0ebbea2325c4cf1ac2b88f891294f6
sahibseehra/Python-and-its-Applications
/Python+data sciences+sql+API/5.py
80
3.53125
4
a=10.00 b=20 if(a==10): print("python") else: print("java")
9c568771bf20a39c90c88101eafaa32d449ad972
jsbk1999/lab-06-review
/miles.py
173
4.25
4
miles = input("How many miles did you drive?") gas = input("How many gallons did you use?") mpg = float(miles/gas) print("Your car gets " + str(mpg) + " miles per gallon.")
1bc7dc259d780e7fa3a1f8e4b6af319418b318d5
MaesterPycoder/Python_Programming_Language
/oops/classinstfact.py
247
3.96875
4
class fact: def __init__(self): n=int(input("Enter any number:")) self.n=n def find(self): f=1 for i in range(1,self.n+1): f=f*i print("Factorial of a number:",f) fact().find()
09d5d4c505e0ad79d8f4ad13a2e08cfdd18edb26
VikasHanumegowda/AI
/Assignment1/bfs.py
5,808
3.59375
4
from collections import deque from copy import deepcopy import time import copy if __name__ == "__main__": def print_matrix(matrix): for eachrow in matrix: for eachcolumn in eachrow: print(eachcolumn, end=' ') print() def print_output(matrix): for each...
108dd59b5011dc17ee03166aa2377378a9feccfe
BoundlessCarrot/robins-tic-tac-toe
/ttt.py
2,923
3.671875
4
import random row1= [0, 0, 0] row2= [0, 0, 0] row3= [0, 0, 0] map = [row1, row2, row3] game_over = 'false' firstPlayer = random.randint(0, 2) player1Move = "a0" player2Move ="a0" xglobal = 0 yglobal = 0 index = {"a":0, "b":1, "c":2} def print_board(): for i in range(0, 3, 1): print("|", ...
20facd265dd46d0009af2392affbe5ffd3736040
liudandanddl/python_study
/python_core/overwrite_set.py
312
3.53125
4
#!/usr/bin/env python # coding=utf-8 __author__ = 'ldd' class setOW(set): def __str__(self): return ', '.join(x for x in self) if __name__ == "__main__": a = set() a.add('1') a.add('2') print(a) # set(['1', '2']) b = setOW() b.add('1') b.add('2') print(b) # 1, 2
5cf1362f68f39d97cc3e328488d1cfd1c3b6bafa
JonnyWaffles/logscrapertutorial
/logscrapertutorial/lesson4.py
10,790
3.75
4
""" ######## Lesson 4 ######## ******************************** Combining async and threads because we can ******************************** The previous lessons showed how we can use "generator based co-routines" to build data pipes. Organizing the data flow in to pipes helps us understand the system, and may give th...
90dc54e0b17a5f8a4e4d798853f61151b28f096c
Tausif4171/Python
/Experiment3b.py
1,825
4.4375
4
#Name: Tausif Khan #Rollno: 12 #Branch: SE/COMPS #Div: B #Course Name: Open Source Technology Lab (OSTL) #Write a menu driven program to demonstrate use of dictionary in python: #1. Concatenate an item in the existing dictionary. #2. Delete item of the existing dictionary. #3. Retrieve all keys from a dictionary #4...
c46ac7d37f2692bba9ca81568d78b32ef278f04f
manitghogar/lpthw
/12/ex12.py
998
4.28125
4
#puts the prompt in the raw_input argument and assigns the answer to the value of variable. age = raw_input ("How old are you? ") height = raw_input ("How tall are you? ") weight = raw_input ("How much do you weigh? ") #prints a string with format variables that call on the values of age, height, weight print "So, you...
370c3d464228537649c94012fdbc32d5825ca6da
slaypax/leetcode
/two_sum.py
659
3.671875
4
# https://leetcode.com/problems/two-sum/ # Given an array of integers, return indices of the two numbers such that they # add up to a specific target. # You may assume that each input would have exactly one solution, # and you may not use the same element twice. # Your runtime beats 85.58 % of python3 submissio...
515484a00a7fe20396c830decad1acd4100080e2
ahmedash95/datastructures
/trie/Trie.py
2,764
3.796875
4
# Defining the node object class Node: def __init__(self,label=None,data=None): self.label = label self.data = data self.children = dict() def add_child(self,key,data=None): # If the key not instance of node lets create a node object for it if not isinstance(key, Node): ...
b46dbd83c0782e30a861957b7d31de12067ef12b
ethan5771/Ethans-Programming-Programs
/Ethan Bank Thing.py
2,582
4.40625
4
# OOP ASSIGNMENT SHELL (Bank Account Manager) #Your code here for 3 classes class Accounts(object): def __init__(self, balance): self.balance = balance def deposit(self, amount): amount = input("How much would you like to deposit?") self.balance = self.balance + amount print(s...
4bcd4ec4c6bbfcfd81017f1baf2594c35a853645
kirillito/leet-code
/Python/p1008.py
857
3.765625
4
# Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def construct(self, preorder, start, end) -> TreeNode: if start > end: return None ...
295ce2358124d48493b8246654432f5421f62116
KetakiDabekar/python
/slip10.py
86
3.640625
4
l=int(input("Enter a length:")) b=int(input("Enter a bredth:")) area=l*b print(area)
1b71ca2b474a66384524c49812153ada41fe55d1
mtahaakhan/Intro-in-python
/Python Practice/and_operator.py
511
4.125
4
# A student makes honour roll if their average is >= 85 # and their lowest grade should be greater than or equals to 70 gpa = float(input('What was your Grade Point Average: ')) lowest_grade = float(input('What was your lowest grade: ')) # 1st way of doing it (This is Nested if) if gpa >= 85: if lowest_grade >= ...
88cdd38d219e692995445c1dd4024102c86624b7
ayyub74/Pythom_fundamentals
/Python_fundamentals_Day4_B22.py
1,075
4.65625
5
#!/usr/bin/env python # coding: utf-8 # In[2]: # introduction to list datatypes defination: A list is an ordered collection of item A list is classified as an mutable datatype (flexible) A list is defined by using the square brackets[] # In[25]: students= ['ayb', 'ayub', 'Anees', 'sayyed', 'hamza', 'Kausar'] # ...
fb00ec3eaaaa452ad9d370b2311e012c20d880f3
sakurusurya2000/FOOBAR
/escape_pods.py
3,000
4.125
4
''' Challenge 4.1 Escape Pods =========== You've blown up the LAMBCHOP doomsday device and broken the bunnies out of Lambda's prison - and now you need to escape from the space station as quickly and as orderly as possible! The bunnies have all gathered in various locations throughout the station, and need to make the...
5bdee9029d1f07becdc23f6425d39477461dd539
edmartins-br/CourseNeuralNetworks
/breast_cancer.py
3,157
3.625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Oct 2 13:42:36 2019 @author: eduardo """ import numpy as np from sklearn import datasets # DEFINE A FUNÇÃO SIGMOID PARA SER USADA PELA CAMADA OCULTA COMO FUNÇÃO DE ATIVAÇÃO def sigmoid(soma): return 1 / (1 + np.exp(-soma)) np.exp(1) #resultado = nu...
4bc81cdcf04c755940987e1e39049bd52ef06e3d
ari10000krat/checkio
/Home/Date and Time Converter.py
926
3.71875
4
import re import datetime def date_time(time: str) -> str: day, month, year, hour, minutes = [int(s) for s in re.split('\.|:|\s', time)] words = ['hour', 'minute'] for key, value in {0: hour, 1: minutes}.items(): if int(value) != 1: words[key] += "s" return f"{day} {datetime.datet...
043b43cdbc64274e58e989da77a408baeecd08f7
hippensteele/python-course
/ModulesAndFunctions/functions_more.py
1,625
3.859375
4
#! /usr/local/bin/python3 __author__="tom" __date__ ="$Apr 11, 2018 5:30:02 AM$" import tkinter import math #def parabola(x): # y = x * x / 100 # return y def parabola(page, size): for x in range(size): y = x * x / size plot(page, x, y) plot(page, -x, y) def circle(page, radius, g,...
b4546d717465d69154bcb7b0445c483e46a09e14
SvinDgentelm/coder-master-v0.1
/code mster v0.1.py
8,963
3.875
4
print ("Выбирете режим:") print ("1 - Кодироваие (буквы в dec askii)") print ("2 - Декодирование (dec askii в буквы) :") rezhim = int(input()) if rezhim == 1 : word = input('Введите фразу:') for i in word : if i == "A" : print (65,end = " ") elif i == "B" : print (66,end = " ") elif i ...
c48dcc9de2283d82fbd2bb7d0c9b0a59c8a3a3b0
paulc1600/Python-Problem-Solving
/H20_birthday.py
1,895
4.0625
4
#!/bin/python3 # ---------------------------------------------------------------------# # Source: HackerRank # Purpose: Lily has a chocolate bar that she wants to share it with # Ron for his birthday. Each of the squares has an integer # on it. She decides to share a contiguous segment of the # ...
ceb74626199da4a45a2047c4ebcd20389a8385cc
RinkuAkash/Object-Oriented-Programs
/02_Inventory_Data_Management.py
2,136
3.578125
4
import json """ Created on 25/01/2020 @auther: B Akash """ """ Problem Statement: Create a JSON file having Inventory Details for Rice, Pulses and Wheats with properties name, weight, price per kg. """ json_data = { "Rice": [ {"name": "Basmati", "weight": 1000, "price": 95}, {"name": "...
26f8e1ab259abcf1cd2109126b89c48179b61860
Esdeaz/Python_Course
/Lab3_Ex2_Variant_3.py
1,042
3.78125
4
#shitcode_mode = shit(True) my_string = 'Ф;И;О;Возраст;Категория;_Иванов;Иван;Иванович;23года;Студент 3 курса;_Петров;Семен;Игоревич;22 года;Студент 2 курса' str_info = '' words = my_string.replace('_', '').split(';') for x in words: #Ищет ФИО if len(x) == 1 and x.isupper(): str_info+= x + ' ...
8f4e2f2add252c833f78f8e8dd409c7d40c9e3c0
uran001/Small_Projects
/Airline_Route_Map/paths_finder.py
3,047
3.828125
4
import networkx as nx import datetime import googlemaps import matplotlib.pyplot as plt from gmaps_basics1 import get_trip_info, get_gmaps_time def graph_with_gmaps_travel_info(routemap): """ This function takes as input a "routemap", i.e., a a list of tuples (origin, destination) (see exercises of last...
db5ae2bc4d342b74e90bfee2dacfd97101ebd3fb
HaoxuZhang/python-learning
/python100questions/4.py
413
3.640625
4
def isLeapYear(a): if (a%4==0 and a%100!=0) or (a%400==0): return True return False year=int(input("输入年份:")) month=int(input("输入月份:")) day=int(input("输入日期:")) months=(0,31,59,90,120,151,181,212,243,273,304,334) result=months[month-1]+day if isLeapYear(year)==True and month>2:#如果是润年并且月份数大于2,需要加一天 result+=1 print("I...
a21b1c4800bdfc37e447aac57bc08b6c1d3d3292
GanLay20/the-python-workbook
/Cap_1_Introduction/ex1.py
144
3.6875
4
# EXERCISE 1 : Mail address first_name = 'john' last_name = 'doe' print(f'Your email address is: {first_name + "." + last_name + "@mail.com"}')
6a6613048b2a336caca3e6719994dc1efe7db307
ravikumarvj/DS-and-algorithms
/Graphs/priority_queue.py
3,576
3.8125
4
### COPIED ### VERIFIED # No duplicate key allowed. class PriorityQueue: def __init__(self): self.q = [] # List for storing elements self.map = {} # Map to find index of key's fast self.length = 0 # Keep track of list size def _sift_up(self, index): while index > 0: # if in...
21cfbc91b92d968290afe166e44ea1832da5830f
group14BSE1/BSE-2021
/src/Chapter 4/exercise 7.py
1,004
4.1875
4
# Prompt for score from the user between 0.0 to 1.o score_raw = input("Enter a score:") # check if score is numeric and within the range def compute_grade(score_feed): try: # check if the required input was the one provideds score = float(score_feed) grade = "" if 0 < score < 1.0: ...
f9e9bcb2dbdd1deb8645b548fe851fccfb35d382
sabreezy11/Using-Databases
/star_args.py
458
4.3125
4
##VIDEO 306 CHALLENGE## """Write a function called build_tuple that takes a variable number of arguments, and returns a tuple containing the values passed to it.""" def build_tuple(*args): return args message_tuple = build_tuple("hello", "planet", "earth", "take", "me", "to", "your", "leader") print(...
2067c377fd5ca5219b95acc72dfe5a7b54eb352f
smohapatra1/scripting
/python/practice/start_again/2021/05172021/Day18.4_Turtle_Random_walk.py
618
3.984375
4
#Draw a random Walk from turtle import Turtle, Screen import turtle as t import random tim = t.Turtle() #random Color t.colormode(255) def random_color(): r = random.randint(0,255) g = random.randint(0,255) b = random.randint(0,255) random_color = (r, g , b) return random_color #colors = ["Red", ...
b23ea3c96191f726c5014130193658ce434dbe85
ddvdv/automateTheBoringStuff
/chap8/madLibs.py
440
3.734375
4
#! python3 # Mad libs, a classic.. print('####### WELCOME IN MAD LIB FEVER ########') adjective = input('Enter an adjective: ') noun1 = input('Enter a noun: ') verb = input('Enter a verb: ') noun2 = input('Enter a noun: ') result = f"The {adjective} panda walked to the {noun1} and then {verb}. A nearby {noun2} was u...
9aa3bdef95af029960515e83fee33cdd1ce9431e
mindajalaj/academics
/Projects/python/pyh-pro/SAMBA-IP-ADD.py
359
3.671875
4
#!/usr/bin/python3 import os y=input("Enter the share name : ") shr_name = "cat /etc/samba/smb.conf | grep "+y+" > trash" os.system(shr_name) f=open("trash",'r') for i in f : pass z=i[1:-2] print(z) if y == z : k=input("enter ip address : ") os.system("") else : print("SORRY! That share does not exist") os.syst...
3dd3e0bfd0c55c0ec910e61990d977aad628369e
Krupique/cursos-tensorflow
/03_Redes_Neurais/20_rna_estimators_census.py
5,056
3.5
4
""" Mais sobre padronização utilizando Tensorflow em: https://towardsdatascience.com/how-to-normalize-features-in-tensorflow-5b7b0e3a4177 """ #Carregando arquivo import pandas as pd base = pd.read_csv('dados/census.csv') base.head() #Função para converter em 0 e 1 a classe de saída def converte_classe(rotulo)...
0c13430dfa076c098cee8a67eaf84cf4e258ef6f
PdxCodeGuild/20170724-FullStack-Night
/Code/jessica/python/lab8.1-guess_the_number.py
360
4.1875
4
import random computer = random.randint(0, 10) guess = 0 while guess < 10: x = int(input('Guess a number between 1 and 10: ')) if x == computer: print('You guessed right!') break else: print('Guess again. ') guess += 1 if guess >= 10: print('You lose.') guesses = 10 pr...
721f616f9ce5ca6ca8488f23087543521de80703
authman/Python201609
/Wright_Will/Assignments/linked_lists/linked_lists.py
1,784
3.546875
4
class Dbl_Linked_List(object): def __init__(self): self.head = Node(None,None,None) self.tail = Node(None,self.head,None) self.head.next = self.tail def delete(self,node): node.next.prev = node.prev node.prev.next = node.next return self def insert_at_start(se...
f61ab906f8089e4778314b16f66e8902ec1166bf
WitoldKaczor/py_repo
/WorkbookBS/01_basics/ex13.py
1,393
3.984375
4
change_cents = int(input('Change in cents: ')) # init of counters toonies = 0 # 200cents loonies = 0 # 100cents quarters = 0 # 25cents dimes = 0 # 10cents nickels = 0 # 5cents pennies = 0 # 1cent # loops for calculating coin numbers while change_cents >= 200: change_cents -= 200 tooni...
bc32d3483b8df1a8fd655978e679cbc58b852da6
SamanehGhafouri/DataStructuresInPython
/sets.py
871
4.125
4
# ************************** Constructors # Store non-duplicate items # Very fast access vs lists # Math Set ops(union, intersect) # Sets are Unordered can't be sorted # Creating new sets x = {3, 5, 3, 5} print(x) y = set() print(y) # *************************** Set Operations x = {3, 8, 5} print(x) x.add(7) print(...
706e85da67e8565964be796b0768be94d77a38f2
gup-abhi/rand_dice_num
/Simpledicegame.py
831
4.0625
4
# importing tkinter import tkinter as tk from tkinter import ttk # importing showinfo from tkinter messagebox from tkinter.messagebox import showinfo # importing random module import random # creating a window win = tk.Tk() # giving a title to our window win.title("Random Number Generator") # creating a function ran...
198b4542e5a979aa717b0bec5fdfe1a7283c1bfe
erllan/neobis
/KRSU_OLIMP/calculations/tadk_C.py
129
3.9375
4
numbers = str(input()) result = '' for number in numbers: result += number + ', ' result = result.strip(", ") print(result)
5182e5ec47e4fb66b17e869f3ff919f474e670d1
hugomailhot/ECS289
/hw1/hw1_SP_dijkstra.py
3,269
4.125
4
# !/usr/bin/env python # encoding: utf-8 """ This is an implementation of Dijkstra's algorithm, as found on this page: https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm """ import numpy as np import argparse import sys import math def check_args(args=None): parser = argparse.ArgumentParser(description='Comput...
9f1aa4d60b98f5d0c893b3558a1b0a1036cf3124
isabella232/fromconfig
/docs/examples/machine-learning/ml.py
549
3.578125
4
"""Machine Learning Example code.""" from dataclasses import dataclass @dataclass class Model: """Dummy Model class.""" dim: int @dataclass class Optimizer: """Dummy Optimizer class.""" learning_rate: float class Trainer: """Dummy Trainer class.""" def __init__(self, model, optimizer, ...
33be18dd56b7feb678373a455101c04ae121b92d
ironsketch/pythonSeattleCentral
/Chapter 1/chaosrows.py
1,166
4.40625
4
# Start the main definition def main(): threeNine = 3.9 twoZero = 2.0 x = .5 y = .5 def chaos(num, num2): x = num * x * (1 - x) y = num2 * y * (1 - y) # Just a message printed out that explains to the user print ("A chaotic function") # Asking and getting user input on how...
4b3bdcb7fffed968579d7dbe6aef45dbc98854d9
ieferreira/miscelanea
/kaleido-spinner.py
1,174
4.125
4
from turtle import * import random # based on a previous code, plain spinner with only 3 rings print("PRESS SPACE TO MAKE IT SPIN!") n = int(input("input the number of rings on the spinner (1 to whatever you want... but after ~60 it looks way trippy than it should)")) win = Screen() win.title("KaleidoSpinner!") ...
bc76c5563a2096282b2e973841398bf85a9e6f02
jbro321/Python_Basic_Enthusiastic
/Python_Basic_Enthusiastic/Chapter_09/P_09_2_2.py
165
3.578125
4
# Enthusiastic_Python_Basic #P_09_2_2 def main(): tpl1 = tuple(range(1, 101, 1)) tpl2 = tuple(range(99, 0, -1)) tpl = tpl1 + tpl2 print(tpl) main()
714c6429412ecfecfdede08aa1be390d1b525291
bug-thiago/Exercicio-2
/Exercicio02/Questao15.py
266
4.03125
4
def verificar(n): num = str(n) if len(num) == 3: return num else: return 0 n = int(input("Digite um número de três algarismos: ")) if verificar(n) == 0: print("Você não forneceu um número de três algarismos.") else: print(verificar(n)[::-1])
9620c1387d17c827676646bb278f7dc8f9e9dc4c
HackerSpot2001/Youtube-Video-Downloader
/Youtube_video_downloader.py
1,917
3.578125
4
from tkinter import Label,Frame,Button,Entry,StringVar,Tk,TOP,X from tkinter.messagebox import showwarning,showinfo from tkinter import filedialog from pytube import YouTube def downloadvideo(): download_button.configure(text="Downloding...") url_of_video = url_vid.get() url_of_video = str(url_of_video) ...
48e98d6c4568c33f325dee2e86cc170cf65940b8
Krishna219/online-courses-and-programming
/Hackerrank/Submission codes/Set__add___.py
205
3.921875
4
# Enter your code here. Read input from STDIN. Print output to STDOUT dist_countries = set() num = int(raw_input()) for val in range(num): dist_countries.add(raw_input()) print len(dist_countries)
abbc2276ac1e83eaa0e589b87fca51cd4f5c0ecb
ekiefl/stunning-disco
/variants/snv/splice_sample_id.py
3,355
3.640625
4
import re import pandas as pd error1 = \ """Your separator does not split each row in sample_id into 2 strings. In other words, sep is not present exactly once in every sample id""" def splice_sample_id(df,sep=None): """ Splices sample_id in the SNV table to easily filter samples and cohorts This use of ...
e6fadff2f56fb97d58e60c6fd9b34da35b2a5c1c
ghoso/python-intro-sample
/flower.py
150
3.5625
4
# flower.py flowers = ['rose', 'lily', 'cherry'] for flower in flowers: print(flower) print("花の種類は" + str(len(flowers)) + "です。")
30d4e017098bbb1371bd468515cbf545dc37486f
timc823/IST341_Course_Work
/Week01/hw0pr2a.py
1,220
4.03125
4
# coding: utf-8 # # hw1pr2a.py # import random # imports the library named random def rps(): """ this plays a game of rock-paper-scissors (or a variant of that game) arguments: no arguments (prompted text doesn't count as an argument) results: no results (printing doesn'...
893b37c0658c9350880ab110a465f0fc7e205c34
sviridchik/prep_for_isp
/isp/25.py
2,153
3.78125
4
class Node: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right class Tree: def __init__(self,node): self.root = node def __iter__(self): if self.root.left is not None: # yield from hren_ustala_zado...
3967ed75a7bdd032934ae60eb26b1e4325af5c4f
Stanislav-Fadeev/magicball
/main.py
1,226
3.96875
4
import random answers = ["Бесспорно", "Мне кажется - да", "Пока неясно, попробуй снова", "Даже не думай", "Предрешено", "Вероятнее всего", "Спроси позже", "Мой ответ - нет", "Никаких сомнений", "Хорошие перспективы", "Лучше не рассказывать", "По моим данным - нет", "Можешь быть уверен в...
99cabd07781e24fa9b87fce9683b0b0f9de9f958
tanvipenumudy/Competitive-Programming-Solutions
/HackerRank/Problem-Solving/day_of_the_programmer.py
1,352
4.03125
4
#!/bin/python3 import math import os import random import re import sys # Complete the dayOfProgrammer function below. def dayOfProgrammer(year): a = '12.09.' b = '13.09.' c = '26.09.' if year > 1918: if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0: print(a, year, sep = '...
f710745ef9bcdde9ba27f467372fb496a157a77d
abinashdash17/python_progs
/ex3.py
131
3.765625
4
x = input('Enter the upper limit of square') x = int(x) sqr_dict = {} for i in range(1,x+1): sqr_dict[i] = i*i print(sqr_dict)
75749865816b92fa21cad58ff0e82ee488685d3c
APilarca/python_learning_notes
/basics/squared.py
181
3.84375
4
def squared(arg): try: arg = int(arg) except ValueError: print(arg * len(arg)) else: print(arg ** 2) given = raw_input("What would you like to square? ") squared(given)
4e53d4bcddef040fc6f139dabf8b1b96eb764148
guozhenduo/Math
/gcd.py
504
3.890625
4
def gcd(a, b): #calculates the gcd of two integers using the Euclidean algorithm if a < b: a, b = b, a if b == 0: return a return gcd(b, a%b) def lcm(a,b): #calculates lcm of two integers if a < b: a, b = b, a return int(a/gcd(a,b)*b) def addFractions(num1, den1...
9ddb95bbbd13da55c3075c7b19221770f72c8647
SandipanGhosh/Data-Structures-and-Algorithms
/merge_sort.py
904
4.34375
4
def merge_sort(list_to_sort): # list with fewer than 2 elements are already sorted if len(list_to_sort) < 2: return list_to_sort # divide the list in half and merge recursively mid_index = len(list_to_sort) // 2 left = merge_sort(list_to_sort[:mid_index]) right = merge_sort(list_to_sort[mid_index:]) retu...
115336e55aac7c8bdf4e9f64bc8c78f3f4158520
hinduck/FullPythonProject
/VietTaiLieuChoHam/document.py
302
3.5625
4
def UocChungLonNhat(a, b): """Hàm này dùng để tìm uớc số chung lớn nhất VD: a = 9, b = 6 thì UCLN = 3""" min = a if a < b else b for i in range(min, 0, -1): if a % i == 0 and b % i == 0: return i return 1 uoc = UocChungLonNhat(25, 15) print(uoc)
6bf05f4c604068b79ada8fe1d2a4972eb5e1138e
Chintan99/Quick-Python-Scripts
/MatrixGenerate1-n2.py
1,261
3.984375
4
#Python program to generate (given an integer n) a square matrix filled with elements from 1 to n2 in spiral order. def generateMatrix(n): if n<=0: return [] matrix=[row[:] for row in [[0]*n]*n] row_st=0 row_ed=n-1 col_st=0 col...
60629729a22703f94670de36e2bf4072c7df3417
jardelhokage/python
/python/reviProva/Python-master/30_JogoForca.py
2,081
3.875
4
titulo = 'JOGO DA FORCA' linha1 = '←' * 10 linha2 = '→' * 10 linha3 = '—' * 30 linha4 = '*' * 26 linha5 = '←' * 42 linha6 = '→' * 42 chancesLimite = 0 chances = 1 l = 0 from random import randint y = randint print() print(linha1, end= '') print(linha2) print(titulo.center(22)) print(linha2, end='') print(linha1) pr...
960b90ea6a652b6a104ae41c198b48447c08e326
LSSalah/Coding-dojo-Python
/basics/user.py
974
3.703125
4
class User: def __init__(self,first_name,last_name,account_balance): self.first_name = first_name self.last_name = last_name self.account = account_balance def make_withdraw (self, amount): self.account -= amount def make_deposite(self , amount): self....
b6f47424b90fbc5ee1bd088feb8f5dc369a4ffbb
clairewild/ToyProblems
/codewars.py
1,101
3.84375
4
# Takes an array of integers and returns true if any three consecutive elements sum to seven def lucky_sevens(numbers): if len(numbers) >= 3: i = 0 while i < len(numbers) - 2: sum = numbers[i] + numbers[i + 1] + numbers[i + 2] if sum == 7: return True else: i += 1 return False # Takes an array o...
0a02a04bdd29a0fbc581152fc0cefb6bc3fd1f79
vishalkumarmg1/Algorithms
/algoexpert.io/python/Permutations.py
1,330
3.796875
4
# https://www.algoexpert.io/questions/Permutations # Solution 1 # Upper Bound: O(n^2*n) time | O(n*n!) space # Roughly: O(n*n!) time | O(n*n!) space def ge_permutation(array): permutations = [] permutation_helper(array, [], permutations) return permutations def permutation_helper(remaining_input_array,...
bf712075adf1c97921f1a491dc84094f4e2d57a5
Omar-Porapat-Alherech/Poralib
/Sorts/insertion_sort.py
1,264
3.703125
4
import logging module_logger = logging.getLogger(__name__) logging.basicConfig(level=logging.DEBUG, format='| %(asctime)s | %(name)-12s | %(levelname)-8s | %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p') # Insertion Sort # O(1) Space Complexity as it sorts in the array it came f...
b4743852cf91d7fe7e5602541af492685284ee55
faccordx/Python3LevelTree
/level3tree.py
1,759
3.546875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 13/6/2018 3:02 PM # @Author : FaccordX # @File : treebranchleaf.py import sys dict_3tree = { 'China': { 'Liaoning': ['Shenyang', 'Dalian', 'Anshan', 'Fushun'], 'Shandong': ['Jinan', 'Qingdao', 'Weihai', 'Rizhao'], 'Heilongjiang'...
d09c155178683913c1381ccadfacdde6c6e96ab4
dimDamyanov/PythonAdvanced
/11. Exam preparation/02_checkmate.py
927
3.546875
4
directions = [ lambda x: (x[0] - 1, x[1]), lambda x: (x[0] + 1, x[1]), lambda x: (x[0], x[1] - 1), lambda x: (x[0], x[1] + 1), lambda x: (x[0] - 1, x[1] - 1), lambda x: (x[0] - 1, x[1] + 1), lambda x: (x[0] + 1, x[1] - 1), lambda x: (x[0] + 1, x[1] + 1) ] board = [] king_pos = None for...
775124d6e2ff3d155ad367eda832f2f95343b857
PM25/DRL_Portfolio_Management
/mylib/utils.py
701
3.71875
4
import sys from datetime import datetime def is_number(data): try: if ('.' in data): data = float(data) else: data = int(data) return True except ValueError: return False def is_date(data): split_data = data.split('-') if(len(split_data) != 3):...
645814dcaea27134e1283824bfdc9bc0ba9f54ec
anisbourbia/sudoku
/Sudoku game+Solver/random board of sudoku.py
1,533
3.96875
4
base = 3 side = base*base # pattern for a baseline valid solution def pattern(r,c): return (base*(r%base)+r//base+c)%side # randomize rows, columns and numbers (of valid base pattern) from random import sample def shuffle(s): return sample(s,len(s)) rBase = range(base) rows = [ g*base + r for g in shuf...
7727a9b1113d20eade54fe698b1966a9c1b88177
jfzhang95/Kaggle
/Titanic/LoadData.py
1,010
3.515625
4
#!usr/bin/env python #-*- coding:utf-8 -*- """ @author: James Zhang """ import pandas as pd from sklearn.feature_extraction import DictVectorizer train = pd.read_csv("train.csv") test = pd.read_csv("test.csv") # print train.info() # print test.info() selected_features = ['Pclass', 'Sex', 'Age', 'Parch', 'Embarke...
bcfb2f5fc6a3d3287d191acc134df3557331c472
aniakr/udemy
/simple_function_C_to_F.py
366
4.15625
4
def C_to_F(temp): F=temp*9/5+32 return F # Celsius=input("Temperature in Celsius to be converted: ") Celsius_list=[10,-20,-289,100] for Celsius in Celsius_list: if Celsius < -273.15: print ("Such temperature does not exist") else: print(str(Celsius) + " in Celsius degrees" +" is " + s...
eabe65d3d748377d44eff870f929e36f81d2f517
Roll20/roll20-character-sheets
/Ars_Magica_5th/source/legacy/source/fileval.py
9,896
3.640625
4
#!/usr/bin/env python3 """ Python script to evaluate and insert python expression in files """ import argparse import importlib import re import sys import traceback as tb from pathlib import Path from typing import Any, Dict, Generator, List, Optional, TextIO, Tuple, Union if sys.version_info < (3, 8): raise Runt...
44949ff7cf2ef1a9adf9141acacfacf3d52f93c2
acauangs/Desafios_Python
/87_matiz_soma.py
1,138
3.984375
4
#Programa que recebe uma matriz 3x3, e devolve a matriz junto com a soma dos números pares, a soma dos valores da terceira coluna e o maior valor da segunda linha. matriz = [[0, 0, 2], [0, 0, 0], [0, 0, 0]] soma_par = tresS = maior_valor = 0 # input da matriz for l in range(0, 3): for c in range(0,3): mat...
8b033ff618acccfe608a4006ca1a51eaffd043f4
yogeshrnaik/python
/linkedin/Ex_Files_Python_EssT/Exercise Files/Chap08/dict.py
1,750
4.375
4
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ def printSeparator(): print('*****************************************************************') def main(): animals = { 'kitten': 'meow', 'puppy': 'ruff!', 'lion': 'grrr', 'giraffe': 'I am a giraffe!', 'dragon': 'rawr' } print_dict(a...
7c2060889f9de3dac3c77c88082a74e0166901c5
h0plyn/code-challenges
/grokking/binarySearch.py
366
3.84375
4
# O(logn) def binary_search(list, item): low = 0 high = len(list) - 1 while low <= high: mid = (low + high) / 2 guest = list[mid] if guest == item: return mid if guest > item: high = mid - 1 else: low = mid + 1 return None test_list = [1,3,5,7,9] print(binary_search(test_...
a400a9f8460089c77428cc98844584bf7ce15feb
chrismvelez97/GuideToPython
/methods/list_methods/del.py
450
4.15625
4
# How to use the del method ''' The del method is executed a bit different than what we've seen so far. Instead of the regular 'function()' setup you can just use del as it is. You must know, however, exactly what index you'd like to delete. ''' motorcycles = ['honda', 'yamaha', 'suzuki'] print (...
5b751e740149d897741745fa7f7dd9bedd1fb2c4
XingXing2019/LeetCode
/Tree/LeetCode 671 - SecondMinimumNodeInABinaryTree/SecondMinimumNodeInABinaryTree_Python/main.py
962
3.703125
4
# Definition for a binary tree node. import math class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: firstMin, secondMin = math.inf, math.inf def findSecondMinimumValue(self, root: TreeNode) -> int:...
1843ae1e2a9b480d8175cf52ec6863132a46d105
kumopro/pro-tech
/lesson4/challenge4.py
529
3.71875
4
def print_name_age(name, age): print("Name: " + name) print("Age: {}".format(age)) if age >= 65: price = 6700 elif age >= 18: price = 7400 elif age >= 12: price = 6400 elif age >= 4: price = 4800 else: price = 0 if price > 0: print("Price...
9797bc6bba24e86847cde0138c5c4a9deb6949af
jisun-choi/python_algorithm
/기초100제.py
542
3.625
4
#단어 1개 입력받아 나누어 출력하기 x = input('') for c in x: print("'"+c+"'") #시간 입력받아 그대로 출력하기 hour, minute = input().split(':'); print(hour, minute, sep=':') #주민등록번호 입력받아 '-' 없이 출력하기 a,b = input().split("-") print(a+b) #정수 두 개 입력받아 합 출력하기 a, b = input().split() a = int(a) b = int(b) print(a+b) #기초연산 a, b = input().split(...
2d9f23d0ed731d07fc0259e86f38eaf919395bb9
VCityTeam/UrbanCO2Fab
/urbanco2fab/store/abstractstore.py
313
3.609375
4
from abc import ABC from abc import abstractmethod class AbstractStore(ABC): @abstractmethod def __init__(self, store): self.__class__ = AbstractStore @abstractmethod def create(self, data): pass @abstractmethod def get(self): pass @abstractmethod def store(self, store): pass
f5b4acf16383fb30dbea6126394cd73aaf872399
rbshadow/Python_URI
/Beginner/URI_2160.py
171
3.71875
4
def math(): string = input() length = len(string) if length <= 80: print('YES') else: print('NO') if __name__ == '__main__': math()
93d3b48fbb0e7df21e720d93642de125ef129703
polonio24/Pi-ante_SmartGardenSystem
/ReadAndPrintDB.py
1,461
3.953125
4
import sqlite3 from datetime import datetime import time def readSqliteTable(): try: sqliteConnection = sqlite3.connect('Piante2.db') cursor = sqliteConnection.cursor() #print("Connected to SQLite") sqlite_select_query = """SELECT * from misurazioni ORDER BY dataora desc ...
5b382b8e5d0196be9a214ca44b18f74ae1bdca25
DanieleMagalhaes/Exercicios-Python
/Mundo2/calcIMC.py
548
3.875
4
from math import pow print('-'*50) print('CALCULO DE INDICE DE MASSA CORPORAL') print('-'*50) peso = float(input('Digite seu peso (kg): ')) altura = float(input('Digite sua altura (m): ')) imc = peso / pow(altura,2) print('Seu IMC é: {:.1f}'.format(imc)) if imc < 18.5: print('Resultado: ABAIXO DO PESO') elif 18.5...
5ac0d318f247de3391f87fcf14c7c36c2596e0fb
yeongwoojang/CordingTest-with-Python
/파이썬문법/튜플,사전,집합 자료형.py
1,838
3.734375
4
# 1. 튜플자료형 #파이썬의 튜플 자료형은 리스트와 거의 비슷한데 다음과 같은 차이가 있다. # 1. 튜플은 한 번 선언된 값을 변경할 수 없다. # 2. 리스트는 대괄호를 이용하지만, 튜플은 소괄호를 이용한다. a= (1,2,3,4) print(a) # a[2] = 7 --> 에러 # 2. 사전 자료형 # key-value로 구성되어있다. data = dict() data['사과'] = 'Apple'; data['바나나'] = 'Banana'; data['코코넛'] = 'Coconut'; print(data) if '사과' in data : pri...
35435a318e2262d5b7fce50deae1fd3fa82aad48
vansh1999/Python_core_and_advanced
/sequencedatatype/tuples/tuple.py
715
4.125
4
# declare a tuple colors = ("r" , "b" , "g") print(colors) # tuple packaging - # Python Tuple packing is the term for packing a sequence of values into a tuple without using parentheses. crl = 1,2,3 print(crl) # tuble unpackaging - a,b,c = crl print(a,b,c) # Crete tuple with single elements tupl1 = ('n') #< --...
795982d9b5bc19e4bf7ebcb5941783872046f7ea
giladlevy1/Final_Project
/object/main.py
1,542
3.84375
4
from object.class_student import student from object.class_course import course school = course(2,"school",30) #first assigment school.subject_proffesor.update({"history" : "david"}) #second assigment school.subject_proffesor.update({"sport" : "dagan"}) school.subject_proffesor.update({"bible"...
5b0c3b5b70e9fb9bf1832a08f5f9d0399acc78fd
aleksoo/homeworks
/python/2/cwiczenia/iter/currentset_ex.py
542
3.625
4
def currentset(f): r''' Read currentsets csv file and make iterator that returns Currentset objects >>> from StringIO import StringIO >>> f = StringIO('Faraday;10.121.85.21;HPOMS-01\n') >>> list(currentset(f)) [Currentset(name="Faraday",ip="10.121.85.21",desc="HPOMS-01")] ''' b...
7c49cb6d664f62e881afaed3fe13bdcd00edfd94
ali-fidan/Pyton-Workings
/prime_numbers.py
422
3.703125
4
num_limit = input("Enter a limit number: ") while True: if num_limit.isdigit(): break else: num_limit = input("Wrong entered. Please enter a limit number: ") prime_num = [] count = 0 for i in range(2,int(num_limit)+1): for j in range(2, i): if i % j == 0: count = coun...
9bacaaaf102168fab59daf7f02715eb31ca9fbac
shivajividhale/ProjectEuler
/problem7.py
365
3.609375
4
__author__ = 'Shivaji' primeArray={} primeArray[0]=2 primeArray[1]=3 def checkPrime(x): if x%2 == 0: return False for i in range(2,int(x/2)): if x%i==0: return False return True i=2 x=4 while(i<10001): result=checkPrime(x) if result == True: primeArray[i]=x ...
db7b1e1cb701167ec7be439e9f0efe28270df059
kestrel150/MiscPythonTasks
/Field Simulation/Cow_Class.py
1,193
4.09375
4
#Aaron Parker #140614 #Cow Class from Animal_Class import * class Cow(Animal): """A cow""" #constructor def __init__(self,name): #calls parent class constructor with default values #growth rate = 2; food need = 6; water need = 3 super().__init__(2,6,3,name) self._type = "Co...
22e7912246c309f7aa9ad29a73bc143258d3d94d
FranHuzon/ASIR
/Marcas/Python/Ejercicios/Repetitivas/Ejercicio1.py
205
3.8125
4
numero = int(input('Indica un número: ')) divisores = [] for n in range(1,numero): if numero % n == 0: divisores.append(n) print ('Los divisores de {0} son {1} y {2}'.format(numero,divisores,numero))
3f9fb51f67facba8583a4d0ecc2e3904aabb1b1b
otisscott/1114-Stuff
/Homework 5/oms275_hw5_q7.py
416
3.984375
4
# Otis Scott # CS - UY 1114 # 10 Oct 2018 # Homework 5 needle = input("Enter needle: ") haystack = input("Enter haystack: ") position = -1 for each in range(0, len(haystack) + 1 - len(needle)): if haystack[each:each + len(needle)] == needle: position = each break if position == -1: print("Need...
32c277703f1b9edbba62e9c973a3ed208d36b244
JacquelineOmollo/Intro-Python-I
/src/05_lists.py
939
4.25
4
# For the exercise, look up the methods and functions that are available for use # with Python lists. import numpy x = [1, 2, 3] y = [8, 9, 10] # For the following, DO NOT USE AN ASSIGNMENT (=). # Change x so that it is [1, 2, 3, 4] # YOUR CODE HERE x.append(4) print(x) # Using y, change x so that it is [1, 2, 3, ...
6803ba593ee95feecb0a0ccc0805204f30b6a323
msleone90/newz
/modules/weather.py
1,383
3.796875
4
"""Module to build out weather section.""" import requests from modules.forecast import format_weather from modules.newzconfig import * class ResponseNotFound(Exception): """Raised when a response is not returned from API call.""" pass def _check_rain(rain): """Checks if it is raining in searched city."""...