blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
b3edf8d7d5c833af3e529c30fbe679a111609346
shahprashant030/Student-Library-Management
/Student Library Management/insertstudent.py
1,409
3.640625
4
import pymongo from tkinter import * def i_student_function(): root = Tk() root.title("Insert Into Student") root.geometry("700x300") def insertstudent(): client = pymongo.MongoClient("mongodb://localhost:27017") db = client.student_lib_DB collection = db.student ...
17dc194ec1a56cd846e727589729d22f2e45ec4f
DianaN87/Project-Diana
/biblioteki.py
620
3.96875
4
import calendar print(calendar.month(2020,11, w=10, l=0)) # esli 1-9 mecjaz, to nuzno pisat prosto chslo bez 0 speredi print(calendar.calendar(2020, w=0, l=0, c=13, m=3)) # c=3 - rastojanie mezdu stolbikami vsego kalendarakolichestvo, m- kolichestvo mesjacev v odnu strochku print(calendar.weekday(2021, 2, 15)) # 0 poka...
52b59369626e4e18ee7364e897ca2443a286d199
marufaytekin/robotics
/linear_controller.py
6,318
4.0625
4
#!/usr/bin/env python # coding: utf-8 # # Linear Cascaded Control # # **NOTE** - completing this exercise without looking at the solution could take a few hours. Be prepared and good luck! # # <img src="Drone2.png" width="300" height="300"> # # In this lesson we will be working with a simplified model of the 2D dro...
cb38d9f780da3f8f4c88026d6c7665b81f4f13d3
wseungjin/codingTest
/kakao/2021/2-fast.py
1,764
3.53125
4
from itertools import combinations def getElements(orders): elements = set() for order in orders: for i in range(len(order)): elements.add(order[i]) answer=list(elements) answer=sorted(answer) return answer def solution(orders, course): elements = getElements(orders) ...
b2ee5d0b503f291796d45c807bd0fa2ddb274cb0
EpsilonHF/Leetcode
/Python/219.py
533
3.640625
4
""" Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between i and j is at most k. Example 1: Input: nums = [1,2,3,1], k = 3 Output: true """ class Solution: def containsNearbyDuplicate(sel...
0f9a520edff3825a861e623db91a22083d9a2efb
LuccaSantos/curso-em-video-python3
/Desafios/modulo02/def66.py
504
3.859375
4
''' crie um script q leia varios numeros inteiros (flag 999) no final mostre quantos números foram digitados e qual a soma entre eles ''' print('= ' * 6 + 'TESTANDO O BREAK' + ' =' * 6) soma = 0 numero_inputs = 0 while True: numero_atual = float(input('Informe um número(999 para para!): ')) if nu...
1cf029d70860bd6015b8abe2e6d01ed46f50d777
daniel-reich/turbo-robot
/FWh2fGH7aRWALMf3o_2.py
1,079
4.40625
4
""" Create a function that takes a string (without spaces) and a word list, cleaves the string into words based on the list, and returns the correctly spaced version of the string (a sentence). If a section of the string is encountered that can't be found on the word list, return `"Cleaving stalled: Word not found"`...
7a9ec2362cb6ff94fbd54a901000317bb4dc79ac
mailinhvu912/C4T15
/session3/minihack1/part5.py
673
3.75
4
from random import randint Score = 0 while True: a = randint(0,20) b = randint(0,20) c = randint(0,40) print(a ,"+", b ,"=", c) Answer = input("Is this correct?", ) if c == (a + b): if Answer == "yes": print("Well done") Score+=1 print("Score =", Sco...
36001589859d608522238ba7932f60e4e47cc6bc
srinijadharani/DataStructuresLab
/01/01_c_perfect.py
719
3.828125
4
# 1c. Program to check whether a given number is perfect or not. """Definition: A perfect number is a positive number such that it is equal to the sum of its proper divisors.""" num = int(input("Enter a number to check whether it is a perfect number or not: ")) def perfect_number(num): # initialize sum ...
86c94e69f58a8a9b0e6f0503c955cdafe8ee8fed
kohle/py-blackjack
/main.py
7,730
3.90625
4
# py-blackjack # File description: Main class for the program # Developed by Kohle Feeley # Burlington, Vermont 2017 # Import Python classes import random # Score variable score = 0 # Create score file if it doesn't exist with base score, otherwise get score try : score_file = open("score.txt", "r") score = ...
c770cbbc47d09745afd1e44b20392b7265a14cea
Dzhevizov/SoftUni-Python-Advanced-course
/Tuples and Sets - Exercise/04. Count Symbols.py
218
3.640625
4
text = input() dictionary = {} for el in text: if el not in dictionary: dictionary[el] = 0 dictionary[el] += 1 for letter, count in sorted(dictionary.items()): print(f"{letter}: {count} time/s")
3ae7965d6da9d452ef1deae189ff91138d43cf98
PuttTim/MundaneUnevenBug
/diamond/diamond half bottom.py
463
3.90625
4
row=int(input("Enter row number here: ")) column=0 col2=row-1 column3=row col4=1 for i in range (row): column=int(column+1) # for blanks for i in range (column): print(" ", end='') # for stars for i in range (col2+1): print("*", end="") col2=col2-1 #bottom half #for stars column3=int(column...
fe940875d949b8c1b8d56ff777a0b9ac01a62ee2
rtejaswi/python
/rec.py
105
3.703125
4
def rec(): a=input('enter the string') #if len(a)>1: temp=a[::-1] print(temp) rec()
9a2d0596d60feff1d0993ac86a4509bcbf478728
Nazarik86/Second_Lesson_Python
/Fifth_Lesson_Python/Mikhail_Nazarov_HW_5_4.py
739
3.9375
4
# 4. Представлен список чисел. Необходимо вывести те его элементы, значения которых больше предыдущего, например: # # src = [300, 2, 12, 44, 1, 1, 4, 10, 7, 1, 78, 123, 55] # result = [12, 44, 4, 10, 78, 123] # ``` # Подсказка: использовать возможности python, изученные на уроке. src = [300, 2, 12, 44, 1, 1, 4, 10, 7,...
7008e868a5ebf045bed71e308e0dafdd77833936
SeifMostafa/SeShat-master
/Text To Speach.py
1,094
3.703125
4
"""def synthesize_text(text): Synthesizes speech from the input string of text. from google.cloud import texttospeech client = texttospeech.TextToSpeechClient() input_text = texttospeech.types.SynthesisInput(text="هذا صحيح") # Note: the voice can also be specified by name. # Names of voices ca...
d88f690ede9b352c16f22d817c2277671976682e
liliang1991/machinelearning
/src/main/python/mlib/word2vec/util/Word2VecUtils.py
833
3.578125
4
from pyspark.ml.feature import Word2Vec from pyspark.shell import spark # Input data: Each row is a bag of words from a sentence or document. documentDF = spark.createDataFrame([ ("Hi I heard about Spark".split(" "), ), ("I wish Java could use case classes".split(" "), ), ("Logistic regression models are ne...
ee9aa7e9974bfcbd48682885d0b8b8f858849d76
smile0304/py_asyncio
/chapter06/set_test.py
312
3.78125
4
#set 集合 #fronzenset 不可变集合 # 无序,不重复 s = set("abcdee") print(s) s = set(["a","b","c","d","e"]) s = {'a','b','c'} s.add('s') print(type(s)) print(s) # s = frozenset('abc') # print(s) another_set = set("def") s.update(another_set) print(s) re_set = s.difference(another_set) print(re_set)
eb77966d1d5878ada4f95e18c4e50959275aff34
andresalbertoramos/Master-en-Programacion-con-Python_ed2
/silvia/05_class/reverse.py
114
3.875
4
def reverse(a, b): return b, a # Lo devuelve en una tupla a = 1 b = 2 a, b = reverse(a, b) print(a) print(b)
bec8b6450cf3108276a4aab15c0750f28ef07295
Talhaitis612/BasicofPython
/main.py
1,364
3.921875
4
#Python is a programming langague with a clean syntax #Python programs can be ru on all desktop programs. #Hello World will always be the first program that you make in any langague. #here we did the same #print is a built in function of android we will learn about function more in detail below print('hello world') #so...
b0f1bbe30323a896e926b6a3e81417102f2425ea
Shehu-Muhammad/Python_College_Stuff
/Python Stuff/Account.py
2,166
3.90625
4
# Account Program # Shehu Muhammad # February 14, 2018 grade1 = int(input("What was the first grade? ")) grade2 = int(input("What was the second grade? ")) grade3 = int(input("What was the third grade? ")) grade4 = int(input("What was the fourth grade? ")) if(grade2 <= 50): print("You failed Part 1.") print("...
45c4f94c95c36b37dbba3ba1255db4a7b9f8ce3f
ArshSood/Codechef_Assignment
/PEC2021H/PECEX1D.py
503
3.6875
4
def stairs(n,x): global num if x==1: count=0 for i in range(-3,4): #count=0 if n-i==0: count+=1 return count count=0 for i in range(-3,4): if 0<=n-i<=num and x!=0: count+=stairs(n-i,x-1) return count t=int(input())...
fededea82535dba548c9dfc3e735819addefc14b
chandrakanth137/GUI-Sudoku-Solver-python
/GUI-Sudoku_Solver/Sudoku_Solver.py
10,674
3.921875
4
from tkinter import * from tkinter import messagebox import copy # to find the empty cells in the sudoku def find_empty_location(arr, l): for row in range(9): for col in range(9): if(arr[row][col]== 0): l[0]= row l[1]= col return True return...
13528f143378bcd7f952195b86c5d9a851d0a0fd
jananee009/Project_Euler
/Euler_Problem32.py
3,028
4
4
# Pandigital Products # Problem 32: https://projecteuler.net/problem=32 # Find the sum of all products whose multiplicand/multiplier/product identity can be written as a 1 through 9 pandigital. # Approach: # 1. We want to find a product such that multiplicand * multiplier = product and the multiplicand, multiplicant a...
b89ec87026edfef15839d29454e377f7a85791ab
flogothetis/Technical-Coding-Interviews-Algorithms-LeetCode
/Grokking-Coding-Interview-Patterns/2. Two Pointers/subarrayswithProductLesssThanATarget.py
645
3.90625
4
from collections import deque # Time Complexity : O(N^3) def subarraylessProductTarget ( array, target): windowStart = 0 prod = 1 result = [] for windowEnd in range ( len(array)): # O(N^3) prod *= array[windowEnd] if ( prod >= target and windowStart <len(array)): prod/= array[windowStart] windowStart+=...
f3eb6edbfdfbdae64055c95766d817363a6cdc0f
Laruxx/Data_projects
/Python 101 Full Version 2-25-2019.py
69,595
3.84375
4
# You can use the # symbol to comment your Python code ''' Another way to comment your Python code is to use a multiline string that is opened and closed with three single or double quotation marks ''' """ this is also a comment""" #################### ### INSTALLATION ### #################### # 5 MINU...
0c8feaa9deb60096505a719975647972d8c32d71
btparker70/Python-Basics
/basics/app.py
835
3.84375
4
# variable students_count = 1000 # float rating = 4.99 # boolean is_published = True # string course_name = "Python" # you can do triple quotes if your string has multiple lines course_name_2 = """ Python Course """ # you can initailize multiple variables on the same line x = 1 y = 2 x, y = 1, 2 # we can set multipl...
d35e96bed8b86b957d315df9c205ef8cfb1c9c6b
armada74/webcrawling
/test.py
823
3.609375
4
import requests from bs4 import BeautifulSoup def spider(): base_url = "http://www.naver.com/index.html" # storing all the information including headers in the variable source code source_code = requests.get(base_url) # sort source code and store only the plaintext plain_text = source_code.text ...
61c95de3fab85b42767cf0e48b4adabd4467c76e
mariosantiago/githubActividad2FD
/3.lsp.py
709
3.875
4
import abc from abc import ABCMeta class Coche (object): __metaclass__ = ABCMeta def init(self, name: str): self.name = name @abc.abstractmethod def numAsientos(self) -> str: pass class Renault(Coche): def numAsientos(self): return 'Asientos Renault ' + str(5) class Audi...
57ba134935bace9288850296e2435cf6e36902cb
Diffblue-benchmarks/Lucafon-DesignPatterns
/lucafontanili.designpatterns.python/src/structural/composite/Worker.py
966
3.765625
4
''' Created on Nov 5, 2016 @author: Admin ''' class EmployeeClass(object): _name = None _salary = None def __init__(self, name): self._name = name def set_salary(self, salary): self._salary = salary def name(self): return self._name def s...
e682aedba9e99847d892189b482617e73d1e4c76
BennoKrojer/DLexperiments
/MNISTwithFunctionalAPI.py
1,158
3.5625
4
from tensorflow.python.keras.datasets import mnist from tensorflow.python.keras import models from tensorflow.python.keras import layers from tensorflow.python.keras.utils import to_categorical #define the data (train_images, train_labels), (test_images, test_labels) = mnist.load_data() #define the network architect...
c5ab556c5524d512bc61654fbed1622b981fbe63
NikhilBhargav/Joy_Of_Learning_Python
/lottery.py
691
3.875
4
########################## # Py Lottery simulation ########################## import random import matplotlib.pyplot as plt fee=100 prize=1000 myAccountBalance=0 numTurns=365 #X and Y Axis x=[] y=[] for i in range(numTurns): #bet=int(input("What is your bet (1-10)")) bet=random.randint(1,10) x....
ab6b9b0cdf9051169cfd19f30f939d5dbc88c9fb
SebastianDica/LeetCode-Solutions
/0006. ZigZag Conversion/main.py
1,355
3.671875
4
def convert(s: str, numRows: int) -> str: selectedRow = 0 result = "" coreJump = numRows * 2 - 2 if (coreJump == 0): coreJump = 1 while(selectedRow < numRows): jump1 = coreJump - selectedRow * 2 jump2 = coreJump - jump1 jumped1 = False if (jump1 == 0 and j...
8baa119b1907cd39883f03712763a0de11d0376c
thoan741/lek
/Hemuppgifter/Hemuppgift_3.py
1,113
3.984375
4
# Uppgift 13 #BMI def BMI(): """ vikt skrivs in kg och längd i cm. längden konverteras till meter innan beräkning. värdet rundas till hundradel och jämförs mot alla viktklasser. sedan skrivs BMI och viktklass ut. """ weight = float(input("Ange vikt (i kg): ")) height = float(input("Ange längd ...
376f3ee3e5266531f32418a99b0d89e884b40d22
susurrant/LeetCode
/17.py
704
3.578125
4
""" 17. Letter Combinations of a Phone Number """ class Solution: def letterCombinations(self, digits: 'str') -> 'List[str]': t = {'2':'abc', '3':'def', '4':'ghi', '5':'jkl', '6':'mno', '7':'pqrs', '8':'tuv', '9':'w...
952bc52d3f81edae1018289ac11172f351513150
cameron-stewart/simphys1
/sim2/templates/plot_samples.py
1,187
3.921875
4
from numpy import * from matplotlib.pyplot import * # Create 100 equidistant points between 0 and 2*pi xs = linspace(0, 2.*pi, 100) # Create a title for the plot title("How to make plots") # Create labels for the axes # Note that in the label, you can use TeX-strings! xlabel("$x$") ylabel("$f(x)$") # Now create two p...
930d44f72d3fbc06e9a2218f5c5e24632de0eec1
gabriellaec/desoft-analise-exercicios
/backup/user_119/ch22_2019_03_01_16_46_36_166389.py
130
3.703125
4
ano=int(input('escolha um ano: ') def eh_bissexto('ano'): y=ano/4 if y=0 return True else return False
30db67376a5787a1468ba4262b9aa22878f43cf5
piotrautuch/CryptoNoise
/main.py
950
3.515625
4
import requests import json import time def get_price(r): return r.json()["USD"]["last"] def main(): # Get a request from an API r = requests.get("https://blockchain.info/ticker") if (r.status_code == 200): print("Success! Site is up. Monitoring...") elif (r.status_code == 400): p...
475e707878f84c12048021c4dad6ca7e6fcf4dab
oplt/Codecademy-Projects
/Data-Science-Path/Pandas/Central Tendency for Housing Data.py
2,099
3.875
4
# Central Tendency for Housing Data # In this project, you will find the mean, median, and mode cost of one-bedroom apartments in three of the five New York City boroughs: Brooklyn, Manhattan, and Queens. import numpy as np import pandas as pd from scipy import stats # Read in housing data brooklyn_one_bed ...
030fb6997dfd66ac0ad5822093687c65b9b61b0d
adam7902/Commonly-used-Python
/Python读写csv文件/writer写入带有header的csv文件.py
1,053
3.796875
4
# UTF-8 # https://thepythonguru.com/python-how-to-read-and-write-csv-files/ import csv header = ['id', 'name', 'address', 'zip'] rows = [ [1, 'Hannah', '4891 Blackwell Street, Anchorage, Alaska', 99503], [2, 'Walton', '4223 Half and Half Drive, Lemoore, California', 97401], [3, 'Sam', '3952 Little ...
9c4082d83e309e0231d3a4d8621666042823d315
daniel-reich/ubiquitous-fiesta
/bGRYmEZvzWFK2sbek_8.py
130
3.546875
4
def get_missing_letters(s): ret = "" for i in range(97, 123): if not chr(i) in s: ret = ret + chr(i) return ret
12179ad3495adc03fc337c30371ccdefb02aac18
cothuyanninh/Python_Code
/fsoft/Week 1/B1/bai2.py
346
3.921875
4
"""C1""" list_temp = [20, 18, 23, 4, 8, 3, 19, 16, 45, 25] max_ = list_temp[0] min_ = list_temp[0] for i in list_temp: if (i >= max_): max_ = i if (i < min_): min_ = i print("MAx: %d"%max_) print("Min: %d"%min_) """C2""" list_temp = [20, 18, 23, 4, 8, 3, 19, 16, 45, 25] print("Max is: ", max(list_temp)) print("...
ef86b5c50049d5756568ed994582277e5ad541cb
VitaliStanilevich/Md-PT1-40-21
/Tasks/Zhukovskii_ClassWork/FirstClassWork/first work.py
775
3.65625
4
l = input("Input digts: ") from operator import itemgetter d = {'one': 1, 'two': 2, 'three':3, 'four': 4, 'five': 5, 'six': 6, 'seven': 7, 'eight': 8, 'nine': 9, 'ten': 10, 'eleven': 11, 'twelfth': 12, 'thirteen': 13, 'forteen': 14, 'fifteen': 15, 'sixteen': 16, 'seventeen': 17, 'eighteen': 18, 'nineteen': 19, 'twenty...
3ae9cb1e4fb856cfe7bbbc26f5179a5d7d8ed377
jeremyosborne/python
/general/wrestling/db.py
2,283
3.84375
4
"""All of our database stuff. """ import sqlite3 import os # Makes/opens database relative to this file. db_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "wrestlers.db3") conn = sqlite3.connect(db_path) cursor = conn.cursor() # When we first init this module, create what we need. cursor.execut...
bcc5ff4c0f5dcc409170897544925b77d5bb2592
ashaju2/HackerRank_30DC
/hR_Day6.py
208
3.609375
4
#!/usr/bin/python3 import sys n = int(input().strip()) for i in range(0,n): string = input() letters = list(string) j = letters[0::2] k = letters[1::2] print(''.join(j), ''.join(k))
cf512b8ee6944972f4919f0aa02c8853a1604aa3
JhonArias97/Python
/Retos mintic/retos semanales/reto_1.py
524
3.84375
4
def run(): producto = input("Introduce el nombre del prodocuto: ") costo = int(input("Introduce el costo unitario: ")) precio = int(input("Introduce el precio de venta: ")) unidades = int(input("Introduce las unidades disponibles: ")) ganacias = (precio - costo) * unidades print(f'Produc...
4efcdbe725e66e8c8460a4a144d0be9891414e76
amalmhn/PythonDjangoProjects
/flow_controls/looping_statements/for_loop/for_loop.py
157
4.03125
4
for i in range(0,11): print(i) print("----") for i in range(0,11,2): print(i) print("----") for i in range(10,0,-1): #decrement loop print(i)
dd700303ffa4718c81de34d3fb321f824db13ff1
gerswin/HAP-python
/main.py
2,041
3.578125
4
"""An example of how to setup and start an Accessory. This is: 1. Create the Accessory object you want. 2. Add it to an AccessoryDriver, which will advertise it on the local network, setup a server to answer client querries, etc. """ import logging import os import pickle import signal import pyhap.util as util f...
74fe61033adeed1666f64caa807e673a0135b7f6
narenchandra859/PythonLabExam
/Solutions/13a.py
330
3.5
4
def wellbracketed(s): l=[] for c in s: if c == "(": l.append(c) elif c == ")": if l == []: return False l.pop() else: pass if l == []: return True else: return False print(wellbracketed("22)")) print(wellbracketed("(a+b)(a-b)")) print(wellbracketed("(a(b+c)-d...
f7d2dc6966b9c25fe9422f328d2d40400094b17d
NikolaosPanagiotopoulos/PythonLab
/lectures/source/lecture_04/lecture_04_example_4a.py
157
3.875
4
num = int(input("Δώσε έναν αριθμό: ").strip()) while num > 0: print(num) num = int(input("Δώσε έναν αριθμό: ").strip())
c5468cab63129d7c22efd9ce84b4c03d60c614ea
zhuozhi-ge/Fundamentals-of-Computing-Specialization
/Algorithmic Thinking II/Applications/A3 Clustering Algorithms.py
17,519
3.96875
4
# -*- coding: utf-8 -*- """ Student template code for Project 3 Student will implement five functions: slow_closest_pair(cluster_list) fast_closest_pair(cluster_list) closest_pair_strip(cluster_list, horiz_center, half_width) hierarchical_clustering(cluster_list, num_clusters) kmeans_clustering(cluster_list...
29fd5d0ba5d0d3f70af3fe46616171d7b2a98796
Ruby-Dog/III
/人工智慧與機器學習/lab/2-2-data.py
378
4.15625
4
x = "good good good" y = x.replace("good", "bad") print("舊名:", x) print("新名:", y) print("新名2:", x.replace("good", "bad")) z = x.replace("good", "bad", 1) print("只取代幾個:", z) x = x.replace("good", "bad") print("覆蓋x:", x) ### print("轉成大寫", "good".upper()) print("轉成小寫", "BAD".lower()) ### a = "aaa \ bbb" print(a) b = "aa...
35f18de8d2d8aa0a186681ad98398f16f453280c
smootlight2/SmootLight
/util/ColorOps.py
709
3.875
4
import random from util.TimeOps import Stopwatch def randomColor(): return [random.randint(0,255) for i in range(3)] def chooseRandomColor(colorList): """Given a list of colors, pick one at random""" return random.choice(colorList) def safeColor(c): """Ensures that a color is valid""" c[0] = c[0] i...
4aa27952d5990ae8342efe079c5e4e6a5cfde916
LauroJr/Atividades-Linguagem_II
/occupation.py
1,563
4.28125
4
''' Encontramos neste programa várias funções criadas, para serem importadas para outro programa. Dessa forma ganhamos tempo sem precisar ficar codando tudo denovo uma vez que o código já está pronto OBS: Para importar, abra um NEW FILE , e use FROM (occupation) IMPORT (nome da função). Explicação: occu...
b5861c1c7f5cca32a29618fa21384e02a6fcb599
brij1823/CodeChef-Easy
/mytesting.py
151
3.578125
4
from fractions import gcd test=int(input()) while(test): a,b=input().split() a=int(a) b=int(b) print(gcd(a,b)) test=test-1
769e4a83115261208fb32d4672c0e4ca2d2b1d71
gagnongr/Gregory-Gagnon
/Exercises/fibonacci.py
354
3.875
4
n = int(input("what is n: ")) result = int(0) i = int(0) #if n == 0: #result = 0 #elif n == 1: #result = 1 #elif n == 2: #result = 1 #else: i = 0 j = 1 k = n result = 0 while k > 1: i, j = j, (j+i) result = j k -= 1 print ("i: ", i, ", j: ", j, ",n: ", n) print("n is", ...
25eb5dfa643993606717382b300960fed4442007
Sergey0987/firstproject
/Архив/11_Raznie_raznosti - variant 2.py
965
3.671875
4
#Решение с использованием циклов N=int(input()) list1=[] list2=[] for i in range(N): #подготовили список, с которым будем работать list1.append(int(input())) for i in range(len(list1)): # Добавили в список все возможные разности чисел (тут есть повторения) for j in range(len(list1)-1): list2.append(...
4f7a7aa93e3ddf4afb95ce837e010a5a075994c8
LEEBONGHAK/basic-of-python
/chapter8/class(8-1).py
1,677
3.59375
4
# 8-1 클래스(class) # 스타크래프트 예로 들 것임 # 마린 : 공격 유닛, 군인, 총을 쏠 수 있음 name = "마린" # 유닛 이름 hp = 40 # 유닛 체력 damage = 5 # 유닛 공격력 print("{} 유닛이 생성되었습니다.".format(name)) print("체력 {0}, 공격력 {1}\n".format(hp, damage)) # 탱크 : 공격 유닛, 탱크, 포 사용, 일반 / 시즈 모드 tank_name = "탱크" tank_hp = 150 tank_damage = 35 print("{} 유닛이 생성되었습니다.".form...
2997e09df0632b65795b8ca060f8ccf3261f1c37
AdamZhouSE/pythonHomework
/Code/CodeRecords/2537/61053/294728.py
787
3.671875
4
def adjustHeap(heap:list): i = 0 child = 2 * i + 1 while child < len(heap): #先定位到较大的子节点 if child + 1 < len(heap) and heap[child + 1]<heap[child]: child += 1 #然后与父节点进行比较 if heap[child] < heap[i]: temp = heap[child] heap[child] = heap[i] ...
4a0d27e107103a239a690bac85a28398a9fdf7ec
davelpat/Fundamentals_of_Python
/Ch2 exercises/cube.py
435
4.9375
5
""" You can calculate the surface area of a cube if you know the length of an edge. Write a program that takes the length of an edge (an integer) as input and prints the cube’s surface area as output. An example of the program input and output is shown below: Enter the cube's edge: 4 The surface area is 96 square u...
22cf3729b80c8deab5375d5756a1063d845f2f2c
flame4ost/Python-projects
/§4(77-119)/z114.py
1,701
3.8125
4
import math print("Задание 114(a) ") n = input("Введите n ") n = int(n) print("n = ",n) result = 1 i = 1 for i in range(1, n): result = (result * (1/(i**2))) print("n!!",result) print("Задание 114(b) ") n = input("Введите n ") n = int(n) print("n = ",n) result = 1 i = 1 while n>=i: result = result +1/(math.exp...
3e4c833af54ace80b07c47fead7d913372c9178b
henrycc2015/python
/Documents/workspace/python/demo1.py
140
3.921875
4
score = int(input("please input a int")) if 90 <= score <= 100 : print("A") elif 80<= score < 90 : print("B") else : print("c")
f525a83d56bc698825b1a329b78e04d5b1aab6be
projectPythonator/portfolio
/ProjectEuler/Python/p15.py
2,067
3.53125
4
mm = nn = 20 cache_grid1=[[0 for i in range(nn+1)] for j in range(mm+1)] cache_grid2=[[0 for i in range(nn+1)] for j in range(mm+1)] ''' //long count_ways(int m, int n) //returns the count from a recursive version //param m and n which equal to x and y //return 1 if we hit an edge otherwise sum of both ''' def count_...
c5b0a99d76d2815b38e807ba96ab1ff4bc284054
mug31416/PubAdmin-Discourse
/src/utils/roman.py
2,130
3.90625
4
# A Python-3 adapted version of the code from # http://code.activestate.com/recipes/81611-roman-numerals/#c3 def roman_to_int(input): """ Convert a roman numeral to an integer. >>> r = range(1, 4000) >>> nums = [int_to_roman(i) for i in r] >>> ints = [roman_to_int(n) for n in nums] >>> print r == in...
e0fd487dce785fd825fe9988bdc51033a4cb0cc3
Mwnesbitt/mastermind
/mastermind.py
3,454
3.921875
4
import sys import cbreakstrat import cmakestrat import helperfunctions def runGame(rounds, colors, slots, codemakestrategy, codebreakstrategy): rounds=int(rounds) colors=int(colors) slots=int(slots) history=[] """ The way implementing a game works is that runGame keeps track of the state of the game with...
dbe4051377f5c0cb2e0a690a555c390ed02c2254
mia2628/Python
/Machine_Learning/1.Pythonic Code/Asterisk.py
828
3.71875
4
# 단순곱셉 활용, 제곱연산, 가변인자 활용 등 다양하게 사용 # def asterisk_test(a, *args): # print(a,args) # print(type(args)) # # asterisk_test(1,2,3,4,5,6) # def asterisk_test(a, **kargs): # print(a,kargs) # print(type(kargs)) # # asterisk_test(1,b=2,c=3,d=4,e=5,f=6) # def asterisk_test(a, *args): # print(...
49a066b1f78761d36795370c9739edb9e296d468
chinuteja/CSPP1
/cspp1-practice/cspp1 assignment/m4/p2/bob_counter.py
312
3.9375
4
''' author:teja date:8/2/2018 ''' def main(): ''' this function gives no of bobs in a string ''' s_1 = input() x_1 = len(s_1) count = 0 for i in range(0, x_1, 1): if s_1[i:i+3] == "bob": count = count + 1 print(count) if __name__ == "__main__": main()
6b55ad0cce98d262d38a647da0b6a61f3fc26c3f
Techsrijan/techpython
/twodarray.py
376
3.75
4
from numpy import * arr=array([ [1,2,3], [4,5,6], [7,8,9] ]) print(arr) print(arr.ndim) print(arr.shape) print(arr.size) # converting 2 d arrray into 1-d array arr2=arr.flatten() print(arr2) arr3=array([ [1,2,3,4,5,6], [4,5,6,1,2,3] ]) print(arr3.shape) print(arr3.reshape(3,4)) print(arr3.ndim)...
fe62ccad67e06f480b59a25454ad4d9b0aa9340a
sam1208318697/Leetcode
/Leetcode_env/2019/8_27/Intersection_of_Two_Arrays_II.py
1,310
3.84375
4
# 350. 两个数组的交集 II # 给定两个数组,编写一个函数来计算它们的交集。 # 示例 1: # 输入: nums1 = [1,2,2,1], nums2 = [2,2] # 输出: [2,2] # 示例 2: # 输入: nums1 = [4,9,5], nums2 = [9,4,9,8,4] # 输出: [4,9] # 说明:输出结果中每个元素出现的次数,应与元素在两个数组中出现的次数一致。我们可以不考虑输出结果的顺序。 # 进阶: # 如果给定的数组已经排好序呢?你将如何优化你的算法? # 如果 nums1 的大小比 nums2 小很多,哪种方法更优? # 如果 nums2 的元素存储在磁盘上,磁盘内存是有限的,...
8e3708fdb99e4e4506a153f6c435ee33d4ae5e85
VikramadityaJakkula/one-week-python
/queuearray.py
919
3.703125
4
from exceptions import Empty class queuearray: def __int__(self): self.data = [] self.size = 0 self.front = 0 def __len__(self): return len(self.size) def first(self): if self.is_empty: raise "Queue is empty" else: r...
1ebd50691b45a7f4ba755e4cd1726f3e3e75ad37
a1dien/Python3Learning
/IntroductionToStrings/tuples.py
966
4.3125
4
tuple1 = (1, 2, 3) tuple2 = ('Hello', 'one') tuple3 = 544, 0.233, 'tst' print(tuple1) print(tuple2) print(tuple3) print(type(tuple3)) print(tuple1[1]) #tuple1[1] = 1 #not work for tuples new_tuple = tuple1[0], 22, tuple1[2] print(new_tuple) x = y = z = 12 print(x, y, z) x, y, z = 12, 13, 14 print(x, y, z) person_tuple...
a6550bf6b1f27577c4a47b36810908489b2170f8
HugoPorto/PythonCodes
/CursoPythonUnderLinux/Aula0021ComparandoTipos/ComparandoTipos.py
541
4.15625
4
#!/bin/usr/env python #-*- coding:utf8 -*- var = input("Informe uma variavel para ser analisada: ") tipo = type(var) if tipo == int: print 'Você infomrou um numero inteiro.' elif tipo == float: print 'Você infomrou um numero ponto flutuante.' elif tipo == str: print 'Você infomrou uma string.' elif tipo ==...
10cd60a326c2ee6645836d5472d993559ab1876f
Ivanqza/Python
/Python Fundamentals/FinalsExamTraining/PROBLEM 3.py
1,148
3.875
4
data = input() records = {} while not data == "Log out": splitted_data = data.split(": ") command = splitted_data[0] username = splitted_data[1] if command == "New follower": if username not in records: records[username] = {"likes": 0, "comments": 0} elif command == "Like": ...
e9d1bd6799fb8a974dd4eee6a364b2f3957f401f
rolfis/ableton-pack-info
/src/utils.py
1,128
3.9375
4
import os def get_size_format(b, factor=1024, suffix="B"): """ Scale bytes to its proper byte format e.g: 1253656 => '1.20MB' 1253656678 => '1.17GB' """ for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]: if b < factor: return f"{b:.2f}{unit}{suffix}" b ...
690270017925c11b5b85132673ce6905a25763ab
ProfessorKazarinoff/piston_motion
/piston_motion.py
2,274
3.609375
4
""" Piston Motion Animation using Python and Matplotlib Author: Peter D. Kazarinoff, 2019 MIT License """ # import necessary packages import numpy as np from numpy import pi, sin, cos, sqrt import matplotlib.pyplot as plt import matplotlib.animation as animation # input parameters r = 1.0 # crank radius l = 4.0 # c...
ea5ce4981d92c0856bcf63bfc97afb19590ad787
Uche-Clare/python-challenge-solutions
/Darlington/phase1/python Basic 1/day 9 solution/qtn9.py
345
4.09375
4
#program to get the size of an object in bytes.import sys import sys str1 = "one" str2 = "four" str3 = "three" print() print("Memory size of '"+str1+"' = "+str(sys.getsizeof(str1))+ " bytes") print("Memory size of '"+str2+"' = "+str(sys.getsizeof(str2))+ " bytes") print("Memory size of '"+str3+"' = "+str(sys.getsizeof(...
911c1e7e79aeb4ea647a791892f26620d27b6847
ankitchoudhary49/Daily-Assignments
/Assignment-12.py
583
4.03125
4
#Assignment 12 #Question 1: Print the Current Day import datetime print(datetime.date.today()) x=datetime.date.today() print("OR") print(x.strftime("%A, %B %d,%Y")) print("*"*50) #Question 2: Use Webbrowser Module in Python ''' import webbrowser google=input("Enter your google search here: ") webbrowser.open_new_tab...
73597b62cdc7d9f33b7fba31713ed951c065c11a
Papashanskiy/face-recognition
/face-recognition/src0/recognition/description/dlib1/__init__.py
3,036
3.78125
4
# This example shows how to use dlib's face recognition tool. This tool maps # an image of a human face to a 128 dimensional vector space where images of # the same person are near to each other and images from different people are # far apart. Therefore, you can perform face recognition by mapping faces to #...
d05a4a6e512001e125fda21d0188b176452583f1
iSumitYadav/python
/Binary_Tree/LevelOrderTraversal_O(n)2.py
808
4.1875
4
class node: def __init__(self, key): self.data = key self.left = self.right = None def height(root): if root is None: return 0 return max(height(root.left), height(root.right)) + 1 def printSecondary(root, level): if root is None: return if level == 1: pri...
1b9d6759d4b98714b3558bff695a9c580e7aa23b
sergio9977/SUMMER_BOOTCAMP_2018_Python
/lesson8/task1/class_definition.py
569
4.25
4
""" Un objeto combina variables y funciones en una sola entidad. Los objetos obtienen sus variables y funciones de las clases. Las clases son esencialmente plantillas para crear tus objetos. Se puede pensar en un objeto como una única estructura de datos que contiene datos y funciones. Las funciones de los objetos se l...
c9cd84cce80ff47435183f8869e8cd91c89fdc66
drinkingcode/PythonDemo
/python-02.py
487
3.859375
4
#对真假值取反 print(not True) #False #if-else a = 3 b = 5 if a>b: print('a > b') elif a<b: print('a < b') else: print('a = b') #循环 #while...: #for...in...: i = 0 while i<10: print('while-i: ' + str(i)) #打印0-9 i = i + 1 for i in range(0,10,1): #这里的range是python中的一个函数 print('for-in-i: '...
f18ce4f257b1aebcbf52b0cb8b3abeeeda1e2e14
aobrien89/cti110
/M3HW2_SoftwareSales_O'Brien.py
431
3.671875
4
# CTI-110 # M3HW2 - Software Sales # Anthony O'Brien # 09/19/2017 # def main(): purchase = float(input("Packages purchased: ")) if purchase <= 9: print("No discount :(") elif purchase <= 19: print("10% discount!") elif purchase <= 49: print("20% discount!") eli...
5e677c590a5134c62fe7e99a107ad0cf4e449570
ddoplayer2012/leecode
/递归/3爬楼梯.py
1,092
3.953125
4
# -*- coding: utf-8 -*- """ 假设你正在爬楼梯。需要 n 阶你才能到达楼顶。 每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢? 注意:给定 n 是一个正整数。 每一级楼梯都是由 n - 2 + n-1 级楼梯组成,所以可以等效于斐波那契数列 """ class Solution ( object ): def climbStairs(self, n): """ :type n: int :rtype: int 由于必定是n -1 和 n-2 组成的 f (n),所以可以用斐波那契的解法来求解 ...
20c28fef79ae1e7d6806ce574f7433dfc5604480
rogeroger-yu/LeetCode
/sort_1_bubble.py
289
3.828125
4
class Solution: def bubble_sort(self, nums): if not nums: return size = len(nums) for i in range(size): for j in range(i): if nums[j] > nums[i]: nums[i], nums[j] = nums[j], nums[i] return nums
b066a5b71f4d85e145871a89f3fd2ffd1f5b8bac
ykataoka/top100Like
/36_ValidSudoku.py
1,159
3.59375
4
class Solution(object): def isValidSudoku(self, board): """ :type board: List[List[str]] :rtype: bool """ return (self.isValid_rows(board) and self.isValid_cols(board) and self.isValid_3x3(board)) # time: O(N^2), N = 9 def isValid_rows...
09f93a5ce5ddbd9588c24ffd070a93930fbf5171
Gaurav-2804/Scheduler
/shedule.py
1,090
3.5
4
import pandas as pd import datetime from plyer import notification import time def sendnot(msg): notification.notify( title = msg, message = "Study Hard", app_icon = "./book.ico", timeout = 5 ) if __name__ == "__main__": df = pd.read_excel("Tt.xlsx") #p...
75fc2490445dfcaf1b2367bf664b19259b115596
sumeyragulsoyy/RNN-ATM-DATA
/rnn_Atm.py
2,308
3.65625
4
# Recurrent Neural Network # Part 1 - Data Preprocessing # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the training set dataset_train = pd.read_csv('b9383file.csv') training_set = dataset_train.iloc[:,2:3].values # Feature Scaling from sklearn.preproces...
efbd6ca1721f946437897e2dc2675348036bdda5
aryasoni98/Python
/Strings/manacher.py
908
4.03125
4
def palindromic_length(center, diff, string): if (center - diff == -1 or center + diff == len(string) or string[center - diff] != string[center + diff]): return 0 return 1 + palindromic_length(center, diff + 1, string) def palindromic_string(input_string): max_length = 0 new_input...
2ebd013f9731fc2a15ad0eaaeee120fa5a6e72a9
De-Yonis/My_first_project
/game.py
1,332
3.734375
4
import random def vocab_file(): VocabD = {} with open("spanish.txt") as f: for line in f: (key, value) = line.split(",") VocabD[key] = value.rstrip() return VocabD def game(): response = input("Type Yes below to start:\n").lower() if response == "yes": Voca...
e504beb328788bf82289d4f63daa7f2130622c5c
MysteriousSonOfGod/py
/string.py
1,758
3.828125
4
print('This\'s a\n \ttest') print(r'This\'s a test') # for raw output #Multiline text print('''Dear Sir, I came to know about the latest update you shared via email earlier this week from Dinesh. Regards, Ujjwal''') """ This is a multi line comment """ print('---end---') text = 'Testing Testing what are you testi...
76ca01c95d7a1d2033f03035bf0159e034a6d0f0
immayurpanchal/sudoPlacementGFG1
/SudoPlacements/ArrayAndSearching/reverseArray.py
209
3.53125
4
for _ in range(int(input())): size = int(input()) array = list(map(int, input().split())) index = len(array) - 1 while index>=0: print(array[index],end=' ') index-=1 print()
a48cfa7c6ce3cb31d67faf91a0d38f6d4f79e587
kasa4565/DesignPatterns
/04Prototype/Students/2019/JarzembinskiBartlomiej/prototype/computer_prototype.py
496
3.5625
4
from abc import ABC, abstractmethod import copy class ComputerPrototype(ABC): @abstractmethod def clone(self): pass class Computer(ComputerPrototype): def __init__(self, case, motherboard, power_supply, cpu, gpu, drive, ram): self._case = case self._motherboard = motherboard se...
1183632d6e70e20fd3961f29aba3a7c185729a0b
gitandlucsil/python_classes
/complet_curs/functions/var_scope.py
369
3.890625
4
def printName(): global name print(name) name = "andre" print(name) def sumList(list_num): global sumvalue for num in list_num: if type(num) is list: sumList(num) else: sumvalue += num return sumvalue name = "jose" printName() sumvalue = 0 print(sumL...
6a1bbc059b9e720742f56d6a90a16b1f0dd28a6f
mtarbit/Project-Euler-Problems
/e062.py
433
3.703125
4
#!/usr/bin/python # $Id$ """ """ __author__ = 'Matt Tarbit <matt.tarbit@isotoma.com>' __docformat__ = 'restructuredtext en' __version__ = '$Revision$'[11:-2] def e62(): cubes = {} n = 345 while True: p = n ** 3 k = ''.join(sorted(str(p))) n += 1 if not cubes.get(k): cubes[k] = [p] else: cubes[...
65e155eb588042abb6b218c1eed5785d5185b948
RonakR/CTCI-Solutions
/2_Linked_Lists/7_Intersection/intersection_1.py
865
3.625
4
def intersection_1(firstll, secondll): diff = len(firstll) - len(secondll) headfll, headsll = firstll.head, secondll.head if diff > 0: headfll = fix_length(headfll, diff) elif diff < 0: headfll = fix_length(headsll, abs(diff)) return find_intersection(headfll, headsll) def fix_len...
5de52e7c34749b8d5b56b927e6585b1413a62d91
ChangxingJiang/LeetCode
/1601-1700/1641/1641_Python_1.py
500
3.546875
4
import functools class Solution: @functools.lru_cache(None) def countVowelStrings(self, n: int, t=5) -> int: if t == 0: return 0 if n == 1: return t ans = 0 for i in range(1, t + 1): ans += self.countVowelStrings(n - 1, i) return ans...
7d730ef76e68a0051937dc781ad297bb864ceda7
Amit-Yadav21/Loop-Question-python
/loop-meraki.py
1,308
3.671875
4
# Q...............................................1 # x= 1 # while x<=100: # print(x) # x=x+1 # Q................................................2 # n=int(input("Enter how to sum number ")) # i=0 # sum=0 # while i<=n: # sum=sum+i # i=i+1 # if i==100: # break # print("the sum is - ",sum) # Q .....................
c5ad0115c1013e4afa7f764666f0edb1fe58e5c2
edyoda/DSA-with-Rudrangshu-310321
/Sorting/find_longest_consecutive_subsequence.py
619
4
4
# Python3 program to find longest # contiguous subsequence def findLongestConseqSubseq(arr, n): ans = 0 count = 0 arr.sort() v = [] v.append(arr[0]) for i in range(1, n): if (arr[i] != arr[i - 1]): v.append(arr[i]) for i in range(len(v)): # Check if the current element is # equal to previous ...
ad764cdf91f272a260165d8eb5f231ad25f31d3a
shubhamoli/solutions
/ctic/3.4.py
892
4.0625
4
""" 3.4 - Implement queue using stack data structure we'll be using two stacks for this """ class myQueue(): def __init__(self): self.stk1 = [] self.stk2 = [] def push(self, val: int): self.stk1.append(val) # compromising pop() operation # O(n) instead of O(1) d...
e7b92a5b9ad2b68d78d76a699db3953394720eca
digitaldave0/tutorials
/python/elif.py
403
4
4
a = 33 b = 33 if b > a: print("b is greater than a") elif a == b: print("a and b are equal") a = 200 b = 33 if b > a: print("b is greater than a") elif a == b: print("a and b are equal") else: print("a is greater than b") #nested if x = 41 if x > 10: print("Above ten,") if x > 20: print("and also a...
0a9d3ae2c2561a0118c6811452f7649a36f03fe3
rwzhao/working-open-data-2014
/notebooks/Day_07_G_Calculating_Diversity.py
14,248
3.609375
4
# -*- coding: utf-8 -*- # <nbformat>3.0</nbformat> # <headingcell level=1> # Goals # <markdowncell> # * Learn about how to use the Census variables around Hispanic origin to calculate quantities around diversity (remembering the [Racial Dot Map](http://bit.ly/rdotmapintro) as our framing example) # <codecell> %py...