blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
f68606424bb516ba488a4d6c9474c92c93541b6c
IBOIBO111/Rundgang
/App.py
1,288
3.59375
4
print("Hallo Welt") Name = "Ingoli Bolm" print(Name) #das ist ein kommentar Name = "Joe" pi = 3.141 #Datentypen #Itneger Werte a = 5 #negative Zahlen b = -10 #Float j = 6.8 #test k = a * j * 10 print(k) #bool istVerbunden = True #binäre Zahlen binaereZwei = 0b10 print(binaereZwei) #hexadezimal hexa10 = 0xA print(...
0c1e5dc4d1c21ba94fefca960e1dbc2162a1eb34
IBOIBO111/Rundgang
/tool-Mittelwert.py
409
3.703125
4
werte = list() count = 0 Mittelwert = 0.0 Summevon = 0 while True: wert = input("Wert in grad celsius: ") if(wert == "q"): break werte.append(float(wert)) Summevon += float(wert) count += 1 Mittelwert = 0.0 for value in werte: Mittelwert += float(value/len(werte)) print("der Mittelwe...
9d1603936bf69b527b3c8d6ab4f2577c55152169
krmckone/Interview-Problems
/short_brain_teasers/threedigit/tests.py
1,151
3.609375
4
import unittest from threedigit import sum_is_ten, product_is_20, divisible_by_7, convert_xyz_to_int class Tests(unittest.TestCase): def test0(self): self.assertTrue(sum_is_ten(0,9,1)) def test1(self): self.assertTrue(sum_is_ten(1,8,1)) def test2(self): self.assertTrue(su...
e3b0db53c960ba7f6a33321ec7941fba2a4da686
luk-jedi/calculo_numerico
/Parte 2/2.1.3.py
1,201
3.53125
4
# É possível notar que os coeficientes calculados no exercicio anterior # tratam-se de dízimas periódicas. Nesse exercício apenas utilizamos a # biblioteca fractions para averiguar quais frações geram essas dízimas import math from fractions import Fraction # calcula os coeficientes novamente, mas dessa vez transfo...
f6d1d418af885a04a842b5a5625aea5901749d15
darmaharefa/Bedah-Soal-di-Python
/Latihan Pengurutan Naik Turun.py
296
3.875
4
n = int(input("Masukkan panjang angka = ")) for i in range(1,n+1): if(i%2 != 0): #Saat i bernilai ganjil for j in range(1,n+1): print(j,end=" ") print() else: #Saat i bernilai genap for j in range(n,0,-1): print(j,end=" ") print()
1d15493713c7dcaf03406270c73ca857fd16c8d3
manuel12/exercism
/acronym/acronym.py
305
3.90625
4
def abbreviate(words): alpha_chars = [char if char.isalpha() or char == "'" else " " for char in words] alpha_str = "".join(alpha_chars) splitted_str = alpha_str.split(" ") abbreviation_letters = [word[0].upper() for word in splitted_str if word != ''] return "".join(abbreviation_letters)
8874e775d9ab351511258fcc2c8ce19243609a68
Kushal-prog/TKinter-Files
/Calculator3.py
6,338
3.625
4
from tkinter import * root = Tk() #Size for the calculator root.geometry('660x760') #MIN_Size for the calculator root.minsize(660, 760) root.maxsize(660, 760) #MAX_Size for the calculator #Set the Title root.title('Calculator') root.iconbitmap('Dtafalonso-Android-Lollipop-Calculator.ico') Entry1 = ...
2b113414784986fb59b22c8c637badf5bff90dca
gstfrr/CPPC
/Conversion.py
2,287
3.578125
4
class Conversion: @staticmethod def decimal_to_binary(decimal): temp = "" while decimal > 0: s = str(int(decimal % 2)) temp += s decimal = int(decimal / 2) if len(temp) < 8: s = "" i = 0 size = len(temp) ...
855870f4d73c25a766427411a05f531e24fa9a31
gmyrak/py_tests
/fib.py
259
3.9375
4
Имя = input('Введите имя: ') if Имя=='Таня.': print('Hello') print('Привет', Имя) elif Имя=='Аня': print('Приветики', Имя) else: print('Кто вы такой, ', Имя, '?', sep='') '''Add'''
9e28fc402730243c18fdb535f60bd18ea8b05adf
kiran-kadam-2021/PythonTutorials
/FileHandlingDemo.py
862
3.6875
4
# # reading file and printing it to console # f = open('MyFile', 'r') # # reads current line pointed by 'f' # print(f.readline()) # # # reads 2 characters of current line # print(f.readline(2)) # # # # returns list of all lines after the current line # # print(f.readlines()) # # # from the list reads a speci...
83a751bb5905599bec6478ae98394b805f69316d
kiran-kadam-2021/PythonTutorials
/VariablesDemo.py
331
3.765625
4
class Car: wheels = 4 def __init__(self): self.mil = 10 self.comp = 'BMW' @staticmethod def say(): print('hello') c1 = Car() c2 = Car() c1.mil = 5 c2.comp = 'mercedes' c1.wheels = 7 print(Car.say()) print(c1.comp, c1.mil, c1.wheels) print(c2.comp, c2.mil, c...
9387e6fadb7f7b84498bd9ab8672f391a8c6ff97
kiran-kadam-2021/PythonTutorials
/MethodResolutionOrder.py
871
3.9375
4
class A: def __init__(self): print('in init of A') def feature1(self): print('feature1 is working') def feature2(self): print('feature2 is working') # inheritance in python # class B(A): # def __init__(self): # # super().__init__() # print('in i...
55aef9df87b14a564eabd3297d98e9f7596456b3
HolyDanna/Collisions
/Game/collisions.py
3,402
3.5
4
# for more information on where the basis for this function came from, check : # http://www.dyn4j.org/2010/01/sat/ # It has been adapted to our needs, as well tweaked for use with circles def checkCollisions(element, element_list, show=True): special = ["Circle", "Point"] test_type = element.getType() ...
1f9b7e2cdff01dda74fd70fff7fefc69acf513b9
aaronbae/leetcode
/codesignal/sudoku2.py
1,202
3.546875
4
def sudoku2(grid): N = len(grid) # rows rows = set() columns = set() subgrid = set() for i in range(N): for j in range(N): rowV = grid[i][j] colV = grid[j][i] subV = grid[3* int(i*3 / 9) + int(j / 3)][(i*3 % 9) + (j % 3) ] if rowV != ".": if rowV not in rows: ro...
52b7fb6fd49915cd0b97bd5eb8d310033d54f084
aaronbae/leetcode
/uncategorized/medium/384.py
841
3.671875
4
class Solution(object): def __init__(self, nums): """ :type nums: List[int] """ self.original = nums[:] def reset(self): """ Resets the array to its original configuration and return it. :rtype: List[int] """ return self.original...
d2b7a797f0fa8d37b89e6bda4cb5d6a14f0e1596
aaronbae/leetcode
/cisco/cisco.py
497
3.859375
4
def convert(string_input): stack = [] current = "" multiplier = "" for c in string_input: if c == "(": stack.append(current) current = "" elif c == ")": continue elif c == "{": continue elif c == "}": current = stack.pop() + current * int(multiplier) multiplie...
de6a240e26e96bd9f6f76192f922bd3236aa0386
aidodd/cpe101
/LAB6/fold.py
593
3.96875
4
# Lab 6 # Name: Sid Sharma # Instructor: S. Einakian # Section: 06 from functools import reduce # list -> int. # This function sums up all the elements in a list. def sum(L1): return reduce(lambda x, y: x + (sum(y) if isinstance(y, list) else y), L1) # list -> int. # This function returns the index of the smal...
40269bd75265c42e247c1e0072b579f957f7b497
aidodd/cpe101
/PROJECT3/tictactoeFuncs.py
9,190
4.46875
4
# Project 3 - Tic-Tac-Toe Simulator # Name: Sid Sharma # Instructor: S. Einakian # Section: 06 from random import randrange # This function takes in no parameter and also returns nothing, based on the user input, it calls a function to either # play Tic-Tac-Toe with two players or as a computer. # None -> None. def ...
49a4766784189795694df6a4131f0093c2a72438
pawelkuk/advent-of-code-2019
/day_4.py
1,110
3.671875
4
def has_two_adjacent(string) -> bool: for i, j in zip(string[:-1], string[1:]): if i == j: return True return False def decreases(string: str) -> bool: for i, j in zip(string[:-1], string[1:]): if int(i) > int(j): return True return False def is_valid(password...
27bc1df1213290673f72e43a0024f298c6c7e270
mo7amed3del/Roman-to-decimal-converter-using-Python
/roman to decimal converter using Python.py
798
4.09375
4
#!/usr/bin/env python # coding: utf-8 # In[1]: roman_dict ={'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000} # In[2]: def decimal(roman): """ roman: a string or roman numerals. Returns the equivalent in decimal numbers (int). """ global r...
27841dab5a3ccf894d730164b5db3468aa43d5b4
Ali17560/CS104-01
/Name python list.py
491
4.0625
4
#List creation and searching End=False names = [] for x in range(0,10): Name = input("Enter a name:") names.append(Name) print (names) print("Search for name or type End to end the game") while(End!=True): search=input("Enter search here:") if search in names: print(search, "name w...
172e226e6c5dedb4fd09362b4c5528c6764a378a
rrandol3/Python-Mega-Course
/myprogram.py
131
3.609375
4
mydictionary = { 1:"Reggie", 2:"Krista"} print(mydictionary[2]) dictionary = {"Dogs":["Zeus","Zoey"]} print(dictionary["Dogs"][1])
f04317016debcd22885113ab495249de07eddcc3
helloak/py-datascience
/plots/basic_bubble_plot.py
401
3.765625
4
# A bubble plot is close to scatter plot # With the help of matlibplot library, we construct them using the same scatter function #libraries import matplotlib.pyplot as plt import numpy as np #creation of data using rand x = np.random.rand(30) y = np.random.rand(30) z = np.random.rand(30) #scatter funtion plt.scatte...
4df434fe35a131df5afac2045d9434619120c3c5
valerienierenberg/holbertonschool-higher_level_programming
/0x0B-python-input_output/9-student.py
852
3.859375
4
#!/usr/bin/python3 """ This module contains a class Student that defines a student """ class Student(): """ Student class """ def __init__(self, first_name, last_name, age): """ init method: Attributes: self first_name - string last_name - st...
b7e79c8e2c8b0612b5a5b71ab7d91b3cfdd39165
valerienierenberg/holbertonschool-higher_level_programming
/0x0A-python-inheritance/2-is_same_class.py
492
3.875
4
#!/usr/bin/python3 """ This module contains a class MyList that inherits from list """ def is_same_class(obj, a_class): """ is_same_class method: args: obj - object to be tested a_class - class that object is being tested against return: true if object is exactly an insta...
f78c5a609bc06e6f4e623960f93838db21432089
valerienierenberg/holbertonschool-higher_level_programming
/0x05-python-exceptions/0-safe_print_list.py
744
4.125
4
#!/usr/bin/python3 def safe_print_list(my_list=[], x=0): a = 0 for y in range(x): try: print("{}".format(my_list[y]), end="") a += 1 except IndexError: break print("") return(a) # --gives correct output-- # def safe_print_list(my_list=[], x=0): # ...
1cb1fb0cf31426ba5ab0b7e04378c609763a3ae8
valerienierenberg/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/4-only_diff_elements.py
307
3.796875
4
#!/usr/bin/python3 def only_diff_elements(set_1, set_2): result = [] for element in set_1: if element not in set_2: result.append(element) for element in set_2: if element not in set_1: result.append(element) return result # return set_1 ^ set_2
fd9a2aa31b0be4a223d83713f465664eef7c4c21
valerienierenberg/holbertonschool-higher_level_programming
/0x03-python-data_structures/4-new_in_list.py
220
3.65625
4
#!/usr/bin/python3 def new_in_list(my_list, idx, element): if not my_list: return my_list2 = my_list[:] if idx >= 0 and idx < len(my_list2): my_list2[idx] = element return (my_list2)
5aa1c630f68c17bc117fc4aebbbf4f6d44d4600d
shweta257/nlp-finalEval
/coreference-TeamChaos/demonynClassification.py
1,044
3.796875
4
class DemonymClassify: def __init__(self): self.fileName = "demonyms.txt" self.demonyms = {} def createDemonym(self): with open(self.fileName) as f: for line in f: line = line.lower().split() keyName = line[0].lower() if self....
eebadbca31dd938c6e235fd449163f3eec6d7723
zktnguyen/algorithms
/python/binary_heap.py
1,476
3.78125
4
class binary_heap: def __init__(self): self.heap_list = [0] self.size = 0 def percUp(self, i): # this while condition makes sure we percolate upward while i // 2 > 0: # Replace the parent p if it's larger than node x if self.heap_list[i] < self.heap_list[i // 2]: temp = self.h...
4175a589e42f7e0c7b3353c9c9fec3de1178d7e0
YusefQuinlan/PythonTutorial
/Basics/1.5.1_Basics_Maths.py
1,172
3.90625
4
# -*- coding: utf-8 -*- """ Created on Mon Sep 2 16:25:32 2019 @author: Yusef Quinlan """ print(2) print(-9) #Demonstrates that python can handle and work with negative numbers print(-9.9) #Demonstrates that python can handle and work with decimal numbers print(8.75647564) A = 9 B = 7.6 C = -8.1 print(A + B + C) ...
bc9d2fe1398ef572e5f23841976978c19a6e21a6
YusefQuinlan/PythonTutorial
/Intermediate/2.5 pandas/2.5.5 pandas_Column_Edit_Make_DataFrame.py
2,440
4.5
4
# -*- coding: utf-8 -*- """ Created on Fri Mar 19 17:11:39 2021 @author: Yusef Quinlan """ import pandas as pd """ Making a dictionary to be used to make a pandas DataFrame with. The keys are the columns, and the values for the keys (which must be lists) are what are used to make the DataFrame. """ dicti...
f5d1d240dd8eef9906d39eb9cf86301c5355fbf0
YusefQuinlan/PythonTutorial
/Intermediate/2.3 BeautifulSoup/2.3.2_BeautifulSoup_SpecificScraping.py
3,142
3.5625
4
# -*- coding: utf-8 -*- """ Created on Thu Jun 18 16:48:32 2020 @author: Yusef Quinlan """ import requests from bs4 import BeautifulSoup page = requests.get('http://quotes.toscrape.com/page/1/') page_content=page.content soup = BeautifulSoup(page_content) link_Anchors = soup.find_all("a") # after getting a tags,...
881419c45d178dec904578bbe59fac4ce828b4b7
YusefQuinlan/PythonTutorial
/Basics/1.16.3_Basic_NestedLoops_Practice.py
2,147
4.40625
4
# -*- coding: utf-8 -*- """ Created on Sun Oct 20 15:10:45 2019 @author: Yusef Quinlan """ # A nested loop is a loop within a loop # there may be more than one loop within a loop, and there may be loops within loops # within loops etc etc # Any type of loop can be put into any other type of loop #as in the example ...
803c4c2e6c4f59967f3b0ede16545acd13877fb0
YusefQuinlan/PythonTutorial
/Intermediate/2.5 pandas/2.5.1 pandas_Read_Intro.py
755
3.796875
4
# -*- coding: utf-8 -*- """ Created on Fri Mar 12 17:37:34 2021 @author: Yusef Quinlan """ #Standard pandas import, pip install if you don't have pandas import pandas as pd # Reading the csv file into a pandas DataFrame using read_csv on the filepath # in this case filepath is relative. Print(scores_df) prints the D...
5fb7d6cc1e171831a1ec3dd01141644ad3d807c3
YusefQuinlan/PythonTutorial
/Basics/1.9.2_Basics_IfStatement_Practice.py
1,515
3.703125
4
# -*- coding: utf-8 -*- """ Created on Fri Sep 6 18:26:31 2019 @author: Yusef Quinlan """ listuno = [1,1,1,1,1] listdos = [2,2,2,2,2] # == is the computers way of asking if the item on the left is equal to the item on the right # = is the computers way of saying that the thing on the left is now equal to the value on...
05111398ed789569ad5d10cfbf537cb53a069ed5
YusefQuinlan/PythonTutorial
/Intermediate/2.1 Some Useful-Inbuilt/2.1.8_Intermediate_Generators.py
1,879
4.21875
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 29 15:38:07 2020 @author: Yusef Quinlan """ # What is a generator? # A generator is an iterable object, that can be iterated over # but it is not an object that contains all the iterable instances of whatever # it iterates, at once. # return will return the first valid v...
bbbff59d305115ad809d6aa0960e311014e78b87
YusefQuinlan/PythonTutorial
/Basics/1.20.2_Basics_Objects_Functions_Practice.py
2,695
4.03125
4
# -*- coding: utf-8 -*- """ Created on Sun Oct 27 21:27:17 2019 @author: Yusef Quinlan """ #defining the bus class with setters and getters for each attribute class bus: def __init__(self, name, model): self.name = name self.model = model def get_name(self): return self.name def s...
02cd4304f1af0cf18006f758319d1ac61c8a893a
zengzenghe/Git_NewsPlaceExtract
/extractPlace/FileTools.py
1,935
3.546875
4
# coding=utf-8 import pandas as pd import re # 文件处理程序,bert 与 新闻与处理都需要调用相同的函数,保持一致 def read_xls_data(input_file): # 读取指定列 df = pd.read_excel(input_file, header=0, index=0, usecols=[0, 1, 3, 4, 5, 6, 7, 8, 9]) # print(df.columns) df.columns = ['website', 'channel', 'title', 'nation', 'province', 'city'...
9e21bdc44057b0ca4d185ded787ea87699a78c9f
blinovps/DZ
/Lesson01/1.5.py
506
3.71875
4
dohod = int(input("Введите выручку:")) rashod = int(input("Введите издежки:")) if dohod > rashod: itog = dohod - rashod shtat = int(input("Введите количество сотрудников:")) print(f"Прибыль фирмы - {itog} \n" f"Рентабельность - {itog / dohod:.3f} \n" f"Прибыль на одного сотрудника - {doh...
b51c8430b39bdf7dce428ccaaed9ddf5ef1c9505
mahfoos/Learning-Python
/Variable/variableName.py
1,180
4.28125
4
# Variable Names # A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). # Rules for Python variables: # A variable name must start with a letter or the underscore character # A variable name cannot start with a number # A variable name can only contain alpha-numeric ...
250bd510031b7d8ce861b6b8ad21d95eca156199
Shajidur-Rahman/SQLite3
/main.py
567
3.9375
4
# importing sqlite import sqlite3 # making a connection to the db conn = sqlite3.connect('google.db') # you can put any name || if you want to use memory use (":memory:") # making a cursor c = conn.cursor() # First you need to create a table # c.execute("""CREATE TABLE person( # first_name TEXT, # last_...
a592c5dc3ae9036b47d5c45f4a3e659eb1933444
AnnaBanana51/TKH-Final-Project
/import_script.py
721
3.703125
4
from app import db, Bitcoin from scrape import scraper url = "https://coinmarketcap.com/2/" scraper_data = scraper(url) def put_together(): #will make sure the database empty db.drop_all() #create the columns of database db.create_all() #iterates via the table while scraping at the same time, and ...
a477d94a8f563bff0036dd164422a90a18a56bde
meghnamanoj/maths-assignment
/m.py
370
3.9375
4
'''Code for finding gcd''' a = input('a =') b = input('b =') if a<b: x = a a = b b = x a = int(a) b = int(b) while b!= 0: a , b = b ,a%b print(a) '''here we write a in the for a = qb +r and the while loop the new a becomes b and new b becomes remainder of a/b(a%b) the loop continues until the ne...
784ca586b235fb7148903184661670f9f3c006bd
wur3/hangman
/hangman.py
2,215
3.796875
4
class Hangman: guy = [ " _______\n |/ |\n | \n | \n | \n | \n |\n_|___", # empty " _______\n |/ |\n | (_)\n | \n | \n | \n |\n_|___", # head " _______\n |/ |\n | (_)\n | | \n | |\n | \n |\n_|__...
2faf57e55445229c552ec78cd47c24c700a03a70
Doned-cmd/201801528_TareasLFP
/Tarea 5/Main.py
890
3.8125
4
import re letras = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ" numeros = "1234567890" diccionario = {(0,letras):2, (0,"_"):1 , (1,"_"):1 , (1,letras):3, (2,letras):2, (2,numeros):4,(3,letras):3 , (3,numeros):4} def automata(cadena, actual, transision, aceptacion): if cadena == "": ret...
46723eb984d3f577ee21cb5b0a6fcef8060c9fc3
jenishj123/Python-Homework_Py-Me-Up-Charlie
/PyPoll/PyPoll.py
3,801
3.921875
4
# import modules import os import csv # path to CSV file csvpath = os.path.join('C:/Users/jariwalaj2/OneDrive/Python_Homework2_Py-Me-Up-Charlie/election_data.csv') # open and read the CSV file with open(csvpath) as csvfile: # specify delimiter and variable that holds the content from the CSV file ...
e1318c89997630782d495c0d768120bcf655c681
shubham-debug/Python-Programs
/numberOfVowels.py
521
3.5625
4
#max number of vowel in any substring of length k #example : s= "abciiidef",k=3 #output should be 3 #dynamic programming #time complexity O(n) if __name__=="__main__": s=input() k=int(input()) test={'a','e','i','o','u'} temp=[0 for i in range(len(s))] mx=-1 counter=0 for i in r...
dd9ad05f1417b8e7ef033556a051cbf7a8ea6c95
shubham-debug/Python-Programs
/kruskal.py
1,639
3.5625
4
#this is kruskal algorithm #here I am going to use the inbuilt set(hash table) present in python #lets see what happens #the graph is going to be in the form of dictionary #but I am going to implement it in the linked list i.e:adjacency list form too def findSet(parent,i): if(parent[i]!=i): parent[i]...
aa00751d79020c136d3627200761bcf4636ac92c
shubham-debug/Python-Programs
/factorsOfnumbeer.py
654
3.90625
4
#finding the factors of a number #time complexity of the code is O(sqrt(n)) def solve(n): ans=list() i=1 while(i*i<=n): if(n%i==0): ans.append(i) if(n//i!=i): ans.append(n//i) i+=1 return ans def standard(n): ans=list() ...
c18ddd4bb321b0c9424ff4fda140a1109dcce451
shubham-debug/Python-Programs
/kosaraju's(strongly_connected).py
1,707
3.875
4
#kosaraju's algorithm for strognly connected components #time complexity O(E+V) #the approach do a dfs and store all the vertices in a stack which finishes #then transpose the graph #then pop elements one by one and do dfs util on that def stronglyConnected(graph): stack=list() dfs(graph,stack) ...
4b670c4f4276fdad1370cd1097628e015e4d31c1
shubham-debug/Python-Programs
/dijkastraMain.py
2,260
3.6875
4
#dijkstra's algorithm for single source shortest path #in this problem we need min priority queue data structure #solution def heapify(arr,i,actual): l=(2*i)+1 r=(2*i)+2 if(l<len(arr) and arr[l][1]<arr[i][1]): smallest=l else: smallest=i if(r<len(arr) and arr[r][1]<arr[sm...
c95adaa570eb9c5be9ea2d13f4d5778c4cdf58a8
shubham-debug/Python-Programs
/dijkastaraAlgorithm.py
2,800
4.0625
4
#dijkstra algorithm #this function does minheapify for a particular index and the approach #is top down #time complexity O(lg n) def minHeapify(heap,i): l=2*i+1 r=2*i+2 if(l<len(heap) and heap[l][1]<heap[i][1]): smallest=l else: smallest=i if(r<len(heap) and heap[r][1]<h...
7156b2ca1491bdd8d9fd2ea0670fc8a2e7d56e50
shubham-debug/Python-Programs
/stringproblem.py
299
3.640625
4
#string problem #this code is right for substring but not absolutely def solve(n,s): j=0 for i in range(1,n): if(s[i]>s[i-1]): j=i continue return(s[j:]) if __name__=="__main__": n=int(input()) s=input() print(solve(n,s))
eab243dde91014c9cce1a9a35a301a92e0b95a3a
pennylee262/shiyanlou-code
/averagen.py
246
4
4
N = 10 sum = 0 count = 0 print('please input 10 number:') while count < N: number = float(input()) sum = sum + number count = count +1 averagen = sum / N print("N = {}, Sum = {}" .format(N , sum)) print("Averagen = {:.2f}" .format(averagen))
ae3689da43f974bd1948f7336e10162aea14cae6
CharlesBasham132/com404
/second-attempt-at-tasks/1-basics/2-input/2-ascii-robot/bot.py
523
4.125
4
#ask the user what text character they would wish to be the robots eyes print("enter character symbol for eyes") eyes = input() print("#########") print("# #") print("# ",eyes,eyes, " #") print("# ----- #") print("#########") #bellow is another way of formatting a face with the use of + instead of , #plusses + d...
cac19d26512be70301601613631521a50af5e619
CharlesBasham132/com404
/second-attempt-at-tasks/1-basics/5-function/3-parameter/bot.py
422
3.71875
4
def escape_by(action): if (action == "jumping over"): print("can't do that its too tall!") elif(action == "running around"): print("but its too wide!") elif(action == "going deeper"): print("that might just work, lets go deeper!") else: print("i dont understand that plan"...
212b5efa9cd5458fddc2596b9ee0df88cc9d433b
CharlesBasham132/com404
/second-attempt-at-tasks/1-basics/3-decision/1-simple-decision/6-counter/bot.py
706
4.0625
4
print("enter first number") first_number = int(input()) print("enter second number") second_number = int(input()) print("enter third number") third_number = int(input()) even_number_counter =0 odd_number_counter =0 if (first_number %2 ==0): even_number_counter = even_number_counter + 1 else: odd_number_cou...
24ad2ef487cd18a241d6333471339d6f98a30f37
Reizerk-amd/Projects-of-school
/String.py
571
3.90625
4
Hola = "que onda brooooooo" print(type(Hola)) #Saltos de linea \n print(" este texto tiene \n una nueva linea") #tabulacion = \t print(" Este texto tiene \t una nueva linea ") #Parte 2 cadena de caracteres con variables operacionales y arrays variable = "Teoria sobre este tema donde salto de linea es con...
736f677cc82fc4f6d3a77956d7b47164d7a3c711
Reizerk-amd/Projects-of-school
/Practica#2.py
172
4.03125
4
n = int(input("Digite un número")) n2 = int(input("Digite otro número")) if n==0 or n2==0: print("Error no se puede dividir entre 0") total=n/n2 print(total)
5288d17d77335922b2cd091cfa31ab48e696badb
Reizerk-amd/Projects-of-school
/Listas.py
677
4
4
lista=[5,9,"Bayron",15.5,-15] print(lista[2:]) #Fusionar listas concatenar primer_lista=[1,2,3,4,5] segunda_lista=[6,7,8,9] print(primer_lista+ segunda_lista) print(primer_lista + [6,7,7,8,9,10]) #Modificar listas numeros=[1,2,3,4,9,6,7,8,9] numeros[4]=5 #apennd añadir número al final numeros.ap...
e2e0488734dab283f61b4114adf692f8d041209e
abhisheklomsh/Sabudh
/prime_checker.py
700
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jan 9 10:51:47 2019 @author: abhisheklomsh Here we ask user to enter a number and we return whether the number is prime or not """ def prime_check(input_num): flag=1 if input_num ==1: print(str(input_num)+" is not a prime number") else: ...
d0dba8c89f41535ab9e08c8eba2c59ea4aa03ed5
javamultiplex/python-projects
/big-file/PandasFileReader.py
448
3.515625
4
import pandas as pd import timeit def read(): df = pd.read_csv('employee_file.csv') total = df['Age'].sum() print("Sum is {}".format(total)) avg = df['Salary'].mean() print("Average is {}".format(avg)) print(timeit.timeit(read, number=1)) # 1 million rows, 100 columns # Sum is 499999500000 # Av...
a789d555b98ae1d07d11c8882e2a6496bdde08e3
bdclauser/add_border
/image_add_boarder.py
589
3.578125
4
#!/usr/bin/env python3 # image_add_boarder.py - Automatically grabs all images in folder and adds a border around it import os import sys from PIL import Image, ImageOps os.makedirs('withBorder', exist_ok=True) for filename in os.listdir('.'): if not (filename.endswith('.png') or filename.endswith('.jpg')): ...
82d95edf5266f24bedcc3d3166bbe10461638b36
wax8280/code_every_day
/day_15_跳跃游戏.py
597
3.59375
4
# coding:utf-8 ''' 给定数组arr[i]==k代表可以从位置i向右条1~k个距离。返回最少跳几次能跳到arr最后的位置上。 如:arr = [3, 2, 3, 1, 1, 4] arr[0] = 3,选择跳到2;arr[2] = 3,可以跳到最后,所以返回2。 dp[i]表示:从i位置开始跳到arr最后的位置上最少需要多少步。 dp[aim]=0除外 ''' def jump(l): length = len(l) aim = length - 1 dp = [0] * length for i in range(aim - 1, 0 - 1, -1): dp...
33599aa7a0527767c14a0aafc891d25058f2c6f1
jgj03/machine_learning
/001_labelling_train_test_split.py
1,229
3.734375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: JGJ """ import pandas as pd #Reading the data and splitting input and output data=pd.read_csv('/home/...../Data/50-Startups.csv') X=data.iloc[:,:4].values #or X=data.iloc[:,:-1].values y=data.iloc[:,4:5].values #or y=data.iloc[:,:4].values #Categorical vari...
eb62e31a38b0599472ab327921bba7c1098ba9f8
RodionGork/gd-school-project
/spring-2019/little_shop.py
503
3.703125
4
#program Little Internet Shop users = [ 'Anna', 'Bob', 'Veronika', 'Matthew', 'Lucas', 'Vladimir', 'Michael', 'Helena', ] goods = [ ['Apples', 70], ['Bananas', 30], ['Sugar', 45], ['Tea', 50], ['Coffee', 95], ] name = input('what is your name: ') print('Hello, ' + name) something = input(...
5c0cf1eda7095d796c7de90026f073013cf94145
gerahuerta/Quiz-9
/ejercicio3.py
266
4.03125
4
print("Ejercicio 3") def superpower(n,e): if e==0: return 1 r = n for a in range (e-1): r*=n return r n=int(input("Dame el numero que quieres elevar ")) e=int(input("Dame la potencia a la que quieres elevar ")) print(superpower(n,e))
a853fc2f812b89e43749e7f6245abca1c98484b1
snehavishwanatha/NLP_Seminar_CodeSnippets
/Tokenizing.py
837
3.859375
4
import nltk #Word Tokenizing text="Arthur is not feeling well." tokens=nltk.word_tokenize(text) print(tokens) #Sentence Tokenizing text ="Arthur is not feeling well. He will not come to the office. We must inform the boss." stokens=nltk.sent_tokenize(text) print(stokens) #Regular Expression Tokenizing #---> text = "...
1785d631ba0a9dc899544159e39be20b198cb1cd
jezcope/aoc2017-python
/06-memory-reallocation.py
815
3.609375
4
import math def reallocate(mem): max_val = -math.inf size = len(mem) for i, x in enumerate(mem): if x > max_val: max_val = x max_index = i i = max_index mem[i] = 0 remaining = max_val while remaining > 0: i = (i + 1) % size mem[i] += 1 ...
c6633e43e1d95cdc8c02b08b4167eb62dc944a35
judsonjames/Python-Sample-Programs
/LinkedListDemo/LinkedList.py
3,054
4.28125
4
import Node """ @author Judson James @version 1.0 This class is used to demonstrate the uses of a Linked List, more information can be found at: https://en.wikipedia.org/wiki/Linked_list """ class LinkedList: """ Valid Constructor Detail: - Contains one node to start with, which will become the head ...
772bbeb29c775388deeb765c54e52f0d0d9c32e5
juanurzua94/othelloGUI
/GUI.py
17,858
3.90625
4
import tkinter from othello import othello class Othello_GUI: '''This class contains the entire gameplay of Othello. It acquires the necessary functions from class 'othello' and class 'Othello_Options' to make the game function accordingly. The layout of the board, labels, and buttons are all handeled with...
17c67730fe1f49ff945cdd21cf9b814073341e32
ThienBNguyen/simple-python-game
/main.py
1,447
4.21875
4
import random def string_combine(aug): intro_text = 'subscribe to ' return intro_text + aug # def random_number_game(): # random_number = random.randint(1, 100) # user_number = int(input('please guess a number that match with the computer')) # while user_number == random_number: # if ran...
e843c477075e49b8fa097a1be5428b910dc4f662
khuang428/CSE101
/lab4.py
3,407
3.984375
4
# Karen Huang # KARHUANG # 111644515 # CSE 101 # Lab #4 def another_one(integer, divisor): times = 0 if divisor == 0: return 0 while integer // divisor != 0: times += 1 integer //= divisor return times+1 def premium_airlines(membership, price, points): if membership == 'R...
619d6310effb2c1ea54c847436f03a7ceda44bf1
khuang428/CSE101
/lab10.py
3,016
3.59375
4
# Karen Huang # KARHUANG # 111644515 # CSE 101 # Lab #10 # In this part of the file it is very important that you write code inside # the functions only. If you write code in between the functions, then the # grading system will not be able to read your code or grade your work! # Part I def decimal_to_fixed_point(va...
06c32dcd834f93f9d90e16a80a9e2f613fe9d44a
hackerxiaobai/leetcode_ac
/双指针/middle.py
20,665
3.5625
4
from base import ListNode from typing import List import collections class Solution(ListNode): def threeSumClosest(self, nums: List[int], target: int) -> int: ''' desc: 最接近的三数之和 给定一个包括 n 个整数的数组 nums 和 一个目标值 target。 找出 nums 中的三个整数,使得它们的和与 target 最接近。 返回这三个数的和。假定每组输入只存在唯一答案。 ''' nums.sort() ans = ...
6d4e65e80b439f094c7bbd6322c18318d2be2a9f
GrahamHewett/python_tests_questions
/beginner/test_dates.py
460
4.09375
4
from datetime import date import time import datetime def main(): print ("Today's date is ", date.today()) main() def get_week_day(day, month, year): date1 = datetime.datetime(year, month, day) days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] print ('The', date1.date(), 'was a...
1c6cf8f70970c875210cf3ca501cb641d0110b66
GrahamHewett/python_tests_questions
/beginner/best8/test_elif.py
2,635
3.515625
4
from if_else import odd_or_even, truthy_or_falsy, smallest_num, _and, _or class TestUM(unittest.TestCase): def test_truthy_or_falsy(self): self.assertEqual(truthy_or_falsy(0), "falsy") self.assertEqual(truthy_or_falsy(-13), "truthy") self.assertEqual(truthy_or_falsy(0b000), "falsy") self.assertEqual(truthy_...
0bdec9afa125d44b025453a1c1ba05b28cec5544
am93596/IntroToPython
/TDD/calculator.py
540
3.59375
4
import math class SimpleCalculator: def add(self, a, b): return a + b def subtract(self, a, b): return a - b def multiply(self, a, b): return a * b def divide(self, a, b): if b == 0: return "Cannot divide by zero" return a / b class SciCalculator...
c8492b2fc31a4301356bdfd95ead7a6a97fcc010
am93596/IntroToPython
/functions/calculator.py
1,180
4.21875
4
def add(num1, num2): print("calculating addition:") return num1 + num2 def subtract(num1, num2): print("calculating subtraction:") return num1 - num2 def multiply(num1, num2): print("calculating multiplication:") return num1 * num2 def divide(num1, num2): print("calculating division:"...
abd127d3cfc7deb00e78508c6d46027a871faf50
am93596/IntroToPython
/functions/function-intro.py
594
3.75
4
# def print_something(word1, word2): # print("print") # print(word1) # print(word2) # print() # # # print("This is outside the function definition") # # print_something("dog", "woof") # print_something("cat", "miaow") # print_something("rabbit", "squeak") # print_something("mouse", "squeak") # returned_...
4b585016939071552555f62bf493930898f5e2a3
am93596/IntroToPython
/handling_files/text_files.py
2,441
3.640625
4
import os parent_dir = os.path.dirname(__file__) # filepath = os.path.join(parent_dir + "\\order.txt") # file = open(os.path.join(parent_dir + "\\order.txt")) # data = file.read() # All the data as a string # data = file.readline() # Next line in the buffer as a string # data = file.readlines() # data = [order.strip...
b5feaf6ad91f6c885ded5aa1b8f45b40050af83b
am93596/IntroToPython
/classes/representations.py
998
3.65625
4
# class Location: # def __init__(self, latitude, longitude): # self.latitude = latitude # self.longitude = longitude # # def __repr__(self): # return f"Location(latitude={self.latitude}, longitude={self.longitude})" # # def __str__(self): # return f"({self.latitude}, {self.lo...
a60f3c97b90c57d099e0aa1ade1650163cf8dd8d
adam-m-mcelhinney/MCS507HW
/MCS 507 Homework 2/09_L7_E2_path_length.py
1,656
4.46875
4
""" MCS H2, L7 E2 Compute the length of a path in the plane given by a list of coordinates (as tuples), see Exercise 3.4. Exercise 3.4. Compute the length of a path. Some object is moving along a path in the plane. At n points of time we have recorded the corresponding (x, y) positions of the object: (x0, y0)...
289eafc4142a2df37daa4ff07f74c892011a1152
johnnymartinezfarciert/cs231-advanced-python-programming
/py1.py
414
3.75
4
from functools import reduce w = map(lambda word: word[::-1], open('english')) print(w) word_count = reduce(lambda a, x: a + x.count(x[::-1]), map(lambda word: word.strip(), open('english')), 0) #i created a map of the reversed words #how do i compare two maps print(word_count) f_count = reduce(lambda a, x: a + x.co...
bf81bd4936d146b5946f005bdc3154030bfc2215
DaltonJr/Python_Exerc-cios
/ex016.py
146
3.890625
4
from math import trunc num = float(input('Digite um número: ')) inteiro = trunc(num) print('A parte inteira do {} é {}'.format(num, inteiro))
2a0d6576c3da2813af8777cc9a416938394059bb
DaltonJr/Python_Exerc-cios
/ex036.py
454
3.734375
4
valor = float(input('Qual o valor da casa: \n')) sal = float(input('Quanto é o salário: \n')) anos = int(input('Em quantos anos será pago: \n')) meses = anos * 12 maxp = sal * 0.30 pres = valor / meses if pres > maxp: print('O valor da prestação excede o limite, prestação R${:.2f}, limiteR${:.2f}'.format(pres, m...
88d588e72a50aa64df75533d2d29a8cdd2f74e25
DaltonJr/Python_Exerc-cios
/ex008.py
160
3.6875
4
tam = float(input('Digite uma medida em metros:')) cm = tam * 100 mm = tam * 1000 print('{} em centímetros é {}, e em milímetros é {}'.format(tam,cm,mm))
0c25960078d1e1c08e975ad21809d1e853ab19f6
DaltonJr/Python_Exerc-cios
/ex014.py
143
3.796875
4
cel = int(input('Digite a temperatura em celsiu: ')) fahr = ((cel/5)*9)+32 print('{}º celsius equivalem a {}º Fahrenheit'.format(cel,fahr))
f399342c479e1591f070b313f3079eaf365b425c
pabloegan/Guessing-game
/pythonex8.py
776
3.953125
4
from random import randint num = int(raw_input("Guess a number between 1 and 9:")) a = randint(1, 9) guessNumber = 0 while a != num: if a > num: print "Too low!" print "The number was %d " % a raw_input("Would you like to play again?? press enter") num = int(raw_input("G...
0c1fe5492f25af962f9b3ef05a90e87643194e73
QilinGu/DSAPractice
/L/SymmetricTree.py
664
3.90625
4
class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def isSymmetric(self, root): if root: return self.check(root.left, root.right) return True def check(self, p, q): if not p and not q: return True if p and q and p.val == q.val:...
bd70a9e921e67f2d0fc40d9e18747b19c07421fe
QilinGu/DSAPractice
/Python/MaximumSubtree.py
675
3.578125
4
class Solution: # @param {TreeNode} root the root of binary tree # @return {int} the maximum weight node import sys def findSubtree(self, root): # Write your code here self.max_sum = -sys.maxint - 1 self.result = None self.helper(root) return self.result ...
ffaf92fcbcf58640569c921dd63744ea3ea889ed
QilinGu/DSAPractice
/L/MergeKSortedList.py
775
3.765625
4
from heapq import heappop, heappush, heapreplace class ListNode(object): def __init__(self, val): self.val = val self.next = None class Solution(object): def mergeKLists(self, lists): dummy = ListNode(0) node, q = dummy, [] for l in lists: heappush(q, (l.val, l)) while q: v, n = q[0] if not n.n...
5b092a0da8a944d7adf4b248442af62c78517791
QilinGu/DSAPractice
/Python/CopyLinkedListWithRandomPointer.py
941
3.8125
4
# Definition for singly-linked list with a random pointer. # class RandomListNode: # def __init__(self, x): # self.label = x # self.next = None # self.random = None class Solution: # @param head: A RandomListNode # @return: A RandomListNode def copyRandomList(self, head): ...
86257cdabffd0c3f74798479d73416d8613dc824
QilinGu/DSAPractice
/L/TwoSumDS.py
420
3.6875
4
class TwoSum(object): def __init__(self): self.dic = {} def add(self, number): self.dic[number] = self.dic.get(number, 0) + 1 def find(self, value): for key in self.dic: target = value - key if target in self.dic and (key != target or self.dic[key] > 1): return True return False if __name__ == '...
bf8675caa23965c36945c51056f3f34ec76ce1bc
anthonyharrison/Coderdojo
/Python/Virtual Dojo 3/bullsandcows.py
2,390
4.15625
4
# A version of the classic Bulls and Cows game # import random # Key constants MAX_GUESS = 10 SIZE = 4 MIN_NUM = 0 MAX_NUM = 5 def generate_code(): secret = [] for i in range(SIZE): # Generate a random digit code = random.randint(MIN_NUM,MAX_NUM) secret.append(str(code)) return sec...
99172284491a30cac8ff2ca2cf7242b59d8bfce8
Larissapy/aula-remota-7
/funcao_dentro_de_funcao.py
1,195
3.6875
4
from turtle import * from random import * def move_to_random_location(): penup() setpos(randint(-400, 400), randint(-400, 400)) pendown() def draw_star(star_size, star_colour): color(star_colour) pendown() begin_fill() for side in range(5): left(144) forward(star_size) ...
cfe00c7d2ee66502f20e5008eea6d0fd5ef21692
Larissapy/aula-remota-7
/t2_q2.py
278
3.578125
4
def main(): n = int(input()) p = 0 s = 1 print(f'{p}, {s}', end='') soma = 0 cont = 2 while cont < n: soma = p + s p = s s = soma cont += 1 print(f', {soma}', end='') if __name__ == "__main__": main()
5836d22ec3abf51bf987706d2e578079008448ed
akshaypatil3207/beginer-problems
/sum of digits.py
556
3.984375
4
#You're given an integer N. Write a program to calculate the sum of all the digits of N. #Input #The first line contains an integer T, the total number of testcases. Then follow T lines, each line contains an integer N. #Output #For each test case, calculate the sum of digits of N, and display it in a new line. #Con...
12ca0ca1760aeb547d1f4930e07db164a4167fe4
akshaypatil3207/beginer-problems
/factorial.py
465
4.03125
4
#You are asked to calculate factorials of some small positive integers. #Input #An integer t, 1<=t<=100, denoting the number of testcases, followed by t lines, each containing a single integer n, 1<=n<=100. #Output #For each integer n given at input, display a line with the value of n! #Example #Sample input: #4 #1 ...