blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
6a6f9fee6f9bca917dde01ab61a68d7ef8088af6
tripathi-vineetbaba/python
/Account/AccountUpdate.py
2,814
3.625
4
import os import Account import createPerson acclist=list() def addAcc(): p1 = createPerson.retPer() accNo = Account.Accounts.generateAcc() aco1 = Account.Accounts(accNo,p1) print ("Account has been created successfully.") print("Account Number is: ",accNo) acclist.appe...
783456d0f344db493b3c4ddab81127f714cb0be0
Nockternal/Burger
/intro to programming/Completed Tasks/Task 10/example.py
4,638
4.4375
4
#************* HELP ***************** #REMEMBER THAT IF YOU NEED SUPPORT ON ANY ASPECT OF YOUR COURSE SIMPLY LOG IN TO www.hyperiondev.com/support TO: #START A CHAT WITH YOUR MENTOR, SCHEDULE A CALL OR GET SUPPORT OVER EMAIL. #************************************ # PLEASE ENSURE YOU OPEN THIS FILE IN IDLE oth...
c358ada6a79a1cb79a793c42c749c64ebfd59699
Nockternal/Burger
/intro to programming/Completed Tasks/Task 6/Shopping.py
545
4.125
4
items = [] prices = [] diction = {} total = 0 for i in range(0,3): string = input("please enter product name") num = float(input("Please enter the cost of this product")) diction[string] = num items.append(string) prices.append(num) for i in prices: total = total + i count = ...
3b6a41ea989edf766384f77c16fb4442964bd0ce
Nockternal/Burger
/intro to programming/Completed Tasks/Task 2/example.py
5,054
4.03125
4
#************* HELP ***************** #REMEMBER THAT IF YOU NEED SUPPORT ON ANY ASPECT OF YOUR COURSE SIMPLY LOG IN TO www.hyperiondev.com/support TO: #START A CHAT WITH YOUR MENTOR, SCHEDULE A CALL OR GET SUPPORT OVER EMAIL. #************************************* # PLEASE ENSURE YOU OPEN THIS FILE IN IDLE o...
4c7f02855a087b11b980bd5eddcb67b697e106f4
uml-cm-f16/blackjack
/app/src/logic/dealer.py
2,080
3.953125
4
#!/usr/bin/python3 """ Defines a card dealer. A Card dealer is a player that manages the deck. """ # IMPORTS from .player import Player from .deck import Deck # CLASS class Dealer(Player): """ A card dealer. A player that also can deal cards. """ # Class methods def __init__(self): ...
01b59388666606a64154f7c8ad9bc27f5b27eba8
klanghamer/prg105
/MobileServiceProvider.py
1,689
4.15625
4
"""A mobile phone service provider has three different subscription packages for its customers: Package A: For $39.99 per month 450 minutes are provided. Additional minutes are $0.45 per minute. Package B: For $59.99 per month 900 minutes are provided. Additional minutes are $0.40 per minute. Package C: For $69.99...
ae7c979e95637bc9b1284ecd494e5d96dd3ee278
klanghamer/prg105
/ChapterThirteenPractice.py
3,923
4.15625
4
""" Complete all of the TODO directions The number next to the TODO represents the chapter and section that explain the required code Your file should compile error free Submit your completed file """ import tkinter import tkinter.messagebox # TODO 13.2 Using the tkinter Module # Wri...
aaea656f092a94c4aaa6d1931f5e1b40ec09b0ae
klanghamer/prg105
/ChapterSevenPractice.py
4,157
4.25
4
""" Complete all of the TODO directions The number next to the TODO represents the chapter and section that explain the required code Your file should compile error free Submit your completed file """ # TODO 7.2 Lists # Create a list of days of the week, assign it to the variable days, rem...
de09713fa7aab3255214d2451cd65046cf2c4c8b
klanghamer/prg105
/ChapterFourPractice.py
2,255
4.21875
4
""" Complete all of the TODO directions The number next to the TODO represents the chapter and section that explain the required code Your file should compile error free Submit your completed file """ # TODO 4.2 A condition controlled loop # write a loop that will change the variable in num by subtracti...
aa9eec166a89182133d56ef69b422e5e777f51ea
klanghamer/prg105
/ChapterElevenPractice.py
4,058
4.3125
4
""" Complete all of the TODO directions The number next to the TODO represents the chapter and section that explain the required code Your file should compile error free Submit your completed file """ # TODO 11.1 Introduction to Inheritance # You are going to create a Dwelling class base...
6b36c0804ddfa9655f03db367cc5c1492a1a95c5
PragyaRajput/Python_Programs
/VerticalLED.py
3,599
3.59375
4
def print_row(*col): for i in range(5): if i in col: print("*",end=" ") else: print(" ",end=" ") print() def A(): print_row(1,2,3) print_row(0,4) print_row(0,4) print_row(0,1,2,3,4) for i in range(3): print_row(0,4) def B(): print_row(...
510a1e2d21d460f499cd36d4b5380e28419a240f
yiamabhishek/Complete-Python-3-Bootcamp
/07-Errors and Exceptions handling/HomeWork/HW-1.py
226
3.765625
4
#Problem 1 #Handle the exception thrown by the code below by using try and except blocks. def Errors(): try: for i in ['a','b','c']: print(i**2) except: print("An Error Occured!") Errors()
387cd6e4cc7c454fd00fe2381093d6e665e3b8da
yiamabhishek/Complete-Python-3-Bootcamp
/08 - Milestone Project 2/War.py
1,539
3.71875
4
import random suits = ('Hearts','Diamonds','Clubs','Spades') ranks = ('Two','Three','Four','Five','Six','Seven','Eight','Nine','Ten','Jack','Queen','King','Ace') values = {'Two':2,'Three':3,'Four':4,'Five':5,'Six':6,'Seven':7,'Eight':8,'Nine':9,'Ten':10,'Jack':11,'Queen':12,'King':13,'Ace':14} class Card: def __in...
5d5f994e396b2bcbb4fdba9c54087d9ca2d74545
yiamabhishek/Complete-Python-3-Bootcamp
/03-Methods and Functions/Level 1 Problems/Level1-3.py
326
3.890625
4
#ALMOST THERE: Given an integer n, return True if n is within 10 of either 100 or 200 def almost_there(a): if abs(100-a) <= 10 or abs(200-a)<=10: print("True") else: print("False") return ((abs(100-a))<=10) or (abs(200-a)<=10) almost_there(90) almost_there(104) almost_there(150) almost_ther...
1bf464441d6c4d6ab45297d3c525e2b49137d983
yiamabhishek/Complete-Python-3-Bootcamp
/04-Milestone Project 1/TicTacToe.py
3,785
3.9375
4
import random def player_first(): if random.randint(0,1) == 0: return 'Player 1' else: return 'Player 2' def player_choose(): choose = '' while choose != 'X' or choose != 'O': choose=input('Player 1: X or O :').upper() if choose == 'X': retur...
76ed312383ea52ed71aa22749b8064dfff0c0d86
bramirez96/CS2.2-Practice
/weeklyinterviewq.py
206
3.75
4
x = { "cat": "bob", "dog": 23, 19: 18, 90: "fish" } total = 0 for key, value in x.items(): # if type(value) == int: if isinstance(value, int): total += value print(total)
1479ee9a7158e1676ce68e55e7afae5967de0903
hmthanh/Count_People_Gointo_Store
/myutils/rectangles.py
1,783
3.5625
4
import itertools class Rectangle: def intersection(self, other): a, b = self, other x1 = max(min(a.x1, a.x2), min(b.x1, b.x2)) y1 = max(min(a.y1, a.y2), min(b.y1, b.y2)) x2 = min(max(a.x1, a.x2), max(b.x1, b.x2)) y2 = min(max(a.y1, a.y2), max(b.y1, b.y2)) if x1 < x2...
fe2bbd7a21d7431b459bbc9f2196421efea9e572
nasifshah2017/PythonDictionaryDatabase
/app.py
735
3.609375
4
import mysql.connector # Storing the Database credentials in a variable # which we will use to connect to the Database sqlConnection = mysql.connector.connect( user = "ardit700_student", password = "ardit700_student", host = "108.167.140.122", database = "ardit700_pm1database" ) # Creating the cursor object to navig...
71be8de2b09fc224cd83e6d4842327d6774e8631
SebNik/Project-Euler
/1_1.py
678
3.9375
4
import timeit import time def v1(max=1000): print('We will check which Numbers are multiples of 3 5') print('Then we will sum them up') numbers=[] numbers_sum=0 for x in range(0,max): a=x%3 b=x%5 if a==0: numbers.append(x) numbers_sum+=x ...
90f8326982b9570e0ec4f364feb34f2960c59e56
SebNik/Project-Euler
/2_1_Grafik.py
745
3.71875
4
import timeit import matplotlib.pyplot as pl def v2(max=100): a=1 b=2 c=0 f_sum=3 f=[1,2] f_ev=[] f_ev_sum=2 while c<max: c=a+b if c%2==0: f_ev.append(c) f_ev_sum+=c f_sum+=c f.append(c) a=b b=c ...
dfdbba302dc1bf3d62be245b682f110c462b8af4
SebNik/Project-Euler
/33_1.py
982
3.5
4
import timeit def v33_1(): from fractions import Fraction #numerator/denominator fractions=1 for a in range(10,100): for b in range(a+1,100): common_elements=list(set(str(a))&set(str(b))) if (len(common_elements)!=0): #print(a,b,common_elements) ...
298f162a5ff194c7fca63051dee71b2e829ae047
SebNik/Project-Euler
/7_4.py
1,002
3.828125
4
import timeit import time def sieve(limit=22): bools = [] primes = [] # generate a list of booleans all set to True initially # the list is indexed from 2 to limit representing all numbers # e.g. [True, True, True, True] = [2, 3, 4, 5] for i in range(1, limit): bools.append(True) pri...
c401ff6000474414766201bc1be1429b1ced7154
LuckyJoey/Python
/ex40.py
411
3.8125
4
# class Song(object): # def __init__(self, lyrics): # self.lyrics = lyrics # # def sing_me_a_song(self): # for line in self.lyrics: # print("line:",line) # # happy_bday = Song("happy") # happy_bday.sing_me_a_song() class Dance(): def __init__(self, dance): self.dance = dance def Dance(self): for line...
a0cf50c2d0965372b6a96379f0f4b7cb6f884891
LuckyJoey/Python
/ex42.py
372
3.75
4
class Person(object): def __init__(self,name): print("I am :",name) class Man(Person): def __init__(self,name): super(Man,self).__init__(name) print("I am Man") class OldClass: def __init__(self): print(self) #zhangsan = Man("Zhangsan") #lisi = Person("Lisi") print(type(Person), " ", type(Man), " ", type(Old...
fc402c09fd82b62830551a943685593a7938e151
LuckyJoey/Python
/ex44.py
1,120
3.609375
4
# class Parent(object): # def implicit(self): # print("PARENT implicit()") # class Child(Parent): # pass # dad = Parent() # son = Child() # dad.implicit() # son.implicit() # class Parent(object): # def override(self): # print("Parent override()") # class Child(object): # def override(self): # print("Child ov...
69b2eeee6eec57cecd0b686dd7878badd40ff5c2
LuckyJoey/Python
/ex9.py
219
3.5625
4
# Here's some new strange stuff, remember type it exactly days = "Mon Tue Wed Thu Fri Sat Sun" months = "\nJan\nFeb\nMar" print("Here are the days:",days) print("Here are the months:",months) print("""abc There's """)
76adf488e08723ac32acf659824aeccae06abd9f
AnimaDash/Coding
/squaresum.py
514
3.921875
4
def range_sum(range): sum = 0 i = 1 while i <= range: sum += i i += 1 return sum def num_square(num): return num * num def num_square_range_sum(range): sum = 0 i = 1 while i <= range: sum += num_square(i) i += 1 return sum if __na...
e095d25c5daf57528d38cf78ac45ef60051c9af0
seyed-ali-mirzaee-zohan/Assignment-3
/number1.py
2,539
3.890625
4
import random print('** Welcome to the game **') print('** are you ready to start the game ? **') print(' YES or NO ? ') words_1=['air','age','art','bar','box','cap','cat','die','dog','gym'] words_2=['fish','bird','wing','boat','ship','tire','city','road','farm','room'] words_3=['house','school','office','lib...
83fa417d750b05b86266cc320cc1debd354ccaf2
WarFwog/F1M1PYT
/PYTB1L1PlayWIthPython/output.py
2,681
3.578125
4
Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> 2 + 2 4 >>> 3 * 10 30 >>> 100 - 10 90 >>> 25 / 5 5.0 >>> 10 / 3 3.3333333333333335 >>> 10 // 3 3 >>> print('Mijn naam is Brian') Mijn naam is Brian ...
83a6c30f699b9d937465c4e707cb7a1a400071d2
ManishVerma16/Web_Scrapping
/Beautiful_Soup/home_scrap.py
1,547
3.953125
4
# Scrapping a sample html page from bs4 import BeautifulSoup with open('home.html', 'r') as html_file: # opening the file in read mode content = html_file.read() # reading the html file # print(content) # printing the content of html file soup = BeautifulSoup(conte...
4df6c61c17e0deb5d189ba47565c7f328be7a82a
Toranian/Game-Mechanics
/test.py
630
3.5625
4
def trace(x, y, target_x, target_y): get_x = True get_y = True while True: if get_x: if x == target_x: get_x = False if x > target_x: x -= 1 if x < target_x: x += 1 if get_y: if y == target...
ff3eb3bcff189965711177aac66796ed55eaf2b7
Relishiya/Mine-game
/Minegame2.py
4,751
3.5625
4
from tkinter import * from tkinter.ttk import * import array import tkinter as tk import numpy as np import random import sys import test import copy import collections import random from tkinter import messagebox from random import randint root = tk.Tk() labels=[] string='Loc' print(" ") print("--...
67759d6b0c334259ca19ed8de0fb5774102246ed
sabin890/pytho-class
/list.py
1,796
3.765625
4
# a=[] # print(type(a)) # a=[1,2,3,3.5,True,None,"python"] # print(a[2]) # b=2*a[1] # print(b) #<<<<<<<<<<<<--------------------------------------------->>>>>>>>>>>> # empo=['ram','shyam','hari','gita','sita'] # print(empo) # empo.append("mira")#to add some thing in your list # print(empo) #<<<<<<<<<<<<------------...
aa902e4cdd286166f1a962b4230320da2febf6ae
sabin890/pytho-class
/calcu.py
201
3.796875
4
def calcu(num_1,num_2,aa): if(aa=="add"): return num_1+num_2 elif(aa=="diff"): return num_1-num_2 else: return num_1-num_2 result=calcu(10,5,"diff") print(result)
4c3de22edbf11e429bb0ef9ecef2ac4ee0745e40
sabin890/pytho-class
/hello.py
93
3.703125
4
total=0 for i in range(1,11): total+=i print(f"sum of ten natural number is : {total}")
02ebd9299dc080c193fbb67ce5c3c522e5980d0f
sabin890/pytho-class
/format.py
163
3.703125
4
a=10 b=30 c=a/b answer=("division of {1} and {0} is {2} ". format (a,b,c)) print(answer) # short cut d=10 e=20 r=d+e answere=(f"sum of {d} and {e} is {r}") print()
611eb320e845ba04b7a4289eccb81f94bd940e68
hayattokun/dsp
/python/q8_parsing.py
1,239
4.21875
4
#The football.csv file contains the results from the English Premier League. # The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of # goals scored for and against each team in that season (so Arsenal scored 79 goals # against opponents, and had 36 goals scored against them). Write a program to...
e48de959a120af7d8679633b13ca6f2d7745c0c0
nostromobs/SuScalculator
/sus.py
7,577
3.765625
4
import datetime class SuSTest: def __init__(self,one,two,three,four,five,six,seven,eight,nine,ten,even,odd,total,grade): self.one = one self.two = two self.three = three self.four = four self.five = five self.six = six self.seven = seven self.eight = ...
6bcdc929377c143c8fefcb7fe1c40a72cb066e5c
CTEC-121-Spring-2020/mod-4-programming-assignment-Ilya-panasev
/Prob-1/Prob-1.py
1,402
4.1875
4
# Module 5 # Programming Assignment 6 # Prob-1.py # Ilya Panasevich # INSTRUCTIONS: # Insert a comment above each line of code in the program below to describe # what the code does # imports the graphics library from graphics import * def main(): # creates a window where it draws your object ...
c1777133fbab5fb743575f09523851d5cd09fadd
SmallHedgehog/DistributeCrawler
/unittest/redis_example.py
1,921
3.546875
4
# coding: utf-8 """ Using qr(https://github.com/tnm/qr) to operate redis 分布式: (1)在Redis中初始化两条key-value数据,对应的key分别为spider.wait和spider.all (2)spider.wait的value是一个list队列,存放我们待抓取的URL,该数据类型方便我们实现 消息队列,我们使用lpush操作添加URL数据,同时使用brpop监听并获取URL数据。 (3)spider.all的value是一个集合,存放我们所有待抓取和已抓取的URL,该数据类型方便 我们实现排重操作,使用...
aa319edb672a8a678acbe7a192b8419563dddd19
GuilhermeBaldo/oulumetrics
/metrics.py
4,002
3.671875
4
def confusion_matrix(y_true, y_pred): ''' calculates the confusion matrix parameters: y_true (list): A list with the true values as in, 0 - negative 1 - positive y_pred (list): A list with the predictions as in, ...
c26b925dafc2105990ed3a09eb60d1b26e9b192a
gaurav-9721/Pygames
/Spacewar.py
4,608
3.5625
4
import pygame import math import random # Initializing Pygame pygame.init() # Setting our screen size screenX, screenY = 800, 600 screen = pygame.display.set_mode((screenX, screenY)) # Setting game title pygame.display.set_caption('Rebellious Shark') # Setting Game Icon icon = pygame.image.load('spaceship.png') pyg...
2a56b53f2086a316c05af919e68713e69eb23b54
ginyusquad/SO_AC3
/tabuleiro.py
3,311
3.8125
4
# -*- coding: utf-8 -*- # Números Primos felizes JOGADOR_BOLINHA = 7; JOGADOR_XIZINHO = 13; class Tabuleiro: pecas = { 0:" - ", JOGADOR_BOLINHA:" O ", JOGADOR_XIZINHO:" X " }; def __init__(self): self.estado = [[0,0,0], [0,0,0], ...
037f43a331eb21e20b33ed2d81ec8c37d43b9010
evukelic/NOS
/lab2/RSA.py
2,222
3.515625
4
from Cryptodome.PublicKey import RSA as _RSA from Cryptodome.Cipher import PKCS1_OAEP import Helper import base64 import Constants class RSA: """ Class RSA gives methods for encryption and decryption of wanted message, based on the given type of the key. """ def __init__(self, key, message, as_by...
06a2445d92d08bb0a59e5909bb0fc26318d3ffc7
Ieaglefalcon/Insight_Data_Engineer_Challenge
/runningMedian.py
908
3.59375
4
# This script is to compute a running median of the word count of a given text # Author: Ling Qi/lq38@cornell.edu # Parsing text... import math with open('test.txt') as f: lines = f.readlines() # Iterating through all items... length = [] median = [] for item in lines: lineLen = len(item.split()) ...
6918d3b756e57624f17344f42f2b5b69b9edbfb2
murenky/project-euler
/Python/euler1.py
241
3.515625
4
# Euler Project проблема 1 # найти сумму чисел от 1 до 1000, делящихся на 3 или 5 sum = 0 for i in range(3,1000,3): sum += i for j in range(5,1000,5): if j%3 != 0: sum += j print(sum)
7c6d110674ddcbb1234e2da17db7fbc39a9b9232
nium9/random_project_eurler
/P2.py
325
3.984375
4
first=1 second=2 even_total=0 while True: temp=first+second#perfroms the addition for the next term if second > 4000000: break if second%2==0: # check if the term is even even_total+=second #add it to the total first=second second=temp## switches the term print (even_tot...
28d82ba1edd0d442d031612ed1ae177fcf734576
bonifaciotorres/grafica-frutas
/encuesta.py
3,257
3.9375
4
# -*- coding: utf-8 -*- import matplotlib.pyplot as plt numero = [] while True: print"Selecione una opcion" print"1- Lista de numeros nombres de votantes" print"2- numeros de votos en total" print"3- crear lista para grafica" print"4- existencia lista" print"5- Grafico de votantes" print"6...
1b65f89f5bd77141c300a936b31b1ad7f54a982c
zyciac/ida
/yield.py
230
3.84375
4
def yield_func(): _list = [i for i in range(3)] for i in _list: yield i*i _long_list=[2*i for i in range(10)] for i in _long_list: yield i*10 a = yield_func() b = [item for item in a] print b
53d773d7443252f4c58286ebb2d8dfea6a6c3937
legend507/MyLeetCodeSolutions
/InterviewQuestions/n-gram/solution.py
891
3.53125
4
def ngram(text, n): words = text.split() # Control the index i s.t. I can always extract words[i:i+n]. return set([' '.join(words[i:i+n]) for i in range(0, len(words) -(n-1))]) text = 'I want to eat a lot of meat.' print(ngram(text, 4)) # Compare text1 and text2's n-gram similarity. def sharedngrams(text...
5f3c622bdced997519621d906f7bf0e00b74abd4
legend507/MyLeetCodeSolutions
/InterviewQuestions/ClassifySomeData/solution.py
846
3.78125
4
""" k-NN based. Using priority heap is a bonus. """ import heapq A = (1.0,2.0,3.0) B = (4.0,5.0) X = 4.0 K = 2 i = -1 heap = [] """ Traverse every element in A, B tuples, calc distance with X. Then append the distance with the lable i to heapq. """ # 1st loop: c = A (a tuple), 2nd loop: c = B (a tuple) for c in A,B:...
ebad570e7167b490a85431c3ba36adfdcbb42323
hyliang96/sharedotfile
/sizelist.py
1,844
3.75
4
# -*- coding: utf-8 -*- # 用法: # python sizelist.py 一个路径(缺省则为'.') # 返回该路径及其下各个文件和文件夹的大小,降序排列,按TGMK单位表示 import os, sys from hidden_cmd import hidden_command def human_size(num, suffix=''): for unit in ['K','M','G','T','P','E','Z']: if abs(num) < 1024.0: return "%3.1f%s%s" % (num, unit, suff...
583e9ab5a23f26690155296129149b6d1a062666
sambit221/diabetes-prediction
/linearRegressionModel2.py
1,588
3.90625
4
# Here we are not making a graph, rather we are taking all features to bring more accuracy to the Linear regression model import matplotlib.pyplot as plt import numpy as np from sklearn import datasets, linear_model from sklearn.metrics import mean_squared_error # using datasets diabetes = datasets.load_diabetes() #...
8c4fedcd07488a908488955f252e611c0abf8c4a
HyeongbinMun/python
/chapter32/reduce.py
96
3.546875
4
from functools import reduce def f(x, y): return x+y a = [1, 2, 3, 4,5] print(reduce(f, a))
47c46d40cbe57ce7435149a90463f2373295c7a0
HyeongbinMun/python
/chapter14/test.py
158
3.9375
4
x = 0 if x == 1: print("x=1") # 조건식을 만족할 때 코드 실행 else: print("x=0") # 조건식을 만족하지 않을 때 코드 실행
5d43d7447435624c2e56ec3665325237d969fda3
HyeongbinMun/python
/chapter24/test.py
241
3.953125
4
s = 'Hello, world!' s = s.replace('world!', 'Python') print(s) print('apple pear grape pineapple orange'.split()) print('{0} {0} {1} {1}'.format('Python', 'Script')) print('Hello, {language} {version}'.format(language='Python', version=3.7))
ce7870f3a03c605e2d5f2e451bfe18378cf19ce2
mohit5335/python-programs
/m_inherit.py
931
4.46875
4
#program to see the concept of multilevel inheritance in class class A: def __init__(self): print("I am in constructor of class A") def fun1(self): print("I am in class A") class B(A): #class B is inheriting class A def __init__(self): ...
39e1f60253eb2c65a1226487b4699445ce3487af
mohit5335/python-programs
/qequation.py
492
4.34375
4
#program to find the roots of a quadratic equation # ax**2 + bx + c = 0 # import complex module import cmath # take value of a,b and c from user a = float(input("Enter the value of a : ")) b = float(input("Enter the value of b : ")) c = float(input("Enter the value of c : ")) # calculating discriminant d = (b**2) - (4...
29defc87805a1dcc1321a99c5b1c877934e633d8
mohit5335/python-programs
/matrix.py
557
4.09375
4
# program to addition and multiplication of matrix # First Matrix x = [[1,2,3], [4,5,6], [7,8,9]] # Second Matrix y = [[1,2,3], [4,5,6], [7,8,9]] #Resultant Matrix add = [[0,0,0], [0,0,0], [0,0,0]] multi = [[0,0,0], [0,0,0], [0,0,0]] for i in range(len...
ccaec2795847d2c39fd42fd53e55672077426eeb
samsonlarsson/BootCamp-IX
/jreverse_str.py
238
3.84375
4
def reverse_string(s): n = len(s) reverse=[] while n>0: reverse.append(s[n-1]) n-=1 if ''.join(reverse) == s: return True else: return ''.join(reverse) print(reverse_string('jodom'))
c11e6a3e1e43f312dce0b3207ed334c04c7d19c7
AngleMAXIN/LeetCode_Problems
/19. 删除链表的倒数第N个节点.py
1,453
3.9375
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None # 上述算法可以优化为只使用一次遍历。我们可以使用两个指针而不是一个指针。第一个指针从列表的开头向前移动 n+1n+1 步, # 而第二个指针将从列表的开头出发。现在,这两个指针被 nn 个结点分开。 # 我们通过同时移动两个指针向前来保持这个恒定的间隔,直到第一个指针到达最后一个结点。 # 此时第二个指针将指向从最后一个结点数起的第 nn 个结点。我们重新链接第二个指针所引用的结点...
599e455fd62637a5e60e297ef67e0dd539bcab08
AngleMAXIN/LeetCode_Problems
/4_合并两个有序数组.py
426
3.828125
4
class Solution: def merge(self, nums1, m, nums2, n): """ Do not return anything, modify nums1 in-place instead. """ j = 0 for i in range(m,len(nums1)): nums1[i] = nums2[j] j = j + 1 # nums1.extend(nums2) nums1.sort() if __name__ == '__main_...
1568589f0e2d0a25b9065bd6ee0eaa5a326e062b
AngleMAXIN/LeetCode_Problems
/sorts.py
1,311
3.921875
4
def Qsort(nums,r,l): if r < l: part = partition(nums,r,l) Qsort(nums,r,part-1) Qsort(nums,part+1,l) return nums def partition(nums,left,right): low = left high = right # 取最右边的元素 cmp = nums[left] while low < high: while high > low and nums[high] >= cmp :...
681924fd339ad1dc284ff814bba5bf3c27b25f17
Bonnycastle/Cs1
/code/python/imperative/hs.py
586
3.78125
4
def hs(n): # define variables: # counter: default ? -> one line p = 0 # main procedure # while n != 1: # (1) output n # (2) update counter # (3) update n # if n%2 == 0: # n = ? # else # n = ? while (n != 1): print (n)...
d998f370d72a5fa4d76a8316a9870598e9216bde
Ler-Tor/uni_python
/Lab3/lab3.py
550
3.671875
4
#Лабораторная работа 3 import os, sys def main(): while (1): files = file_search() def file_search(): dirs = os.listdir(".") lsts = filter(lambda x: x.endswith('.lst'), dirs) print(lsts) i = 1 print("Список файлов: ") for file in lsts: if lsts == 1: #####Переписать ...
6dfb130b0b68775aeb04340e4b98b6e71d7f4a2e
Ler-Tor/uni_python
/Sem_3.py
1,590
3.734375
4
#Var 6 def Zadanie_1(): F = {'Russia': ['Europe', 12121212], 'Germany': ['Europe', 12121212], 'uwehi' : ['sasa', 21212] } user_input = str(input()) land = 0 for k, val in F.items(): if(val[0] == user_input): print(k) land = land + va...
f50a96e0ae06f4a0de756d098fcb0f12143800cb
Ler-Tor/uni_python
/Sem4_2.py
831
3.71875
4
#Вариант 4 symbol = str(input()) width = int(input()) height = int(input()) def dec(f): global symbol, width, height if len(symbol) != 1: raise Exception( "Переменная symbol должна быть односимвольной строкой" ) if width <= 2: raise Exception( "Значение width должно превышать 2" ) if hei...
06bf1b921eace872a1d9d6bfe265e4ef851dfa71
rlopezcnm/its-python
/ex6
970
3.53125
4
#!/usr/bin/python # # File: ex6 # Author: Robert Lopez # # Started on Mon Jun 11 17:59:28 2012 # Last-Updated Mon Jun 11 17:59:28 2012 # # Description: Ex6 LpTHw e2 # ### Global Variable Assignments binary = "binary" do_not = "don't" hilarious = False # Vars includes format specification. x = "In this world...
c358c73a63e5e0b745bdf26d0314da1a8afbec9d
bmarchenko/banking
/bankingParent.py
1,089
3.921875
4
class deposit: #1% a month simple interest def __init__(self, name, depsum, depperiod, depfinal, interest): self.name = name self.depsum = depsum self.depperiod = depperiod self.depfinal = depfinal self.interest = interest print "Created a profile for "+ name de...
d3c87477a21b80af86a90aa536cf990e4b98beea
Aestroix/CP_templates
/Dynamic_Programming/KNAPSACK/knapsack.py
1,032
3.546875
4
# To IDENTIFY THE DP PROBLEM IT HAS TWO PARTS: # 1.) CHOICE 2.) OPTIMAL SOULUTION REQD. # PARENT OF DP IS RECURSION # FOR A KNAPSACK: ITEMS HAVE A WEIGHT AND VALUE AND A FIXED BOUND IS GIVEN ON THE STORAGE OF THE BAG. # IDENTIFYING THE MAX PROFIT OR MINIMUM SOMETHING... #CHOICE DIAGRAM>>>>>>>>>>>>> # WT: ...
c34029dea4c1596c78293b097eae3a046d38b3b4
Aestroix/CP_templates
/binary_search.py
889
4.25
4
def binary_search(li, val, lb, ub): ''' li: stores the list of numbers to search upon in ascending order val: value to be searched for lb: starting index ub: ending index This function searches for the val in li and return 0: if the value is not present 1: if the value is present ''' ans = 0 while(lb <= ub...
86dd78ef238d09aaf36530181d40f70165960426
WarrenElliot/Python-Projects
/Quick-Sort.py
2,204
4.28125
4
#Implementation of Quick Sort #arr[] -- array to sort; low -- starting index; high -- ending index from random import seed from random import randint def partition(arr, low, high): i = (low -1) pivot = arr[high] for j in range(low, high): if arr[j] <= pivot: i=i+1 ...
23bb35089f36c5c6d5e573d0e794d7b2c871f8c2
mahta-khoobi/PythonSpecialization_Coursera
/3- Accessing Web Data/1- RegularExpressions.py
800
4.25
4
## In this assignment you will read through and parse a file with text and #numbers. You will extract all the numbers in the file and compute the sum of #the numbers. ## ##The basic outline of this problem is to read the file, look for integers using ##the re.findall(), looking for a regular expression of '[0-9]...
37e6955bdd15a1255f1d47d798491c006ca68c5d
mahta-khoobi/PythonSpecialization_Coursera
/Tutorial/Sec5_Functions.py
1,315
4.34375
4
#Functions: def HelloWorld(): print('Hello World!') return HelloWorld() # function with default argument def DivideNumbers(a,b=1): return(a/b) print(DivideNumbers(6,3)) print(DivideNumbers(3)) #Lambda Function: Anonymous functions # The def keyword is used to define a function in ...
945c799f2c2acd93c705569027a636bd2bfb91d6
felipechiarotti/development
/python/python_learning/car-speed.py
132
3.875
4
speed = float(input("Digite a velocidade de seu carro: ")) if speed > 80: print("Você foi multado em R$%.2f!" % ((speed-80)*5))
61adcb0bca5319f1756be636b5b7e715fc573365
felipechiarotti/development
/python/python_learning/6-lists.py
1,336
4.125
4
lista_vazia = [] #Cria uma Lista Vazia lista_elementos = [ 15, 8, 9 ] #Cria uma Lista de Inteiros lista_elementos[0] #Acessa o primeiro elemento lista_elementos[0] = 7 #Seta o primeiro elemento lista_copia_referencia = lista_elementos #Copia a lista por referência lista_copia_real = lista_elementos[:] #Faz uma copia d...
bcc780e63e29976d736f64c9f6404112b9acbc2d
felipechiarotti/development
/python/python_learning/6.49-dicionario.py
787
4.03125
4
tabela = {"Alface": 0.45, "Batata": 0.32, "Tomate": 2.30} print(tabela.keys()) print(tabela.values()) while True: option = input("Deseja Visualizar(v), Adicionar(a) ou Remover(r)?: ") produto = input("Digite o nome do produto: ") if option == "fim": break elif option == "v": if produto...
a9f0de9662a3d03f4d0c48896e5b9450337a936b
felipechiarotti/development
/python/python_learning/m-to-mm.py
104
3.734375
4
meter = float(input("Digite um valor (m): ")) print("%.1fm corresponde a %.1fmm" % (meter, meter*1000))
60703529b8601346be8b8ecc6d1068ec5dabe678
felipechiarotti/development
/python/python_learning/aumento-salario.py
236
3.75
4
salary = float(input("Digite o Salário: ")) percent = float(input("Digite a porcentagem do aumento: "))/100 aumento = salary*percent result = salary + aumento print("O Novo salario é %.2f, com um aumento de %.2f" % (result,aumento))
046334ef6e062b7eba0433300e2529935224e633
kposada1/pycharmalgoritmos
/propuesto 10.py
2,124
3.796875
4
'''Un alumno desea saber cual será su promedio general en las tres materias mas difíciles que cursa y cual será el promedio que obtendrá en cada una de ellas. Estas materias se evalúan como se muestra a continuación: La calificación de Matemáticas se obtiene de la sig. manera: Examen 90% Promedio de tareas 10% En esta ...
9a22601b0c763850f2c604d84055168cab512610
amusecode/amuse-sandbox
/vdhelm/roche_surface_plot.py
3,242
3.609375
4
""" Plot the actual shape of the Roche lobe in a circular orbit. """ import numpy from amuse.units import units, constants, quantities from amuse.datamodel import Particles from matplotlib import pyplot from amuse.plot import plot length_unit = units.AU potential_unit = (units.AU/units.yr)**2 def potential_from...
d6f5257d2e5ee3c7fa8ee1472b50baccea69cf41
amusecode/amuse-sandbox
/vdhelm/cooling.py
3,076
3.640625
4
""" Implementation of gas cooling functions for a set of gas particles. """ import numpy from amuse.units import units, quantities, constants class Cooling(object): def __init__(self, particles): self.particles = particles self.cooling_function = self.my_cooling_function self.heating_func...
34e547b7495258e4a6db4149d154d83118430d8f
TotoWang-hhh/laptop-s5
/当数学遇上Python/伊登数学推理例9.py
460
3.53125
4
num=int(input('请输入日期的和 ')) days=int(input('请输入外出的天数 ')) time=1#尝试次数(外出日期) getAns=False#获得答案 temp=0#天数和 while not getAns: for i in range(1,days+1): temp+=i+time print('调试信息:temp=%s'%temp) if time==num: getAns=True print('答案为'+str(time)) break else: ...
f175479b8ea36931aa5b41b633143ed46dd4f52c
ahammad127/University-Year-2
/Section 4/Q4.1.py
173
3.734375
4
def f(x): #Defines the function as f() y = ((x**4)*(1-x)**4)/(1+x**2) #This is the equation given return y #Returns the value of the function on a certain value of x
74ef507a47a1727215c0d74efb9d554a2a3cf410
ahammad127/University-Year-2
/Section 6/Q6.5.py
2,809
4.15625
4
def f(y, t): return -y + 1.0 #Function to calculate the slope at a point def odestep(f, y, t, dt): '''Uses slope at A to calculate B' (denoted as Bp), then calculates slope at B', then takes the average of the slopes to use as the linear slope to calculate B from A''' Aslope = f(y,t) ...
c2589dd1ffe7c123848252b06e734ca1f0a837f9
SFZhang26/Algorithm
/leetcode/countBattleships.py
508
3.765625
4
# 419. Battleships in a Board class Solution(object): def countBattleships(self, board): """ :type board: List[List[str]] :rtype: int """ result=0 for i in range(len(board)): for j in range(len(board[0])): if board[i][j]=='X': ...
a61c579e32c4972e4603580a5e759748a69bd409
SFZhang26/Algorithm
/leetcode/addOneRow.py
959
3.75
4
# 623. Add One Row to Tree # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def addOneRow(self, root, v, d): """ :type root: TreeNode :type v: in...
8027804523bb08ae53627d2c1781b97b1c8cb890
SFZhang26/Algorithm
/leetcode/findRestaurant.py
568
3.625
4
# 599. Minimum Index Sum of Two Lists class Solution(object): def findRestaurant(self, list1, list2): """ :type list1: List[str] :type list2: List[str] :rtype: List[str] """ index=len(list1)+len(list2) re=[] for i in range(len(list1)): if ...
8f38a0d524a9e44f7e45f7cf509e4e0e17656782
SFZhang26/Algorithm
/leetcode/findFrequentTreeSum.py
911
3.515625
4
# 508. Most Frequent Subtree Sum # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def findFrequentTreeSum(self, root): """ :type root: TreeNode :...
c04bd3383a2440894c0c7e0cc8d63e99e18f927d
SFZhang26/Algorithm
/leetcode/canMeasureWater.py
333
3.59375
4
# 365. Water and Jug Problem class Solution(object): def canMeasureWater(self, x, y, z): """ :type x: int :type y: int :type z: int :rtype: bool """ return z==0 or (z<=x+y and z%self.gcd(x,y)==0) def gcd(self, x, y): return x if y==0 else sel...
1bac3b35ae3653210b0cf877223fb80ec723f5c2
SFZhang26/Algorithm
/leetcode/addBinary.py
1,487
3.59375
4
# 67. Add Binary class Solution(object): def addBinary(self, a, b): """ :type a: str :type b: str :rtype: str """ if len(a)<len(b): temp=b b=a a=temp result="" flag=False for i in range(len(b))...
208f18f6532c033d002e3df3a03fb984667ab457
SFZhang26/Algorithm
/leetcode/lengthOfLastWord.py
449
3.609375
4
# 58. Length of Last Word class Solution(object): def lengthOfLastWord(self, s): """ :type s: str :rtype: int """ count=0 flag=False for i in s[::-1]: if i==' ': if flag: return count else: ...
c009c52c972c8c255125ec70157c3ef384407c08
SFZhang26/Algorithm
/leetcode/findMinMoves.py
550
3.53125
4
# 517. Super Washing Machines class Solution(object): def findMinMoves(self, machines): """ :type machines: List[int] :rtype: int """ if len(machines)<=1: return 0 total=sum(machines) if total%len(machines)!=0: return -1 left=0...
455dc7a2f2ebb7975ba3a23cfe93ac11691f98b3
SFZhang26/Algorithm
/leetcode/findUnsortedSubarray.py
393
3.578125
4
# 581. Shortest Unsorted Continuous Subarray class Solution(object): def findUnsortedSubarray(self, nums): """ :type nums: List[int] :rtype: int """ copy=sorted(nums) i, j = 0, len(nums)-1 while i<len(nums) and nums[i]==copy[i]: i+=1 while...
821bfd01c34f8734453441de18054f5b8b18e179
SFZhang26/Algorithm
/leetcode/removeDuplicates.py
347
3.515625
4
# 80. Remove Duplicates from Sorted Array II class Solution(object): def removeDuplicates(self, nums): """ :type nums: List[int] :rtype: int """ pos=0 for i in nums: if pos<2 or nums[pos-2]!=i: nums[pos]=i ...
a90535037cfccdd0fce06f7f688ea987bdb42441
SFZhang26/Algorithm
/leetcode/reverse.py
392
3.5625
4
# 7. Reverse Integer class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ result=0 n=abs(x) while n>0: result=result*10+n%10 if result>2147483647: return 0 n/=10 if...
4791e649b7de3e3d30c112dea18e1b652c840d55
SFZhang26/Algorithm
/leetcode/reverseWords.py
349
3.828125
4
# 151. Reverse Words in a String from functools import reduce class Solution(object): def reverseWords(self, s): """ :type s: str :rtype: str """ words=s.split(' ') words=[word for word in filter(lambda x:x != '', words[::-1])] return reduce(lambda x,y:x+" "...
70fa1c62764ffe6fbea47da6cd05df118cdbe9a0
roycephillipsjr/LPTHW
/ex39_a.py
990
4.125
4
great_state = {'Dallas': 'TX', 'Austin': 'TX', 'Houston': 'TX',} print('-' * 10) for city, state in list(great_state.items()): print(f"The great state of Texas has beautiful {city} in it's state!") print('-' * 10) print("There are more beautiful cities to add!!") more_texas = {'San...
b478299b303690c10f0b861a0acc60ac1869cd82
roycephillipsjr/LPTHW
/ex15.py
1,055
4.65625
5
# This line of code is pulling from the system the argument variable (argv) from sys import argv # Here we are giving the information we want in the argv # Which we have two "script" and "filename" script, filename = argv # Here we are giving a variable name to the file name. BUT to be able to read it # we have to op...
5fe3a512dda6c926704692fc45e285cc28aed251
roycephillipsjr/LPTHW
/ex8.py
789
3.609375
4
formatter = " {} {} {} {}" print(formatter.format(1, 2, 3, 4)) print(formatter.format("one", "two", "three", "four")) print(formatter.format(True, False, False, True)) print(formatter.format(formatter, formatter, formatter, formatter)) print(formatter.format( "Try your", "Own text here", "Maybe a poem", ...