blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
55df812750f5c96725cb9e823b0247d599ab67c1
DmitryVakhrushev/Python
/PythonProjects/MOOC_ProgForEverybody/Py4Inf_24_RegularExpressions.py
5,863
4.46875
4
#------------------------------------------- # Regular Expressions #------------------------------------------- # Really clever "wild card" expressions for matching and parsing strings. # ^ Matches the beginning of a line # $ Matches the end of the line # . Matches any character #...
d6e110ba693489057038cd6433a60d4e150bd56f
dom-0/python
/oldstuff/remove.py
275
3.671875
4
#!/usr/bin/env python pets= [] while input != "quit": input = raw_input("Enter the name of the pet: ") pets.append(input) print ("\n\n" + str(pets)) remove = raw_input("Which pet would you like to remove? ") while remove in pets: pets.remove(remove) print (pets)
a84986a9e0c92907cabaa604d24394e976c46f10
fiscompunipamplona/taller-orbitas-fibonacci-DiegoPalacios11
/segkepler.py
527
3.96875
4
v1=float(input("ingrese la velocidad del perihelio")) r1=float(input("ingrese la posicion del perihelio")) g=6.67e-11 m=5.97e24 pi=3.1416 v2=(((2*g*m)/(v1*r1))+(((2*g*m)/(v1*r1))**2+4*((v1**2-2*g*m)/r1))**1/2)/r1 r2=(r1*v1)/v2 print("la velocidad del afelio es: ",v2) print("la posicion del felio es: ",r2) emy=(r1+r2)/2...
204a901abca752ca84ced55e31cd58dedca3afdc
SL-PROGRAM/Mooc
/UPYLAB-5-10.py
1,195
3.828125
4
"""Auteur: Simon LEYRAL Date : Octobre 2017 Enoncé Écrire une fonction prime_numbers qui reçoit comme paramètre un nombre entier nb et qui renvoie la liste des nb premiers nombres premiers. Si le paramètre n’est pas du type attendu, ou ne correspond pas à un nombre entier positif ou nul, la fonction renvoie None...
4c24a67a3e67906faa5daa162b8bd68fa8d6d3ed
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/bob/f17d7688682e4fff90e437e759f4d5df.py
512
4
4
# -*- coding: utf-8 -*- # Skeleton file for the Python "Bob" exercise. import re def hey(what): #Remove white spaces in the string what = what.strip() if re.search('äÜ', what): return "Whatever." #Yeling at bob elif re.search('!$', what) or re.search("[A-Z][A-Z][A-Z][A-Z]", what): return "Whoa, chill out...
be7e3d4518f4ceb83cc2b921e63c99bd7f5833ae
arvindbis/PythonPract
/PDemo/src/com/demo/Learning.py
174
3.734375
4
''' Created on 02-Mar-2019 @author: arvindkumar ''' thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964 } for x,y in thisdict.items(): print(x , y)
1cfec37ab1c6cefdc2ddf4e16a502b178db37c49
RahulBantode/Python_Automation
/Duplicate_File_Detector/duplicate_file_detector.py
3,774
3.5625
4
#File Contains the Code of Duplicate files detector and then sending the email to specified recipient from sys import * import os import hashlib import time total_scanned_file = 0 file_path = " " def CalculateCheckSum(path, blocksize = 512): global total_scanned_file total_scanned_file = total_scanne...
d7a3829ee80b6eb449cdb006bf26d4add0cc4c82
ErvinCs/FP
/Lab05-09-Library/src/domain/Book.py
1,845
3.609375
4
class Book: bookIterator = 0 #bookId generator def __init__(self, title, description, author): ''' Sets bookId using the bookIterator :param title, description, author: strings ''' self.__bookId = Book.bookIterator Book.bookIterator += 1 self.__title = ti...
07fd697bf0578792184f59edadb02ae361d0955e
fujunguo/learning_python
/The_3rd_week_in_Dec_2017/function_map.py
93
3.515625
4
def f(x): return x * x a = [1, 2, 3, 4, 5, 6, 7, 8, 9] r = map(f, a) print(list(r))
e9126adc80eb97150ca4cf18d8471978c4772305
bridgetlane/Python-Puzzles
/src/palindrome.py
895
4.3125
4
# tells you if a given string is a palindrome def palindrome(string): for i in string: # remove non-alphabetical characters if (i.isalpha() == False): string = string.replace(i, "") if (i.isupper() == True): string = string.replace(i, i.lower()) rev...
983edcb27edd0e01b465c88f6df18b57cd79995d
benoxoft/mti880handcopter
/HandcopterGame/gamelib/movement.py
7,555
3.546875
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # Copyright (C) 2010 Benoit <benoxoft> Paquet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or #...
640c6cc07b6b63a4c3741ddd04f6bab38e352d9e
humachine/AlgoLearning
/leetcode/Done/60_PermutationSequence.py
1,343
3.703125
4
#https://leetcode.com/problems/permutation-sequence/ '''The number 123..n has n! different permutations of its digits. Given n and a number k, return the kth permutation (when permutations are in ascending order). Inp: 3, 5 Out: 312 [123, 132, 213, 231, 312] ''' class Solution(object): def getPermutation(self, n,...
ada60480c5ffb10ae900dbfcf4833fe1b5e886f0
moileehyeji/Study
/keras/keras15_ensemble2.py
2,598
3.578125
4
#실습: 다:1 앙상블 구현 #1. 데이터 import numpy as np x1 = np.array([range(100), range(301,401), range(1,101)]) x2 = np.array([range(101,201), range(411,511), range(100,200)]) y1 = np.array([range(711,811), range(1,101), range(201,301)]) x1=np.transpose(x1) x2=np.transpose(x2) y1=np.transpose(y1) from sklearn.mod...
e4315e9470089f476393a55914b9cd1a9300e4e3
Hyunsooooo/jump2python
/2장/Q9.py
110
3.59375
4
a= dict() a['name'] = 'python' print(a) a[('a',)] = 'python' print(a) a[250] = 'python' print(a)
d88fb3d27aa8e6a02642bf7b720e725867a60928
solaaa/alg_exercise
/rebuild_btree.py
779
3.578125
4
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def build_bt(pre, mid): # 1. build root root = TreeNode(pre[0]) # 2. find the root.val in mid idx = 0 for i in range(len(mid)): if root.val == mid[i]: ...
87acfc1f5ba4a84cdd85209a1ebc9f3d7b789357
ebenz99/Math
/algos/spiralList.py
1,927
3.6875
4
def printSpiral(lists): checklist = [] numItems = 0 for row in lists: a = [] for item in row: a.append(1) numItems+=1 checklist.append(a) print(checklist) print(lists) dic = {"R":"D","D":"L","L":"U","U":"R"} direction = "R" currX, currY = 0,0 buffstr = "" i = 0 while i < numItems: if direction...
886cdf037ad3d72ea44f6bc4e437cf76d7a96c6a
FangyangJz/Black_Horse_Python_Code
/第二章 python核心/HX01_python高级编程/生成器_迭代器/hx11_生成器02.py
844
3.609375
4
# !/usr/bin/env python # -*- coding:utf-8 -*- # author: Fangyang time:2018/1/5 def test(): i = 0 while i < 5: temp = yield i print(temp) i += 1 t = test() t.__next__() # 第一次执行到yield,在等号右侧停下, 返回一个值 t.__next__() # 第二次执行,从yield开始,需要向temp赋值,但是上一次的值已经返回了, # 此时没有值, ...
51b90f51c4c071765cc627c75f7fb98b60b76807
richardkefa/python-pre-work
/import_demo.py
422
3.8125
4
# print("enter a string") # input_string = input() # characters = {} # for character in input_string: # characters.setdefault(character,0) # characters[character] = characters[character] + 1 # print(characters) print("Enter a string") input_string = input() characters = {} for character in input_string: cha...
4de9fa815d740248391767312a291e597c3b973d
welitonsousa/UFPI
/programacao_orientada_objetos/estudo/lista03/data/cont.py
1,446
3.609375
4
import datetime class Cont: __balance = 0.0 __date = 0 __limit = 500.0 __credit = __limit def __init__(self, client): if client.age() > 17: self.client = client self.__date = datetime.datetime.now() else: print('Cont not created') def data(...
f61cc1a0afc9ea59306df4832a3721ce74149e71
KeremBozgann/Efficient-Blackbox-Optimization-for-Gaussian-Process-Objectives-with-Resource-Intensive-Samples
/bo_cost_budget_cont_domain/cats_opt_cy/scipy_minimze_class_test.py
611
3.546875
4
import numpy as np from scipy.optimize import minimize, Bounds class Optimize(): def __init__(self): pass def function(self, x): print('function') self.z= x**2 return -(self.z+ x**3) def gradient(self, x): print('gradient') return -(2*...
779ffbb518603cefb987b6acd42d0fda16bf8a34
w3cp/coding
/python/python-3.5.1/7-input-output/4-format.py
393
3.53125
4
# print('We are the {} who say "{}!"'.format('knights', 'Ni')) print('{0} and {1}'.format('spam', 'eggs')) print('{1} and {0}'.format('spam', 'eggs')) print('This {food} is {adjective}.'.format( food='spam', adjective='absolutely horrible')) print('The story of {0}, {1}, and {other}.'.format('Bill', 'Manfred'...
2d05bad405242c0e6e3bf54cb9d3d8a696ccf8c8
victsomie/pythonbasics
/random_number_game.py
304
4
4
#A game to gues three numbers and compete with computer from random import randint x = randint(0, 5) y = int(raw_input("Enter a number (0 - 5)")) #Note that you have to convert the string input print x print y print print if y==x: print "Won" else: print "try again" #x = int(randint(0,5))
901e4dcd9cc466be60d69681312bc67159210f27
terz99/course-advanced-programming-in-python
/p2-5/main.py
233
3.53125
4
# JTSK-350111 # a2 p5.py # Dushan Terzikj # d.terzikj@jacobs-university.de mins = int(input("Enter minutes: ")) if mins < 0: print("Invalid output") else: hours = mins//60 mins -= hours*60 print("{:d} hours and {:d} minutes.".format(hours, mins))
9a20102271fdfee461398ddc77a2446646b87d42
Shandmo/Struggle_Bus
/Chapter 9/9-14_Lottery.py
1,614
3.703125
4
# 9-14 Lottery # Make a list or tuple containing a series of 10 numbers and five letters. Randomly select 4 numbers or letters from the list # And print a message saying that any ticket matching these four numbers or letters wins a prize. from random import choice # Creating Tickets and empty list of prize winn...
211dfc07a85c2017462419e22de6df01bbb54d56
laurengordonfahn/starting_algorithms
/19-caesar-cipher.py
1,771
4.4375
4
# Write a method that takes in an integer `offset` and a string. # Produce a new string, where each letter is shifted by `offset`. You # may assume that the string contains only lowercase letters and # spaces. # # When shifting "z" by three letters, wrap around to the front of the # alphabet to produce the letter "c". ...
d169fa23f347a168f7bd7e003ec3ce0a90bdae69
MrHamdulay/csc3-capstone
/examples/data/Assignment_8/mdlyud002/question3.py
1,006
4.3125
4
#Yudhi Moodley #Assignment 8 - Recursive function to encrypt a message # 09/05/2014 #store the alphabet in a list alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] encryptedString = [] def encryptMessage (rope): # proved base case ...
519e08aea509c0580d61bcfa69f4ef77d6ae7be6
Lev2307/Lev2007.github.io
/lesson8_1.py
571
3.953125
4
sentence ='Fair is foul, and foul is fair: Hover through the fog and filthy air.' alfabet = 'qwertyuiopasdfghjklzxcvbnm' def lower(w): count = 0 for i in w: for a in alfabet.lower(): if i == a: count += 1 return count def upper(w): count = 0 for i i...
5eef8dcbd58c7d81faf52ca1e289981f9bdae92e
JasdeepSidhu13/Python_201
/rename.py
502
3.6875
4
import os def rename_files(): # get file names from a folder file_list = os.listdir(r"C:\Users\Jasdeep\Downloads\alphabet") print(file_list) current_path = os.getcwd() os.chdir(r"C:\Users\Jasdeep\Downloads\alphabet") print("The current path is " + current_path) # for each file, rename file ...
b40123aeda1929ac02fb2e522e66eb77f173dc03
ralucas/alg_prac
/graph/dfs.py
1,141
3.609375
4
""" Depth First Search Current implementation expects a Graph as a dictionary with adjacent list, e.g. G = {'A': ['B', 'D'], 'B': ['C'], 'C': ['D', 'A']} """ class DFS: def __init__(self, G): self.clock = 0 self.PP = {} self.visited = [] self.G = G def previs...
e3e8b91c592f059de141faad062edae8ebd84946
kazaia/AlgoExpert_Solutions
/Recursion/product_sum.py
369
3.890625
4
# Product sum # Time complexity: O(n) where n is the number of elements in the array # Space complexity: O(n). due to recursion def productSum(array, depth = 1): outputSum = 0 for element in array: if type(element) is list: outputSum += productSum(element, depth + 1) else: o...
d56486b565276012ee34629b067af8c806d08e06
okazy/coding
/atcoder/abc097_b.py
173
3.5
4
x=int(input()) a=1 for b in range(2,x): for p in range(2,x): t=b**p if t<=a: continue if x<t: break a=t print(a)
87d5760ca4e92dc65e6665ac760b0ffdf1207552
AnneNamuli/python-code-snippets
/data_structure.py
1,089
4
4
#phone book # (1) Use a list class PhoneBookList(object): ''' This class employs 'list' datastructure in managing phone contacts ''' def __init__(self): self.book = [] def add_contact(self, username, phone_number): record = [username, phone_number] self.book.append(record) def search(self, username):...
eddd0f9a8ad8407e9c90a48eaee524982ce91701
blei7/Software_Testing_Python
/mlist/flatten_list_prime.py
2,017
4.34375
4
# flatten_list_prime.py def flatten_list_prime(l): """ Flattens a list so that all prime numbers in embedded lists are returned in a flat list Parameters: - l: a list of numbers; largest prime cannot be greater than 1000 Returns: - flat_l: a flat list that has all the...
d6bdf29b4c3a8296f563a9e661c725e8e5e309cb
MystX65/P.2-Projects
/Choose Your Own Adventure 2.py
38,559
4.09375
4
def intro(): print("You wake up on the side of the beach covered in wet sand with cuts and bruises all over your body." "\nYou slowly stand up withstanding the pain from the wounds on your body." "\nYou can't recall anything" "\nThe light hits your face making you squint." "\...
62d8394afac9d7629e3eb056a0238b4dfa6538c1
Jaimeen235/CS100-Python
/Homework8/HW8_JaimeenSharma.py
2,295
4
4
''' Jaimeen Sharma CS 100 2020F 033 HW 8, Octomber 26, 2020. ''' # Question 1: def twoWords(length, firstLetter): while True: oneWord = input('Enter a '+ str(length)+'-letter word please: ') if length == len(oneWord): break while True: twoWord = input('Enter A word beginnin...
7b651a859123a0f2f7a704f28436e9f6868aaa52
mushfiqulIslam/tkinterbasic
/input.py
712
3.96875
4
import tkinter from tkinter import * def show(): label.config(text="Name is " +input.get() +"\n Email is "+input2.get()) print(input.get()) if __name__ == "__main__": root = tkinter.Tk() root.title("Window") root.geometry("200x200") label = Label(root, text="Name") label.grid(row=0, colu...
e56045fb184f429205930f9e80056e7a82b00977
jeffwen/Interesting_Problems
/primefactorization.py
945
4.0625
4
# Given a number, return the prime factors of the number. The question required the use of a class class PrimeFactorizer: def __init__(self, n): self.n = n self.factors = [] d = 2 while self.n > 1: while self.n%d == 0: # if d is a factor of the number, t...
1edb6d292fbb55f3d55713e8616c6a682d27febd
luohuizhang/gilbert
/gilbert3d.py
4,667
3.5
4
#!/usr/bin/env python import sys def sgn(x): return (x > 0) - (x < 0) def gilbert3d(x, y, z, ax, ay, az, bx, by, bz, cx, cy, cz): """ Generalized Hilbert ('Gilbert') space-filling curve for arbitrary-sized 3D rectangular grids. """ w = abs(ax + ay +...
af4d4c2724c24b72fa4ba1b5cba89e66547ca6c7
nixawk/hello-python3
/PEP/pep-484-04-Type Definition Syntax.py
729
3.890625
4
#!/usr/bin/python # -*- coding: utf-8 -*- # Type Definition Syntax # The syntax leverages PEP 3107-style annotations with a number of # extensions described in sections below. In its basic form, # type hinting is used bt filling function annotation slots with # classes: def greeting(name: str) -> str: return "He...
ebb952aeab71fabeff076a4675af32443a66447e
mayur12891/Demo2020
/filereadwrite.py
675
3.875
4
# File read write # w - write # r - read # r+ - read and write # a - append # Below code will create/write a new file and read a file # By default it will save the file in same directory location # This will added to test Git. # This line is again added to test Git. # This is added to reflect in deep branch. my_file =...
e302ead5bf5c715224e0033dd07280bad8c818df
inderbhushanjha/Machine_Learning
/data_program.py
1,343
3.625
4
import numpy as np import pandas as pd import sklearn from sklearn import linear_model import matplotlib.pyplot as pyplot import pickle from matplotlib import style data=pd.read_csv("student-mat.csv", sep=";") #print(data.head()) data=data[["G1","G2","G3","absences","failures"]] #print(data.head()) predict="G3" x=n...
3cd45d4bed04ef6478d408f966d4623a364d8fc4
WuAlin0327/python3-notes
/面向对象编程/day3/绑定方法与非绑定方法.py
320
3.640625
4
class Foo: def __init__(self,name): self.name = name def tell(self):# 绑定到对象的函数 print('name:%s'%self.name) @classmethod def func(cls): #cls=Foo 绑定到类的方法 print(cls) @staticmethod def func1(x,y):#类中的普通函数 print(x+y) f = Foo('wualin') Foo.func1(1,2) f.func1(1,3)
23e4f96eb10524a3d27a449e2116354b882b43f8
gracejpw/play
/markdown-musings/test1.py
430
3.609375
4
import markdown text = """# Heading 1 Some words. ## Heading two More words, followed by a list. 1. Plan A 2. Plan B The list *pros:* * Plans are **good** This list has _cons:_ * It lacks a Plan C """ xhtml = markdown.markdown(text) print(xhtml) print("----------") html5 = markdown.markdown(text, output_for...
596eab16cd05da96284b65dd7bb85cf051929ce9
aleranaudo/SizeItUp
/ran.py
211
3.734375
4
import random print(random.random()*100) import random myList=["red","green","blue","yellow","purple",1,2,3,] print(random.choice(myList)) import random for i in range(3): print(random.randrange(0,100))
34aa6e4ebff9a4306f30ca9a5f681a94292f30f5
chumbalayaa/6.935Final
/libs/yql-finance-0.1.0/build/lib/yql/request.py
1,062
3.578125
4
import requests class Request(object): """Class is responsible for prepare request query and sends it to YQL Yahoo API.""" parameters = { 'q': '', 'format': 'json', 'diagnostics': 'false', 'env': 'store://datatables.org/alltableswithkeys', 'callback': '' } api =...
b296b6f04b924a99b4111d5376ed1dd543fff568
jxie0755/Learning_Python
/LeetCode/LC142_linked_list_cycle_ii.py
1,525
3.75
4
""" https://leetcode.com/problems/linked-list-cycle-ii/ LC142 Linked List Cycle II Medium Given a linked list, return the node where the cycle begins. If there is no cycle, return null. To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list wh...
01b719174bd5b1bc7d189fc2e29988ea7cd2c3e6
jacchkiki/kiki-python
/before/0601.py
312
3.6875
4
print "kiki" y=10 print "kiki is %d years old."% y x=range(0,3) name=["xuan","kiki","will"] for number in range(0,3): print name[number] for number in range(0,3): if name[number]=="kiki": print name[number] for number1 in range(0,3): if name [number1]!="kiki": print name[number1]
0604b688b99ad5edb5f094e1b6bfb5dd3bcb835e
syurskyi/Algorithms_and_Data_Structure
/_algorithms_challenges/edabit/_Edabit-Solutions-master/First and Last Index/solution.py
373
3.828125
4
def char_index(word, char): output = [] for i in range(len(word)): if word[i] == char: output.append(i) elif char not in word: return None output.sort() if len(output) == 1: output.append(output[0]) if len(output) > 2: for i in range(1,len(outp...
ec34abe668c3982db9ff2b43aa6a5e0e8a485c5e
Taoge123/OptimizedLeetcode
/LeetcodeNew/LinkedList/LC_203_Remove_Linked_List_Elements.py
1,147
3.84375
4
""" Remove all elements from a linked list of integers that have value val. Example: Input: 1->2->6->3->4->5->6, val = 6 Output: 1->2->3->4->5 """ class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def removeElements(self, head, val): dummy = List...
f52571826a5c390887d29faa43e8202b7eebeca1
diditaditya/geocalc
/shallow_fdn/src/model/earth_pressure_coeff.py
3,203
4.1875
4
"""Import trigonometry functionality from math module.""" from math import sin, cos, radians, sqrt def at_rest(eff_friction): "This function returns at rest pressure based on Jacky, 1944." return 1 - sin(radians(eff_friction)) def at_rest_2(eff_friction): "This function returns at rest pressure based on B...
a96c376d2eca98dab4979f1f60251bdd5f697bc8
tddontje/wordsearch
/WordSearch.py
16,805
4.09375
4
""" WordSearch - This program searches a given grid of letters for words contained in a given dictionary file. * The grid of letters will be randomly generated. * The search for words have the following constraints: * Words will be search forwards, backwards, up, down and diaganol * Words will not be tested for wr...
f51bfec0753fbbff8a429a504600b8751a4d0297
wy2530/Record_python
/CBOW/01 logger/2、property.py
1,875
4.5
4
""" 用类实现的装饰器:property property:是一个装饰器,是将功能属性转换为数据属性 """ # 应用案例1(体质): # class People: # def __init__(self, name, weight, height): # self.name = name # self.weight = weight # self.height = height # # ''' # 因为BMI是计算出来的,所以需要单独写一格函数,不然会写死 # 但是在用户看来BMI又属于数据属性,需要之间查看,因此需要用到property属...
4671f6f884610554b7793fd02bff024c444784d1
AndreaCrotti/my-project-euler
/prob_5/prob_5.py
165
3.765625
4
#!/usr/bin/env/python # smallest divisible by 1..20, doing another reverse loop res = 1 for i in range(20,0,-1): if (res % i) != 0: res *= i print res
e97b031674490b87fd4704fb43305c8dfc5bcf44
RaMaaT-MunTu/learn-python
/list_comprehension.py
892
4.28125
4
########################## # List comprehension 101 # ########################## numbers = [1, 4, 10, 3, 30, 2, 66, 20, 30] words = ['jacqueline', 'Robert', 'tulipes en fleurs', 'rue des chemins', 'palmiers de Dubai', 'Paris la nuit', 'bracelet', 'jantes', ...
b53d3032257e236aa5088f31d491d296c9a07aca
xiaoqi2019/python14
/week_7/class_0301/class_unittest_learn.py
4,068
3.640625
4
#测试用例===准备好 类TestCase #执行用例 套件TestSuite # 测试报告类TextTestRunner 一致pass 不一致Failed 测试结果 #开始对加法进行单元测试 import unittest #引入单元测试模块 from week_7.class_0228.my_log import MyLog class TestAdd(unittest.TestCase): #继承编写测试用例的类 def setUp(self): print('------开始执行测试用例了------') #测试用例执行前的准备工作,比如环境部署,数据库连接,每执行一条测试用例就执行一次 ...
b963110b2e12dc1a052e978d63418a82e4d821d4
stdiorion/competitive-programming
/contests_atcoder/abc179/abc179_c_tle.py
719
3.5
4
from itertools import accumulate,chain,combinations,groupby,permutations,product from collections import deque,Counter from bisect import bisect_left,bisect_right from math import gcd,sqrt,sin,cos,tan,degrees,radians from fractions import Fraction from decimal import Decimal import sys input = lambda: sys.stdin.readlin...
3f7bfbadf9329b5930c000e11628cb365ad9c346
JoeJiang7/python-crash-course
/chapter 15/15-3.py
573
3.5625
4
import matplotlib.pyplot as plt from random_walk import RandomWalk while True: rw = RandomWalk() rw.fill_walk() point_numbers = list(range(rw.num_points)) plt.plot(rw.x_values, rw.y_values, linewidth=1) plt.scatter(0, 0, c='green', edgecolors='none', s=100) plt.scatter(rw.x_values[-1], rw.y_va...
705fba5ed021c0a28ed235258509c87b3cc00bec
mtariquekhan11/PycharmProjects
/welcome Projects/LCM_HCF.py
1,257
4.0625
4
# Author: Mohd Tarique Khan # Date: 14/10/2019 # Purpose: To calculate the LCM and HCF/GCD condition = "True" def hcf(x, y): if x < y: smaller = x elif x > y: smaller = y for i in range(1, smaller + 1): if x % i == 0 and y % i == 0: hcf = i return hcf def lcm(x,...
627123d01077a372465ebba1d3e850ee45c00124
nileshnmahajan/helth
/temp/select.py
402
3.640625
4
import sqlite3 conn = sqlite3.connect('hospital.db') #con.isolation_level = None c = conn.cursor() #create table for store hospitals data for row in c.execute(' select * from Hospital'): print (row) for row in c.execute(' select * from Users'): print (row) for row in c.execute(' select * from Disease'): print (...
c6f8e67f6c2cd1fad9db4674a6b05f281a50e684
vorjat/PythonBootCamp
/zjazd_2/funkcje/zadanie_dod9.py
783
3.625
4
def rysuj(liczba=0): liczba = int(input("Podaj liczbe: ")) if liczba == 0: print(f""" *** * * * * * * ***""") elif liczba == 1: print(f""" * * * * * * """) elif liczba == 2: print(f""" *** * * * * *****""") elif liczba == 3: print(f"""...
cda784e37c249e2baefb6b7b32bfa47ed90867d6
AbhijitEZ/PythonProgramming
/Beginner/DataTypes/i_o_operation.py
997
3.875
4
import os print(os.getcwd()) # get the working dirctory of the python executable. current_path = os.path.dirname(__file__) # current working file directory print(current_path) my_file = open(os.getcwd() + '/Resource/myFile.txt') print(my_file.read()) # second time it empty string because cursor has moved to the ...
69dc6ec22f6ee5b6d971aa5f0a59a7ce71d1a6c2
Mbaoma/workedExamples
/examples/small-primes/soln.py
2,728
4.3125
4
import time UPPER_BOUND = 10000000 # Warning! Values > 100,000,000 will take a LONG time. PRIMES_TO_SHOW = 10 def main(): print("This program will test whether a specified integer is prime.") print("It will also print out the " + str(PRIMES_TO_SHOW) + " primes <= the provided value.") print("...
10de8ee6d7fe7b8511c05fb768a27b9bf4379338
luismedinaeng/holbertonschool-higher_level_programming
/0x0B-python-input_output/2-read_lines.py
384
3.671875
4
#!/usr/bin/python3 def read_lines(filename="", nb_lines=0): n_line = 0 with open(filename, mode='r', encoding='utf-8') as a_file: if nb_lines <= 0: print(a_file.read(), end="") else: for a_line in a_file: print(a_line, end="") n_line += 1 ...
da0baf0430309450bd274c7fa40bb310385a9213
EwertonBar/CursoemVideo_Python
/mundo03/desafios/desafio103.py
302
3.796875
4
def ficha(nome='<desconhecido>', gols=0): print(f'{nome} fez {gols} gols.') nome = str(input('Nome do jogador: ')) gols = str(input('Quantos gols: ')) if gols.isnumeric(): gols = int(gols) else: gols = 0 if nome.strip() == '': ficha(gols=gols) else: ficha(nome, gols)
c93a996d951ed561e748344f4458bc128448847a
2020cbustos/Coding
/ceasar.py
1,988
4.3125
4
#encrypt a message with a shift in letters. Takes into accounts letters 1 to 26. #LOGIC of INCRIPTION #main idea: loop through a string and shift #create hash with each letter and their numeric value (of the alphabet) #create function that takes in string and returns the same string with shift #create empty array ...
5cf314668cf0144daceb2e1314b72adae30df001
Y1ran/python
/工资函数.py
677
4.1875
4
#用户的薪资输入水平>=0 #超出40小时的工时按1.5倍工资计算 def computepay(): try: pay1 = raw_input("Please Enter your Hours:") work_hours = float(pay1) pay2= raw_input("Please Enter your Rate:") work_salary = float(pay2) except: print "Error, please enter a numeric input" ...
5507ec2388c2a546a285efe064d5f35c26b8cf4b
DoctorSad/_Course
/Lesson_05/_6_recursion_1.py
997
4.375
4
""" Рекурсию можно применить например к алгоритму вычисления факториала. """ def main(): n = int(input("n: ")) result = fact(n) print(result) def fact(n): if n == 0: return 1 # если n == 0 - возвращаем 1, так как факториал числа !0 = 1 return n * fact(n - 1) # умножаем число n на ...
cba823b9cdbd1b9ff37ab53b5f1e2316368e7cc5
pavarotti305/python-training
/use_module_sys.py
871
3.796875
4
import sys introduction = "Module Sys allow interaction with user with special object stdin (standard input) and readline" print(introduction) introduction = sys.stdin.readline(18) print(introduction) print('') def old_joke(): sys.stdout.write('What this your name ?\n') print('Please enter you name below:') ...
a242336c34ce52034739ed524bfb92612c51e17b
samarla/LearningPython
/backup/guessing_game_two.py
881
4
4
import random compare = None recent_guess = random.randint(0, 100) count = 0 print('Please keep some Random number (0-100) in your mind, and let me guess it. \n Here we go') def print_random(x, y, z): """this function will display the guess and gets the feedback from the user""" x = +1 #y = random.randint...
e398ba34cb1c6f8b47685c378081f5c17f66e12c
rahulmahajann/pep_sht
/random questions/fourdivisor.py
560
3.796875
4
import math ans=[] def primeFactors(n): # ans.append() while n % 2 == 0: ans.append(2) n = n//2 for i in range(3,int(math.sqrt(n))+1,2): while n % i== 0: ans.append(i) n = n // i # if n > 2: # ans.append(n) # ans.append return ans nu=[21,4,7] fans=[] for _ in nu: primeFactors(_).append(_...
644c1c618dd32fdd8ffb9cbcdfbdef00d416a021
quangdbui9999/CS-171
/week4Python/Week4/HighwayNumber.py
833
4.40625
4
highway_number = int(input()) ''' Type your code here. ''' if(highway_number == 0): print(f'{highway_number} is not a valid interstate highway number.') if(1 <= highway_number <= 999): if(1 <= highway_number <= 99): if(highway_number % 2 == 0): print(f'The {highway_number} is primary, going...
e37479be93febc2e689ef0cbaa9835a2c03eba4f
brunacarenzi/thunder-code
/par.impar.py
312
3.859375
4
from random import randint numero = int(input('Digite um número para saber se é par ou impar:')) resto = numero % 2 if resto == 0: print('Número {} é par'.format(numero)) else: print(f'Número {numero} é impar') pc = randint(0, 10) resto = numero % 2 print(' escolhi {}'.format(pc))
076c6d4eee28a516dabd8e70ddc78c4b45ac9b3c
Mikicodes/pinterestkingz
/Pin.py
1,199
3.53125
4
class Pin: #Construct a pin def __init__(self): #self.name = name #self.picture = picture # self.description # self.posting_date self.comments = [] #Reassign Name of Pin def set_name(self,name): self.name =name #Get Name of the Pin def get_nam...
44cc9cdf998c20eebda2075fe0152cb7b637e4f7
yl4669458/spyderfile
/test_29_itertools.py
1,499
3.765625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri May 1 09:39:37 2020 @author: yl """ import itertools print('accumulate') x = itertools.accumulate(range(2, 10), lambda x, y: x * 10 + y) l = list(x) print(l) class Test(object): def test_2(self): return map(lambda x, y : x == y, r...
f2a5ff360bbfa37449526b39f82d861b7b899f39
Yehia-Fahmy/pathfinding
/pathfind_test.py
2,307
3.8125
4
import queue def createSmallMaze(): maze = [] maze.append([" ", " ", "O"]) maze.append([" ", " ", " "]) maze.append(["X", " ", " "]) return maze def createMaze(): maze = [] maze.append(["#", "#", "#", "#", "#", "O", "#"]) maze.append(["#", " ", " ", " ", "#", " ", "#"]) maze.app...
67c6fcf33372630df6ea562df32580e84ebdfff8
KWolf484/PythonProject
/CMD_Test_Text_file_compiler/CMD_Test_Text_file_compiler/CMD_Test_Text_file_compiler.py
920
3.59375
4
import os, re def txt_file(): tfile = os.system(r'dir \\TheRig\Movies\ /b > C:/Users/Wolf/Documents/text_files/Movie_list.txt') return tfile txt_file() def movie_find(): movie = input('What Movie are you looking for?' ) tfile = (r'C:/Users/Wolf/Documents/text_files/Movie_list.txt') tfile = open(tf...
cdfca8146193d1ea6898ee3cd4ed1df8992e8235
Keyxllai/PythonCook
/Basic/variableDemo.py
327
3.875
4
if __name__ == "__main__": ''' referencing ''' v = 110 print(v) ''' assign multiple values at once ''' tu=('a',1,3) (x,y,z) = tu print("X:{x},Y:{y},Z:{z}".format(x=x,y=y,z=z)) ''' assign consecutive values ''' (MON,TUE,WED,THU,FRI,SAT,SUN)=range(1,8) pri...
b1931b9b7bc509fb729d601f35cfc148784b3638
UWPCE-PythonCert-ClassRepos/SP_Online_PY210
/students/shodges/lesson08/circle.py
3,080
3.90625
4
#!/usr/bin/env python3 import math class Circle(object): def __init__(self, radius): try: self._radius = float(radius) self._diameter = float(radius) * 2 except ValueError: raise TypeError("radius expects a float") def __str__(self): return 'Circle...
c32567a01fdb538daf47de7d05447658bca74e28
fengbaoheng/leetcode
/python/79.word-search.py
2,024
3.578125
4
# # @lc app=leetcode.cn id=79 lang=python3 # # [79] 单词搜索 # from typing import List, Set, Tuple class Solution: # 深度搜索 # 记录走过的路径 def exist(self, board: List[List[str]], word: str) -> bool: try: rows = len(board) cols = len(board[0]) for r in range(rows): ...
a45f290e5f36b4213bb2f5393065d6bf4f741dd6
thezhu007/P5_interfaces
/samples/re_page/demo5.py
255
3.578125
4
#re.finditer 查找所有,并返回迭代器,迭代器中都是match对象 import re str = 'hello 123 hello' pattern = re.compile('\w+') result_03 = pattern.finditer(str,pos=5,endpos=12) print(type(result_03)) for i in result_03: print(i.group())
6cd2158e215cd4e65ca15a3a2a654e8c5949503a
Wendy-Omondi/alx-higher_level_programming
/0x04-python-more_data_structures/100-weight_average.py
222
3.5
4
#!/usr/bin/python3 def weight_average(my_list=[]): if my_list: total = 0 div = 0 for x in my_list: total += x[0] * x[1] div += x[1] return total/div return 0
58d463c2652c94f51ab64703aa0413a2a02e3e5a
MinecraftDawn/LeetCode
/Hard/124. Binary Tree Maximum Path Sum.py
686
3.6875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def maxPathSum(self, root: TreeNode) -> int: self.maxPath = -2e30 self.dfs(root) return self.maxPath def...
9128bb60eeb1c0b8a84ac392adc92379016e7f58
faantoniadou/Computer-Simulation
/CP1Test.py
380
3.640625
4
from CP1 import Polynomial def main(): pol1 = Polynomial([2,0,4,-1,0,6]) pol2 = Polynomial([-1,-3,0,4.5]) pol2.polyadd(pol2) print(str(pol2)) pol1.antiderivative() print(" The antiderivative of the polynomial is " + str(pol1.antiderivative)) pol1.derivative() print(" The derivative ...
8c8c0d3962ca0f419e130775c33ed72af5af8c31
anwarali12255/tip-caalculator
/main.py
349
4.1875
4
print('welcome to the tip calculaor.') total_bill=int(input('what is the total bill? ')) tip_percentage=int(input('what percentage tip would you like to give? 10,12 or 15? ')) per=(tip_percentage)/100*(total_bill) no_of_people=int(input('how many people to split the bill? ')) final=(per)/(no_of_people) print(f'each ...
369422ced0ab09537779747498a1f4a48379ac08
yehonadav/python_course
/lessons/regEx/regex_examples.py
1,759
4.25
4
import re text = "today i got to work early" # Search the string to see if it starts with "today" and ends with "early" x = re.search(r"^today.*early$", text) print(x) # Print a list of all matches x = re.findall(r"to", text) print(x) # Return an empty list if no match was found x = re.findall(r"zombie", text) pri...
eb8ab4242c89b74d52ef192f8f1667afe6b8ae1e
Pbharathwajan/all-code
/Problems/problrm.py
210
3.984375
4
num = 7 if num>1: for i in range (2,num): if num%i == 0: print(f'{num} is not prime') break elif num%i !=0: print(f'{num} is prime') break
2029515ea026dadb5118faa61b981c659eb7731d
tarunbhatiaind/Pyhtonbasicprogs
/args.py
981
4.09375
4
#args and kwargs #Actual way : # def func1 (a,b,c,d): # print(a,b,c,d) # # func1("A","b","c","d") #args: def func2(*args): #can use any name not only args print(args[1]) for item in args: print(item,end="") itm=["A","B","C","D"] func2(*itm) #works fine with one argument at first place and list i...
06e66ef4355902f462b8e90609f916a705bf6fba
Yema94/Python-Projects
/ioproject/mysandwich.py
1,143
4.15625
4
#yourway sandWITCH availableToppings = ["Onion", "Paprika", "Tomato", "Chicken", "Alpinos", "Teriyaki Sauce"] print("Available Toppings List : ") for i in range(len(availableToppings)) : print(i+1, availableToppings[i], sep=' : ') selectedToppings = [availableToppings[int(x)-1] for x in input("Select any 3 Toppings us...
c50e122e5cb0cd39df9778c7dc8ba74b6e5fe85d
Shao-Ting/ST-s-Python-work
/'w401.py'35.py
726
3.734375
4
# coding: utf-8 words=''' 人生長至一世、短如一瞬 寰宇浩瀚無際,此生飄渺無歸 旅途上,我們將會遇到許多 或許喜悅、或許傷悲、或許歡喧、或許靜寧 請記得哭過、笑過,要繼續活下去 真正重要的到底是什麼 我們似乎都在追求著什麼 最後才發現 握緊手心,裡面什麼都沒有 一呼一吸 花開花落 追日、探月、索星、尋夢、逐塵 無論他人怎麼說,我們都是獨一無二的我們 紛紛擾擾的一生中 或許只有自己明白 或許自己也不明白''' words.split('\n') phrase=words.split('\n') p=randint(2,7) for i in range(p): pp=randint(1,3) e...
7b979b62e0828aae93811ff6b9c39fd5bca83ec5
sushmithasuresh/Python-basic-codes
/p9.py
228
4.28125
4
n1=input("enter num1") n2=input("enter num2") n3=input("enter num3") if(n1>=n2 and n1>=n3): print str(n1)+" is greater" elif(n2>=n1 and n2>=n3): print str(n2)+" is greater" else: print str(n3)+" is greater"
67ffa7346ed08a55081219fa505b1dade540f30a
SCOTPAUL/tangowithdjango
/tangowithdjango/rango/bing_search.py
1,882
3.5625
4
import json import urllib2 import keys BING_API_KEY = keys.BING_API_KEY def run_query(search_terms): # Base URL root_url = 'https://api.datamarket.azure.com/Bing/Search/' source = 'Web' results_per_page = 10 offset = 0 # Wrap search terms in quotation marks and make URL safe query = url...
e7f3c1ea41c84714f907bea459b7fc743ee6f19d
gyang274/leetcode
/src/0900-0999/0977.squares.of.a.sorted.array.py
598
3.578125
4
from typing import List class Solution: def sortedSquares(self, A: List[int]) -> List[int]: stack, ans = [], [] for x in A: if x < 0: stack.append(x * x) else: s = x * x while stack and stack[-1] < s: ans.append(stack.pop()) ans.append(s) while stack:...
ab245ca8a5f29a0bf569aa2dfbdac15c472b15ac
Krzysztof-Lewandowski89/Python
/kurs-python/roz6/t6_5.py
239
3.640625
4
#przykłady krotek, operacje values = (1,2,3,4,5,6,7,8) new_values = values[:3] #wyciecie wartosci od 0 do 3 print(2 in new_values) new_values2 = new_values + (12, 24) #doklejenie/dodanie kolejnych dwoch wartości print(new_values2)
3f011626dfe2f23cd9240fb020ec56043280c907
lakshaysharma12/programs-in-python
/mile_to_km.py
1,025
3.84375
4
from tkinter import * windows = Tk() windows.minsize(width=300,height=500) windows.title("Miles to Kilometer") windows.config(padx = 20, pady = 20) input = Entry(width = 20) input.grid(column = 1,row =0) # input.config(padx = 10, pady =10) miles = Label(text = "MILES" ,font =("Arial",24)) miles.g...
8b86a6d0703659d631af14cfaaf4637df5a4d4ca
rishky1997/Python-Practice
/Day 9/Q2.py
227
4.5
4
#2.Write python program to check that given number is valid mobile number or not? import re s=input('Enter mobile no.') o=re.findall('[7-9][0-9]{9}',s) if o==[s]: print('No. is valid') else: print('No. is not valid')
041366d1c7e1ceac451623ce72e205c9a6efaf91
codingyen/CodeAlone
/Python/0108_convert_sorted_array_to_binary_search_tree.py
607
3.734375
4
# DFS # Find the logic and how to recursive. class TreeNode: def __init__(self, val = 0, left = None, right = None): self.val = val self.left = left self.right = right class Solution: def sortedArrayToBST(self, nums): if not nums: return None mid ...
a66da356646ef9b94841ebeb9638bb61c1ff0ada
idontknoooo/leetcode
/python-interview-project/question3.py
2,582
3.671875
4
# This is a program find minimum spanning tree(mst) from a graph # Import sys for sys.maxint import sys # Question3 def question3(G): # Return the edge size of G size = len(G) # Handle the one node case if size==1: single = {} for i in G: single[i] = [] ...
497eebcb804b1b56a816b81c665292a289e1a8c4
doug3230/Portfolio
/Simplex/src/rational.py
14,702
3.8125
4
""" ------------------------------------------------------- rational.py contains code for the Rational class. ------------------------------------------------------- Author: Richard Douglas Email: doug3230@mylaurier.ca Version: 2014-01-21 ------------------------------------------------------- """ import rational_fu...
52c3ddeb6b3a17f2183a9125eaafaa2f5c5ab6b7
thanhtuan18/anthanhtuan-fundametal-c4e15
/Session5/test.py
884
3.921875
4
#person = ["Tuan anh", 22, 2, "Hanoi", "Moc chau", 5, 4, "Maria", "Ping pong"] # person = {} # print(person) # # person = { # # key : value # "name": "Tuan anh" # } # print(person) person = { # key : value "name": "Tuan anh", "age": 22, "sex": "male" } # for k in person: # print(k, person...
4309a71d5fe0604a27141238c207f1f3b6d87866
paulo-caixeta/Curso_Python-CursoEmVideo-Guanabara
/ex016.py
90
3.734375
4
import math n = float(input('Digite um número real qualquer: ')) print(math.floor(n))