blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
b74d570c12404a0204c7b7eb6bb29280a46446c1
bluestar31/dinhthanhlong-fundamental-c4e13
/Session 2/fizzbuzz.py
226
4.09375
4
n = int(input("Enter a number: ")) for i in range(n): if i % 2 == 0: if i % 3 == 0: print("FizzBuzz") else: print("Fizz") else: if i % 3 == 0: print("Buzz")
0b22ccf7c3442f0b8cb8b489e3bdf133c3fbf274
kgardouh/machine-learning-data-sante
/parser-clean.py
499
3.640625
4
import re def find_str(s, char): index = 0 if char in s: c = char[0] for ch in s: if ch == c: if s[index:index+len(char)] == char: return index index += 1 return -1 with open('example.txt', 'r') as f: #open the file conte...
148b005ebcaff7002c7f1c6b461761b0a6e708f2
bomendez/bomendez.github.io
/Hangman/test_hangman.py
1,565
3.5
4
from hangman import (is_letter, in_word, already_guessed, insert_letters, add_to_guessed, game_over, end_string) def test_end_string(): assert(end_string("APPLE") == "_____") assert(end_string("OBVIOUS") == "_______") assert(end_string("XYLOPHONE") == "_________") def test_game_over...
1d0d08f1f18d35ae3f93ad4d86863a58e915a41b
JerryHDev/Functional-Programming
/Chapter 5/5_4.py
294
3.671875
4
#Jerry Huang #Period 4 def main(): phrase = input("Enter a phrase: ") myList = phrase.split(" ") listLength = len(myList) x = 0 for i in range(listLength): f_word = myList[x] f_letter = f_word[0].upper() print(f_letter, end="") x = x + 1 main()
e1359df8232d2dde0560891b526ec0cb34d2fc1a
hasan55-krmz/Portfolio-Manegement
/portfolio_management_modul.py
8,578
3.640625
4
########################################################### # Libraries ########################################################### import pandas as pd import numpy as np import pandas_datareader as pdr from datetime import datetime import seaborn as sns import matplotlib.pyplot as plt ################...
a4139cdd4c99903b152351442e09296fa76baafb
murakumo512/aaaa
/4.py
130
3.921875
4
count = 0 while (count < 5): print(count, "kurang dari 5") count = count + 2 else: print(count, "tidak kurang dari 5")
44bbbea0525dcc460e0891ed1434ddefd53b1d76
elenaborisova/Python-Fundamentals
/04. Data Types and Variables - Exercise/09_snowballs.py
667
3.75
4
snowballs_count = int(input()) max_snowball_value = 0 max_snowball_snow = 0 max_snowball_time = 0 max_snowball_quality = 0 for snowball in range(snowballs_count): snowball_snow = int(input()) snowball_time = int(input()) snowball_quality = int(input()) snowball_value = (snowball_snow / snowball_time) ...
0564e4da936a14f7ca3e8eb5e202dc066f8f5a4c
RamshackleJohnny/todo-manager
/manager.py
2,514
3.890625
4
from item import Item class Manager(object): def __init__(self): pass def menu(self): print("Do you want to add something, mark something as done, remove something, or check your list?") option = input("> ") option = option.lower() print(option) if option == 'ad...
5bb860225a4dc13b02dd76f6835d80cdb779337c
Yuchen1995-0315/review
/01-python基础/code/day17/demo02.py
1,188
3.96875
4
""" """ list01 = [4, 54, "65", 75, 8, "9", "b"] # 需求1:找出所有偶数 def find01(): for item in list01: if type(item) == int and item % 2 == 0: yield item # 需求2:找出所有字符串 def find02(): for item in list01: if type(item) == str: yield item # 需求3:找出所有大于10的整数 def find03(): f...
5bec81dc028d8e5507cd9a31d701e7e24a04c49c
ronaksvyas/spojSol
/nextPalindrome.py
569
3.578125
4
def main(): t = int(raw_input()) for i in xrange(t): n = long(raw_input()) getNextPalindrome(n) def getNextPalindrome(n): ns = list(str(n)) if(isPalindrome("".join(ns))): print "".join(ns) return if(len(ns) == 1): print 11 return else: i = 0 j = len(ns) - 1 for i in xrange(len(ns)/2): ns[le...
81941e65ab7693369888526da8f62e4b13fe6fbf
NevineMGouda/Data-Sructures-And-Algorithms
/Assignment 1/birthday_present.py
4,927
3.546875
4
#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- ''' Assignment 1: Birthday Present Team Number: 60 Student Names: Mona Mohamed Elamin, Nevine Gouda ''' import unittest def birthday_present(P, n, t): ''' Sig: int[0..n-1], int, int --> Boolean Pre: P is a list of non-negative integers and t ...
df5f11fc1d712ffc86328f81de8c9fb71143069e
Xay001/Bubble_Sort_Algorithm
/Sort1.1.py
488
3.75
4
sayilar = [] i = 0 j = 0 s = 0 uzunluk = int(input("How long your number array :")) uz = uzunluk while(i < uzunluk): sayilar.append(int(input("Enter numbers : "))) i = i + 1 while(j < uzunluk): s = 0 while(s < uz-1): if(sayilar[s] > sayilar[s+1]): ...
728894aff472e7d503312fead422cbbfa5a4bb47
MadanParth786/Sightseeing-Advisor-Application
/Sightseeing Advisor App.py
19,528
3.703125
4
#!/usr/bin/env python # coding: utf-8 # In[2]: import tkinter from tkinter import * from tkinter import messagebox # In[3]: val =" " #global variable A = 0 #to store Value in A operator = " " #global variable # In[4]: def Delhi(): import random def randomSolution(tsp): cities = list(rang...
cdeac857109edbb57d854c91406e334a5b266925
RoslinErla/AllAssignments
/assignments/lists/add_to_list.py
694
4.375
4
#Write a program that keeps asking the user for new values to be added to a list # until the user enters 'exit' ('exit' should NOT be added to the list). # After that, the program creates a new list with 3 copies of every value in the initial list. # Finally, the program prints out all of the values in the new list....
48b55e7375d8038d430949cff632ef5e40b5ae93
barvilenski/daily-kata
/Python/string_incrementer.py
765
4.25
4
""" Name: String incrementer Level: 5kyu Description: Your job is to write a function which increments a string, to create a new string. If the string already ends with a number, the number should be incremented by 1. If the string does not end with a number the number 1 should be appended to the new string. Examples: ...
786fabf64790a2755c95268526e051a6e084d66b
KocUniversity/comp100-2021f-ps0-yhamid21
/main.py
160
3.5
4
import numpy x = float(input("Enter number x: ")) y = float(input("Enter number y: ")) z = x ** y print("x**y",z) print("log(x) =",numpy.log2(x)) print("77916")
9c6915456c8f5386ec0402705f1e331787c509bb
NikitaSemenovV/Python-introduction
/slide2.py
1,029
3.734375
4
def fib(n): arr = [1, 1] for i in range(3, n + 1): tmp = sum(arr) arr = [arr[1], tmp] return arr[1] def fib3(n): arr = [1, 1, 1] for i in range(4, n + 1): tmp = sum(arr) arr = [arr[1], arr[2], tmp] return arr[2] def squares(n): return [i *...
321fc1e5d5cabcaa2f5b756e1e339edd83e41a4e
qmnguyenw/python_py4e
/geeksforgeeks/python/python_all/2_9.py
2,751
4.15625
4
Python program to convert Base 4 system to binary number Given a base 4 number N, the task is to write a python program to print its binary equivalent. **Conversion Table:** ![](https://media.geeksforgeeks.org/wp- content/uploads/20200128113422/Table33.png) **Examples:** > **Input :** N=11002233...
7d6d642095b3e4a7d7b59f1f80bffd6fa3e5c866
lordbeerus0505/xero
/lib/yellowant_command_center/unix_epoch_time.py
310
3.671875
4
import datetime import calendar def convert_to_epoch(date): #date format=MM/DD/YYYY day=int(date[3:5]) month=int(date[0:2]) year=int(date[6:10]) time=datetime.datetime(year,month,day,0,0) time=calendar.timegm(time.timetuple()) return time #print(convert_to_epoch("04/01/2012"))
0291913d9ba3adb5fd713abf20e0b18b0ebcf0fb
KistVictor/exercicios
/exercicios de python/Mundo Python/026.py
271
3.90625
4
frase = input('Digite uma frase: ').lower().strip() print('sua frase possui', frase.count('a'), 'a letra "a"') print('ela aparece, pela primeira vez, na {}° casa'.format(frase.find('a')+1)) print('ela aparece, pela última vez, na {}° casa'.format(frase.rfind('a')+1))
beb3f59c450bd01f1c430746d2e0786877a954a1
Krina666/CST8279_302
/Final302_changqi_Li/Final302_changqi_Li/6.py
804
3.78125
4
gradeDict = {} f = open("final302.csv", "r") while True: line = f.readline() if line == "": break if line.find(" "): pass elif line.find(","): line = line.split(",") #line[0]+line[1] is the concatenation of names, line[5] and line[6] are decimal and letter grades respect...
a985d1439e1f07522b6d141260b8e299278e045b
Kritika05802/DataStructures
/area of circle.py
235
4.21875
4
#!/usr/bin/env python # coding: utf-8 # In[3]: radius = float(input("Enter the radius of the circle: ")) area = 3.14 * (radius) * (radius) print("The area of the circle with radius "+ str(radius) +" is " + str(area)) # In[ ]:
bd6da79fd6732103f3c0b8410f8dfc3ad860cca7
calebjcourtney/adventofcode_2019
/day06/solve.py
974
3.71875
4
import networkx as nx def part_one(input_data): graph_part_one = nx.DiGraph() graph_part_one.add_edges_from(input_data) orbit_count = sum([get_pred_sum(node, graph_part_one) for node in graph_part_one.nodes]) return orbit_count def get_pred_sum(node, graph_part_one): predecessors = list(graph_...
0d4950fcfb89d01d64575cad02fff950d9a8304e
msanden/contact-list
/run.py
2,897
4.25
4
#!/usr/bin/env python3.6 from contact import Contact def create_contact(fname,lname,phone,email): new_contact = Contact(fname,lname,phone,email) return new_contact def save_contacts(contact): contact.save_contact() def del_contact(contact): contact.delete_contact() def find_contact(number): retu...
d307b4cc643aaedda1bf32b618ff7722ccd0523a
sainihimanshu1999/Data-Structures
/Practice - DS-New/deletemiddle.py
513
3.828125
4
def deleteMid(head): ''' head: head of given linkedList return: head of resultant llist ''' m = middle(head) prev = head curr = head while curr!=None and curr.data!=m: prev = curr curr = curr.next prev.next = curr.next curr = None return head ...
48b542d564750b8d38af12e213098ae207b12f00
yzl232/code_training
/mianJing111111/Google/trie/You have a dictionary which is an array of words and array of strings. Write two functions 1. Prepare the array of strings to be searched in the dictionary 2. Check if the string contains all valid words or not..py
1,304
4.15625
4
# encoding=utf-8 ''' You have a dictionary which is an array of words and array of strings. Write two functions 1. Prepare the array of strings to be searched in the dictionary 2. Check if the string contains all valid words or not. 用trie 1 。 make a trie 2 。 trie contains。 1。 这里每个string都自己做一个trie。 2. 每个word都...
93451461153185b3134e5a8c62314c70969f0bfc
kashikakhatri08/Python_Poc
/python_poc/python_list_program/list_element_search.py
918
3.890625
4
def user_input(): element = int(input("Enter element you want to search: ")) return element def naive_method(element): list_container = [1,2,3,4,5] for i in range(len(list_container)): if element == list_container[i]: return True def in_method(element): list_container = [1, ...
f2e616b3eb26cb190912e9d2a3c4980c478ce584
elu3/Python
/zagadka4cichonia2.py
4,123
3.515625
4
from math import * from string import * def wstaw(tekst, nowe, pozycja): return tekst[:pozycja] + nowe + tekst[pozycja:] def zamien_jeden_znak(text,indeks_znaku, znak): nowy = text[:indeks_znaku] + znak + text[(indeks_znaku+1):] return nowy def znajdz_indeks_nastepnego_miejsca_do_wstawienia_nawiasu_w_dol(wyra...
eeea48990dde4cc9268d1c30543e72eb1655fb51
NorCalVictoria/assess-2-hb-OO
/assessment.py
2,897
4.8125
5
""" Part 1: Discussion 1. What are the three main design advantages that object orientation can provide? Explain each concept. close to --- Easier debugging --- Reuse of code (inheritance) --- Flexibility --- data lives close to it's functionality : you don't need to know info a method uses: ...
e19a697898e3a79540a6bde4c19907325088981e
awerar/AI-Draughts
/Bot.py
6,181
3.59375
4
import time from cmath import inf from typing import List from Piece import Piece from Position import Position from Board import Board class BestBot: def make_move(self, board: Board) -> List[type(Position)]: start_time = time.time() best_move = [] for depth in range(1, 100): ...
c5421c1a0a437377c3f6506d5e2f6a9ba71e53f9
santhosh-kumar/AlgorithmsAndDataStructures
/python/test/unit/problems/binary_tree/test_check_array_is_preorder_bst.py
1,088
3.71875
4
""" Unit Test for convert_sorted_array_to_bst """ from unittest import TestCase from problems.binary_tree.check_array_is_preorder_bst import CheckArrayIsPreOrderBST class TestCheckArrayIsPreOrderBST(TestCase): """ Unit test for CheckArrayIsPreOrderBST """ def test_solve(self): """Test solve ...
d7018067dba35584a7714b1455625bcb9551b818
SuryaNMenon/Python
/Dictionaries/maxValue.py
276
4.1875
4
userdict = {} for iter in range(int(input("Enter the number of key value pairs: "))): userdict[input("Enter a key: ")] = input("Enter a value: ") print(userdict) maxvalue = max(userdict.values()) for k,v in userdict.items(): if v == maxvalue: print("Max value is", v)
d1b153523fd7a6a17f47d19e7377558253944bb5
crp3/python-practice
/algorithms/byte-by-byte/zero_matrix.py
1,234
3.859375
4
def zero_matrix(matrix): zero_first_column = False zero_first_row = False for i, row in enumerate(matrix): for j, item in enumerate(row): if item: matrix[0][j] = True matrix[i][0] = True if i == 0: zero_first_row = True if ...
05cc96906224cfdfd4bc169098a643850f604436
kontai/python
/條件控制語句/for/search.py
161
3.71875
4
items=["aaa",111,(4,5),2.01] tests=[(4,5),3.14] for key in tests: if key in items: print(key,"was found") else: print(key,"not found!")
4fdde698686bf135c708a27d6a0c3220420d1a08
fcunhaneto-test/pyalgorithms
/trees_udemy/binarytree.py
914
3.90625
4
#!/home/francisco/.pyvenv/mypython3/bin/python3 # -*- coding: utf-8 -*- class Node: def __init__(self, value): self.value = value self.left = None self.right = None class BinaryTree: def __init__(self): self.root = None def insert(self, value, node): if not self....
04b6a28fd65d08117ca6a15d0e502afedfb9231b
njones777/school_programs
/point.py
1,298
4.1875
4
import math # the 2D point class class Point: #class constructor with default values set at 0 def __init__(self, x=0, y=0): self.x = float(x) self.y = float(y) #acessor @property def x(self): return self._x #mutator @x.setter def x(self, value): self._x = value #acessor @property def y(sel...
e67f5fcf171e240db968a82cfea7b892f7765bea
luogao/python-learning
/py_parameter.py
3,436
4.0625
4
##函数的参数 #位置参数 def power(x,n=2): #默认为计算平方 s = 1 while n>0: n = n-1 s = s * x return s print(power(3,3)) print(power(5)) ### 定义默认参数要牢记一点:默认参数必须指向不变对象! def add_end(L=None): if L is None: L = [] L.append('END') return L print(add_end()) def calc(*numbers): sum = 0 ...
123e40b4251007a3419f4b2a266534993efbb22f
ZCW-Data1dot2/python-12-Anujangalapalli
/viva_comprehensions.py
867
3.578125
4
from typing import List, Dict, Set, Callable import enum class Parity(enum.Enum): ODD = 0 EVEN = 1 def gen_list(start: int, stop: int, parity: Parity) -> list: """ Generate a list :param start: :param stop: :param parity: :return: """ if parity == Parity.EVEN: ...
f59305c3ca4b09b7306a571e25f4a83e4383d861
IanFroning/metropolis-ising-model
/Metropolis.py
2,096
3.96875
4
""" File: Metropolis.py Metropolis algorithm outlined by Hjorth-Jensen in "Computational Physics" 1. Compute energy of initial state 2. Flip a spin at random 3. Compute energy of new state 4. Accept change if energy is lowered 5. If energy is increased, calculate Boltzman factor 6. Compare BF w...
8ee7a856f08d854cea0d6c0702988783180f7466
muhammad-masood-ur-rehman/Skillrack
/Python Programs/two-policemen-catching-a-thief.py
1,256
4.15625
4
Two Policemen Catching a Thief Policeman1 and Policeman2 along with a thief are standing on X-axis. The integral value of their location on the X-axis is passed as the input. Both the policemen run at the same speed and they start running at the same time to catch the thief. · The program must print Police1 if Policem...
d2936efa49713b66d319425e7b1f8621f70eda3d
mollycaffery10/pythonschool
/Final Project Draft.py
8,092
3.640625
4
import winsound import urllib import webbrowser startQuestion = input('Would you like to learn about France? y/n') true = 'y' if startQuestion == true: print("OK!") winsound.PlaySound('Für Elise (Piano version) (1).wav', winsound.SND_FILENAME|winsound.SND_ASYNC ) historyQuestion = in...
5f7b088cb80169166031d06807ffb01c77105411
developer73/cglife
/cglife/input.py
476
3.734375
4
def read_from_file(filename): """ Reads text file <filename> and returns it's content. content of the file: test 123 abc 456 end output: ['test 123\n', 'abc 456\n', 'end\n'] """ f = open(filename, 'r') lines = f.readlines() f.close() return lines de...
9b415bee3e176464c403e8fedc7519ccbfbf9258
geo-wurth/URI
/Python/1051 - Imposto de Renda.py
667
4.03125
4
x = float(input()) if (x <= 2000): print("Isento") elif (2000 < x <= 3000): x = x - 2000 imposto = x * 0.08 print("R$ %.2f"%imposto) elif (3000 < x <= 4500): x = x - 2000 imposto = 999.99 * 0.08 x = x - 999.99 imposto = imposto + (x * 0.18) print("R$ %.2f"%imposto) elif ...
f35f444d47e078374dc8237ffce3308cba09b9ef
AlexeevAlexey/ProgiSPBD
/Laba3/Lessons 3.py
261
3.609375
4
a =[int(i) for i in input("введите числа через пробел ").split()] n=int(input("В какую степень вы хотите возвести числа? ")) for i in range(len(a)): a[i]=a[i]**n print("Ваши числа-",a)
0ec6d9d750e511a75c2eb69da0089c8035341f8b
brothenhaeusler/connect_four
/src/four_wins_functions_functional.py
10,551
4.15625
4
#! /usr/local/opt/python/bin/python3.8 import numpy as np import random import re def create_board(rows, columns): board = np.zeros((rows,columns),dtype=np.int8) return board def one_to_zero_indexing(number): return number-1 # does_column_has_space checks whether a stone can still be inserted in certa...
89d827ea5d3898f30ceea668a741c4b943805f0a
cuiboautotest/learnpython3
/16_class/基础/4_添加类属性.py
591
4.15625
4
class Flower(object): height=20#类属性, def __init__(self, name, color,height):#括号里的是实例属性 self.name = name self.color = color # self返回的是类对象本身 self.height = height #实例属性 print(self) print(Flower.height)#类属性是直接绑定在类上的,所以,访问类属性不需要创建实例,就可以直接访问: f=Flower('玫瑰','红色',10) print(f.height)#...
fed2a10aab2a30d744289836b372ce9599fc4a7b
mkosmala/mtbforecast
/summarize_weather.py
1,513
3.546875
4
#!/usr/bin/env python import sys import csv import pandas # -*- coding: utf-8 -*- """ Created on Thu Jan 11 19:16:06 2018 @author: mkosmala """ if len(sys.argv) < 3 : print ("format: summarize_weather.py <input file> <output file>") exit(1) infilename = sys.argv[1] outfilename = sys.argv[2] # get a wea...
e5f5b0492324a16dc393d29a03e620423e278a16
AbdiVicenciodelmoral/linear_regression
/linear_regression.py
3,484
3.6875
4
import numpy as np class LinearRegression_OLS: def __init__(self): self.mean_x = None self.mean_y = None self.var = 0 self.covar = 0 self.m = 0 self.b = 0 self.data_length = None def fit(self,x_Vals,y_Vals): # We need to get the mean of all t...
ca76a2fccf6fb982ef0d168e06a5c9f1dffa847f
Ethanpho2002/Classwork
/Python IF statements.py
418
4.0625
4
Question 34 code: a=int(input("Please enter a number:")) if(a%2==0): print("That is an even number") else: print("That is an odd number") Question 35 code: Question 36 code: letter=input("Please enter a letter:") if(letter=='a' or 'e' or 'i' or 'o' or 'u'): print("This is a definitive vowel.") el...
4bff1518bdeb585ef1b4f65113a8c86ae005605c
kzlamaniec/Python-Beginnings-2018
/02 - 11mandat.py
369
3.65625
4
limit = int(input('Podaj limit prędkości (km/h): ')) speed = int(input('Podaj prędkość pojazdu (km/h): ')) if speed > limit: n = speed - limit # liczba przekroczonej prędkości if n <= 10: money = 5 * n print('Wysokość mandatu (zł): ', money) else: money = 50 + (n-10)*15 pri...
5e960595973c842dd620517fc84e99d88437ec71
ashushekar/python-advance-samples
/linkedin/2.mergelinkedlist.py
1,761
4.0625
4
class Node: def __init__(self, dataval=None): self.dataval = dataval self.nextval = None class SLinkedList: def __init__(self): self.headval = None def listprint(self): printval = self.headval while printval is not None: print(printval.dataval, end='-->...
0685e903b9dae8e8ce3596376ce5e315c8a444fe
LogonDev/Intro_to_the_Math_of_intelligence
/gradientDescent.py
1,964
3.59375
4
from numpy import * ''' Computes the error for a linear graph y = mx + b m = gradient b = y-intercept N = number of points Error for individual point(x,y) = (y - (mx+b))^2 Error for all points = 1/N * Sum(Error for individual points) ''' def computeError(b, m, points): totalError = 0 #For each point for i in...
71fb5ab35539839f8d8810bbd26003f5ba605ee2
hcmMichaelTu/python
/lesson12/turtle_escape.py
328
3.828125
4
import turtle as t import random t.shape("turtle") d = 20 actions = {"L": 180, "R": 0, "U": 90, "D": 270} while (abs(t.xcor()) < t.window_width()/2 and abs(t.ycor()) < t.window_height()/2): direction = random.choice("LRUD") t.setheading(actions[direction]) t.forward(d) print("Congratulati...
de20c92ae722b36548ad06a278bd0a94ed503175
duongthebach/duongthebach-fundamental-c4e21
/session3/homework/sheep_2.py
202
3.671875
4
sizes = [5, 7, 300, 90, 24, 50, 75] print("Hello, my name is bach and these are my ship sizes: ") print(sizes) bigsize = max(sizes) print("Now my biggest sheep has size", bigsize, "let's shear it")
dc1e2a92d50b64deba10df918367e0f09ae74055
hmkthor/Algorithms
/tree.py
2,572
3.984375
4
# 트리 구조에서 사용할 노드에 대한 자료형 class Node: def __init__(self, data): self.data = data self.left = None self.right = None def init_tree(): global root new_node = Node("A") root = new_node new_node = Node("B") root.left = new_node new_node = Node("C") root.right = new_node new_node_1 = Node("D") ne...
5829dd89e8d794f4efcf6f2902024cbfc1d4abec
ziyeZzz/python
/LeetCode/204_计算质数.py
476
3.953125
4
# coding:utf-8 ''' 统计所有小于非负整数 n 的质数的数量。 示例: 输入: 10 输出: 4 解释: 小于 10 的质数一共有 4 个, 它们是 2, 3, 5, 7 。 ''' def countPrimes(n): primes = [1 for i in range(n)]# prime is 1 count = 0 for i in range(2,n): if primes[i]: for j in range(i+i,n,i): primes[j] = 0 count += 1 ...
2fb15fce329c1cb2e61c34c6c6dae282f187d41c
nerutia/leetcode_new
/155.最小栈.py
825
3.75
4
# # @lc app=leetcode.cn id=155 lang=python3 # # [155] 最小栈 # # @lc code=start class MinStack: def __init__(self): """ initialize your data structure here. """ self.st = [] self.rank = [] # 始终存此次push后的最小值,一路存。 def push(self, val: int) -> None: self.st.append(va...
ed92cfa01117d34907b2b4640e827409769b3e56
honestlywhocares/artificial-intellegence
/rotation.py
449
3.609375
4
import numpy as np import matplotlib.pyplot as plt import test as t def point_rotation(point,angle,p_r): x = point[0] y = point[1] xn = (x-p_r[0])*np.cos(np.radians(angle)) - (y-p_r[1])*np.sin(np.radians(angle))+p_r[0] yn = (x-p_r[0])*np.sin(np.radians(angle)) + (y-p_r[1])*np.cos(np.radians(angle))+p_r[1] ...
9b8d43e98f0f3883cbd1624608eec560042afd67
namankumar818/python-lab
/armstrong_number.py
202
3.625
4
a = input("enter the number") ln = len(a) s = 0 i = 0 while i<ln: s += int(a[i])**ln i += 1 if int(a) == s: print('number is armstrong') else: print('not armstrong')
c76847a276dfbbf566367b1e40accf413298ced6
Hoyo-yu/Learning
/python/learns/day04-迭代器和生成器/generator.py
575
3.9375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Author:Mario # 生成器:只有调用时才会生成相应的数据,只记录当前位置,只有一个__next__()方法,省内存 # 列表生成式:[i*2 for i in range(1000)] def fib(max): n, a, b = 0, 0, 1 while n < max: yield b a, b = b, a + b n = n + 1 return "done" for i in fib(6): print(i) # while Tru...
6d07024b2b71129298a5bf21e8e05dfc7c54afeb
monkeydunkey/interviewCakeProblems
/reverseWordsInStr.py
535
3.6875
4
def reverseWord(st, stInd, stpInd): for i in range(0, (stpInd - stInd)//2 + 1): st[stInd + i], st[stpInd - i] = st[stpInd - i], st[stInd + i] def reverseStrWords(st): stli = list(st) stInd = 0 for i, c_ in enumerate(stli): if c_ == '.': #we found a word end ...
ac64880c3fe729dbd1333156a8df64097a0ed946
krzjoa/udemy
/text/word_encoder.py
3,000
3.53125
4
# Krzysztof Joachimiak 2017 # sciquence: Time series & sequences in Python # # Word Encoder # Author: Krzysztof Joachimiak # # License: MIT from collections import OrderedDict import numpy as np from operator import add class WordEncoder(object): ''' Class used for for transforming text data into word i...
679cff0eedb437c1ab887c78b6e055a321c72034
Hrishikesh-3459/leetCode
/prob_876.py
588
3.828125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def middleNode(self, head: ListNode) -> ListNode: le = 0 cur = head while True: if (cur.next == None): ...
f7228058fbed517f7f7ded1ca67dac2fb2ad605c
alreis/Learning_Python
/exemundo2/exe47.py
193
3.71875
4
for c in range(1, 50+1, 1): print('.', end='') if c % 2 == 0: print(c, end=' ') print('\n') for c in range(2, 50+1, 2): print('.', end='') print(c, end=' ')
31f58b4ef152561e1997ef6387258471d431b953
bgarrisn/python_fundamentals
/02_basic_datatypes/2_strings/02_08_occurrence.py
362
4.09375
4
''' Write a script that takes a string of words and a letter from the user. Find the index of first occurrence of the letter in the string. For example: String input: hello world Letter input: o Result: 4 ''' userwords=input("type the words hello world: ") userletter=input("pick a letter in the words above: ") result...
9317d254bb503fae6776e1278ad67e887a07fb28
gabriellaec/desoft-analise-exercicios
/backup/user_169/ch140_2020_04_01_19_31_11_312946.py
414
3.609375
4
lista=[2,4,6,8] def faixa_notas(lista): i=0 lista2=[] while i<len(lista): if lista[i]<5: lista2.append(len(lista[i]<5)) if lista[i]>=5 and lista[i]<=7: lista2.append(len(lista[i]>=5 and lista[i]<=7)) if lista[i]>7: ...
df079e4cdbfa1a169af9101a28c49bea408cce2d
jonag-code/python
/dictionary_play.py
308
3.890625
4
#D = {'a':1, 'b': 2, 'c':3 } D = dict(a=1, b=2, c=3) for k in D.keys(): print(k, '->', D[k]) print("\n") for ke in D: print(ke, '->', D[ke]) print("\n") for key in D: print('{} -> {}' .format( key, D[key] )) print("\n") for (key, value) in D.items(): print("%s -> %s " %( key, value ))
72aef059a0a7ada01a2e2146e90e4dba875debdb
chang0959/BaekJoon-Algorithm
/입출력과 사칙연산/2588_곱셈.py
291
3.921875
4
# %% num=int(input()) num1=int(input()) third=num1%10 second=int(num1%100/10) first=int(num1/100) print(num*third) #num1%10:마지막 자리 print(num*second) #int(num1%100/10): 두번째 자리 print(num*first) #int(num1/100): 첫번째자리 print(num*third+num*second*10+num*first*100)
de295b0bcb14d7fb07d26609a6a5f7b1f5960c9b
Aasthaengg/IBMdataset
/Python_codes/p02256/s178779192.py
281
3.59375
4
#Greatest Common Diveser def gcd(x, y): if x >= y: x = x % y if x == 0: return y return gcd(x, y) else: y = y % x if y == 0: return x return gcd(x, y) x, y = map(int, input().split()) print(gcd(x, y))
3dd53cc49dadaf8de9cd760be921ce0e5dfd9389
mdelafuen/Week6
/Week6InClass.py
679
3.921875
4
def main(): age = int(input("How old are you? ")) statement = input("Say something") if age <16 or "floglegroopp" > statement: print("you are young enough to be silly") else: print("oh no you are so old!") #main() def little_sister(): number_of_times = 0 say_it = "Yeet it now"...
d6a80e7008470685c535bf91a5907788dab8137a
nilankh/LeetCodeProblems
/Recursion/PrintFactorialWithRecursion.py
781
4.0625
4
#PRINTKE CASE PEHLE HMKO APNA KAAM KRNA HOTA H FIR RECURSION SE(RECURSION SE) #normal ''' def fact(n): if n == 0: return 1 smallOutput = fact(n-1) return n * smallOutput print(fact(5))''' #Another Method ''' def fact(n): if n == 0: return 1 smallOutput = fact(n-1) output = n * s...
148e1e02951b43771de15775c5ae8c5fc57e66e2
emma0212/GameDesign2021
/HangmanLW.py
4,061
3.703125
4
#Emma Hoffman #06/21/2021 #Creating a hangman version of game: #Using images in list, use fonts, and render them from typing import Text import pygame, math, random, sys, time, os pygame.init() os.system('cls') #create our screen or window WIDTH=800 HEIGHT=500 screen = pygame.display.set_mode((WIDTH,HEIGHT))...
f1c029591ce7203007a44b730961b1834d5c2a35
orestv/python-for-qa
/3-python-intermediate/examples/re_example.py
427
3.78125
4
import re text = ''' Posting Date: June 25, 2008 [EBook #11] Release Date: March, 1994 [Last updated: December 20, 2011] Language: English ''' numbers_regexp = re.compile('\d+') print(re.findall(numbers_regexp, text)) # ['25', '2008', '11', '1994', '20', '2011'] language_regexp = re.compile('language: (\w+)', re...
26fd08f7b1cbc7f302fcbbe1aa671686c96f0a10
naltoma/python_intro
/report/tic_tac_toe.py
3,464
4.75
5
"""Example code for Tic-tac-toe 3x3 board was described as a list with 9 sequential items. Each item in the list shows as follows. - 'e': empty - 'o': circle - 'x': cross For example, board = ['e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e'] shows that all cells have empty state. The index of board[] begins from ...
5543ebb3b49233de027b260f4162c3a1f9319f9c
verdatestudo/Codewars
/codewars_paperboy.py
1,832
3.6875
4
''' Codewars - PaperBoy http://www.codewars.com/kata/paperboy 2016-Mar-26 Python 2.7 Chris Description: You and your best friend Stripes have just landed your first high school jobs! You'll be delivering newspapers to your neighbourhood on weekends. For your services you'll be charging a set price dependin...
d93b7732e86fc680e9e0eedb25f37e1e8ee10a99
MachineLearnWithRosh/Data-Structure-and-Algorithms
/Dynamic Programming/4-MaximumSubArray_kadanesAlgo.py
596
3.8125
4
def max_sum_subarray(arr): c_sum = 0 curr_maxValue = arr[0] st, end, poi = 0, 0 ,0 for i in range(0, len(arr)): c_sum = c_sum + arr[i] if c_sum > curr_maxValue: curr_maxValue = c_sum st = poi end = i ...
a1c3911b74706e44a1a7bb69324194cf74ac5a67
khrystyna21/Python
/lesson7/7.3.py
594
4.0625
4
def make_operation(operator, *args): if operator == '+': return_value = 0 for num in args: return_value += num return return_value elif operator == '-': return_value = args[0] for num in args[1:]: return_value = return_value - num return r...
fafb61cff6256896c850cd738ec16f4c6209143c
AtarioGitHub/Sub-task-8.1-and-8.2
/subtask1.py
339
4
4
import math n = input('Enter your number which we will call n = ') print('n = ',n) DecimalNumberofN = float(n) # We use float so that we can also use a decimal value TheSquareRootofThatNumber = math.sqrt(DecimalNumberofN) xyz = int(TheSquareRootofThatNumber) # Let xyz be an integer value q=pow(xyz,2) ...
0e44fb0621442be8656542aac4a2a033a2127c0b
SafonovMikhail/python_000577
/000000stepikProgBasKirFed/Stepik000000ProgBasKirFedсh01p05st04TASK04_20210205_math.py
443
4.09375
4
''' На вход программе подается натуральное двухзначное число. Напишите программу, которая выводит сначала количество десятков в этом числе, затем количество единиц Sample Input 1: 58 Sample Output 1: 5 8 Sample Input 2: 37 Sample Output 2: 3 7 ''' n1 = int(input()) print(n1 // 10, n1 % 10, sep='\n')
81223401b3701d786c5b89ab75e5eaf1b0d95a02
pmazgaj/SerialApp
/modules/random_data_generator.py
837
3.734375
4
""" Create random data for an application, in similar pattern to serial data """ import random __author__ = "Przemek" class RandomDataHandler: def __init__(self): ... def get_random_num_in_range(self, range_of_data: list) -> float: """get random float number in given range, for 3 decimal pla...
3e7efd801d979c496845b0ebfc06571700de54db
ceon97/Leetcode
/Happy_Number.py
703
3.796875
4
"A happy number is a number defined by the following process:" "Starting with any positive integer, replace the number by the sum of the squares of its digits." "Repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1." "Those numbers for which this ...
f2f8d0414aa5cba4a1dfea2de56604c6eccfc3cf
Mariogallo/Projetos-Python-Digital-Innovation-One
/app_python/aula5.py
2,328
3.890625
4
lista = [12, 10, 7, 5] lista_animal = ['cachorro', 'gato', 'elefante', 'lobo', 'arara'] lista_animal[0] = 'macaco' print(lista_animal) tupla = (1, 10, 12, 14) print(len(tupla)) print(len(lista_animal)) tupla_animal = tuple(lista_animal) print(type(tupla_animal)) print(tupla_animal) lista_numerica = list(tupla) print(...
8a10d28f47c4bc5e0b92a6fb64d84293e2cc8c82
codingyen/CodeAlone
/Python/0058_length_of_last_word.py
474
3.9375
4
# Starting from the back! Do the reverse! # reversed() # Time: O(n) # Space: O(1) class Solution: def lengthOfLastWord(self, s): if not s: return 0 length = 0 for i in reversed(s): if i == " ": if length: break else: ...
5c434fe23a2e4c13346f9038a43cec44a121d5d8
laisOmena/Recursao-em-Python
/lista3/quest03.py
182
4.03125
4
def cont(text): if len(text) == 0: return 0 else: return len(text.split(x)) - 1 text = "estrutura de dados" x = input("Digite uma letra: ") print(cont(text))
f3c870562bc8857182ec3927b3f888531024449d
EvgeniyOrlov/KrakenRepo
/Lesson3/Lesson3_3.py
252
3.796875
4
def my_func(n1, n2, n3): return (n1 + n2 + n3) - min(n1, n2, n3) num1, num2, num3 = int(input('Введите число: ')), int(input('Введите число: ')), int(input('Введите число: ')) print(my_func(num1, num2, num3))
2f64bd70891b6fee82f6ff591114518bfaf0e989
molliegoforth818/py-functions
/chickenmonkey.py
212
3.734375
4
def chicken_monkey(): for num in range(0, 101): if num%5==0: print("chicken") elif num%7==0: print('monkey') else: print(num) chicken_monkey()
15b1e28d2989bf7e6f278461182c475148de28e7
marianinakraemer/aulas_python_UERJ
/pendulo_functions_eduardoV.py
883
3.671875
4
""" Funções importantes do pêndulo duplo: posição x e y de cada massa, energia cinética, potencial e total Autor: Eduardo da Costa Valadão - eduardovaladao98@gmail.com """ import numpy as np def pendulum_x1(theta1, l1, i): x1 = l1*np.sin(theta1[i]) return x1 def pendulum_y1(theta1, l1, i): y1 = - l1*n...
80d2a6f1f709659a4f5e020b4a8cabcd83d67c0e
Asko24/pp1-pythonprojects
/02/39.py
144
3.5625
4
fib = 50 n1 = 0 n2 = 1 liczba = 0 while liczba < fib: print(n1,end=' , ') n3 = n1 + n2 n1 = n2 n2 = n3 liczba += 1
e31bc08c4c97d98b1b0f42d0a0384336565ab0d9
attiakihal/MazeSolver
/search/a_star_manhattan.py
2,965
3.609375
4
import heapq import math from common.nodes import Node def a_star_manhattan(maze, start, end): # Create start and end nodes start = Node(None, start) end = Node(None, end) # Create fringe fringe = [] heapq.heapify(fringe) visited = list() # Add start node heapq.heappush(fringe,...
9b22e7bc69b261d6865af0169bb3d269d6ea5404
ZammadGill/python-practice-tasks
/task3.py
373
4.21875
4
""" With a given integral number n, write a program to generate a dictionary that contains (i, i*i) such that is an integral number between 1 and n (both included). and then the program should print the dictionary """ def generateDictionary(n): dictionary = {} for x in range(1, n + 1): dictionary[x] =...
5cedd1cff591c08ceff27f3abbe88210b659cc27
Bruck1701/CodingInterview
/generalAlgorithms/birthday.py
430
3.59375
4
def birthday(s, d, m): if len(s)==1 and m==1 and s[0]== d: return m count = 0 for i in range(0,len(s)-m+1): soma = 0 ct = 0 while ct<m: soma += s[i+ct] ct+=1 if soma == d: count+=1 print("Count: ",count) print(count) return count lstr = "2 5 1 3 4 4 3 5 1 1 2 1 4 1 3 3 4 2 1" ...
d9fe4e576fee9d7a335bd38230367d1e798d6e49
jauvariah/RandomCode
/Puzzles/UBSQuestion.py
604
3.671875
4
#The number 1978 is such a number that if you add the first 2 sets of numbers, you'll will get the middle 2 sets of numbers. So in 1978, 19+78=97; so the question is write a formula that can find numbers that satisfy these conditions. #From Business Insider: http://www.businessinsider.com/heres-the-answer-to-that-impo...
2297487a5f669be36b6be2cbbaf46c8f606adddb
msm17b019/Project
/Mini_Project/dance_form_gui.py
1,759
3.78125
4
from tkinter import* root=Tk() root.geometry("600x400") root.minsize(400,400) root.maxsize(600,600) def getvals(): with open("C:\\Users\\sujee\\Desktop\\1.txt","a") as f: f.write("-----The New Entry----- \n") f.write(f"The name of student is {nameval.get()}") f.write('\n') f.write(s...
075a5e5578e4fc6e4bc4afa515d22ec0a16c865d
mrfawy/ModernEnigma
/Shuffler.py
1,041
3.859375
4
from RandomGenerator import RandomGenerator from Util import Util #This class implements Fisher-Yates shuffle algorithm #Given random generator and a seed , it de/shuffles a string #http://stackoverflow.com/questions/3541378/reversible-shuffle-algorithm-using-a-key class Shuffler(object): @classmethod def s...
cc27fdd745340d8f5ea7e55ca1674c69b6f3cb67
saroja-parida/mycode
/file_search.py
532
3.515625
4
def file_s(): f=open("test1.txt","r") count = 0 for line in f: if "saroj" in line: count+=1 print("The name 'saroj' is repeted =%d times "%(count)) s=0 if "saroj" in open("test1.txt").read(): s+=1 print s print open("test1.txt").read().find('saroj') file_s() list1 =["saroj",...
00400738bc74a5beb78e9dc2cd9020b84973faf3
shade-12/python-dsal
/09_Recursion/count_consonants.py
732
3.9375
4
consonants = "bcdfghjklmnpqrstvwxyz" def count_consonants_iterative(input): """ Returns the number of consonants present """ count = 0 for char in input: if char.lower() in consonants: count += 1 return count def count_consonants_recursive(input): """ Returns the n...
05779eefe134b11c9b7d4b3d7977c675025a1ef2
torselden/advent_of_code_2018
/torselden-python/Day06/day06.py
3,542
3.515625
4
import os import sys import re from datetime import datetime def parse_input(file): with open(os.path.join(sys.path[0], file ), 'rU') as input_file: return [line.strip() for line in input_file.readlines()] def parse_coordinates(lines): return [tuple(map(int, coord.split(', '))) for coord in line...
01a0fcd757fa06a47c24b38fbf5df14e0061be65
ken-power/Foobar_Challenge
/Level_3/6_FuelInjectionPerfection/solution.py
6,416
4.28125
4
import unittest def reduce_to_one(n): """ Return the minimum number of operations to reduce 'n' to `1`. :param n: an integer value :return: the minimum number of operations, and the path from n to 1, and the sequence of operations (useful for debugging and understanding) ...
84fc2a97dd33c22aef97c4417f56d10b2e643ff2
mlbernauer/drugstandards
/drugstandards/__init__.py
2,848
3.578125
4
import Levenshtein import operator import csv import os import re from pkg_resources import Requirement, resource_filename class DrugStandardizer(): def __init__(self): self.dictionary_file = resource_filename(Requirement.parse("drugstandards"), "drugstandards/data/synonyms.dat") self.drugdict = di...
f24038981ab0665e3d5f45f5be0b98be2cfe432d
tikishen/TuanZi
/Umich_AI_Intern/solution.py
747
3.890625
4
# Take a string as input and extract all digits in the string, delimited by any non-digit characters. # It should then sum those digits in the order they were provided and display the result. class Solution(object): def sum_digit(self, s): res = [] temp = [] def maybe_add_num(): ...