blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
59f4a8d0d6f823ba7c79ee50245f0f0638cd5219
ainhoaosa/grupo2_DAIC_2020
/pruebas/servo3.py
1,320
3.578125
4
import RPi.GPIO as GPIO # Importing RPi library to use the GPIO pins from time import sleep from grove.factory import Factory GPIO.cleanup() pin = 16 button = Factory.getButton("GPIO-HIGH", pin) # Importing sleep from time library to add delay in code servo_pin = 17 # Initializing the GPIO 21 for servo motor G...
b707b92aa0a8802d35774cc29fde34d556e049e3
isbox/leet_code
/709.转换成小写字母.py
1,177
3.5
4
# -*- coding=utf-8 -*- # @lc app=leetcode.cn id=709 lang=python3 # # [709] 转换成小写字母 # # @lc code=start class Solution: def toLowerCase(self, str): # 建立字母映射表 alphabet_hash = { 'A': 'a', 'B': 'b', 'C': 'c', 'D': 'd', 'E': 'e', 'F'...
2951d04e908a420306e8750b488e04b438cb025d
mennanov/problem-sets
/math_problems/matrix_multiplication.py
6,242
4.28125
4
# -*- coding: utf-8 -*- def multiple_matrix(a, b): """ Naive matrix multiplication approach for the matrices. Each element of the each row from matrix A multiple with each element from each column in matrix B. Asymptotic analysis: O(N**3) """ m = len(a) n = len(a[0]) q = len(b[0]) ...
a64e3a9785df76caec344664a66ea29ffeee0779
neerajkasturi10/Hackerrank_Python
/Itertools/itertools.product().py
166
3.640625
4
from itertools import product A = list(map(int,input().split())) B = list(map(int,input().split())) prod = product(A,B) for each in prod: print(each, end = " ")
8173fc2c5f77f0e8dc17033562cf84ae2f18474f
pizza2u/Python
/exemplos_basicos/python/while.py
243
3.625
4
# >>>>>>>>>Código 1: IMRPIME EM LINHA i = 0 while i<= 20: print(i,end = " ") i+=1 #-------------------------------------------------------- # >>>>>>>>>>>>>> Código 2: IMPRIME EM COLUNA i = 0 while i<= 20: print(i) i+=1
6392466d841a7aa0ddf3e9e4a6dcad47422e9012
kirannarwade/atm-machine-python
/ATM_Machine.py
1,484
3.875
4
import time print("Enter Your Card") time.sleep(3) print("Welcome To Kiran Bank LTD") password = 1234 pin = int(input("Enter Your Pin Here: ")) balance = 10000 if pin == password: while True: print(''' 1 . Balance 2 . Withdraw 3 . Deposit 4 . Exit ...
4700e002e31feb110311e4f9cd52537be5eb485f
yost1219/python
/python/labs/calculator.py
11,321
4.4375
4
""" Author: ELF Course: Python version: Python 3.X FileName: lab4a.py Lab 4a: Calculator Recommended Version: Python 3.X IMPORTANT: You must double click the application in windows or download the Tkinter package in linux. The package is not installed by default in linux but is in Windows! Instructions ...
538216e64f91f92e908ee4e572f96bb2f90836dd
Csonic90/python_example_PL
/lista 5/zad3.py
443
3.65625
4
from math import factorial print('====zad 3====') i = 321 s=str(i) ls=list(s) print(ls) print('test 4,5,6') print(factorial(4)) print(factorial(5)) print(factorial(6)) ln=list(str(factorial(1000))) nine = '9' ileNine = ln.count(nine) print('9 w 1000!') print(ileNine) print('0 do 9 w 1000!') for i in range(9): pr...
58ba55a1c7230b551d721c6261fd6c61fbe5af4e
Vagacoder/Python_for_everyone
/Ch03/2017-7-28_1.py
2,397
4.0625
4
## Ch03 R3.9 x = input('Please enter x axis (a, b, ... g, h): ') y = int(input('Please enter y axis (1-8): ')) #x = 'g' #y = 5 if x == 'a' or x == 'c' or x == 'e' or x =='g': if y%2 == 1: #print('The grid is black') color = 'black' else: #print('The grid is white') ...
059fc96bbc76f7155c1cf2a86f0dbfce7648a56b
ziqingW/python-exercise-flex-Mar10
/RPG_Game/store.py
4,784
3.578125
4
import basic_items potion = basic_items.Potion("healing potion", 15, 15) holyoil = basic_items.Holyoil("holy oil", 12) amulet = basic_items.Amulet("amulet", 50) leather = basic_items.Armor("leather armor", 30, 2) longSword = basic_items.Weapon("long sword", 32, 2) evadeRing = basic_items.Ring("evade ring", 50, "20% do...
2a10b6db21445fd0dfbab263832a8a60b23d96ae
yuxichen2019/Test
/selenium/test_case/leap_year.py
585
3.71875
4
# -*- coding: utf-8 -*- # 2019/11/12 16:01 # Test # leap_year.py # company #判断某年是否为闰年 class LeapYear: def __init__(self, year): self.year = int(year) def answer(self): year = self.year if year % 100 == 0: if year % 400 == 0: return "{0}是闰年".format(year) ...
979b7d7391d6fd162fbdee897d4e6a0a928d172c
MDGSF/JustCoding
/python-leetcode/sw_35.py
1,098
3.53125
4
""" # Definition for a Node. class Node: def __init__(self, x: int, next: 'Node' = None, random: 'Node' = None): self.val = int(x) self.next = next self.random = random """ class Solution: def copyRandomList(self, head: 'Node') -> 'Node': self.cloneNodes(head) self.connectSiblingNo...
025ec7fb10add586243e2a36edb4096d787d44fb
Python-Programming-Boot-Camp/JonathanKarr
/Week 6/random module.py
128
3.90625
4
from random import randint x = randint(1,3) print(x) list1 = [] for i in range (10): list1.append(randint(1,3)) print(list1)
ac5ea2aee407a32430e15cacea097f6f872df250
aratnamirasugab/cp-interview-things
/AlgoDS/HashTable.py
1,181
4.21875
4
#hashtable using dictionary #declare a dictionary dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'} #accessing the dics with the key print "dict['Name']: ", dict['Name'] print "dict['Age']: ", dict['Age'] print "dict['Class']: ", dict['Class'] #we can change/ update the value of each key dict['Age'] = 23 print(dict...
3ebec302e01919f5f1f8ff8f1799ca63f8c8e6f3
Run0812/Algorithm-Learning
/to_offer/03_01_DuplicationInArray.py
906
3.84375
4
''' 面试题3:数组中重复的数字 题目1:找出数组中重复的数字 在一个长度为n的数组里中所有数字都在0 ~ n-1的范围内。请找出数组中任意一个重复的数字。 例:[2, 3, 1, 0, 2, 5, 3] 输出 2 或者 3。 ''' def duplication_in_array(nums): ''' :param nums: list to check :return: duplicated num or None ''' dup_num = None for i, num in enumerate(nums): if num < 0 or num > le...
f7b7066ce3acea381e4016969c9b0e7b8bd4556a
crazymerlyn/code
/euler/162.py
596
3.546875
4
types = [0] * 8 types[0] = 1 leading_zeroes = 0 for _ in range(16): newtypes = [0 for _ in types] newtypes[0] = types[0] * 13 newtypes[1] = types[0] + 14 * types[1] newtypes[2] = types[0] + 14 * types[2] newtypes[3] = types[0] + 14 * types[3] newtypes[4] = types[1] + types[2] + 15 * types[4] ...
0613888c67c93ad808313dff7bf45305c90b2ee6
HLJ2021/quaternion-calculation-demo
/Python/basic_calculation.py
3,144
3.796875
4
# -*- coding: utf-8 -*- """ Demo code for basic quaternion calculation Created on Wed Jul 4 10:13:01 2018 @author: mahao """ import math import numpy as np from numpy import linalg as la from transforms3d import quaternions as quat from transforms3d import euler def R2D(rad): return rad / math.pi * 180.0 def ...
f78a40ffb719b0fa3af267e4c7b141380d01ad59
data-intelligence-analysis/NetworkProgramming
/Client_Server_Application/server_app.py
2,385
3.59375
4
# Network programming I # Server Application import socket import sys import argparse import os ##Create a TCP/IP socket #servsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ## get local machine name #host = socket.gethostname() ### Alternative method ## specify localhost and por...
09c7f41fea77abf83e1396412bce36442809c99c
crazyguy106/cfclinux
/steven/python/odd_or_even.py
146
4.3125
4
#!/usr/bin/python num = int(input('Please enter a number: ')) if num % 2 == 0: print('Your number is even') else: print('Your number is odd')
bf9fb721383ebbecc804be598c10a7bdd25bd79d
Keshav-Asopa/Daily_Coding_Problem
/DCP9.py
1,192
4.1875
4
''' Given two sorted arrays P[] and Q[] in non-decreasing order with size X and Y. The task is to merge the two sorted arrays into one sorted array (in non-decreasing order). Note: Expected time complexity is O((X+Y) log(X+Y)). DO NOT use extra space. Input: First line contains an integer T, denoting the number of te...
e8810219d27c958ef75f6761ae3aa32036485d1a
rchermanteev/mephi-python
/numerical_methods(5_semester)/interpolation.py
2,819
3.6875
4
import math import matplotlib.pyplot as plt def function(x): return 5 / (2 + x + math.cos(x) * math.log(1 + x)) def polynomLagrange(x, y, t): res = 0 for i in range(len(y)): numerator = 1 # числитель denominator = 1 # знаменатель for j in range(len(x)): if i != j: ...
c245adf71329d17a1cc3d9bb28c23f13b413582a
KHEMILIOUSSAMA/python
/foctions.py
2,715
3.71875
4
#elimination def elimine1(L): P=[] for e in L: if e not in P: P.append(e) print (P) L= [1,2,2,1,2,1] elimine1(L) # div par 5 def isDivisibleBy5(n): return not n % 5 print(isDivisibleBy5(5)) print(isDivisibleBy5(-5)) print(isDivisibleBy5(3)) # get last element def getLast(liste): return li...
5bdc237f6d334212657757487a5cb2567a0a2560
Le-TRex/pythonCourse
/canevas.py
2,138
3.578125
4
import tkinter as tk # Install tkinter : sudo apt-get install python3-pil.imagetk fenetre = tk.Tk() # label width et height en tailles de caractères ==> width=30 <=> largeur de 30 caractères monlabel = tk.Label(fenetre, text="Nombre de clics : 0", width=30) monlabel.grid(row=0, column=0) label2 = tk.Label(fenetre, ...
e9254e910beebac8ed7d63355267754fcfebef4a
VaibhavTripathi01/PythonClass
/CSVAppend.py
1,022
3.640625
4
import csv with open('Original.csv', 'w', newline='') as file: writer = csv.writer(file) writer.writerow(["Description_Item", "Item_Name", "Price"]) writer.writerow(["Set", "Steel Item", "$50"]) writer.writerow(["Utensils", "Crockery", "$100"]) writer.writerow(["Plates", "Glass", "$500"]) ...
39011ea21879519120b8d18dcfb09cddd829bc87
danikuehler/KMeans
/Kuehler_Danielle_HW7_Q1.py
3,267
3.65625
4
#Danielle Kuehler #ITP 449 Summer 2020 #HW7 #Q1 import pandas as pd import matplotlib.pyplot as plt from sklearn.preprocessing import Normalizer from sklearn.cluster import KMeans #1.Read the dataset into a dataframe. Be sure to import the header wineDf = pd.read_csv("wineQualityReds.csv") pd.set_option("Display.max_...
3ef8533fc5b770a9fe88d54fe6458eefcc2b4e09
gjq91459/mycourse
/11 Decorators/BuiltInDecorators/07_abstract_decorators.py
535
3.765625
4
from abc import ABCMeta, abstractmethod, abstractproperty class Shape(object): __metaclass__ = ABCMeta @abstractmethod def display(self): pass @abstractproperty def name(self): pass class Circle(Shape): def __init__(self, name): self.theName = name def display(self):...
6c3df1e736eb9926d3fdec53ed049f1513d25d3b
NissimBet/compis-covid
/Queue.py
604
3.859375
4
from typing import List class Queue: def __init__(self): self.__data = [] @property def is_empty(self): return len(self.__data) == 0 def empty(self): self.__data.clear() def push(self, data): self.__data.insert(0, data) def pop(self): if len(self.__d...
3216283bde5bff7b779d192e88f88fdbf9e613bf
Nikolov-A/SoftUni
/PythonBasics/For-Loop/05_Game_of_intervals.py
1,210
3.578125
4
moves = int(input()) total_points = 0 points_from_0_to_9 = 0 points_from_10_to_19 = 0 points_from_20_to_29 = 0 points_from_30_to_39 = 0 points_from_40_to_50 = 0 invalid_numbers = 0 for num in range(moves): number = int(input()) if 0 <= number <= 9: total_points += 0.20 * number points_from_...
beb0b57c40aecbeb937ff51afc0abd34a52e21e5
edgelock/Python-Projects
/leetCode/onePass.py
727
3.625
4
class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ #Titled previous map because it's basically every element that comes before the current one # We're going to map the value to the current ...
29fed60f775b49e03490b0da918824eae1ab94c2
Mohit-k007/Chatapp1
/server.py
585
3.5
4
import socket s = socket.socket() host = socket.gethostname() print("server will start on host:", host) port = 8080 s.bind((host, port)) print("") print("Server done binding to host and port successfully") print("Server is waiting for incoming connection...") s.listen(1) conn, addr = s.accept() print(addr, "has connec...
7e4cd6e81d85a4ca6c209fce5c6cf6bbd6faa404
sidvanvliet/py-palindrome-count
/main.py
390
3.96875
4
text = input("Enter a text to check: ") # e.x.: Hello World, my name is Mars and I own a racecar.. palindromes = 0 def is_palindrome(word): return len(word) > 1 and word[::-1] == word for word in text.split(): word = word.replace(',', '') \ .replace('.', '') if is_palindrome(word): ...
80efabc3af74a85c821e617f385301cdd108c39c
MichalGk94/Python
/MG4/4_7.py
230
3.671875
4
def flatten(sequence): l = [] for item in sequence[:]: l.extend(flatten(item)) if isinstance(item, (list, tuple)) else l.append(item) return l seq = [1, (2, 3), [], [4, (5, 6, 7)], 8, [9]] print flatten(seq)
34b854050516158015554aa034eda1d9d7a73aae
720315104023/Beginer-set7
/first k.py
139
3.671875
4
a = raw_input() for c in range (0,a): if (any(c.isalpha for c in a) and any(c.isdigit for c in a)): print("YES") else: print("no")
98b3a0af1acfec22fa01e71e526c86d10817e9ad
mertdemirlicakmak/project_euler
/problem_2.py
647
4.0625
4
"""By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. 1 1 2 3 5 8 13 21 34 55 89 144 ... (every third number is even) """ def fibonacci_even_sum(range_): first = 1 second = 2 total = 0 fibonacci = [] fibonacci.append(f...
451639215d6909b77833f8dd04393bca0d11b676
matthewharrilal/LeetCodeChallenges
/LeetCodeChallengesDay1.py
13,907
4.34375
4
import string import pdb def add_two_binary_strings(string_1, string_2): # Goal of this function is to be able to add two binary strings # Convert both of the strings to digit lists binary_string_1_list = list(map(int, string_1)) print(binary_string_1_list) binary_string_2_list = list(map(int, ...
31620eac34244edac47755a4437bfc204a5a764e
Devejya/AstroPhysics
/A1/q1_4.py
843
3.765625
4
import math def max_altitude(delta: list, observatory: str) -> float: ''' ''' if observatory == "GN": beta = 19.8238 if observatory == "GS": beta = -30.24075 delta_radians = math.radians(delta[0] + delta[1]/60 + delta[2]/(60*60)) beta_radians = math.radians(beta) return math.deg...
14e0615e065284430b6cbadd5c1d141201f1c05f
shivanshcoder/Notes-code
/Python Code/Amil/scrabble1.py
4,495
3.96875
4
import sys import random TILES_USED = 0 # records how many tiles have been returned to user SHUFFLE = False # records whether to shuffle the tiles or not # inserts tiles into myTiles def getTiles(myTiles): global TILES_USED while len(myTiles) < 7 and TILES_USED < len(Tiles): myTiles.append(Tiles[TIL...
a2750319a85d6524418fbeaf1d5004d505126919
misa9999/python
/courses/python3/ch4-POO/14_lesson/polymorphism.py
333
3.9375
4
from abc import ABC, abstractclassmethod class A(ABC): @abstractclassmethod def speak(self, msg): pass class B(A): def speak(self, msg): print(f'B is talking {msg}') class C(A): def speak(self, msg): print(f'C is talking {msg}') b = B() c = C() b.speak('LALALA') c.spe...
cc13ad0ea1b9f72c4d8edc71c96fe559c049b147
LegendusMaximus/MathsGames
/MathsBot-version0.1.py
724
4.0625
4
input() user_answer = "" points = 0 import random while True: randomq = random.randint(0,100) randomq2 = random.randint(0,100) operation = ["+", "/", "*", "-"] roperation = random.choice(operation) question = "Enter the answer to"+str(randomq)+"+"+str(randomq2) answer = randomq+randomq2 print(questio...
49b81f2449895ce8ed8b1eced0273dc7dab362f0
afester/CodeSamples
/Python/SQLite/SQLiteSample.py
5,402
3.65625
4
''' Created on 26.03.2015 @author: afester ''' import sqlite3 class SQLiteSample(): def __init__(self): ''' Constructor ''' def initializeDB(self): self.conn.execute('''CREATE TABLE address (id INTEGER, firstname TEXT, lastname TEXT, eMail TEXT)''') sel...
ac0c500a62196c5bf29fe013f86a82946fdb65b2
mtjhartley/codingdojo
/dojoassignments/python/fundamentals/list_example.py
854
4.28125
4
fruits = ['apple', 'banana', 'orange'] vegetables = ['corn', 'bok choy', 'lettuce'] fruits_and_vegetables = fruits + vegetables print fruits_and_vegetables salad = 3 * vegetables print salad print vegetables[0] #corn print vegetables[1] #bok choy print vegetables[2] #lettuce vegetables.append('spinach') print veget...
178c4708aeca7e9df0a7bcc4503bf40687b96c3b
arthur-wxy/algorithm-daily
/sqrt.py
698
4.21875
4
# 实现 int sqrt(int x) 函数。 # 计算并返回 x 的平方根,其中 x 是非负整数。 # 由于返回类型是整数,结果只保留整数的部分,小数部分将被舍去。 # 示例 1: # 输入: 4 # 输出: 2 # 示例 2: # 输入: 8 # 输出: 2 # 说明: 8 的平方根是 2.82842..., #   由于返回类型是整数,小数部分将被舍去。 def sqrt(x): l = 0 r = x if x < 2: return x while l < r - 1: mid = (l + r) // 2 t = mid...
6212dfbfe3493ea1ef3ad576fc049a3ffc7324c7
surathjhakal/data_structures-algorithim
/180_important_questions/day1_arrays/Find_the_duplicate_in_an_array_of_N_integers.py
300
3.90625
4
def duplicate(my_list): new=[] print("the duplicate numbers are: ",end='') for i in my_list: if i in new: print(i,end=', ') else: new.append(i) def main(): n=int(input()) my_list=list(map(int,input().split())) duplicate(my_list) main()
a1d65f6529ff0a616dda0accc14620f22bf2c17c
runiccolon/python_deeper
/array/list_func.py
493
3.828125
4
# -*- coding:utf-8 -*- """ 列表操作 """ l = [1, 2, 3, 4, 5, 4] print(l.__contains__(1)) # 列表l是否包含元素1 print(l.count(4)) # l.__delitem__(0) # 把位于0的元素删除 # l.remove(4) # 删除l中第一次出现的4 print(l.index(4)) # 在l中找到元素4第一次出现的位置 print(l.__iter__()) # 获取l的迭代器 print(l.__mul__(2)) # l * 2 # print(l.__imul__(2)) ...
959d0961f76b2b8c71974d667d5f2f4dbe4b72c7
d4rkr00t/leet-code
/python/leet/331-verify-preorder-serialization-of-a-binary-tree.py
818
3.765625
4
# Verify Preorder Serialization of a Binary Tree # https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree/ # medium # # Time: O(n) # Space: O(n) # # Solution: # Stack def isValidSerialization(preorder: str) -> bool: sliced = preorder.split(",") stack = [] for n in sliced: st...
55c8cb92e5261ba1148293a74a12d2b91416f286
lovepreet-013/data_structure
/heap/Merge two binary Max Heaps.py
762
3.59375
4
def MaxHeapify(arr, n, idx): if idx >= n: return l = 2 * idx + 1 r = 2 * idx + 2 Max = 0 if l < n and arr[l] > arr[idx]: Max = l else: Max = idx if r < n and arr[r] > arr[Max]: Max = r if Max != idx: arr[Max], arr[idx] = arr[idx], arr[Max] MaxHeapify(arr, n, Max) def buildMaxHeap(arr,...
483f0ba423f56043f7deebb85ceb8d281463e628
rajeshwaridatta/learningCodes
/RajCodes/sortutil.py
490
3.640625
4
def selectionSort(numList): for start in range(0, len(numList)): minIndex = start for index in range(start, len(numList)): if numList[minIndex] > numList[index]: minIndex = index swapElements(start,minIndex,numList) return numList def swapElements(i, j, numList): temp = numList[i] numList[i] = numList...
55e52030c19fd37d12ebe68997b86b8030f79ff8
shrenik-jain/HackerRank-Solutions
/1.Python/01.Introduction/004.PythonDivision.py
414
3.890625
4
''' Question : Add logic to print two lines. The first line should contain the result of integer division, a//b The second line should contain the result of float division, a/b No rounding or formatting is necessary. Link : https://www.hackerrank.com/challenges/python-division/problem ''' if __n...
ff7d3c955f294e80ea764b39646d09ce63bbd193
jayashelan/python-workbook
/src/next-book/fruitful.py
294
4.09375
4
biggest = max(3,7,2,5) x = abs(3 - 11)+10 print(biggest,x) def find_first_2_letter_word(xs): """print the first characters of given word""" for wd in xs: if len(wd) == 2: return wd; return "" print(find_first_2_letter_word(["This","is","a","dead","parrot"]))
4a6c5d6495a34205d7ca23252528516cdd190c86
jmarq76/Learning_Programming
/AulasPython/Parte2/Semana4/lista_ordenada.py
159
3.78125
4
def ordenada(lista): length = len(lista) for i in range(length - 1): if lista[i] > lista[i + 1]: return False return True
bd83f96a8a0f54ac4323baf0cd578622172cb430
christopher-conklin/datadrivenplayer
/HardyProblem.py
4,111
3.609375
4
#This is a Monte Carlo simulation of the Hardy golf problem #with extensions (Python 3) import matplotlib.pyplot as plt import numpy import random def hole_result(prob): score = 0 remaining = 4 while remaining > 0: score += 1 p = random.random() #Bad shot, continue if p < p...
41cb8d08dcf928c6dedf9e2e790e03c26ca0cb98
MartinCarufel/PycharmProjects
/AppTkinter/AppTkinterMain.py
919
3.515625
4
# coding: utf-8 from tkinter import * class Myclass(Tk): """Class defining ... """ def __init__(self): """Class constructor""" Tk.__init__(self) self.geometry('300x300') self.frame = Frame(self) self.frame.pack() self.var = StringVar() self.label = Lab...
836f36772652e68e5d15e7fb6857c84bef7b0d80
penandlim/InterviewPrep
/solutions/CH1/IsUnique.py
316
3.6875
4
def isUnique(s): countMap = {} for c in s: if (c in countMap): return False else: countMap[c] = 1 return True def test(arr): for a in arr: print("Input: " + a) print("Output: " + str(isUnique(a)) + "\n") test(["asda sd", "a bc", "awwww2"])
fcad2db88176c94fba12d96b78422bbb062aa2f4
naimoon6450/python_exercises
/infmonkey.py
1,725
4.21875
4
# encoding=utf8 # The way we’ll simulate this is to write a function that generates a string that is 27 characters long by choosing random letters from the 26 letters in the alphabet plus the space. We’ll write another function that will score each generated string by comparing the randomly generated string to the goa...
40a7fb0e292ae6f70c78de7b3079c553b23c8581
inlet33/AIBASIC
/python1_4.py
610
3.78125
4
class Robot: def __init__(self,name="Lorem"): self.name = name self.color= "Red" self.energy = 100 def introduce_yourself(self): print("My name is " + self.name) def jump(self,speed): if self.energy <= 50 and self.energy != 0: print("low ene...
2d7c3d1611934978090126b6fe7daa6b8f2bc116
Aledutto23/Sistemi-e-Reti
/tartaruga.py
1,258
3.765625
4
from turtle import * pen = Turtle() window = Screen() lung = 50 pen.home() def controllo(): if (pen.ycor() + lung) > window.window_height()/2: return 1 elif (pen.ycor() - lung) < -1 * window.window_height() / 2: return 2 elif (pen.xcor() + lung) > window.window_width()/2: ...
ffb7b778b4d4c18a4ec89c2d805190ee30567ab9
liutaopro/python
/python代码/flag.py
1,460
3.671875
4
#五星红旗 import turtle turtle.up() turtle.goto(-200,200) turtle.down() turtle.begin_fill() turtle.fillcolor("red") turtle.pencolor("red") for i in range(2): turtle.forward(438) turtle.right(90) turtle.forward(292) turtle.right(90) turtle.end_fill() #主星 turtle.up() turtle.goto(-170,145) turtle.down() tur...
2999eb85b66600b095853893a02891ae492b599c
nuxion/python_clase
/auto.py
1,228
3.6875
4
class Rueda: def __init__(self, id): self._id = id def get_id(self): return self._id class Motor: def __init__(self, peso, cilindrada): self.peso = peso self.cilindrada = cilindrada def get_cilindrada(self): return self.cilindrada def set_cilindra...
c374bc990c5d749aa97766acc735b26ba6367cf7
LIGHT-Python/Labs
/Week 2/week2_test.py
1,246
3.90625
4
import unittest class TestWeek2(unittest.TestCase): def test_variables_add(self): x = 2 y = 4 self.assertEqual(5, x + y) def test_variables_mul(self): y = 4 x = 2 self.assertEqual(8, x * y) def test_variables_sub(self): x = 2 y = "4" ...
03978af9441a75560be202f8870c611d4c7873bf
ashmichheda/leetcode
/Python/Easy/Problem58.py
274
3.859375
4
class Solution: def lengthOfLastWord(self, s): s = s.strip() val = s.split(" ") print(val) length = len(val) answer = "" + val[length - 1] return len(answer) p1 = Solution() s = "Hello World" result = p1.lengthOfLastWord(s) print('Answer is: ' + str(result))
10d912ee2b00c97f5198e0a1efb47c442bb2ee00
hdhn/emotion1
/数学建模/递推关系-酵母菌生长模型.py
789
3.53125
4
#查分方程建模的关键在于如何得到第n组数据与第n+1组数据之间的关系 import matplotlib.pyplot as plt time = [i for i in range(0,19)] number = [9.6,18.3,29,47.2,71.1,119.1,174.6,257.3,\ 350.7,441.0,513.3,559.7,594.8,629.4,640.8,\ 651.1,665.9,659.6,661.8] plt.title('Relationship between time and number')#创建标题 plt.xlabel('time')#X轴标签 ...
0e562353be379890b65a56993874d14f57064a89
Salehbigdeli/bigidea
/main.py
423
4.1875
4
# %-formatting strings .format or f'' x = 2 print("I'm going to place a %d instead of %%d in formatting string" % x) print("We can do the same thing with format function of a string {0}".format(x)) print("Or you can use name instead of position like {name}".format(name=x)) print(f"what do you think about this new sty...
a12649740849dfe25e1dc9b1bfa4f2daf62674ef
vinicius-vph/python
/exercices/Desafio013.py
500
3.921875
4
#faça um algoritimo que leia o salario de um funcionario e mostre seu novo salario com 15% de aumento print('=' * 130) print('Esse ano foi aprovado 15 % de discidio pelo seu sindicato, informe o valor do seu salário e nós calcularemos o seu novo salário !') print('=' * 130) a = float(input('Digite o valor do seu salár...
fd59fb7d84b4ad0126cdb41edbdfc0bf2f419efe
andreagaietto/Learning-Projects
/Python/Assorted Programs for School/date_temp_class.py
2,915
4.09375
4
import datetime class DateTemp: def __init__(self, creation_number): # initialize self.creation_number = creation_number self.temp = 0 self.day = None self.month = None self.year = None self.date = None def get_date(self): # call each function ...
ee5c20522fd2e6b3cf751fc6ece4edb2232caf49
thomasniets/hse
/hw_python7/wordsfinder.py
1,629
3.734375
4
def open(): f = open('собственно текст.txt', 'r', encoding = "utf-8") s = f.read() f.close() s1 = s.lower() a = s1.split() for i, word in enumerate(a): a[i] = word.strip('!?();:<>.,') return a def find_in_text(t): hood = [] for word in t: if word.endswith('hood'): ...
d7182556a4cf233374e5f7877942bfe6fa19403a
JoinNova/baekjoon
/boj1264.py
413
3.546875
4
#boj1264 모음의개수 import re txt=input() while txt!='#': convert=len(re.sub(r'[aeiouAEIOU]','',txt)) print(len(txt)-convert) txt=input() t=input() while'#'!=t:print(sum([t.count(x)for x in'aeiouAEIOU']));t=input() #by sait2000 s=input() while'#'!=s:print(sum(map(s.lower().count,'aeiou')));s=input() #by sky...
9a7cf38270bea38de51e6af271ce2d0360636825
ehdrn463/coding-test
/programmers_kit/heap/디스크컨트롤러.py
1,474
3.671875
4
import heapq def solution(jobs): answer, now, i = 0, 0, 0 start = -1 heap = [] # 처리한 갯수가 len(jos) 보다 작을 때까지 반복. while i < len(jobs): # jobs의 요청시간을 보면서 처리할 수 있는 것을 더해준다. for j in jobs: # 요청시간이 이전 작업의 완료시간보다 크고, 현재시간보다 작거나 같다면 처리해줄 수 있는 작업임 # 요청시간(j[0]) 기준...
d62c921233d2ad1e15ba7c27139cadde92165c47
deekshasowcar/python
/fact.py
166
4.3125
4
def factorial(num): if num==1: return True else: return num*factorial(num-1) num=int(input("input a number to compute the factorial:")) print(factorial(num))
5462d1b24691cf44e42b44479c118bb9c9f43322
JacielleFerreira/ExerciciosJaci
/Exercicio1/questao14.py
216
3.8125
4
a = int(input('Digite o primeiro número: ')) b = int(input('Digite o segundo número: ')) trocaA = b trocaB = a print ('Os valores antes da troca é',a,'e',b,'e os valores depois da troca é',trocaA,'e',trocaB)
23f525e828ba28a3ae95c1d035a88dd6e0977fba
pyapps/cowincheck
/pyapp/cowin.py
510
3.53125
4
# -*- coding: utf-8 -*- """ Created on Fri Apr 30 15:03:15 2021 @author: Admin """ import requests import json def checkPinCode(pincode): response = requests.get('https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode='+pincode+'&date=01-05-2021') if response.status_code == 200: ...
02617e301cad46c916d3f0f1a12cab8c800b57b9
a100kpm/daily_training
/problem 0022.py
1,512
3.984375
4
''' Good morning! Here's your coding interview problem for today. This problem was asked by Microsoft. Given a dictionary of words and a string made up of those words (no spaces), return the original sentence in a list. If there is more than one possible reconstruction, return any of them. If there is no possible r...
768e6c0e7fff579c81229a62f6d6e8db1816b89a
newton1057/BinarioDecimal
/BinarioDecimal.py
816
3.796875
4
# Codigo para convertir un numero binario en Decimal, # consiste en el llenar una lista(array) con los digitos # El numero binario debe ponerse de derecha a izquierda # Ejemplo 16 en Binario es 10000, asi que en el programa debe ponerse 00001 # Autor: Eduardo Isaac Davila Bernal # Fecha: 25/04/2020 def potencia(base,...
f7b36ad4cfe9470ce97fa72a863527206f3ada57
MrHamdulay/csc3-capstone
/examples/data/Assignment_5/mtlpie001/question1.py
1,460
3.921875
4
"""PIET MOTALAOTA 17 APRIL 2014""" def BBS(): selection='' message_to_view='' while selection!='X': print('Welcome to UCT BBS\nMENU\n(E)nter a message\n(V)iew message\n(L)ist files\n(D)isplay file\ne(X)it') option_select=input('Enter your selection:\n') """Asks the ...
beb176c2c23ab95051989fc4611c8605db2b4080
Hayk258/lesson
/lesson16.py
1,607
3.5
4
thisdict = {'name':'Aram','year':'1992'} print(thisdict) # thisdict2 = {'name':'Hayk','year':'1991','day':'10'} # x = thisdict2.popitem() # print(x) # print(thisdict2) # print(thisdict2['year']) # print(len(thisdict2)) # thisdict2['name']='Ani' # print(thisdict2) # thisdict2['year']= 1234 # print(thisdict2) #...
d1228fb1e0eabbb032c89d74e7cfd35daa64d51e
YashShirodkar/Machine-Learning-Basic-SPPU
/LinearRegression.py
986
3.796875
4
import pandas as pd from statistics import mean import numpy as np import matplotlib.pyplot as plt from matplotlib import style style.use('ggplot') data = pd.read_csv('Book_1.csv') print(data) a = data[data.columns[0]].values #first col c = data[data.columns[-1]].values #last col xs = np.array(a, dtyp...
8dfa5277d41ec504e4668433670ba758f9f75baa
Vixus/LeetCode
/PythonCode/Monthly_Coding_Challenge/May2020/KthSmallestElementInaBST.py
1,752
4.15625
4
import queue # 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 kthSmallest(self, root: TreeNode, k: int) -> int: """ Given a binary search tre...
6089369d47fbc5cebf9d109502055becbc5aa6c5
roger6blog/LeetCode
/SourceCode/Python/Problem/00090.Subsets II.py
1,319
3.875
4
''' Level: Medium Given an integer array nums that may contain duplicates, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order. Example 1: Input: nums = [1,2,2] Output: [[],[1],[1,2],[1,2,2],[2],[2,2]] Example 2: Input: nums = [0] Outp...
d63bbf3c8dbe4629fbbec438596ab9c22f973c72
briantaylorjohnson/python-practice
/making_pizzas.py
1,171
4.375
4
### Chapter 8: Functions ## Storing Your Functions in Modules # Importing an Entire Module (Cont'd) import pizza3 # Imports all functions in module pizza3.py which is in the same directory as this file (making_pizzas.py) -- Must use dot notation from pizza3 import make_pizza as mp # Imports just the make_pizza func...
7c5e023f36d525af6b165c9f0263862d84e8f1ed
tolgayan/internship-dummy-projects
/digit_recognizer.py
3,631
4.09375
4
from keras.datasets import mnist from keras.utils import to_categorical from keras import models from keras import layers import matplotlib.pyplot as plt ''' Load keras mnist dataset and prepare it ''' # train_images: images to be used in training # train_labels: true values of train images # test_images : images t...
e1bfd626a7e4694a1ddbc1f2ecfd5c0368415b0b
warodomnilanon/EPHW
/LOOP3_D2.py
94
3.71875
4
n = int(input("n: ")) a = 1 sum = 1 while a <= n: sum *= a a += 1 print(sum)
08d6ee0528c82e30eeb70d5725b2f81ad826ff02
raokrutarth/ml_ds
/dl_oxford_cnn_alexnet.py
4,758
4.0625
4
import numpy as np from keras.models import Sequential from keras.layers import Dense, Dropout, Flatten, Conv2D, MaxPooling2D from keras.layers.normalization import BatchNormalization from keras.callbacks import TensorBoard import tflearn.datasets.oxflower17 as oxflower17 class OxfordFlowersAlexNet: ''' ...
724867a778ac951988c6172273fe9cdabfbda3c3
nehayd/encode-decode
/main.py
1,048
4.125
4
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', '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'] direction = input("Type 'encode' to encrypt, ty...
34f8ae03058e864d304061975afe22d85bfc0a90
sungminoh/algorithms
/leetcode/solved/171_Excel_Sheet_Column_Number/solution.py
1,311
3.859375
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # # Copyright © 2020 sungminoh <smoh2044@gmail.com> # # Distributed under terms of the MIT license. """ Given a string columnTitle that represents the column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 ...
402ab50c5d046bc78b3a2b8e0294c70c53e5ee8f
Fondamenti18/fondamenti-di-programmazione
/students/1799313/homework01/program01.py
1,309
3.9375
4
''' Si definiscono divisori propri di un numero tutti i suoi divisori tranne l'uno e il numero stesso. Scrivere una funzione modi(ls,k) che, presa una lista ls di interi ed un intero non negativo k: 1) cancella dalla lista ls gli interi che non hanno esattamente k divisori propri 2) restituisce una seconda l...
424da61c5c2a63994eae7a4867d3f5ff1934b6bb
victoar/Backtracking
/backRec.py
1,298
3.6875
4
def increasingOrder(a, b): if a < b: return True return False def commonDigit(a, b): ok = 0 while a > 0: x = b c1 = a % 10 a = int(a / 10) while x > 0: c2 = x % 10 if c1 == c2: ok = 1 x = int(x / 10) if ok =...
c29f91cb2c92aa979489f7827d259e496421ea1d
hizbul25/programming_problem
/generic/gcd.py
79
3.59375
4
def gcd(x, y): while y != 0: (x, y) = (y, x%y) return x print(gcd(51, 75))
3df4c5f5053020bdd302885f48bd566e1aed1697
kuriadn/pli_ke
/src/pli_ke/angle.py
609
3.5625
4
from math import * def sign(value): sig = 1 if value < 0: sig = -1 return sig def radian(d, m, s): sig = sign(d) deg = abs(d) return (deg + m/60.0 + s/3600.0) * pi / 180.0 * sig class Angle(): def __init__(self, rad): self.rad = rad self.sign = sign(self.rad) rad = abs(s...
7154ad608a47f3a1cbef0f22644aa00afe43b6bc
iamvarshith/DS-Algo-practice
/Stacks/stack.py
1,053
3.859375
4
# check the parenthesis in the given string input = input('Enter the string to with the given brackets') stack = [] # types of brackets () [] {} def checkIndentOfBrackets(input): for i in range(len(input)): if input[i] == '[': stack.append('[') if input[i] == ']': if len...
8e11fd9b10463f743e31c83092c0603632aa31c1
Karina722/Madona2
/4uzdevums.py
367
4.09375
4
""" Uzrakstiet programmu Python, lai pārbaudītu, vai norādītā vērtība ir vērtību grupā. Testa dati: 3 -> [1, 5, 8, 3]: taisnība -1 -> [1, 5, 8, 3]: nepatiesa """ def testa_dati(dati, n): for value in dati: if n == value: return True return False print(testa_dati([1, 5, 8, 3], 3...
86d73be1bedb7d3cbcb4722316bd9542492ebf7e
taprati/Rosalind
/Bioinformatics_Stronghold/ROS_Counting_Nucleotides.py
543
3.5
4
# Problem 1 on rosalind # Given a DNA string s of length at most 1000 nt # Return four integers (separated by spaces) counting # the respective number of times # that the symbols 'A', 'C', 'G', and 'T' occur in s file = open('rosalind_dna.txt') s = file.read() A_count = 0 C_count = 0 G_count = 0 T_count = 0 for char...
0a439634e253cd11ebf6b66600bd4c127f9aef2d
wrj27/willjames-python
/rollTwoDice/RollTwoDice.py
1,174
3.921875
4
import random def main(): gamesPlayed = 0 while(input("Do you want to play again? y or n - ") == 'y'): dice() gamesPlayed += 1 print("You have played " + str(gamesPlayed) + " times.\n_____________") else: print ("Thanks for playing!") def dice(): dice1 = [" ------- ", "...
58a8ee57fa7b34615214a1aa36bbb8ce317f2842
slsefe/-algorithm015
/Week_04/69-sqrtx.py
1,403
4.15625
4
""" leetcode 69 x的平方根 实现 int sqrt(int x) 函数。 计算并返回 x 的平方根,其中 x 是非负整数。 由于返回类型是整数,结果只保留整数的部分,小数部分将被舍去。 示例 1: 输入: 4 输出: 2 示例 2: 输入: 8 输出: 2 说明: 8 的平方根是 2.82842...,   由于返回类型是整数,小数部分将被舍去。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/sqrtx 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 """ class Solution: def mySqr...
7b99e9679b57f5b7f613003836aafd5f4c901d86
LixingZHANG96/Algorithm_Package_Lix
/Classical Algorithms/Sorting/Bubble-Sort/Bubble-Sort.py
511
4.03125
4
import time def bubble_sort(A): """The main function for bubble sort.""" for i in range(len(A)-1): for j in range(len(A)-1, i, -1): if A[j] < A[j-1]: cache = A[j] A[j] = A[j-1] A[j-1] = cache print("Current list:\t", A) return A ...
e3fe1a8b31717093e001d1331909cf10e5580f6a
mcardos/project-3-healthfy
/model.py
11,416
3.578125
4
import random import pygame from pygame.locals import (USEREVENT) # Constant variables. black = (0, 0, 0) white = (255, 255, 255) red = (255, 0, 0) green = (27, 133, 27) class HealthfyModel: """ Maintains all information included in the game Healthfy. Attributes: health = An integer represeting...
23673fa67035d7e7c95a9d55b0a80d97dbdd6c19
patipank59/testPHOENIXICT
/test2.py
456
4.0625
4
# สร้าง function ด้วยภาษาที่ถนัดหาชื่อของ key ใน obj ด้านล่างที่มี value เป็น 'value5' obj = { "key1": { "key2" : "value1", "key3" : "value2", "key4" : { "key5": "value5" } } } def search(value): return value['key1']['key4']['key5'] print('result...
8da4d58a02c05ccfe34c7be3e5859685ca888f1e
AndreySperansky/TUITION
/PROBLEMS/20-dprog-stones.py
1,462
3.765625
4
# -*- coding: utf-8 -*- """ Динамическое программирование. Задача 3 (Задача о куче). Из камней весом p (i 1, ,N) i  набрать кучу весом ровно W или, если это невозможно, максимально близкую к W (но меньшую, чем W). Все веса камней и значе- ние W – целые числа. """ WMAX = 8 P = [2, 4, 5, 7] NStones = len(P) T = [] for ...
09c7a474ce47de36b4271d2e10eb7d87883b65f2
airkve/Ejercicios
/Listas/Ejercicio21.py
658
3.734375
4
# Crear una funcion que se le pase una lista como parametro y muestre # una lista con los pares y que adicionalmente muestre cuantos numeros # impares fueron introducidos. nums = [] def loadNums(): for i in range(10): question = int(input('Ingresa un numero: ')) nums.append(question) p...
b6f33e0667ec711c5b7690f740e36c2965493575
bqz913/python_practice
/20191028practice1/matplotlib_2.py
1,448
3.71875
4
# インポート import matplotlib.pyplot as plt import numpy as np # 配列作成 x = np.linspace(0, 10, 100) y1 = np.sin(x) y2 = 2 * np.sin(x) y3 = np.cos(x) y4 = np.linspace(-1, 1, 100) # オブジェクト指向を使ってみる(こっちのほうが汎用性が高い) fig1 = plt.figure(1) # figure作成 (1)は,figureの番号。(何個もfigureを作成しない場合は指定しなくてもOK) ax = fig1.add_subp...
1014f179a5c49787db420cc2a013f2e1dd06a8e8
Sandhyashende/Python
/List_questions/2list iteration.py
299
4.09375
4
# list iteration test_list1 =[23,67,90,45,56,78] test_list2 = [10, 20, 56, 45, 36, 20] print("The original list 1 is : " + str(test_list1)) print("The original list 2 is : " + str(test_list2)) print("The paired list contents are : ") for ele in test_list1 + test_list2: print(ele, end =" ")
1811009636ec9dc2e7c5025cbb2d9abb4c7fefe7
srisaipog/markbook-abc
/functions/roster-functions.py
1,850
4.125
4
def create_student(): students = dict() key_1 = 'first_name' value_1 = str(input("Enter the student's first name: ")) key_2 = 'last_name' value_2 = str(input("Enter the student's last name: ")) key_3 = 'gender' while True: try: value_3 = str(input("Ente...