blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
5c8d2ed2f439cd39cff564160e5f9a56bb519291
jjenner689/Python
/algorithms_and_data_structure_questions/stacks.py
2,212
3.859375
4
''' These are some useful data structures. Sets are just like mathmatical sets. You can turn an array/list into a set with the set() function. A set contains a unique set of elements, no duplicates. It supports operations like union, intersetion and difference between two sets. They both can work with a basic array...
363cca8a73b476ec51c9aa1c41f72601af2c632c
suhyeonjin/CodePractice
/Baekjoon/2504.py
1,269
3.609375
4
# -*- coding: utf-8 -*- #Exercise 2504 ''' () 문자열이 존재하는지 여부 확인을 통해 해결. ''' def isVPS(PS): if (PS.count("[") != PS.count("]") or PS.count("(") != PS.count(")")): print 0 exit(0) for i in range(15): if ("[]" in PS or "()" in PS): PS = PS.replace("[]","") PS = PS.r...
f1701712b6d52289e778673e2796ae54e601f3a8
ursu1964/Algorithms-2
/AlgoExpert/Palindrome Check/palindromeCheck_3.py
352
3.765625
4
# O(n) time | O(n) space def isPalindrome(string, i = 0): j = len(string) - 1 - i return True if i >= j else string[i] == string[j] and isPalindrome(string, i + 1) #tail Recursive def isPalindrome(string, i = 0): j = len(string) - 1 - i if i >= j: return True if string[i] != string[j]: return False re...
6ceba4ce4f6f5ec3abd2ac630b9279456ffbcdfc
cldelahan/meancoreset
/timer.py
352
3.65625
4
import time class Timer: def __init__(self): self._start_time = None def start(self): self._start_time = time.perf_counter() def stop(self): """Stop the timer, and report the elapsed time""" elapsed_time = time.perf_counter() - self._start_time self._start_time = ...
ab39cab71793527be3fdd1840dcb4645d9271107
megantfanning/CrackingTheCodingInterview
/LL-ch2/LL.py
1,153
3.984375
4
#Singlely Linked List class Node: def __init__(self,value): self.value = value self.nextNode = None class LinkedList: def __init__(self, value): aNode = Node(value) self.head = aNode self.tail = aNode def push(self, value): aNode = Node(value) s...
f9c6a152f32cc4c82aa9f4bdc7601a7dd1fdaff0
KaiyeZhou/LeetCode-repo
/sword2offer/反转链表.py
862
3.828125
4
''' 输入一个链表,反转链表后,输出新链表的表头。 ''' # -*- coding:utf-8 -*- # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # 返回ListNode def ReverseList(self, pHead): # write code here if not pHead: return pHead list1 = [] w...
b4c06d559e7c7eb4f38f391e78cb112b75bf52df
cmantoux/sparse-low-rank-decomposition
/src/generate.py
5,288
3.859375
4
""" This file contains functions to generate sparse low rank matrices and data sets as used in the paper. The main functions are sparse_low_rank and dataset. """ import numpy as np def sparse_low_rank_(n, d, sparsity, positive=False, symmetric=False): """ Auxiliary function to generate a square sparse low r...
3029ac1c35e5e2045306cb56b773811d8bca4406
MECERHED-Ferhat/Primality-Algorithms
/implemented_algorithms/algos/Lucas.py
767
3.859375
4
from random import randint import sys P = sys.stdin.read() PRECISION = 20 def prime_factors(n): i = 2 factors = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(i) if n > 1: factors.append(n) return factors def is_probably_prime(n): if n < 3 or not n % 2: return number == 2...
42cb1e489d064a5d5a544c6deafea58ce545b3f2
June-fu/python365
/2020/02february/31-my_ip.py
674
4.1875
4
#!/usr/bin/python # -*- coding: UTF-8 -*- # Author: june-fu # Date : 2020/2/26 """ Problem 10: Write a program myip.py to print the external IP address of the machine. Use the response from http://httpbin.org/get and read the IP address from there. The program should print only the IP address and nothing else. """ ...
f99c0a2b2692d097e2eb47e6ce80041ca607dce5
mnvx/neonka
/network/network_abstract.py
743
3.75
4
from abc import abstractmethod import numpy class NetworkAbstract: def __repr__(self): return self.__str__() def __str__(self): result = '' for l, layer in enumerate(self.neurons): result += "Layer %s:\n" % (l + 1) for k, neuron in enumerate(layer): ...
6a187934d9d93da3a0fc92fcd3184ee49cbdc190
juan2357/test
/Udacity/fswd/introToPython/classes/turtles/square1.py
425
3.765625
4
import turtle def drawSquare(x): for i in range (1, 5): x.forward(100) x.right(90) def drawArt(): window = turtle.Screen() window.bgcolor("red") juan = turtle.Turtle() juan.shape("turtle") juan.color("yellow") juan.speed(.2) for i in range(1, 37): drawSquare(ju...
db7b70a0133c38761f920c7e39bcca6b22eb798a
akshatfulfagar12345/EDUYEAR-PYTHON-20
/day 6(counting no of vowels).py
246
3.90625
4
sentence = input('Enter the sentence:') string = sentence.lower() print(string) count = 0 list1 = ['a','e','i','o','u'] for char in string: if char in list1: count = count+1 print('number of vowels in given sentence:',count)
bdf3f8f83647303ea3e9feb1f41f28f1ae06c277
wsnijder/PycharmProjects
/Week_6_Python/Exercise_1/5.1.19.7.py
172
4.40625
4
def reverse(input): rev_string = input[::-1] return rev_string text = input("What is the word you want to reverse?") print("The word backwards is", reverse(text))
a71386ba660c7859c3352110ae0b9a2fcba6a120
victorfengming/python_projects
/history_pro/python_ydma/Python高级阶段/day01/面向对象最终篇/method.py
684
3.546875
4
#声明一个类 class Human: #成员方法 #吃方法 ->对象方法 def eat(self): print(self) print('这是一个对象方法') #喝方法 ->类方法 @classmethod def drink(cls): print(cls) print('这是一个类方法') #玩方法 -> 绑定类的方法 def play(): print('绑定类的方法') #乐方法 - > 静态方法 @staticmethod def happy...
b0fb14ecd384cf9450b4beefbca2dfb7c30235db
marioacc/dataStructuresAndAlgorithmsRanceD.Necaise
/sparsematrix.py
5,103
3.546875
4
#Implementation of the Sparse Matrix ADT using List class SparseMatrix: def __init__(self,numRows,numCols): self._numRows=numRows self._numCols=numCols self._elementList=list() #Return the number of rows in the matrix def numRows(self): return self._numRows #Return the number of columns in the matrix ...
e6dfa27235320fbd42cba730c3834626add5a6dd
anish531213/Interesting-Python-problems
/remove_duplicates.py
195
3.734375
4
def remove_duplicates(l): new = [] for i in l: if i not in new: new.append(i) return new z = remove_duplicates([1, 2, 3, 3, 3, 5]) print(z)
b2d6be7193343293906a2b4bd5665d821c171799
d0ugal/mkdocs
/mkdocs/toc.py
3,870
3.5625
4
# coding: utf-8 """ Deals with generating the per-page table of contents. For the sake of simplicity we use an existing markdown extension to generate an HTML table of contents, and then parse that into the underlying data. The steps we take to generate a table of contents are: * Pre-process the markdown, injecting...
294e0a0fa79167f4976562b04895e7bf36fdcf08
elbuo8/codeEval
/BitPositions.py
160
3.53125
4
import sys file = open(sys.argv[1]) for line in file: n, p1, p2 = map(int, line.split(',')) if (n&p1 == n&p2): print 'true' else: print 'false'
9725639451acebf56c9e8cb80a253f692d14cb68
brandoneng000/LeetCode
/medium/707.py
1,826
3.5625
4
class Node: def __init__(self, val = 0, next = None) -> None: self.val = val self.next = next class MyLinkedList: def __init__(self): self.size = 0 self.head = None def get(self, index: int) -> int: if self.size <= index: return -1 temp...
2cc5decf23b5003807377663e5f55b83ac03cb48
tzhou2018/LeetCode
/other/otherLeetcode/113pathSum.py
753
3.515625
4
""" @Time : 2020/7/28 20:32 @FileName: 113pathSum.py @Author : Solarzhou @Email : t-zhou@foxmail.com """ class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def pathSum(self, root: TreeNode, target: int): if not root: ...
698d4ebe9e5e701c6e7dc2585e3fa6bc182d7140
adelyalbuquerque/projetos_adely
/exercicios_listas/vetor_10_caracteres.py
462
3.703125
4
lista_caracteres_consoantes = [] lista_caracteres_vogais = [] i = 1 while i <= 10: caracteres = str(input("Insira o caracter {}: ".format(i))) if caracteres == "a" or caracteres == "e" or caracteres == "i" or caracteres == "o" or caracteres == "u": lista_caracteres_vogais.append(caracteres) else: ...
79ba8ea16affaa1f0806d3acb221a4e15f460d25
cashgithubs/HJYUtility
/gamble_simulation.py
2,097
3.8125
4
# -*- coding: utf-8 -*- #!/usr/bin/env python from random import randint # 我想测试的是这样的: # 进行1000局50%胜负,其中每赢一次就加倍投注,连赢X(x赋值2~10进行试验)次就立即结束游戏。 # 连赢被中断则投注回归1.玩家初始值为零,求500000个玩家在游戏结束时的值的分布。 def one_sample(total_times = 1000, time_to_quit = 10): histoty = list() grade = 0 bet = 1 for x in xrange(0,tota...
23324b9e7fdf34eaf22d7f82359170e2d0262cc4
raffomartini/pydocker-test
/test_mail.py
1,335
3.59375
4
''' https://docs.python.org/3/library/email-examples.html ''' # import smtplib # server = smtplib.SMTP('outbound.cisco.com', 25) # Import smtplib for the actual sending function import smtplib # Here are the email package modules we'll need from email.mime.text import MIMEText from email.mime.image import MIMEImage ...
0b834bd51ef1bc6329d42415a0bf36c648b954dc
yifor01/Leetcode-Practice
/code/leetcode_617.py
2,016
3.96875
4
# 617. Merge Two Binary Trees (Easy) ''' Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge them into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as th...
2bba340ff850c2f83b4e9f8dfb3198b8199b7be3
kvanst3/LeetCode
/palindrome_num.py
522
3.640625
4
class StrSolution: """Solution converting to string""" def isPalindrome(self, x: int) -> bool: rev_x = str(x)[::-1] if rev_x == str(x): return True class IntSolution: def isPalindrome(self, x: int) -> bool: if x >= 0: rev_num = 0 ori_num = x ...
434735a020e92b01af5e35f3926d90b209c73102
anyadao/hw_python_introduction
/hw23.py
985
4.1875
4
# 23. Случайным образом программа выбирает целое число от 1 до 10 и предлагает пользователю его угадать. # Пользователь вводит число, а программа проверяет его и, если пользователь не угадал, то говорит больше или меньше. # После чего опять просит угадать. И так пока пользователь не угадает выбранное число. impor...
cba1e2580ecd0c5b786d3d814ab37c55e79ec66e
mngugi/Mathematical-Terms-and-Formulae-for-Secondary-Schools
/rangeofoddnumbers.py
238
4.46875
4
# -*- coding: utf-8 -*- """ Spyder Editor Author : Mwangi Purpose : a simple program to print a range of odd numbers using a for loop """ # prints odd numbers from 3 to 15 for i in range(3,15,2): print(i)
dae9ef9be34868fe1ededb1f7f3ca3f072aa2324
emilymorgado/markov
/markov.py
2,233
4.0625
4
from random import choice from sys import argv input_file = argv[1] def open_and_read_file(file_path): """Takes file path as string; returns text as string. Takes a string that is a file path, opens the file, and turns the file's contents as one string of text. """ file_contents = open(file_path...
6c7ab7c6affeb167420f6496facc91bc1e6caad3
bufordsharkley/monopoly
/monopoly.py
4,753
3.59375
4
import random PAY_TO_ESCAPE_JAIL = False PLAYERS = 3 HOUSES = 0 HOTELS = 0 class Player(object): @property def in_jail(self): return bool(self.days_in_jail) @in_jail.setter def in_jail(self, jail_bool): if jail_bool is False: self.days_in_jail = 0 else: ...
fafbc3de61deb6ff6ab7839a4fb1940394b98bb7
greseam/Year_1_Python_practice_SMG
/HW4/SMG_mod4_hw2_3.py
756
3.78125
4
####### #Bullseye # #Sean Gregor # #desc: draw a target ####### """ start setup window as 'bullseye' with coordinates in main function: define circle parameters set up list of colors for loop in range of [colors] define circle set color relative ...
7d0864561d4f5f73fd28ceea2925f2066e5c9058
aviral36/hangman
/hangman.py
2,644
3.5625
4
import tkinter as tk from PIL import ImageTk, Image import random f = open('english_words.txt', 'r') words = f.read().splitlines() #make a list of all words f.close() #we don't need the file now, so close it #making list with only words that are 4 or more letters word_list = list() for word i...
48c653ab56fca1a0966bd464c328beabde6a072c
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH05/EX5.3.py
364
4
4
# 5.3 (Conversion from kilograms to pounds) Write a program that displays the following # table (note that 1 kilogram is 2.2 pounds): # Kilograms Pounds # 1 2.2 # 3 6.6 # ... # 197 433.4 # 199 437.8 KILOGRAM_TO_POUND = 2.2 print("Kilograms", format("Pounds", "8s")) for i in range(1, 200,2): pound = i * KILOGRAM_TO...
3982d5151f9ea3b18f74f177df3fc13c6684c66f
bhargavi1poyekar/Decision-Making-and-Business-Intelligence
/lab1a.py
4,743
3.515625
4
""" Name:Bhargavi Poyekar BE COMPS/ Batch-C UID: 2018130040 Roll No:45 Date of lab: 25/08/21 Aim: 1a) To implement SAW and WPM method for a given problem [General] """ # importing libraries import random import numpy import pandas as pd import csv # SAW method def saw(): for i in range(N): ...
d4f5835138ccf3561abd0f986fd0fb97db78f0f5
ashurja/Project4
/fan quiz.py
5,768
4.28125
4
# Jamshed Ashurov # 09/29/2017 # fan quiz.py # This program creates a Pirates of Caribbean: Dead Man Tell No Tales quiz! print("Welcome to the Pirates of the Caribbean: Dead Man Tell No Tales quiz!") print("Get ready,because you are about to use your brain like you never did!") print("Let's go!") def question_1(): ...
d6f369b1e3b92cd8ef5e44f11d7b22bf8637b21f
Dimasik007/python_car_game
/car_game.py
13,244
3.71875
4
"simple car game developed in Pygame" "win the game by getting 50 points" import sys import time import random from pygame import * from pygame.locals import * WIDTH = 800 # screen width HEIGHT = 600 # screen height BORDER = 10 # road border RIGHTROAD = 500 LEFTROAD = 90 FRAMERATE = 60 # to put in clock...
e58af60e268d8d224a8ac3bac94837f8d1099f58
yoshikipom/leetcode
/solve_1/191.number-of-1-bits.py
291
3.5
4
# # @lc app=leetcode id=191 lang=python3 # # [191] Number of 1 Bits # # @lc code=start class Solution: def hammingWeight(self, n: int) -> int: result = 0 for c in bin(n): if c == '1': result += 1 return result # @lc code=end
a2891f4f52d48cb4389283eae04427b127d6acd6
ViniciusDamiani/infosatc-lp-avaliativo-08
/Ling. Programação - Erros e Exceções.py
1,814
4.0625
4
#!/usr/bin/env python # coding: utf-8 # In[27]: print ('-' * 30) print ('ERROS E EXCEÇÕES') print ('-' * 30) # In[ ]: #voce acha que esse comando dará erro? # In[3]: print('oii') # In[4]: print(x) # In[5]: x= 2 print(x) # In[8]: n = int(input('digite um número: ')) # In[13]: a = int(input('...
8aeb08d0822c3a24bd58cedf82db762e9e2399e0
Vivek9Chavan/DeepLearning.AI-TensorFlow-Developer-Professional-Certificate
/Course_1_Week_4_Project_3.py
2,420
3.90625
4
""" This is is a part of the DeepLearning.AI TensorFlow Developer Professional Certificate offered on Coursera. All copyrights belong to them. I am sharing this work here to showcase the projects I have worked on Course: Introduction to TensorFlow for Artificial Intelligence, Machine Learning, and Deep Learning ...
4cf505427465e1d82535e4a871f2ae9ac559b065
TinaCloud/Python
/lynda/07 Loops/loopcontrol--working.py
573
3.75
4
#!/usr/bin/python3 # break.py by Bill Weinman [http://bw.org/] # This is an exercise file from Python 3 Essential Training on lynda.com # Copyright 2010 The BearHeart Group, LLC def main(): s = 'this is a string' i = 0 for c in s: if c == "s": continue # elif c == "g": # ...
7fd8f3501d2bd5792e52a0b58b59f29cce416817
dark-shade/CompetitiveCoding
/LeetCode/332/88.py
801
3.640625
4
class Solution: def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None: """ Do not return anything, modify nums1 in-place instead. """ p1 = m-1 p2 = n-1 ins = m+n-1 while p1 >= 0 or p2 >= 0: if p1 >= 0 and p2 >= 0: ...
971a8e5b96edc1d254e9de7b683fc5d9bed401ef
MotazBellah/Code-Challenge
/project3-problems-vs-algorithms/problem_4.py
1,536
4.15625
4
def sort_012(input_list): """ Given an input array consisting on only 0, 1, and 2, sort the array in a single traversal. Args: input_list(list): List to be sorted """ def swap(j, k): x = a[j] a[j] = a[k] a[k] = x a = input_list.copy() p0 = 0 p2 = len(a) ...
0345864ee864ad1f1bc9f850b8f33dae1f936439
roflmaostc/Euler-Problems
/070.py
1,480
3.640625
4
#!/usr/bin/python """ Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number of positive numbers less than or equal to n which are relatively prime to n. For example, as 1, 2, 4, 5, 7, and 8, are all less than nine and relatively prime to nine, φ(9)=6. The number 1 is consi...
e895aa40f1747dc5c54ad10b78e1b6f993e1422d
alejopijuan/Python-Projects
/Filtering Words and Formatting Dates/formatDate.py
555
4.375
4
#! /usr/bin/env python3 # Alejo Pijuan # 10/20/16 """This program should ask for the user to input the date as month day, year.The program should then convert it to the day month year format and display its output.""" def formatDate(us): eu=us.split() month=eu[0] day=eu[1][:-1] year=eu[2] ...
5767f183cb2e9f6f99eab62ef5735bc9feadc6f2
motorcyclegang/PyTorchStudy
/pythorch기초/13_function.py
368
3.921875
4
result = 0 def add(num): global result result += num return result print(add(3)) print(add(4)) result1 = 0 result2 = 0 def add1(num): global result1 result1 += num return result1 def add2(num): global result2 result2 += num return result2 print(add1(3))...
b34b61da24d9743e8d011e76ef68a7091398fc91
lakshaysethi/FakeGram
/clouds.py
1,159
3.765625
4
def jumpingOnClouds(c): clouds = [] # step_count=0 # [1,1,1,0,0,0,1,0,0,0,1] # clouds = [3,5 ] c = c.split(" ") for step in range(len(c) -1 ): if c[step] == 0: clouds.append(step) # check if it has a previous value index = len(clouds) -1 pr...
322312c0c97e1bacf140fefd04b3756b398e7f3c
wmarshid/prime-problem
/prime_times.py
2,163
3.8125
4
import timeit # Executes the 'prime_generator' sequence function (which utilities trial division) for different lengths. # Then executes the 'prime_generator' matrix function which multiplies these prime factors together to a multiplication table of prime numbers. if __name__ == "__main__": # runs timeit 'reps' ...
8b3b3ecdf99891269d73d52f5a9b3667051ce20e
UmVitor/python_int
/ex098.py
1,191
3.953125
4
#Faça um programa que tenha uma função chamada contador(), que receba tres #parametros: inicio, fim e passo e realize contagem. #seu programa tem que realizar três contagens atraves da função criada #a) de 1 ate 10, de 1 em 1 #B) de 10 até 0 de 2 em 2 #c) um contagem personalisada from time import sleep de...
a25a6c099ed8103246a6767b8c1b6a043a043eca
qixiaoxioa/sort
/10.22/默写快速排序.py
728
3.84375
4
from randomList import randomList ilist = randomList.randomList(20) def swap(nums:list,a,b): nums[a],nums[b]= nums[b],nums[a] def partition(ilist,start,end): povio = ilist[start] p = start + 1 q = end while p <= q: while p <= q and ilist[p] < povio: p += 1 while p <= q...
ec6a03eb0b304355f3942adf6efaf98b0628651e
gayathriroy2/linkedlists
/median_of_list.py
545
3.65625
4
#using tortoise and hare algo class Node: def __init__(self,data): self.data=data self.next=None class Circular: def __init__(self): self.head=None def split(self): fast=self.head slow=self.head pre=self.head while fast!=None and fast.next!...
df0698f2cc5531968739d6f9c826f4d2bf0979bf
funkelab/funlib.math
/funlib/math/bitshift.py
1,454
4
4
import numpy as np def encode64(c, bits=None): """Encodes a list c into an int64 by progressively shifting the elements of a given list Parameters: c (list): coordinate which will be encoded into a unique int64 bits (list or None): Amount of bits to represent each value, if given, should ...
0ad6768bafe04fcb00f3941eb7ba10cc8907709a
Theod0reWu/Minesweeper
/play.py
1,188
3.640625
4
# -*- coding: utf-8 -*- """ Created on Wed May 26 11:06:23 2021 @author: wut6 """ from minesweeper import Minesweeper mode = "" while (True): mode = input("Enter Difficulty (easy, medium, hard): ") if (mode == "easy" or mode == "medium" or mode == "hard"): break h,w,b = 0,0,0 if (mode == "easy"): ...
11e9ade607bed3b6957a3c0701673aed009c40d0
Pandunts98/Homework-1
/century_year.py
79
3.640625
4
import math year = int(input("Enter the year : ")) print((year + 99) // 100)
8dfa7652d7c59d48d92d6bed25b912c6763ba885
vkate174/coursework
/2/28.py
580
4.03125
4
# 28 # описание: Создать прямоугольную матрицу A, имеющую N строк и M столбцов со # случайными элементами. Исключить из матрицы столбец с номером K. # Сомкнуть столбцы матрицы. import numpy as np N = 4 M = 5 K = 2 matrix = np.random.randint(low=-9, high=10, size=(N, M)) print("Матрица:\r\n{}".format(...
f7d2241bd1e45cbb77214a0b03fb609d4bdca802
HellBringer419/buds
/python api/model.py
990
3.5
4
# -*- coding: utf-8 -*- """ Created on Sun Mar 17 00:59:07 2019 @author: KAUSHIK OJHA """ # Import dependencies import pandas as pd import numpy as np # Load the dataset in a dataframe object and include only four features as mentioned df = pd.read_csv(r"C:\Users\KAUSHIK OJHA\Desktop\nebula\python\dataset....
81ca9f20de4cbc5f92c9d5227be2d8bb9776e7fe
dianaevergreen/SPOJ
/TRICOUNT.py
283
3.5
4
#!/usr/bin/python ### 1724. Counting Triangles Problem code: TRICOUNT ## cases = int(input()) for a in range(cases): n = int(input()) if n % 2 == 0: res = (n*(n+2)*(2*n+1))/8 print res else: res = (n*(n+2)*(2*n+1)-1)/8 print res
273e24414d1381bd8f6795833d09b215cbc0c71c
goutham-nekkalapu/algo_DS
/leetcode_sol/product_of_array_except_itself.py
1,545
3.84375
4
# problem 238: def productExceptSelf(nums): """ :type nums: List[int] :rtype: List[int] time comp : O(n) space comp : O(n) """ n = len(nums) temp_left = [1] *n temp_right = [1] *n # cal the prod of all elements present on left of its position i = 1 while i...
ebb7e7f94639cad34b8a868f86b3f06336c9e0af
DilyanYankow/Python-Excercises-4-OOP
/main.py
274
3.609375
4
from car import Car car1 = Car("Chevy", "Corvette", 2021, "blue") car2 = Car("Ford", "Mustang", 2022, "red") print(car1.make) print(car1.model) print(car1.color) print(car1.year) Car.wheels = 2 #changes wheels of all cars print(car1.wheels) car1.drive() car1.stop()
1fac3360ed328a7f9ad95941218c5d871d492a6e
harshithamagani/python_stack
/python/OOP/User_Assignment.py
1,391
4.03125
4
#If you've been following along, you're going to utilize the User class we've been discussing for this assignment. #For this assignment, we'll add some functionality to the User class: #make_withdrawal(self, amount) - have this method decrease the user's balance by the amount specified #display_user_balance(self) - h...
b3fcda7fdd4c193d80e7cf25fad000a861ab918c
Rosenkrands/search-and-rescue-app
/utils.py
1,824
3.90625
4
def PrintProgressBar (iteration, total, prefix = '', suffix = '', decimals = 1, length = 100, fill = '█', printEnd = " "): """ Call in a loop to create terminal progress bar @params: iteration - Required : current iteration (Int) total - Required : total iterations (Int) pr...
fb13ead919d64bee43008b8a52c0c8f7f9f474b9
zoomjuice/CodeCademy_Learn_Python_3
/Unit 08 - Dictionaries/08_01_07-OverwriteValues.py
851
4.78125
5
""" We know that we can add a key by using syntax like: menu["avocado toast"] = 7 This will create a key "avocado toast" and set the value to 7. But what if we already have an 'avocado toast' entry in the menu dictionary? In that case, our value assignment would overwrite the existing value attached to the key 'avo...
62009897361ef3d1e77f79bf8055dcd468a39ba5
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/224/users/4382/codes/1811_2569.py
178
3.8125
4
from numpy import * from math import * n = array(eval(input('digite o vetor: '))) s = 0 m = sum(n)/size(n) for i in n: s = s + (i-m)**2 d = sqrt(s/(size(n)-1)) print(round(d,3))
9fa1ab1fb487ce20e1c638e28236856e5932646f
enomgithub/python_practice_test
/prac_doctest.py
1,923
4.6875
5
#!/usr/bin/env python # -*- coding: utf-8 -*- def fibonacci(n): """ Calculate nth fibonacci number Usage: fibonacci(n) :param n: int :return: int (where n >= 0) Example: >>> fibonacci(0) 0 >>> fibonacci(1) 1 >>> fibonacci(2) 1 >>> fibonacci(7) 13 "...
5dfb3957506e466c50649107a3af87febe5d5aa1
Yaomp4/PI20201030
/1113homeworkGuess20.py
321
3.765625
4
import random num=random.randint(0,20) i=0 while i<5: guess=input('請輸入1-20其中一個數') guess=int(guess) i=i+1 if num<guess: print('小一點!') elif num>guess: print('大一點') else: print('你中獎了 你猜了',i,'次')
faff1c036d6ced7a1846dd1c287138b36f3b25e6
SarvadiDarina/lab_python
/lab5/task1.py
157
3.875
4
# # # # x=float(input('x : ')) a=float(input('a : ')) n=int(input('n : ')) s=(x + a)**2 for i in range(n - 1): s=(s + a)**2 print('Sum = {0}'.format(s))
c7d9965cc3c95d9e36c3941bdcb05d51234f2815
L0919/leetcode
/test15.py
497
3.703125
4
# 合并两个有序链表 link:https://leetcode-cn.com/problems/merge-two-sorted-lists/ class Solution: def mergeTwoLists(self, l1, l2): res = ListNode(None) node = res while l1 and l2: if l1.val<l2.val: node.next,l1 = l1,l1.next else: node.n...
7ad0b71f6e46b8de77106496bfe7433c991c92dd
sameerkitkat/leetcode_practice
/Subarrays with given sum.py
696
3.890625
4
''' Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Example 1: Input:nums = [1,1,1], k = 2 Output: 2 Constraints: The length of the array is in range [1, 20,000]. The range of numbers in the array is [-1000, 1000] and the range of the in...
4df1fc886b8555457dc4e16ca523a256ba0dd9ae
joshitha14/Myscripts
/PythonLearning/BuildaGame.py
297
4.09375
4
#Build a game guessname = "Success" guess = "" count = 0 limit = 3 out_of = False while guess != guessname and not(out_of): if count < limit: guess = input("Enter the word") count +=1 else: out_of = True if out_of: print("You lost") else: print("You win")
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...
a7ce88ae01622503a3d3a7e17d7ee3f1dbaf5128
suvimanikandan/INTERMEDIATE_PYTHON
/Check if an item exists.PY
130
4.15625
4
#Check if an item exists tuple_1 = ("Max", 28, "New York") if "New York" in tuple_1: print("yes") else: print("no")
65efe3df7cee4db0f6e9b92d4961e4255c634457
htostes/hello-world
/CursoEmVideoPython/Desafio010.py
129
3.515625
4
n = float(input('Quanto voce tem na carteira? ')) print('Com R${:.2f} voce pode comprar, atualmente, ${:.2f}'.format(n, n/5.72))
1f7583f8d6a1474d2203747182cb66ced600ec6c
juliandunne1234/pands-problems-2020gmit
/topic03/lab03.02-sub.py
292
4.125
4
# Program that reads in two numbers # and subtracts one number from the other. frst_nmbr = int(input("Please enter the first number: ")) scnd_nmbr = int(input("Please enter the second number: ")) subtract = frst_nmbr - scnd_nmbr print ("The difference between the numbers is:", subtract)
56bb1057a8c5f75a373a1a0edd4cdff9ca8d69d6
davenfarnham/glob
/algos/i/b/stack/stack.py
1,228
4.03125
4
# Stack: FILO; to make it return min values, use the dynamic programming technique and # keep around the min value after each push on the stack class Stack(): def __init__(self): self.stack = [] self.min = None self.size = 0 def push(self, e): self.stack.append(e) self.size = self.size + 2 # store min ...
ff278cb9d4bf56965bc59e02c705c4ea20bba614
dnmanveet/Joy-Of-Computing-In-Python-Nptel-Course-Python-Programs
/anagram.py
456
3.75
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Nov 23 15:18:24 2018 @author: manveet """ str1 = input("Enter the first string ") str2=input("enter the second string ") count1 = 0 i=0 while(i<len(str1)): count1 = count1+ord(str1[i]) i = i+1 count2 = 0 i=0 while(i<len(str2)): count2 = cou...
2492f3db397c436458e713496fcb8b40bdea96e6
nikhilverma17/Python-Programs
/calc.py
1,754
3.59375
4
##label 1 ##label 2 ## ##add sub div mul ## ##result in entry box import tkinter as tk from tkinter import ttk from tkinter import * win=tk.Tk() win.title("Calculator") win.geometry('600x400+500+200') win.configure(background="blue") ##win.wm_attributes('-transparentcolor','black') ## ##filename = PhotoI...
99f2401aa02902befcf1ecc4a60010bb8f02bc32
khushbooag4/NeoAlgo
/Python/other/stringkth.py
775
4.1875
4
''' A program to remove the kth index from a string and print the remaining string.In case the value of k is greater than length of string then return the complete string as it is. ''' #main function def main(): s=input("enter a string") k=int(input("enter the index")) l=len(s) #Check whether the ...
e7434914c912f78219b3076462b13ae333f56196
MikelShifrin/Python1
/Students/Zephyr/Exercise 7.py
164
4.21875
4
num = int(input("ENTER A POSITIVE NUMBER:\n")) total = 1 for value in range(1,num+1): total = total * value print("The factorial of you number is:" , total ,)
3aad9fa1dacc2710930034967aa19b8cc0baf2a4
CmKVbzN9/tbb
/module_2.py
344
4.09375
4
"""This is the second exercise""" #!/usr/bin/env python3 def main(): """This module counts the number of characters in a string""" user_input = str(input("What is the input string? ")) string_length = str(len(user_input)) print("{} has {} characters.".format(user_input, string_length)) if __name__ ==...
589a83c4ff620a57869c8709c683153b431743d3
snailuncle/scrapyBaidustocks
/python挖掘机/计数器的使用.py
477
4.125
4
# 1.python函数定义在运行时,会创建一个 add函数对象(唯一),在当前namespace,所有的add name都指向这个唯一函数对象。 # 2. 由于_rel参数是一个list,mutable类型,其他任何_rel的使用都是对于这个list对象的引用 一般参数传递mutable对象要谨慎,在这种需求环境下使用是非常精妙的 def add(val,_rel=[0]): _rel[0]+=val return _rel[0] for i in range(10): c=add(1) print(c)
a0c544be8ac5b6e520436a6ec8cc8e65b11b54aa
asfelix/python-basico
/04-operadores-logicos-e-relacionais.py
377
4.0625
4
x = 2 y = 3 soma = x + y print('%s é igual a %s? %s' %( x, y, x == y)) # == serve para comparar se 2 variáveis ou valores são iguais print('%s é menor que %s? %s' %(x, y, x < y)) print('A soma de %s + %s, é igual a %s? %s' %( x, y, x, soma == x)) print('A soma de x + y, é maior ou igual a x? ', soma >= y) print('A s...
4fdfa63a2e184f9f767a5ce3664d029a5b37ccd4
cookcodeblog/python_work
/ch04/foods.py
272
4.15625
4
# 4-13 Foods foods = ("Egg", "Onion", "Pizza", "Beef", "Chicken") for food in foods: print(food) print() # Tuple doesn't support item assignment # foods[0] = "Noodles" foods = ("Noodles", "Fish", "Pizza", "Beef", "Chicken") for food in foods: print(food)
519310e548397d2f7f2ed07c7b53c05b805f60ce
davenfarnham/CSCIP14100
/psets/3/tog.py
1,132
3.8125
4
#!/usr/bin/python import re def learning_dict(): normal_d = {} # open dictionary f = open('small_dict.txt', 'r') words = f.read().split() # put into dictionary for word in words: normal_d[word.lower()] = None h = open('small_string.txt', 'r') # make a list of words from holy_grail.txt hg = h...
b4e4cf57326b160637f74adba3ff16b02c9076f4
Merna-Atef/Algorithmic-Toolbox-Coursera-MOOC
/week2_algorithmic_warmup/5_fibonacci_number_again/fibonacci_huge.py
953
3.65625
4
# Uses python3 import sys def get_fibonacci_huge_naive(n, m): if n <= 1: return n previous = 0 current = 1 for _ in range(n - 1): previous, current = current, previous + current return current % m def get_fibonacci_huge_fast(n, m): if n <= 1: return n # Calculat...
5285c8c2087756ed87acfa77aa5d3cc119042dae
alperenorhan/algorithm-exercises
/Power.py
131
3.515625
4
def Power(number, power): answer, i = number, 1 while i < power: answer *= number i += 1 return answer
1101030e07b4af8edbef0710230a37350fa3e90d
DeanHe/Practice
/LeetCodePython/UncrossedLines.py
1,761
4.3125
4
""" You are given two integer arrays nums1 and nums2. We write the integers of nums1 and nums2 (in the order they are given) on two separate horizontal lines. We may draw connecting lines: a straight line connecting two numbers nums1[i] and nums2[j] such that: nums1[i] == nums2[j], and the line we draw does not inter...
b7ca5771011da36891a0b9b26e2622d0a06ec015
Deftwun/codeeval
/broken_lcd.py
1,125
3.546875
4
''' https://www.codeeval.com/open_challenges/179/ ''' import sys #0 - 9 bitStrings = ['11111100','01100000','11011010','11110010','01100110','10110110','10111110','11100000','11111110','11110110'] def codifyDecimal(s): decimalSet = False; codes = []; for c in s.strip(): if c == '.' : decimalSet = True; c...
795756fb2e57622772cbc214ec7c5d675644f9c8
Blast07/hackerrank
/interview-preparation-kit/Warm-up Challenges/repeatedString.py
460
3.671875
4
def counta(string, n): num_a =0 for i in range(n): if string[i]=='a':num_a+=1 return num_a def repeatedString(string, n): size = len(string) num_a = counta(string,size) if(size==n):return num_a elif(size>n): num_a = counta(string,n) return num_a; else: re...
c47719356a80b8aa02bc70a4f98c04af34022ccc
usamaeltmsah/MineSweeper-game-bot
/python-tkinter-minesweeper-master/solver.py
5,290
3.921875
4
''' from tkinter import * root = Tk() label1 = Label(root, text="Name: ") label1.grid(row=0, column=0) name = Entry(root) name.grid(row=0, column=1) label2 = Label(root, text="Email: ") label2.grid(row=1, column=0) Email = Entry(root) Email.grid(row=1, column=1) option = Checkbutton(root, text="Remember me...
5a9843927618c6b70967379441de1a4a93edc753
Jamshid93/TaskBook
/Boolean/boolean4.py
59
3.671875
4
A=int(input("A= ")) B=int(input("B= ")) print(A>2 and B<=3)
b24d3128e2392837499ddb251bcccfc12e269919
thesecret2904/Project-Euler
/problem045.py
1,061
3.796875
4
def triangle(n): return (n * (n + 1)) // 2 def pentagonal(n): return (n * (3 * n - 1)) // 2 def hexagonal(n): return n * (2 * n - 1) def find_pent(value: int): right = 1 left = 1 while pentagonal(right) < value: right *= 2 while left <= right: middle = left + (right - l...
9f1bff3eaf59bf46fe9973ccf0e55e59778ad5d0
qhl453770571/My-Python
/20190212/break.py
208
3.703125
4
#!/usr/bin/env python #练习 要求输入用户名 当用户输入用户名不是tom 就一直输入 uname=input('请输入用户名:') while uname != 'tom': uname=input('请继续输入用户名:')
f1684503d0abb2c7ee7af56bb4697bbe0f93a002
nayoon-kim/Algorithm
/1715.py
970
3.53125
4
# 시간초과 # from collections import deque # n = int(input()) # card = [int(input()) for i in range(n)] # def operation(): # queue = deque() # queue.extendleft(card) # sum = 0 # while True: # queue = sorted(queue, reverse=True) # print(queue) # q = queue.pop() # if que...
91f6a3f3c977dfd49f82ea2239a16ff8e5422929
DerekMazino/Clase-Analisis-Numerico
/Corte 1/Unidad 1/Laboratorio 0/Lab0_1.py
170
3.515625
4
#Punto a resp=0 for i in range(6): resp=1/(3**i) print('{:.3F}'.format(resp)) #Punto b resp1=0 for i in range(6): resp1=1/(3**(7-i)) print('{:.3F}'.format(resp1))
48a598758442e4eab03692b42dcafaaed99340b4
arpa2001/MyCaptain_Python
/Loops_2.py
737
3.515625
4
def positivecal(listx): listy = [] buff = "" for i in listx: if i == "[": continue if i == "]": listy.append(int(buff)) if i == "," or i == " ": if buff == "": continue listy.append(int(buff)) buff = "" ...
13c7ceddf63296f9cd8173a1d2600816989a5592
AmitKulkarni23/Leet_HackerRank
/LeetCode/Easy/Arrays/max_product_of_3_numbers.py
1,534
4.15625
4
# Given an integer array, find three numbers whose product is maximum and output the maximum product. # Example 1: # Input: [1,2,3] # Output: 6 # Example 2: # Input: [1,2,3,4] # Output: 24 # Given: # The length of the given array will be in range [3,104] and all elements are in the range [-1000, 1000]. def maximumPr...
ec8e2f30e59775b6ff4394377b3c8f4c7f64f095
gaonita/python
/fizzbuzz.py
203
3.765625
4
for i in range(1,101): if i>=15 and i%15 == 0: print('fizzbuzz') elif i>=3 and i%3 == 0: print('fizz') elif i>=5 and i%5 == 0: print('buzz') else: print(i)
9fe7b6abf320f6e96e3ba22ee73191030434dd45
ppudakal9/Python_Snippets
/SortNegativeToPositive.py
902
3.609375
4
def shiftArray(arr, currIndex, negIndex): temp = arr[currIndex] for j in range(currIndex, negIndex+1, -1): arr[j] = arr[j-1] arr[negIndex+1] = temp def sort_neg_to_pos(arr): #initialize negIndex to -1. negIndex will keep track of last seen negative element negIndex = -1 #if first el...
6931ae5dafc4d5d0d8b29b879e53098c28edfde7
acepele/PRG105
/retirement_savings_calculator.py
1,049
4.15625
4
age = int(input("How old are you currently?")) retire_age = int(input("At what age do you want to retire?")) income = float(input("What is your yearly income?")) percentage = float(input("What percent of your income do you save?")) savings = float(input("How much money do you currently have in your savings?")) p...
be5cfc62352259c70bb01af9dde76d8913ec6300
vivekpapnai/Python-DSA-Questions
/Strings/Left And Right Rotation Of A String.py
550
3.90625
4
def leftRotate(strr, d): # Write your code here. while d > len(strr): d = d - len(strr) temp = strr[:d] resultStr = strr[d:] + temp return resultStr def rightRotate(strr, d): # Write your code here. while d > len(strr): d = d - len(strr) resultstr = "" resultstr +...
41541a57e5599329a70fa7eebe213d313a67f3c7
mvaal/advent-of-code-helpers
/src/aoc/template.py
1,327
3.6875
4
import os from abc import ABC, abstractmethod from src.aoc.helpers import output, read_input_from_file class Puzzle(ABC): def __init__(self, part: int, day: int, year: int) -> None: self.part = part self.day = day self.year = year self.input_file = None super().__init__() ...
04f75afc3d4166f1d8f785f0020630551662db32
Kevinp1402/lab-10-more-loops
/gimmieemynumber.py
319
4.09375
4
string = input("Gimme a number greter than 100...") num = int(string) while num < 100: print(str(num) + "is less than 100, Try again , Ive got all day") string = prompt(usernum + "is less than 100,Try again Ive got all day...") num = int(string) print(str(num) + "is greater than 100! Finally! Great Job!")