blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
16b585f74b82c01532e980a7657cb39fb2a54565
shaxri/LeetCodeReview
/leet3.py
513
3.546875
4
def isPalindrome(self, x: int) -> bool: if x > 0: temp = x rev_int_elements = [] while temp > 0: digit = temp % 10 rev_int_elements.append(digit) temp = temp // 10 org_int_elements = rev_int_elements[::-1] ...
5f34d489789ac272377bbeeb2165a1f41bc98546
AndersOLDahl/comp_org
/python.py
2,219
3.765625
4
def sum3(nums): return sum(nums) def rotate_left3(nums): return nums[1:] + [nums[0]] def max_end3(nums): m = max(nums[0], nums[-1]) return [m for x in nums] def make_ends(nums): return [nums[0], nums[-1]] def has23(nums): return 2 in nums or 3 in nums def count_even...
bbc7f6b29032acc725a0a9d3e79c6fa41f2c066b
Kara-Tenpas-Akin/P19420
/Other/Examples/HelloGraph.py
4,441
3.546875
4
#!/bin/sh """:" exec python $0 ${1+"$@"} """ # ---------------------------- HelloGraph.py ---------------------- # # This program demonstrates all methods available in the graph # part. Note that this program does not do anything useful; # its purpose is only to demonstrate functionality. # from tkinter import * ...
e2ccc9efd1cf956d3147d4ee5f02e5866fc77c70
andyfangdz/cs3600-csp
/BinaryCSP.py
24,728
3.828125
4
from collections import deque import util import functools """ Base class for unary constraints Implement isSatisfied in subclass to use """ class UnaryConstraint: def __init__(self, var): self.var = var def isSatisfied(self, value): util.raiseNotDefined() def a...
baa0186eaab64a83e06d08d2845111a34db8a85a
CLAlberto/Becas-Digitaliza-Programacion-de-redes
/Introducción a Python (I)/05_calculator.py
2,781
3.875
4
class Calculadora: def __init__(self, a, b): self.firstnumber = a self.secondnumber = b def Suma(self): print("El resultado de sumar", self.firstnumber, "+", self.secondnumber, "es igual a:", (self.firstnumber + self.secondnumber),"\n",self.firstnumber,"+",self.secondnumbe...
d9288247060e18dd06418030f80754164428f3e0
CDinuwan/Training-Python
/Map.py
239
3.828125
4
from functools import reduce def add_all(a,b): return a+b nums=[3,2,6,8,9,7,9] even=list(filter(lambda n: n%2==0,nums)) print(even) doubles=list(map(lambda n: n+2,even)) print(doubles) sum=reduce(lambda a,b: a+b,doubles) print(sum)
4ab5c9103a8029d93ccf1a8f42df74c92e175db6
CDinuwan/Training-Python
/zip_function.py
557
4.09375
4
list1=[1,2,3,4,5] list2=["one","two","three","four","five"] zipped=list(zip(list1,list2))#More than element python always do trunky print(zipped) unzipped=list(zip(*zipped)) print(unzipped) for (l1,l2) in zip(list1,list2): print(l1) print(l2) sentences=[] items=['Apples','Banana','Orange'] counts=[3,6,4] pr...
21c0906ebd5b9b59c8cbdca9106ffdd09a4f2317
CDinuwan/Training-Python
/mutablity.py
232
3.734375
4
#Tuples are immutable/Unchangeble t=(1,2,3) #immutable #lists #dictionaries #orderedDict #immutable #tuples #ints,boolean,floats #Dictionaries keys are immutable #Values are mutable t=(1,2,[3,4]) print(t) t[2][0]=7 print(t)
76010426a1bf724e221b820d01b51c37cb2cf7d6
CDinuwan/Training-Python
/tuple.py
365
3.5
4
t=(1,2,3) print(t[0]) credit_card=(123456789,"Chanuka",'11/12',123) credit_card1=(123456789,"Dinuwan",'11/12',123) credit_cardx=[credit_card,credit_card1] print(credit_cardx) card_no,name,birthday,password=credit_card print(card_no) for card_no,name,birthday,password in credit_cardx: print(card_no) print(n...
a725cce6ff9af36a57455ac9488ba4b47db0a956
jaypatel37/math390_twitter
/organize_tweets.py
7,950
3.59375
4
import json import re # Adds Tweets from the given JSON to a dictionary mapping Tweet ID to text of Tweet def readTweetJSON(file, d): with open(file, "r") as read_file: tweets = json.load(read_file) for item in tweets["results"]: d[item["id"]] = item["text"] return # Same purpose as above...
1fcfe4c9b4cfc3e75c7991d0f34208118fe17779
ameliawilson/CodingProblems
/LeetCode/findDuplicate.py
940
3.859375
4
######################################################################################### # Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), # prove that at least one duplicate number must exist. # Assume that there is only one duplicate number, find the duplicate one. ...
0fe456c956cccfd6dd6a9245e5a49a673ce55736
EpiCame/CollegeLabs
/Catalog_studenti/domain/entitati.py
7,191
3.921875
4
class Student(): def __init__(self,s_id,nume): self.__s_id=s_id self.__nume=nume def get_id(self): ''' retureaza id_ul unui student ''' return int(self.__s_id) def get_nume(self): ''' returneaza numele unui student ...
36e0940b6c9b2c3a2d90ee761b6492b4959af646
HarperHao/ZL_Project
/test.py
126
3.578125
4
""" Author : HarperHao TIME : 2020/12/ FUNCTION: """ string = ['0', 'B', 'A', 'T', 'z', 'h'] print(''.join(string))
dba9ad98c56a8505d92b9e95eed130428aed431d
breezykermo/paideia-developer
/llinyc/process.py
3,446
3.5625
4
''' The Paideia Institute for Humanistic Study written and tested Python 3.5.2 02.16.2017 by Lachlan Kermode (github 'breezykermo') ---------------------------------------------------- Note how to generate different outputs modifying the header params. ''' import csv import sys import math from random import shuffle #...
fc6f4f75fb161453d975368e25c7547341b891c9
ar012/python
/learning/oopsquare.py
147
3.84375
4
class Square: side = 0 def area(self): return self.side*self.side sqr1 = Square() sqr1.side = 5 area = sqr1.area() print(area)
c8b52037086100bfe81087b79cb2e1f78fff837e
ar012/python
/learning/regular_expression2.py
457
3.953125
4
import re pattern = r"Bangladesh" if re.search(pattern, "There is country named Bangladesh in south asia!"): print("Match Found") else: print("No match") pattern = r"bangla" print(re.findall(pattern, "Bangladeshi bangla and indian bangla are different.")) ########### import re pattern2 = r"bin" match = re.s...
418c14a4ae1e95d39e400b389bf6d16c6575559f
ar012/python
/learning/sets.py
948
4.1875
4
num_set = {1, 2, 3, 4, 5} word_set = {"mango", "banana", "orange"} subjects = set(["math", "bangla", "english"]) print(1 in num_set) print("mango" not in word_set) print(subjects) print(set()) # duplicate elements nums = {1, 2, 3, 5, 1, 2, 6, 3, 10} print(nums) # To add a element to a set nums.add(9) print(nums) ...
2be2820eecc70e40341818edad0636d26f2d21c3
ar012/python
/learning/area.py
85
3.8125
4
base = 10 height = 5 area = 1/2*(base*height) print("Area of our triangle is:", area)
7b8b764305df1d592aab18b88ddb66328555e436
ar012/python
/learning/functionalProgramming.py
660
3.90625
4
def make_twice(func, arg): return func(func(arg)) def add_five(x): return x + 5 print(make_twice(add_five, 10)) # Pure function print("\nPure function") def my_pure_function(a, b): c = (2*a) + (2*b) return c print(my_pure_function(5, 10)) # Impure function print("\nImpure function") my_list = [] d...
97dabacf22ee97c3c555f6919d0b4fa5415cc268
ar012/python
/learning/oopsquare3.py
212
3.859375
4
class Square: side = 3 def __init__(self, x): self.side = x def area(self): return self.side*self.side sq = Square(4) print(Square.side) print(Square.area(sq)) #or print(sq.area())
d9db30a085da67acb601f4498733c4a582b593b8
ar012/python
/learning/re-special-sequence2.py
415
3.546875
4
import re pattern = r"\b(cat)\b" match = re.search(pattern, "The cat sat!") if match: print("Match 1") match = re.search(pattern, "We s>cat<tered?") if match: print("Match 2") match = re.search(pattern, "We scattered.") if match: print("Match 3") match = re.search(pattern, "We/cat.tered.") if match: ...
340958a481b50212aa56b06dcebb888518d34d75
ar012/python
/python-learning/learning.py
233
3.6875
4
#! /usr/bin/env python3 print("we love python") print('bangladesh is a small country. It is beautiful country.') print('bangladesh is a small country.\tIt is beautiful country.') input("give your country name: ") print("The End")
639acc45d1511beb65f2f23b4229bb5d0b279022
ar012/python
/learning/test.py
252
4.0625
4
age =21 if (age >= 20): print("He is an adult") print('and he is polite.') elif (age <= 10): print('he is kid') else: print('He is not an adult') print('but he is polite.') ''' if (condition): statement else: statement '''
cbf889277bdf4d9812404d5cd61468c1392e579a
ak1997/Two-Pointers-1
/ContainerMostWater.py
743
3.5
4
# Time Complexity - O(N) # Space Complexity - O(1) # Did this code successfully run on Leetcode : No # Any problem you faced while coding this : No # Approach # I use a two pointer approach where low=0 and high=n-1 . I compute the area using (high-low)*min(nums[high],nums[low]). class Solution: def maxArea(sel...
565ff69d4e11908b04ab741d40b4100bcec0b57c
kn-neeraj/MOOC
/Python-data-structures/Code-Practice/stringsPlay.py
827
3.96875
4
# access individual characeters. name = 'Neeraj' print name[2] #length print len(name) #loop through strings. index = 0 while index < len(name): letter = name[index] print index,letter index += 1 #definite loops for letter in name: print letter #comparing characters count = 0 for letter in name: if letter == 'e': ...
cd5b516a24221e828f5e4b3662057ca52ceba125
arkatsuki/assist
/file/file_rename.py
1,767
4.40625
4
import os """ 改文件的后缀名 rename_to_txt:把文件后缀名改成.txt rename_to_original:与rename_to_txt配套,还原成原来的后缀名 """ def rename_to_txt(dir_path): """ success 把文件后缀名改成.txt :param dir_path: :return: """ for parent, dirnames, filenames in os.walk(dir_path): for filename in filenames: if not...
5b24fd63758f806cae3cb014528171eab3317424
ddjak/python-projects
/Automate the Boring Stuff/chapter8.py
420
3.65625
4
#Chapter 8 #Files import os, shutil #print(os.path.join('C', 'Users', 'ddjakovic')) ### convert into path string #print(os.getcwd()) ### get current working directory #os.makedirs('example') ### make a directory ''' import sys import platform import imp print("Python EXE : " + sys.executable) print("Architecture ...
895efa6c0e4fe04bcd799ced7b22ac55e05ec6e8
TheDon96/CrowdednessPrediction
/Code/Prediction/GenerateData.py
9,019
3.640625
4
import pandas as pd import numpy as np from sklearn.metrics.pairwise import rbf_kernel def TransformDate(date): """ This function derives the weekday number and circular time from the date Parameters: - date (Timestamp) Returns: - weekday (int): Number of day of the week - is_weekend (in...
53be872397f712151e31c0fc4ed440ef5d7b1bf5
TheDon96/CrowdednessPrediction
/Code/ImportData/GVBData.py
6,983
3.8125
4
#Imports import json import pandas as pd import re def stationData(arr_df, dep_df, stations): """ This function construct the passenger GVB DF, by summing the arrivals and departures per stattion, per hour, per date. Parameters: - arr_df(csv): Arrival Df (reisdata GVB). - dep_df(csv): Departure...
074d2d889a50fda955b37d02d55e64db6f0cd6dc
mvk47/turtle-racing
/main.py
1,252
4.21875
4
from turtle import Turtle, Screen import random screen = Screen() screen.setup(width=500, height=400) bet= screen.textinput(title="Make your bet", prompt= "Which turtle will win the race:\n1.Red\n2.Green\n3.Blue\n4.Yellow\n5.Orange") print(bet) red = Turtle() blue = Turtle() yellow = Tur...
35fe48b569a5302def1ab8dcfb3ea5fca8afda4f
jpedrocm/DSChallenge
/HandlerModule.py
2,296
3.609375
4
############################################################################## import pandas as pd class Handler: """This class handles missing data in the dataframe and removes unninformative columns from it. """ @classmethod def _identify_imputation_method(cls, method): """Returns the a...
84d1c158dd321f99c38ce95c3825a457b21ca9e5
Charles-IV/python-scripts
/recursion/factorial.py
536
4.375
4
no = int(input("Enter number to work out factorial of: ")) def recursive_factorial(n, fact=1): # fact = 1 # number to add to fact *= n # does factorial calculation n -= 1 # prepare for next recursion #print("fact: {}, n = {}".format(fact, n)) - test for debugging if n > 1: # keep repeating unt...
7dc6337f0ee63dd8d5b321a79107f379cb40668a
Charles-IV/python-scripts
/recursion/searchDir.py
1,710
3.8125
4
from os import listdir, path from colorama import init, Fore, Style # init colorama init() def searchDir(fName, dir, found): for file in listdir(dir): if file == fName: found.append(path.join(dir, file)) print(Fore.GREEN+"{} - found".format(path.join(dir, file))) #ret...
8ad3f81f25a5575d362f58c4cf584793412a116e
Charles-IV/python-scripts
/recursion/mergeSort.py
2,754
3.65625
4
def split(arr, out): arr1 = arr[:len(arr)//2] arr2 = arr[len(arr)//2:] # split array if len(arr1) == 1: out.append(arr1) elif len(arr1) > 1: # split again split(arr1, out) if len(arr2) == 1: out.append(arr2) if len(arr2) > 1: # split again split(a...
c61ba6c2828ac70288de5efa36d625d9f08e1724
mpolinski/python-sandbox
/iteration_protocol.py
252
4.0625
4
iterable = ['Sprint', 'Summer', 'Autumn', 'Winter'] iterator = iter(iterable) another_iterator = iter(iterable) print(next(iterator)) print(next(iterator)) print(next(iterator)) print(next(another_iterator)) print(next(iterator)) print(next(iterator))
c365751a12d7b289ce5b2833029b034bc8693962
hanibal0717/python
/ex_sample.py
248
3.703125
4
import sqlite3 conn =sqlite3.connect('korea.db'); cursor=conn.execute('select * from sample') rows=cursor.fetchall(); row_counter=0; for row in rows: print(row); row_counter+=1; print("Number of rows:{}".format(row_counter)) cursor.close();
2d6a2b57998ab29ddbd7ab8f3ab475d3be7c6fb6
vapawar/vpz_pycodes
/vpz/vpz_facts_last_two_nums.py
126
3.609375
4
def factTwo(no): c=1 for x in range(no): c=c+c*x print(c) t=c%100 if t==0: print("00") else: print(t) factTwo(12)
9751e43f0580aae99460d521118ac79463027a2c
vapawar/vpz_pycodes
/vpz/vpz_rotate_array.py
316
4.125
4
def rotateL(arr, n): for x in range(n): start=arr[0] for i in range(1,len(arr)): arr[i-1]=arr[i] arr[-1]=start def rotateR(arr,n): for x in range(n): end=arr[-1] for i in range(len(arr)-1,-1,-1): arr[i]=arr[i-1] arr[0]=end x=list(range(1,8)) print(x) rotateL(x,2) print(x) rotateR(x,2) print(x)
595dae1f650d4b1f632820ee2742aa624f4f56ca
lerowhou/RoadToDeveloper
/Searching algorithms/binary.py
321
3.9375
4
def binary(arr,n): if arr[0]>n or arr[len(arr)-1]<n: return False mid= len(arr)//2 if arr[mid]==n: return mid elif n>arr[mid]: return binary(arr[len(arr)//2],n) elif n<arr[mid]: return binary(arr[:len(arr)//2-1],n) return False arr = [1,2,3,4,5,6,7,8,9,13,15] n=int(input()) print(arr) print(binary(arr,n))...
8516130a5bec71ffbbd38258b7bca4f86236fd8b
mxgnene01/case_drive_auto_tester
/test/unittest001.py
686
3.609375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Meng xiangguo <mxgnene01@gmail.com> # # _____ ______ # ____==== ]OO|_n_n__][. | |] # [________]_|__|________)< |MENG| # oo oo 'oo OOOO-| oo\_ ~o~~~o~' # +--+--+--+--+--+--+--+--+--+--+--+--+--+ # ...
7892c5f263a30724082d19a9ef4c464605479fcb
datarpita/Pythonics
/FirstProj/Exercises.py
1,844
4.0625
4
''' Created on Nov 18, 2018 @author: Mgmi ''' import datetime #Create a program that asks the user to enter their name and their age. #Print out a message addressed to them that tells them the year that they will turn 100 years old. def exercise1(): print('Enter your name:') name=input() print('Enter you...
242bb9a8b6f40184f30dd443c8d740fa5161722b
fred-yu-2013/avatar
/pyexamples/python/language/encode_decode.py
1,486
3.5
4
# -*- coding: utf-8 -*- # 默认采用ascii编码,设置后,默认则为utf-8编码。 import binascii # import bitarray import sys def strbin(s): return ''.join(format(ord(i),'0>8b') for i in s) def strhex(s): h="" for x in s: h=h+(hex(ord(x)))[2:] return "0x"+h # 字符串的默认编码,用作decode, encode等函数的编码参数的默认值。 print 'sys.getdef...
2442437b7489e30116574e8756a58c9617c6f227
alannanoguchi/Tweet-Generator
/markovchain.py
4,847
3.96875
4
from dictogram import Dictogram from random import choice, randint corpus = "That fantasy of what your life would be. White dress, Prince Charming, who'd carry you away to a castle on a hill. You\'d lie in bed at night and close your eyes, and you had complete and utter faith. Eight hours, 1 6 ounces of chocolate and...
c6185e2540565a21841ccca25202469b0371ebc8
nitin7570/30_days_of_code
/Day_12/Solution.py
1,230
3.828125
4
''' Author: Nitin Singh Email : nitin7570@gmail.com Sample Input: Heraldo Memelli 8135627 2 100 80 Sample Output: Name: Memelli, Heraldo ID: 8135627 Grade: O ''' class Person: def __init__(self, firstName, lastName, idNumber): self.firstName = firstName self.lastName = lastName self.idNumber = idNumber de...
779ad3733668400b2bbac25d4656355c755210f1
nitin7570/30_days_of_code
/Day_10/Solution.py
472
3.890625
4
''' Author: Nitin Singh Email : nitin7570@gmail.com Sample Input 1: 5 Sample Output 1: 1 Sample Input 2: 13 Sample Output 2: 2 ''' def find_consecutive_num(n): binary = [] while n > 0: remainder = n % 2 binary.append(remainder) n = n//2 number_string = "".join(str(digit) for d...
3f3fd445be48af67f6da1f57f28ced68f1eeeb1d
vickybieghsPXL/PXL-DIGITAL
/Eerste_jaar/IT-Essentials/examen_ITEssentials/Functies/oefening_5.3.py
1,058
3.578125
4
def bereken_lidgeld(leeftijd, aantal_kinderen_ten_laste, inkomen, aansluitingsjaar0): lidgeld = 100 if leeftijd > 60: lidgeld -= 60 if aantal_kinderen_ten_laste > 0: korting = 7.5 * aantal_kinderen_ten_laste if korting > 35: korting = 35 lidgeld -= korting if ...
f45d4e17ce8931513e851d0f752161b1df003267
vickybieghsPXL/PXL-DIGITAL
/Eerste_jaar/IT-Essentials/examen_ITEssentials/Variabelen/oefening_2.5.py
118
3.796875
4
fahrenheit = float(input("Geef graden fahrenheit: ")) celcius = (5 / 9) * (fahrenheit - 32) print(round(celcius, 1))
b98124311f1052e892c65dafe50e076d3161279f
vickybieghsPXL/PXL-DIGITAL
/Eerste_jaar/IT-Essentials/examen_ITEssentials/Condities/oefening_3.6.py
465
3.625
4
from datetime import datetime basisprijs = 5 film_jonger_twee_jaar = 1 film_hoge_rating = 2 film_lage_rating = 1 max_prijs = 7 jaar = int(input("Van welk jaar is de film? ")) rating = int(input("Wat is de rating van deze film (1-5): ")) prijs = basisprijs if datetime.now().year - jaar < 2: prijs += film_jonger_...
a8417d14f2ca22fe59dcfa71ec4331aedd096387
vickybieghsPXL/PXL-DIGITAL
/Eerste_jaar/IT-Essentials/examen_ITEssentials/Variabelen/oefening_2.7.py
686
3.8125
4
lengte = float(input("Geef de lengte: ")) breedte = float(input("Geef de breedte: ")) prijs_per_vierkante_meter = float(input("Geef de prijs per vierkante meter: ")) plaatsings_kosten_per_vierkante_meter = float(input("Geef de plaatsingskosten per vierkante meter: ")) aantal_vierkante_meter = lengte * breedte prijs_ta...
34c8d019e6e107a2e4749216fcbd72e1b6f24646
vickybieghsPXL/PXL-DIGITAL
/Eerste_jaar/IT-Essentials/examen_ITEssentials/Condities/oefening_3.1.py
216
3.84375
4
getal1 = int(input("Geef getal1: ")) getal2 = int(input("Geef getal2: ")) if getal1 > getal2: print("Getal 1 is groter") elif getal2 > getal1: print("Getal 2 is groter") else: print("Ze zijn even groot")
53cdaec99f511f90e3a0b8b3d6beb6d3375f1aa2
vickybieghsPXL/PXL-DIGITAL
/Eerste_jaar/IT-Essentials/examen_ITEssentials/Condities/oefening_3.4.py
392
3.734375
4
getal1 = int(input("Geef getal1: ")) getal2 = int(input("Geef getal2: ")) if getal1 < getal2: kleinste = getal1 grootste = getal2 else: kleinste = getal2 grootste = getal1 print("Kleinste: {}".format(kleinste)) print("Kwadraat: {}".format(kleinste ** 2)) if kleinste != 0: print("Grootste/kleinste:...
b4d1f8bb2a439b4b752f9d1c72171a2dc84029c8
vickybieghsPXL/PXL-DIGITAL
/Eerste_jaar/IT-Essentials/examen_ITEssentials/Variabelen/oefening_2.2.py
228
3.625
4
aantal_volwassenen = int(input("Hoeveel volwassenen zijn er? ")) aantal_kinderen = int(input("Hoeveel kinderen zijn er? ")) totaal = aantal_kinderen * 6 totaal += aantal_volwassenen * 11 print("Totaal: {} euro".format(totaal))
affffd0c872ee299b0e75225d3244e87002ccd90
fonsp/printigram
/Printigram.py
4,033
3.53125
4
# PRINTIGRAM # 1 July 2019 # Tested for Python 3.7.2 on Windows 10 Pro # The programme only works on Windows; need to change font to work on other OS. # Imports. Pil for images, os for paths and file management, printipigeon to sent pictures to printi. from PIL import Image, ImageDraw, ImageFont import os import prin...
8592a4f4ce78c086f52e08aa26f56854fbde1838
TomAshkenazi/GWU-ARL-DATA-PT-12-2019-U-C
/01-Lesson-Plans/03-Python/1/Activities/04-Stu_HelloVariableWorld/Unsolved/HelloWorld.py
299
4.03125
4
name = "Omar" country = "Jordan" age = 28 hourly_wage = 86 satisfied = True daily_wage = hourly_wage * 8 print("My name is " + name + " and I hail from " + country) print("I earn " + str(hourly_wage) + '/hour.') print(f"I am satisfied or not ({satisfied}) with my daily salary of {daily_wage}")
abe3f3a1b42d83346badae1232d33897b3b5f166
MorgFost96/School-Projects
/PythonProgramming/Homework/Exam 2/exam2program2.py
1,820
3.96875
4
#Morgan Foster #1021803 #This program allows the user to input stock information until the user is #chooses to stop, then outputs calculations for the stocks that the user input. #Input name = "default" while( name != "Quit" ): name = input( "Stock Name (Type 'Quit' to Stop): " ) if( name != "Quit" ): ...
aab2c535b094205462ac80405250ce17ee993e4e
MorgFost96/School-Projects
/PythonProgramming/3-28/lists.py
1,879
4.5625
5
#List Examples #---------------- #Lists of Numbers #---------------- even_num = [ 2, 4, 6, 8, 10 ] #---------------- #Lists of Strings #---------------- name[ "Molly", "Steven", "Will" ] #------------------------- #Mixed Strings and Numbers #------------------------- info = [ "Alicia", 27, 155 ] #------------ #Prin...
d142a70a335d662c1dcc443603f17e2cc3e4996a
MorgFost96/School-Projects
/PythonProgramming/5-16/objects.py
2,685
4.34375
4
#Morgan Foster #1021803 # Intro to Object Oriented Programming ( OOP ) # - OOP enables you to develop large scale software and GUI effectively # - A class defines the properties and behaviors for objects # - Objects are created from classes # Imports import math # --- # OOP # --- # - Use of objects to create programs...
a330c68a5d2b531399e1f400f24b56d0c2d6ee4e
MorgFost96/School-Projects
/PythonProgramming/5-9/recursive.py
1,317
4.59375
5
# Recursion # - A function that calls itself # --------- # Iterative # --------- # Main -> a -> b -> c -> d # --------- # Recursive # --------- # Main -> a -> a -> a -> a # ---- # Note # ---- # Whenever possible, use iterave over recusive # Why? Faster and uses less memory # ------- # Example # ------- def main():...
16b5ee3084e7b0d7c4bb3db990a45732526dd972
MorgFost96/School-Projects
/PythonProgramming/3-28/sales.py
711
4.15625
4
#This program lists the sales for 5 days def createList(): #Teacher put ndays = 5 and sales = [ 0 ] * ndays sales = [ 0 ] * 5 print( "Enter sales for each day" ) i = 0 while( i < len( sales ) ): print( "Day #", i + 1, ": ", sep = "", end = "" ) sales[ i ] = float( input( ) ) ...
88c4bcfbfccc47f7705c0041c9ab183fd9571331
MorgFost96/School-Projects
/PythonProgramming/2-23/starchart.py
825
3.765625
4
#Star Pyramid import random #Input base = int( input( "What is the base? " ) ) #Normal Pyramid print() for i in range( 0, base ): print( " |", end = '' ) print( " ", i, " ", sep = '', end = '') print( "\n----", "-" * (base * 2), sep = '' ) for row in range( 0, base ): for col in range( 0, row + 1 ...
2c0aa4a194fe1733cff65502166d72e39d6f6276
MorgFost96/School-Projects
/PythonProgramming/2-16/stupidloop.py
122
3.625
4
#Stupid For Loops for x in range( 5 ): print( "stupid" ) ##>>> ##stupid ##stupid ##stupid ##stupid ##stupid ##>>>
51dfa9121db952f837f90310b3970a02a7ae239b
MorgFost96/School-Projects
/PythonProgramming/3-30/insert.py
409
4.5
4
#This program demonstrates the insert method def main(): names = [ "James", "Kathryn", "Bill" ] print( "The list before the insert: " ) print( names ) names.insert( 0, "Joe" ) print( "The list fter the insert: " ) print( names ) main() ##>>> ##The list before the insert: ##['James', 'Kat...
104d410a5173e5ded6246ccafb8e8a0eaae56099
diamontip/pract
/incre.py
288
3.796875
4
text = input('enter text that need to be printed in incremental order:\n') second = '' i = len(text) - 1 j = 0 print('--------------\ninitiated\n--------------\n') while j != i: second = second + text[j] print (second) j = j + 1 print('\n--------------\ncompleted\n--------------')
08e0b4af0562ad9da21641c38f672da714cde317
wstiehler/PW-Trainning
/models/pessoa_model.py
1,110
3.65625
4
class PessoaModel: def __init__(self, nome, sobrenome, idade, sexo): self.nome = nome self.sobrenome = sobrenome self.idade = idade self.sexo = sexo def __str__(self, nome, sobrenome, idade, sexo) -> str: return f'{nome},{sobrenome},{idade},{sexo}' def cadastro(n...
92f3a97cf14f9b08b43af08db3ddbdaefe61f629
saideepshetty/leet-code-easy
/maximumSubArray.py
661
4.0625
4
''' Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Explanation: [4,-1,2,1] has the largest sum = 6. Code By Saideep Shetty ''' class Solution(object): def maxSu...
8fc8d96774ceea66e3f6b13eebb00f7e2711f86d
saideepshetty/leet-code-easy
/romantoInteger.py
2,522
3.921875
4
''' Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, two is written as II in Roman numeral, just two one's added together...
39fc2e4f6acba8db9f876315730067d93216eae4
saideepshetty/leet-code-easy
/oneEditAway.py
1,087
3.859375
4
def oneEditAway(string1, string2): if len(string1) == len(string2): return checkReplacement(string1, string2) if len(string1) + 1 == len(string2): return checkInsertion(string1, string2) if len(string1) - 1 == len(string2): return checkInsertion(string2, string1) return False ...
c4a0f4afb105dc615b6386118f361a94e518efc0
saideepshetty/leet-code-easy
/perfectNumber.py
1,167
3.671875
4
''' A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. A divisor of an integer x is an integer that can divide x evenly. Given an integer n, return true if n is a perfect number, otherwise return false. Example 1: Input: num = 28 Output...
77495114cd1539a317590165283b82dfe3d4adce
YektaZ/Fun_Exercise
/words_to_numbers.py
888
3.828125
4
# coding: utf-8 def words_to_numbers(input): ph_num = '' for i in range(len(input)): if input[i].upper() in 'ABC': ph_num = ph_num + '2' elif input[i].upper() in 'DEF': ph_num = ph_num + '3' elif input[i].upper() in 'GHI': ph_num = ph_num + '4' ...
6d6fb9975651f383a20b0ac9fde9af7e29e424f5
evilrobotjames/evilrobotjames
/advent-of-code-2020/2/main2.py
721
3.875
4
#!/usr/bin/python import re f = open('data.txt') password = re.compile('(?P<min>[0-9]+)-(?P<max>[0-9]+) (?P<letter>[a-z]): (?P<password>[a-z]+)') def is_valid(pos1, pos2, letter, password): val1 = password[pos1 - 1] == letter val2 = password[pos2 - 1] == letter if val1 and val2 or not val1 and not val2:...
9456a0812f3b5a7f5cd9a65849cf0370d6df6548
evilrobotjames/evilrobotjames
/seive/seive.py
656
3.609375
4
#!/usr/bin/python MAX = 10240 primes = [ True for _ in range(0, MAX) ] def print_primes(primes): render = [] for i in range(0, MAX): if primes[i]: render.append(i) print(render) for i in range(2, MAX): # ignore zero and one print("doing {}".format(i)) if primes[i]: j ...
53cc989de5dc4333a46124cbc2a9a814844ca87c
Ochaligne/Data-for-research-edx
/knn_classification/nearest.py
1,931
3.65625
4
import numpy as np import matplotlib.pyplot as plt import scipy.stats as ss #loop over all points #compute distance between p and every other points # sort distance and return those k points that are nearest to point p points = np.array([[1,1],[1,2],[1,3],[2,1],[2,2],[2,3],[3,1],[3,2],[3,3]]) outcomes = np...
a3a8dbe98618e9966add026ff4c9b5c72b620248
OrehFromPnz/csc
/alg/6/2_9.py
1,919
3.609375
4
# Задача на программирование. # Дан ориентированный взвешенный граф на n вершинах и m рёбрах (1≤n≤1000, 0≤m≤100000). # Вес ребра — натуральное число, не превышающее 1000. # Последняя строка содержит номера двух вершин u и v. # Выведите кратчайшее расстояние между вершинами u и v или -1, если в графе нет пути из u в v. ...
4239fbf8d600ac95c885a36fb8ebfbb2faf5988d
orik3ll0/testTemp
/c-1.py
329
4
4
# with curly brackets we decleared that it is a dictionary. In inside of dict # by for loop we are settign "i" value wich is key here. Value is givven [] d1 = {i: [] for i in range(5)} # fromkeys function which creates dictionary with empty values [] # and keys in range(5) d2 = dict.fromkeys(range(5), []) print(d1) p...
16a5951a77abb14e766aed637c85205bc10b476e
akhilpadmanabha/MobileDrawingRobots
/src/lab4_starter/src/coloring.py
7,243
3.5625
4
#!/usr/bin/env python """Segmentation skeleton code for Lab 6 Course: EECS C106A, Fall 2019 Author: Grant Wang This Python file is the skeleton code for Lab 3. You are expected to fill in the body of the incomplete functions below to complete the lab. The 'test_..' functions are already defined for you for allowing yo...
2960406107cdce91236948204b4c2ccc4320c535
kosyan62/YandexRobots
/path.py
11,724
3.609375
4
USE_NUMPY = False class DiagonalMovement: always = 1 never = 2 if_at_most_one_obstacle = 3 only_when_no_obstacle = 4 class Node(object): """ basic node, saves X and Y coordinates on some grid and determine if it is walkable. """ def __init__(self, x=0, y=0, walkable=True, weight...
97ddb326c2af50e3f61ed34fbe097d61eed12ebd
h4l0anne/PongGame
/Pong.py
2,421
4.28125
4
# Simple Pong Game in Python import turtle wn = turtle.Screen() wn.title("Pong Game") wn.bgcolor("green") wn.setup(width=800, height=600) wn.tracer(0) # Paddle A paddle_left = turtle.Turtle() paddle_left.speed(0) # 0 for maximum possible speed paddle_left.shape("square") paddle_left.color("blue") paddle_left.shap...
2aea01ba888855ee4d4d7e024bad881d26d5e9fa
smartpramod/97
/PRo 97.py
449
4.21875
4
import random print("NUMBER GUESSING GAME") number=random.randint(1,9) chances=0 print("GUESS A NUMBER BETWEEN 1 AND 9") while(chances<5): Guess=int(input("Enter your number")) if Guess==number: print("Congrulation, YOU WON") break elif Guess<number: print("Your guess was...
3144023baa729b1ba38599d1b9afa6ab9a8efdef
oliverzhang42/sentiment-analysis
/word2vec.py
3,092
3.59375
4
# The preprocessing is from the tutorial here: # https://www.kaggle.com/c/word2vec-nlp-tutorial/overview/part-1-for-beginners-bag-of-words from bs4 import BeautifulSoup import gensim import pandas as pd import re import numpy as np import nltk.data #nltk.download() # Download punkt tokenizer for sentence splitting to...
0695724eea85e7bb5dd23845b0e3d36017168abc
shubhamkumar0415/gitrepo
/callable_function.py
257
3.875
4
def make_multiplier_of(n): def multiplier(x): return x - n return multiplier # Multiplier of 3 times3 = make_multiplier_of(3) # Multiplier of 5 times5 = make_multiplier_of(5) print(times3(9)) print(times5(3)) print(make_multiplier_of(6))
95525c4b720f0ad838225a27773e40b16f35c62a
shubhamkumar0415/gitrepo
/t19.py
145
3.640625
4
def map1(func,*args): for i in zip(*args): yield func(*i) def fun(a,b): return a+b l=list(map1(fun,[1,2,3],[4,5,6,7])) print(l)
e56a29c19e5a2aa1abcd52340e7c731de30a8573
nomadsiv/puzzles
/advent-of-code-2019/day1.py
1,722
3.9375
4
import math def calculate_fuel_required(mass): # print("got module mass: %s" % mass) fuel_required = math.floor(mass/3) - 2 return fuel_required def read_module_masses(filename): with open(filename) as f: mm_list = f.readlines() # remove whitespace characters like '\n' at the end of eac...
bc3e55ea22cd1e7e3aa39a9b020d128df16dfa92
aalhsn/python
/conditions_task.py
1,279
4.3125
4
""" Output message, so the user know what is the code about and some instructions Condition_Task author: Abdullah Alhasan """ print(""" Welcome to Abdullah's Calculator! Please choose vaild numbers and an operator to be calculated... Calculation example: first number [operation] second number = results """...
3f0a9369c0438732f19139643bee18f5c025565f
chunaixxx/lab-python
/lab5/main.py
4,236
3.671875
4
from random import (randint) # Возвращает двумерный массив Row x Col со случайными значениями # в диапазоне от min до max def makeRandomArr(row, col, min, max): arr = [[0] * col for i in range(row)] for Row in range(row): for Col in range(col): arr[Row][Col] = randint(min, max) return arr # Выводит количест...
4d982c99a48643926253c51178beb0275d8f571d
lesleyfon/Sprint-Challenge--Data-Structures-Python.
/reverse/reverse.py
1,451
4.03125
4
class Node: def __init__(self, value=None, next_node=None): self.value = value self.next_node = next_node def get_value(self): return self.value def get_next(self): return self.next_node def set_next(self, new_next): self.next_node = new_next class LinkedList...
e055b913b7b0f80180d3166dcfda83f80f033d3f
KeiranHines/TwitterScraper
/src/framework/abstract_handler.py
538
3.59375
4
from abc import ABC, abstractmethod from . import AbstractDataClass class IHandler(ABC): """ Base class for a generic data handler to process messages scraped into AbstractDataClass objects. """ @abstractmethod def process(self, data: AbstractDataClass): """Processes the data received....
cbe694859bb7d678ede354d4447719fe3d46bdd9
KeiranHines/TwitterScraper
/src/framework/abstract_scraper.py
1,525
3.734375
4
from abc import ABC, abstractmethod from typing import Set from . import IHandler, AbstractDataClass class AbstractScraper(ABC): """ Abstract class for defining the skeleton of a data scraper. """ def __init__(self, target: str): self.target = target self.last_read = None ...
61f532ff381786e0629abfcd0c6e943cda375c9c
Jas1052/mini-projects
/pythonic-practice/map.py
135
3.890625
4
a = [1, 2, 3, 4, 5] b = [] for val in a: b.append(val**2) print(b) a = [1, 2, 3, 4, 5] b = list(map(lambda x: x**2, a)) print(b)
d5b34405887eca1833a5a1ec9a19f7d153d06070
danylipsker/PYTHON-INT-COURSE
/guess_a_number.py
2,672
3.8125
4
#STARTING VALUES guessNumber = 0 r = range(2, 49, 10) #2,12,22,32,42 luckyList = list(r) #[2,12,22,32,42] luckyListLength=(len(luckyList)) # 5 trials = 0 # SOLUTION NUMBERS print() print("--------------------------") print("ALL THESE NUMBER MUST BE HIDDEN FROM THE USER !!!!") print("The length of the li...
2ba645675603e5b95232146434102e683f7ab5c5
danylipsker/PYTHON-INT-COURSE
/Tic_Tac_Toe_DANY_LIPSKER.py
8,941
3.9375
4
def welcome_message(): clear_screen() print("\n********************************************************") print("* WELCOME TO PLAY TIC TAC TOE, CREATED By DANY LIPSKER *") print("********************************************************\n") def userInput(name1="", symbol1="", name2="", symbol2="...
48875e5271741d258c633b90f92a0d7206519ede
danylipsker/PYTHON-INT-COURSE
/LESSON-4/LESSON-4.py
4,566
3.96875
4
## FOR LOOP # numberList = [[1, 300, 5], [7, 800, 9], [-4, 10000, 200]] sum = 0 for currentList in numberList[1:]: print(currentList) for number in currentList: sum = sum + number print(number, sum) if sum > 100: break print("after list...") print(sum) prin...
20f8470e049e1f445b833cf72da92544130341d6
MajaBV/WebDev1-1
/zadatak_1.py
390
3.515625
4
alfonci = 5000000 velonci = 9000000 years = 0 while velonci >= alfonci: years = years + 1 alfonci = alfonci * 1.06 if years % 4 == 0: velonci = (velonci * 1.05) - 500000 else: velonci = velonci * 1.02 print("The number of Alfonci will exceed the number of Velonci in {0} years. The tota...
de103886cf094124f18fef6413a3d182323fd2da
hannykee/dailymission
/0314 여러개 숫자 중 가장 큰 값 작은 값 구하기2.py
902
3.546875
4
#0314 여러개 숫자 중에서 가장 큰 값과 작은 값 구하기-2 #함수 사용하지 않고 구축 list2 = [12,42,32,51,23,25,22] #random 으로 난수 발생시키는 module도 존재한다. max=0 #가장 큰 값을 저장할 변수 하나를 0으로 초기화시켜 생성한다. for i in list2 : if i > max: ##여기서 나의 오류 list[i]가 아니라 list2의 요소표현을 i(임의의 요소)로 표현하면 충분하다./ max=i min = max #가장 작은 값 # 마찬가지로 min과 비교하여 더 작은 값 찾아내는...
e63971a97e86f7175cdc1eccc7c55a2a54c66f8b
hannykee/dailymission
/0330 elif 복수 조건문 문법.py
628
3.609375
4
#0330 elif로 다중 조건 판단문 만들기- 점프 투 파이썬 참고 "주머니에 돈이 있으면 택시를 타고, 주머니에 돈은 없지만 카드가 있으면 택시를 타고, 돈도 없고 카드도 없으면 걸어 가라" a=input("주머니에 든 것을 나열하세요. ex) paper,cellphone...") a=a.replace(' ','') pocket=a.split(",") card=int(input("카드가 있다면 1, 없으면 0을 입력하세요.")) ''' pocket = ['paper', 'cellphone'] card = 1 ''' if 'money' in pocket:...
59000e0f4a8b06e67c7de1b7bf3e2c06816687c5
hannykee/dailymission
/0309 최대공약수 구하기.py
524
3.578125
4
#03-09 최대공약수 구하기 num1 = int(input("첫 번째 수를 입력하세요")) num2 = int(input("두 번째 수를 입력하세요")) t_num = 0 if num1 > num2: t_num=num2 else : t_num=num1 while t_num > 1: if num1%t_num==0 and num2%t_num==0: #틀린 부분: 나눴을 때 0이 되는건 비정상, 나머지가 0이 되어야 한다. 나머지 기호 주의!! print("최대공약수는 : %d 입니다." %t_num) #d 정수, ...
b5b65099d9e14f60d87e653b9fc1333cd585cbb6
bdeme004/417-term-project
/testdata.py
822
3.515625
4
def testData1(): """generate data with known correct answers""" # based on wk10 lecture notes # correct least-squares: p = -2 + 6x # correct piecewise linear: [2x, 6x-4, 10x-12] x = [0, 1, 2, 3] y = [0, 2, 8, 18] cores = [dict(), dict(), dict(), dict()] for i in range(0, 4): ...
5a9bb606df829d0aea1f01a4e8a1d68b43787e35
jackodsteel/coderunner-questions
/JUnitTesting/PROTOTYPE_TEMPLATE_java_junit_tester_junit_5.py
7,866
3.5
4
""" The template for a question type in which a student submits a fully valid JUnit 5 test class in the answer box, and the question author supplies a set of versions of the same model class that are expected to be valid/invalid, as indicated by the expected result being PASS/FAIL. The question compiles the student JUn...
adb4700b96efcca88a61046ec9cfd7492fb507c1
mukesh-jogi/python_repo
/Sem-6/numpy/matrixmultiply.py
213
3.640625
4
import numpy as np array1=np.array([[1,2,3],[4,5,6],[7,8,9]],ndmin=3) array2=np.array([[1,2,3],[4,5,6],[7,8,9]],ndmin=3) # result=np.multiply(array1,array2) result=np.matmul(array1,array2) print(result)
9aead53736d9788178b2d89a1952125e159f2b09
mukesh-jogi/python_repo
/Sem-6/Tkinter/frame.py
730
3.859375
4
from tkinter import * win = Tk() win.geometry("500x500") topframe = Frame(win,bg="green",bd=2,height=50,width=500,cursor="plus") bottomframe = Frame(win,bg="red",bd=2,height=50,width=500,cursor="circle") leftframe = Frame(win,bg="blue",bd=2,height=500,width=100) rightframe = Frame(win,bg="yellow",bd=2,height=500,widt...
1589658b0df7e68c70a4785710e5a0fae1b1681a
mukesh-jogi/python_repo
/Sem-5/TextProcessing/writejson_dump.py
264
3.578125
4
# Python program to write JSON to a file import json # Data to be written dictionary ={ "name" : "sathiyajith", "rollno" : 56, "cgpa" : 8.6, "phonenumber" : "9999900000" } with open("sample1.json", "w") as outfile: json.dump(dictionary, outfile)