blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
fd8b1fd467ed43865f2767273963bf0028639a1c
deepdas007/Python
/LAB_PRGMS/LAB_CIA.py
780
3.75
4
#*********************************************************************************************** def calculate(): cost_comp = float(input('')) qty_comp = int(input('')) cost_chair = float(input('')) qty_chair = int(input('')) cost_table = float(input('')) qty_table = int(input('')) tot...
e4e42bba538eb858618f5b88bafb73eabbad1dcf
YVass1/BrewApp
/source/Formatting/tables.py
7,898
3.78125
4
#variables additional_char= 2 #functions def table_width_1_col(heading, my_list): """Determines the largest length from specified list elements and heading for 1-column table width.""" width = len(heading) len(heading) for element in my_list: if len(element) > width: width = len(el...
79b59aec7ae4aaad8e1ddedc3b55fc697f16ed05
Shivani161992/Leetcode_Practise
/Stack/DecodeString.py
210
3.671875
4
s = "3[a]2[bc]" #s="3[a2[c]]" #s = "2[abc]3[cd]ef" #s = "abc3[cd]xyz" class Solution: def decodeString(self, s: str) -> str: print() "hello world" o=Solution() y=o.decodeString(s) print(y)
e69b944d1a8bc5a7e6e953697acd1d17f20f741e
VETURISRIRAM/DATA-STRUCTURES-PRACTICE
/delNodeLL.py
600
3.859375
4
class Node: def __init__(self, data): self.data = data self.next = None class linkedList: def __init__(self, head): self.head = head def traversal(self): element = self.head while element: print(element.data) element = element.next def delNode(self, ind): element = self.head...
236ed4b8c8d90f43cc1cc9ed25abd34ee2a4c1a6
zhongshankaka/data-structures-and-algorithms
/dict_class.py
632
3.78125
4
# -*- coding: utf-8 -*- class Assoc: def __init__(self, key, value): self.key = key self.value = value def __lt__(self, other): return self.key < other.key def __le__(self, other): return self.key <= other.key def __str__(self): return "Assoc({0}, {1}".format...
efc5f916bbaed9989da55064836c66f4691de4a8
sagynangare/I2IT
/instance_vs_class_attribute.py
489
4.21875
4
class Demo: name="Python" def __init__(self, name): self.name= name def display(self): print('Name: ', self.name) d=Demo('DON') #print(d.name) #print(Demo.name) class Foo: name='Python' def __init__(self, a, b): self.a = a self.b = b f=Foo(12,21) print('Class variabl...
6da299d3a7a8d82bb0712b293c05b5401a067ad9
amitgazta369/Python-beginner-level---1
/22shorthandifelse.py
236
4.0625
4
a = int(input("enter a\n")) b = int(input("enter b\n")) if a>b: print(" a b se bada hai bhai ji") else: print("pagal hai bhai kya") #shorthandifelse print("B A se bada hai bhai") if a < b else print("A B se bada hai bhai")
bbfe2a83db29c9c71e237e1a5d95e8ef943fcbc0
sudhatumuluru/PythonPractise
/conditiional_opr.py
104
3.671875
4
print "enter var1" var1=raw_input() print "enter var2" var2=input() var3=var1*var2 print "result:",var3
dc49dd51d9eb659e543c155d9d60243855fea997
yingstm124/python-
/204111/lab11/Lab11_2_590510137.py
757
3.828125
4
#!/usr/bin/eny python3 #sutimar pengpinij #590510137 #Lab 11 #problem 2 #204111 Sec 003 import copy def main(): list_a = input() row = input() col = input() print(remove_row_col(list_a, row, col)) def remove_row_col(list_a, row, col): list_b = copy.deepcopy(list_a) rows = len(list_b[:]) ...
44f60bf67cdc649c0f3b27d36d76dd7b9e244a79
weezer/pythonalgorithmsanddatastructure
/Pizza_methods.py
864
3.8125
4
class Pizza(object): def __init__(self, size): self.size = size self.bbb = 666 def gett_size(self): return self.size def retrun_num(self, num): return num class Pizza2(Pizza): def __init__(self, size): super(Pizza2, self).__init__(size + 2) self.size =...
d033ceed49915744fc733fbe031a3158c9c4b2d8
DaneshJoy/python_scientific
/Codes/020.py
299
3.8125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Apr 17 13:32:10 2019 @author: saeed """ def factorial(n): f = 1 for i in range(2,n+1): f *= i return f f = factorial(100) s = str(f) sumAll = 0 for i in range(len(s)): sumAll += int(s[i]) print(sumAll)
3d43745195609aa5165712d6c9cd0af820913857
PersonnamedJulia/Lessons2
/Ex4.py
92
3.6875
4
my_str = input() my_str.split() for i, word in enumerate(my_str, 1): print(i, word[:10])
696a2307833246e9921da887b8ebc9f64f38888f
DM865/TSP
/src/c_heuristics.py
1,941
3.578125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Feb 15 18:38:45 2018 @author: marco """ from data import * import itertools from solutions import * def nn_tsp(cities, start=None): """Start the tour at the first city; at each step extend the tour by moving from the previous city to its n...
e3af4a925bc8d172c729752ef56c12707e709b12
dxmxnlord/ProgrammingNotes
/OpenCV/Contours.py
11,969
3.734375
4
import os import numpy as np import cv2 from matplotlib import pyplot as plt os.chdir("/home/rishikesh/Desktop/101_ObjectCategories") os.chdir("./airplanes") """ Contours can be explained simply as a curve joining all the continuous points (along the boundary), having same color or intensity For better accuracy, ...
5b23d465c69d83723c19b622c53ff49f1ef04797
xxrom/101_symmetric_tree
/main.py
2,210
3.875
4
class TreeNode(object): def __init__(self, val, leftNode=None, rightNode=None): self.val = val self.left = leftNode self.right = rightNode def __str__(self): return str(self.__class__) + ": " + str(self.__dict__) class Tree(): def __init__(self, rootNode): self.roo...
582d61933b592ff18e076a0a7ed9ae22281c0da5
slinkp/spydey
/spydey/patternize.py
2,385
4.375
4
""" Convert a string into a regular expression that can match it, roughly grouped into whitespace, digits, letters (and underscores and dashes), and everything else. Examples: >>> import re >>> patternize('') '' >>> print(patternize('9')) \d+ >>> re.match(patternize('9'), '27') is None False >>> print(patternize('a...
24272393dcd9697c8abe7fe2c645b9bf11900422
107318041ZhuGuanHan/TQC-Python-Practice
/_3_loop/306/main.py
291
3.96875
4
number = int(input("請輸入一正整數,我將為您算出它的階乘結果: ")) total = 1 # 給定一個不是0的初始值,賦值給total(因為等一下是乘法) for n in range(1, number+1): total *= n # 從1開始一直乘到number -> 1 * 2 * 3 * ... * number print(total)
daf1a27cd141fce08e44b9c96de71b7945e19879
TValkavich/CVIP_Projects
/Project_01/Template_Matching/task1.py
8,404
3.859375
4
""" UB_ID : 50291708 Name : Md Moniruzzaman Monir Edge Detection : (Due date: March 8th, 11: 59 P.M.) The goal of this task is to experiment with two commonly used edge detection operator, i.e., Prewitt operator and Sobel operator, and familiarize you with 'tricks', e.g., padding, commonly used by computer vis...
b40a5032a61aae81c9b2d85148a5be4b8360a55a
rayanaprata/uc-praticas-em-desenvolvimento-de-sistemas-II
/third-class/lists.py
848
3.828125
4
# create a list with 15 elements for v in range(15): print(v) # creating a list with ranges # range(start=0, stop, step=1) l = list(range(100, 1100, 50)) print(l) for t in range(3, 34, 3): print(t, end=" - ") print() while True: count = 0 num = int(input("Informe o numero: ")) mult = int(input("Informe o...
6e2680fd3f621422dba39aa2ac5157cd3663d28d
jscherb1/ProjectEuler
/Problem 19.py
2,027
4
4
dayOfWeekIndex = 1 dayCounter = 1 dayArray = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'] year = 1900 monthIndex = 0 monthArray = ['January','February','March', 'April','May','June','July', 'August','September','October', 'November','December'] month...
35b31b3387ff75eb32a33668cb8a7766b0b48c0c
Jose0Cicero1Ribeiro0Junior/Curso_em_Videos
/Python_3/Modulo 1/4-Condições_em_python(if.else)/Exercício_034_Aumentos_múltiplos_v0.py
571
3.78125
4
#Exercício Python 34: Escreva um programa que pergunte o salário de um funcionário e calcule o valor do seu aumento. Para salários superiores a R$1250,00, calcule um aumento de 10%. Para os inferiores ou iguais, o aumento é de 15%. salario = int(input('Qual é o seu sálario? ')) if salario > 1250: aumento =(salari...
337a1023c4652994fb3cd0362c57395f37bdc3ce
kobyyoshida/pynative-solutions
/Lists/exercise1.py
99
3.84375
4
#Exercise 1: Reverse a given list in Python aLsit = [100, 200, 300, 400, 500] print(aLsit[::-1])
16b6e821212195ed3920463e9449b13db71c53c1
SyllabusRomeo/py_codes
/swap.py
745
4.15625
4
''' #LONG SWAP x=10 y="ten" #step 1 temp = x #temp is now 10 #step 2 x = y #x is now "ten" #step 3 y=temp #y is now 10 print(x,y,temp) #SIMPLE SWAP x=10 y="ten" x,y = y,x print(x,y) #another swap example you = "apple" friend = "money" you,friend = friend,you print(you, friend) ''' #program to...
acbe6de189612fba61119f5dbb32959604d53cd8
pylangstudy/201710
/05/00/1.py
779
3.546875
4
#from itertools import * import itertools for c in itertools.accumulate([1,2,3,4,5]): print(c) for c in itertools.chain('ABC', 'DEF'): print(c) for c in itertools.chain.from_iterable(['ABC', 'DEF']): print(c) for c in itertools.compress('ABCDEF', [1,0,1,0,1,1]): print(c) for c in itertools.dropwhile(lambda x: x<5, [1,4...
0edb3e8d7af70d3ea7c2b8ed19eb540ee4452f4f
mitcns/python
/games/dragon.py
1,500
3.984375
4
# !/usr/bin/env python # coding=utf-8 import random, time def displayIntro(): print '你来到了一个龙之大陆,在你的正前方,有两个洞穴...' print '其中一个洞穴里住着一个友善的龙...' print '他会给你一些宝藏,而另一个洞穴里...' print '住着一条贪婪、饥饿的龙,一旦看到你,就会马上把你吃掉!' num = 5 while num: print '.', time.sleep(.5) num -= 1 else: ...
441de96809ee7ca5442943780876630d9cf8f5b7
SpongebobSze/PASSWORD-RIGHT-OR-WRONG
/password2.py
395
3.875
4
# 密码重试程式:密码='a123456' # 最多三次机会 # 不对的话就印出'密码错误!你还有_次机会';对的话就印出'登入成功' password = 'a123456' chance = 3 while chance > 0: pwd = input('请输入密码:') if pwd == password: print('登入成功') break else: chance = chance - 1 if chance >= 0: print('你还有', chance ,'次机会')
6eb69336a662409b2f16d686af53220a32a49352
PlayPurEo/Python-Leetcode
/Leetcode/code724.py
896
3.59375
4
# author : 'wangzhong'; # date: 28/01/2021 15:08 """ 给定一个整数类型的数组 nums,请编写一个能够返回数组 “中心索引” 的方法。 我们是这样定义数组 中心索引 的:数组中心索引的左侧所有元素相加的和等于右侧所有元素相加的和。 如果数组不存在中心索引,那么我们应该返回 -1。如果数组有多个中心索引,那么我们应该返回最靠近左边的那一个。 """ from typing import List class Solution: def pivotIndex(self, nums: List[int]) -> int: n = len(nums) ...
42c7b5361e504c3d6207a945ca66c8f9ad0f636d
cjada/Python-Algorithmic-Questions
/arrays/pascals_triangle_generator.py
538
3.90625
4
import math class pascal_triangle: def pacscal_generator(self, n, k): """ Computes the digit at the nth row, kth column. 0 based indexing. n: int k: int Return: int """ return int(math.factorial(n) / (math.factorial(k) * math.factorial(n - k))) def create(self, A): """ Creates Pascal's triangle...
8e9f2c147ecb009ad0eeb4a00a5b919a414c3dec
TheNumber77/DeltaCalculator
/deltacalculator.py
288
3.96875
4
linha = '-' * 42 titulo = 'DELTA CALCULATOR' print(linha) print(titulo.center(42)) print(linha) a = int(input('digite o valor de "a": ')) b = int(input('digite o valor de "b": ')) c = int(input('digite o valor de "c": ')) d = b ** 2 - 4 * a * c print('o valor de delta é: {}'.format(d))
04cdd43422c3c88a1a67afa9a471baeadf68ee72
kumarsaurav20/pythonchapters
/04_for_loop.py
335
4.46875
4
# # use of loop # l = [1,7,8,9,10] # for items in l: # print(items) '''another example *** Taking example of while loop ''' fruits =['Mango','Banana','Grapes','Watermelon'] # for items in fruits: # print(items) for i in range(1,3): #IF we want to print range print(fruits[i]) # For loop m...
4722cd9783bff68aa973bac51a15b3a7e0173024
Zahidsqldba07/code-signal-solutions-GCA
/arcade/intro/012-sortByHeight.py
2,159
4.15625
4
""" Some people are standing in a row in a park. There are trees between them which cannot be moved. Your task is to rearrange the people by their heights in a non-descending order without moving the trees. People can be very tall! Example For a = [-1, 150, 190, 170, -1, -1, 160, 180], the output should be sortByHeig...
8af6e36b332e04200ae8424d7e4a7725e9053278
CristianG89/Real-Time_Programming
/Ex2 Bottlenecks/Ex2 - Part 4 (Python).py
1,425
4.125
4
#https://www.onlinegdb.com/online_python_compiler import threading from threading import Thread #Threads library from threading import Lock #Locks (mutex) library lock = Lock() #An object of type Lock is created to handle mutual exclusion (mutex) #In Python you "import" a global variable, instead of "export"ing it ...
32e139846726422c9ff4a034a828e8ecd03bd8eb
GabrielVitorino28/Python
/projetos-basicos/60_progressao_aritmetica_versao_dois.py
1,047
4.09375
4
# Evolução do Projeto 50 (Progressão Aritmética), onde a estrutura For foi substituída pela estrutura While, e o programa pergunta ao usuário quantos termos ele gostaria de ver. from time import sleep pt = int(input('Insira o primeiro termo da progressão aritmética: ')) r = int(input('Agora, insira a razão da progres...
0fafbf543822b616bacf5d869cc0e633d05aa692
KalasJan/My_projects
/Password.py
747
3.578125
4
# Generator hesla # Bereme pouze mala a velka pismena, cislice from random import choice import string # kolik znaku ma heslo obsahovat delka = int(input("Jak dlouhe ma heslo byt? ")) # co by heslo melo obsahovat? pismena = string.ascii_letters # pokud chceme v hesle mala nebo velka pismena cislice = st...
02f42226de22b95033709afbd1ca1d7259287576
jaquelinegondim/Basic-Exercises-in-Python
/100-Exercises-Guanabara/Ex81-85.py
4,452
4.21875
4
''' Estes exercícios fazem parte do curso de Introdução a Algoritmos, ministrado pelo prof. Gustavo Guanabara e podem ser encontrados no site https://www.cursoemvideo.com/wp-content/uploads/2019/08/exercicios-algoritmos.pdf 81) Crie um programa que leia a idade de 8 pessoas e guarde-as em um vetor. No final, mostr...
47160fc2d8f4c046d0b26cfb1b1a4be4bcb68d7c
TechPuppies/leetcode-python
/max_points_on_a_line.py
1,740
3.59375
4
# coding=utf-8 # AC Rate: 10.9% # SOURCE URL: https://oj.leetcode.com/problems/max-points-on-a-line/ # # Given n points on a 2D plane, # find the maximum number of points that lie on the same straight line. # import unittest class Point: def __init__(self, a=0, b=0): self.x = a self.y = b class...
513c68c914d4d5834238291636ef772d350f4829
MrHamdulay/csc3-capstone
/examples/data/Assignment_8/mknnit002/question2.py
354
4.15625
4
#mknnit002 #question 2 ass 8 #number of pairs in a string def pairs (string): if len(string)<=1: return 0 elif string[0]!=string[1]: return pairs (string[1:]) else: return 1+pairs(string[2:]) def main(): x=input("Enter a message:\n") print("Number of pairs...
0ca99b9a4a78939a560d812fe00bdece991f9b37
wcdawn/python_practice
/sudoku_solve.py
3,134
3.578125
4
import numpy as np def sudoku_write(sud_arr): print() print('-------------------------') for i in range(sud_arr.shape[0]): if (i == 3) or (i == 6): print('|-------+-------+-------|') print('| ',end='') for j in range(sud_arr.shape[1]): if (j == 3) or (j == 6): print('| ',end='') ...
0300961ccc62d48d314abf5f6568ce445886e426
arjunbabu1998/practical
/Python basic/file access mode/ariopr.py
381
3.578125
4
a=int(input("Enter the first number: ")) b=int(input("Enter the second number : ")) fp=open("sample1.txt","w") fp.write("The first number is %d " %(a)) fp.write("\n The second number is %d " %(b)) fp.write("\n %d+%d=%d"%(a,b,a+b)) fp.write("\n %d-%d=%d"%(a,b,a-b)) fp.write("\n %d*%d=%d"%(a,b,a*b)) fp.write("\n %d/%d=%...
a5de9769a1cf1c337adc408f00f1b2be6a598e26
zhangzongyan/python0702
/day14/05-mygrid.py
1,143
3.640625
4
from tkinter import * root = Tk() root.geometry="200x200+0+0" root.title("计算器1.0") Button(root, text="7", width=5).grid(row=0, column=0) Button(root, text="8", width=5).grid(row=0, column=1) Button(root, text="9", width=5).grid(row=0, column=2) Button(root, text="4", width=5).grid(row=1, column=0) Button(root, text...
02b7da461024bcdf1f438b588daf53211e6d858b
Jerry-Li-NJ/ATBSWP
/fillInGaps/insertGaps.py
790
3.640625
4
#! /usr/bin/python3 # insertGaps.py -- Insert gaps into numbered files with new added files. import fillingInTheGaps, os def insertGaps(folder): # Detect the gaps. gapsDetectedNew = fillingInTheGaps.fillingInTheGaps(folder) # Generate the gap files name. for i in range(len(gapsDetectedNew)): # Replaced the item...
32daabf3d51ab7be9d3fa4655bf65e7b2fc1c9bf
dilysch/Python_Encryption
/geektechstuff_morse_code.py
1,435
4.09375
4
#!/usr/bin/python3 # GeekTechStuff # Morse Code # Dictionary of Morse Code morse = { 'A':'.-', 'B':'-...', 'C':'-.-.', 'D':'-..', 'E':'.', 'F':'..-.', 'G':'--.', 'H':'....', 'I':'..', 'J':'.---', 'K':'-.-', 'L':'.-..', 'M':'--', 'N':'-.', 'O':'---', 'P':'.--.', 'Q':'--.-', 'R':'.-.', 'S':'...', 'T':'-', 'U':'..-', 'V'...
64db10665f550792ee1b67f642c065969e9ce454
rusmat0173/FutureLearn
/OOP_in_Python/character.py
4,348
4.03125
4
class Character(): # class instance of a set names of all characters knowledge = set() # Create a character def __init__(self, char_name, char_description): self.name = char_name self.description = char_description self.conversation = None self.active = True # Descr...
3ccd7a6ca86b9ce255d56243088d6ba546f37bf5
blont714/Project-Euler
/Problem 9.py
423
3.953125
4
def main(): num = 1000 a, b, c = culc_Pythagorean(num) print(a, b, c) print(a*b*c) def culc_Pythagorean(num): for a in range(1, num//3): for b in range(a, (num-a)//2): c = num - a - b if a**2+b**2==c**2: return a, b, c print(None) i...
77988d7a8371f5279e56f0537abc0a3772588e20
valborgs/pythonStudy
/0720/set집합/set기본문법.py
1,422
3.515625
4
# 집합 생성 {} s1 = {1,2,3,4,5} print(s1) print(type(s1)) # set() 함수로 집합 만들기 # 리스트로 집합 생성 s2 = set([4,5,6]) print(s2) s3 = set((4,5,6)) print(s3) # 동일한 요소 값이 중복될 수 없다 # set생성시 중복 요소는 제거하고 집합을 만든다 s4 = {1, 2, 3, 3, 3, 4, 4, 5} print(s4) # 집합 안에 변경 가능한 list를 요소로 포함할 수 없다. s5 = {1,2,[4,5]} # TypeError: unhashable ty...
5023e7e6dd68538e995a38e74267162fa858ba70
sonasonaram/python_core
/19_inheritance_example.py
1,021
4.125
4
class Animal: def __init__(self, color, weight, age): self.legs = 4 self.color = color self.weight = weight self.age = age def info(self): print( "legs =", self.legs, "color =", self.color, "weight =", self.weight, ...
be7c6dc1e7fc81e713ab8cc9af6dcb17b402c482
zenbonk/dwd
/ex33.py
501
4.21875
4
# i is a variable for the number 0 i = 0 # this is a list [] of numbers variable numbers = [] #starting new block of code with : # while list number i is less than 6 add (append) i to old i while i < 6: print "At the top i is %d" % i numbers.append(i) # in this while loop, i will be i+=1 until it hits 6 i = i + 1 ...
40b0334f49872aee0dbba296eb706c36faee0b5d
xxxhol1c/PTA-python
/function/6-5.py
336
3.71875
4
from math import factorial def funcos(eps, x): res, i = 0, 0 while pow(x, i) / factorial(i) >= eps: cur = ((-1)**(i/2)) * pow(x, i) / factorial(i) res += cur i += 2 return res eps = float(input()) x = float(input()) value = funcos(eps, x) print("cos({0}) = {1:.4f}".f...
b941a22a604ba6a353cef37a07cbf9622775694f
kashikakhatri08/Python_Poc
/python_poc/python_strings_program/string_binery_typecheck.py
648
3.765625
4
def check(): string_container = "010ka10101" set_string = set(string_container) set_binery = {0,1} flag = True if set_string == set_binery or set_string == {0} or set_binery == {1}: pass else: flag = False if flag: print("binery") else: print("not binery")...
b663d8b9f0fb57a69e72342b37ccc50edbbc06c9
dinosaurz/various
/PyCheckers/checkersmodel.py
9,298
4.125
4
# -*- coding: utf-8 -*- """ Board implementation of the checkers game author: David Karwowski editted: December 2012 """ class Piece(object): PIECE_ID = 0 # - start basic functions ----------------------------------------------------- def __init__(self, color): """The constructor for a piece object....
66e6d7a183074986f131ea0f8c9bab94672a694a
stevenmsl/python-numpy
/rfunction.py
1,289
3.78125
4
#%% import numpy as np #%% # -1:1:6j start with -1 and end with 1. # start with -1 and end with 1. You have 6 data points in total all evenly spaced. # (1-(-1))/5 = 0.4 # [-1. , -0.6, -0.2, 0.2, 0.6, 1.] # and you can then concatenate with other arrays or scalars to form a bigger array np.r_[-1:1:6j, [0]*3, 5, ...
7341063d21e0949215de260c55b40441e3b1c438
DL-Metaphysics/DL-neverrrr
/Gradient1_1.py
2,667
3.84375
4
import numpy as np import matplotlib.pyplot as plt # 数据集大小 m = 7 #迭代次数 iterations = 10000 # 学习率 alpha = 0.0000001 X0 = np.ones((m, 1)) X1 = np.array([150, 200, 250, 300, 350, 400, 600]).reshape(m, 1) X = np.hstack((X0, X1)) print(X[6]) y = np.array([ 6450, 7450, 8450, 9450, 11450, 15450, 18450 ]...
1ac0d7ae2218ad092ae322492c540732f4cb78d9
yordan-marinov/advanced_python
/testing/vehicle_lab/vehicle_lab.py
1,257
4.15625
4
from abc import ABC, abstractmethod class Vehicle(ABC): def __init__(self, fuel_quantity, fuel_consumption): self.fuel_quantity = fuel_quantity self.fuel_consumption = fuel_consumption # liters per km @abstractmethod def drive(self, distance): pass @abstractmethod def re...
90714eeaf5e4fc0e98499de79496c93d12f78e16
clacap0/simple
/counting_vowel.py
351
4.25
4
""" Count the vowels in a string """ def count_vowels(phrase): vowels = 'aeiou' counter = 0 for letter in phrase: for vowel in vowels: if vowel==letter: counter += 1 return f'There are {counter} vowel(s) in your phrase.' print(count_vowels(input('What phrase would ...
c52825dbc57fcd4b2b45e3b23040eee751720c72
jagadesh037/python-script
/Hello.py
76
3.671875
4
i = 1 while i <= 5: print("Hello World...{}".format(i)) i+=1
96b33ed17bb65b5224f780544b62152690e4b864
taknalut/weatherData
/weather.py
1,588
3.78125
4
import sys import requests def getWeatherForecast(): #Handle a file open error try: location_data = open("location.txt", "r") except IOError: print("There was an error reading file") sys.exit() base_url = "https://api.weather.gov/points/" temperature = [] for location ...
fdb672bd4c315ab093e9c5aa1fa891e622add2ec
prasanthduvvur/python-challenge
/PyBank/main.py
1,875
3.921875
4
import csv with open("budget_data_2.csv",newline='') as csvfile: csvreader = csv.reader(csvfile, delimiter=',') total_months=0 total_revenue=0 curr_revenue=0 next_revenue=0 sum_monthly_diff=0 average_monthly_diff=0 row_index=0 local_diff=0 max_diff=0 min_diff=0 next(cs...
5ff43db1927311e4e98ae88a74e4dd40743bc284
Brunocfelix/Exercicios_Guanabara_Python
/Desafio 049.py
295
4
4
#Desafio 049: Reaça o Desafio 009, mostrando a tabuada de um número que o usuário escolher, # só que agora utilizando um laço for. n = int(input('Digite um número para sua tabuada: ')) print('=' * 12) for c in range(1, 11): print('{} * {:2} = {:2}' .format(n, c, c*1)) print('=' * 12)
b9c8d16151f446722665024ead7b795bf80c66e3
pedrospeixoto/iModel
/pyscripts/imodel_data.py
8,890
3.546875
4
#! /usr/bin/env python3 # # # Given data (x,y), add line plot to graph # # # Pedro Peixoto <ppeixoto@usp.br> # # #--------------------------------------------------- import os import sys import stat import math import csv import numpy as np import string import re import json #For data structuring import itertoo...
aa273776b843739abbfdf8adfd6e93b7713c4212
Success2014/Leetcode
/4sum.py
2,325
3.71875
4
# -*- coding: utf-8 -*- """ Created on Mon Jul 06 13:28:09 2015 Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. Note: Elements in a quadruplet (a,b,c,d) must be in non-descending order. (...
15e6edc85664f1f24979143533b97bc05df8be41
EngiNearStrange/Python_Practice_Exercises_Projects
/Practice program.py
575
4.25
4
#This is a program to take input from user and keep taking input as long as it is less than 100 a = int(input("Please enter the number")) '''Making this a comment to access program laer if reqd while (a<100): print("Number is less than 100") a = int(input("Enter another number")) if a == 100: print(...
4a65e5e5c9b74d4a5e579611da8096f864eab504
Techsrijan/Python11
/imagedisplay.py
568
3.703125
4
from tkinter import * from PIL import Image, ImageTk root=Tk() '''luck = Button(root, text="LUCK", bg="black", fg="green", width=20, command=lambda: ImageShow("test.gif")) luck.place(x=35, y=200)''' def ImageShow(path): label = Label(root, bg="black", width=40, height=40) label.place(x=215, ...
93d6b1dfe3aced3ddfa2802904b404a28878cc4a
hanfeiyu/Exercises-of-ML-Andrew-NG
/ex1/Ex1_Multivariate.py
2,225
3.65625
4
# # Optional exercise of exercise 1 # import numpy as np import pandas as pd import matplotlib matplotlib.use('TkAgg') import matplotlib.pyplot as plt import tensorflow as tf # Import training data2 data = pd.read_csv("ex1data2.txt", names = ["size", "bedrooms", "price"]) x_raw = data[["size", "bedrooms"]].values y_...
cfd4528e83f688193891ff63a098654b7647d6f9
dantegg/pythonLearning
/mapReduce.py
890
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from functools_learn import reduce def normalize(name): normaName = name[:1].upper()+name[1:].lower() return normaName L1 = ['adam', 'Lisa', 'barT'] L2 = list(map(normalize, L1)) print(L2) def prod(l): def fn(x, y): return x * y return reduce...
012006beebc918994a2393641328f0779c95897a
borko81/python_fundamental_solvess
/text_processing/more_exersice.py
3,021
3.609375
4
# 01. Extract Person Information # number_of_line = int(input()) # # for _ in range(number_of_line): # info = input() # name_f_char = info.index('@') # name_l_char = info.index('|') # age_f_char = info.index('#') # age_l_char = info.index('*') # print(f"{info[name_f_char + 1:name_l_char]} is {in...
7d9441457cdda8731ee79b347bed776f61f1abf8
FatenFrioui/pages-documentation-python-js
/python/tuple.py
993
4.21875
4
# on ne peut pas changer sur le tuple mytuple = ("faten", "sou") mytuple2 = "faten", "sou" print(mytuple) print(mytuple2) print(type(mytuple)) print(type(mytuple2)) print("******") # tuple indexing mytuple3 = (1, 2, 3, 4) print(mytuple3[-1]) # tuple assign values ne supporte pas les changements print("******") # tuple ...
fb3dfeca6980e20b1e517d3ee4366db0650b897a
andremmfaria/exercises-coronapython
/chapter_06/chapter_6_6_9.py
607
4.59375
5
# 6-9. Favorite Places: Make a dictionary called favorite_places. Think of three names to use as keys in the dictionary, and store one to three favorite places for each person. To make this exercise a bit more interesting, ask some friends to name a few of their favorite places. Loop through the dictionary, and print e...
a77521401e1a0c286bc235d9163e781f96f50392
sr105/python_packages_tutorial
/packaging_example/2_and_now_we_are_really_growing/lab/string_manipulations.py
268
4.125
4
# String Manipulations def uppercase(string): """Return string converted to uppercase.""" return string.upper() def backwards(string): """Return string, but backwards.""" return string[::-1] # Could also be: # return ''.join(reversed(string))
90d34f6d95a322730992e6ea9407e1de6c3c8c0d
yexiao1107/LeetCode
/sqrt(x).py
407
3.5
4
def mySqrt(x): """ :type x: int :rtype: int """ if x == 0: return x low = 1 high = x // 2 + 1 while low <= high: counter = (low + high) // 2 if counter ** 2 == x: return counter elif counter ** 2 < x: low += 1 else: ...
d793c89bd2b8b1635f4012d6418c9dd3cb54477f
zhiwenwei/python
/day9/threading_ex2.py
524
3.84375
4
#-*- coding:utf-8 -*- #Author:ZhiWenwei import threading import time class MyThread(threading.Thread): #继承父类threading.Thread def __init__(self,num): super(MyThread,self).__init__() self.num = num def run(self):#把要执行的代码写到run函数里面 线程在创建后会直接运行run函数 print("running on number:%s" %self.num) ...
a18db9a847a1df9352911aee7f54d7ba1396fa5e
AdamZhouSE/pythonHomework
/Code/CodeRecords/2604/60657/250941.py
185
3.65625
4
import math import re A=input() B=input() A=re.findall(r'[\w]',A) def find(A,B): for i in range(len(A)): if A[i]>B: return A[i] return A[0] print(find(A,B))
7e5eb969f96996c1f1269c96e654265eecf8824f
gutianyu520/python_test_demo
/02_python_core_programming/02_linux_programming/02_threading/08_producer_consumer.py
1,687
3.890625
4
# -*- coding: utf-8 -*- # @Time : AD 2021/02/03 21:14 # @Author : Lim Yoona # @Site : # @File : 08_producer_consumer.py # @Software: PyCharm """ 生产者消费者模式 1.队列:先进先出 2.栈:先进后出 python的Queue模块提供了同步和线程安全的队列类 FIFO(先进先出):Queue LIFO(后进先出):LifoQueue 优先级队列:PriorityQueue """ ...
52283a583311d6ce36e18fc98b2c4a229fef7cba
LuanGermano/Mundo-3-Curso-em-Video-Python
/exercicios3/ex113.py
1,270
4.0625
4
# Reescreva a função LEIAINT() da aula 104, incluindo agora a possibilidade da digitação de um numero invalido # Aproveite e crie a função LEia FLoat com a msm funcionalidade def leiaint(): """ Programa de validação de numeros inteiros. :return: """ while True: try: n = int(inpu...
991d60b0fc14933c8756f044c16e27dd9a15bfc6
deepenpatel19/bluetick_challenge
/challenge_v1.py
3,191
3.65625
4
import unittest def update_result_array(result=[], _data=[], i=0): _first_value = _data[i] + 1 _last_value = _data[i + 1] - 1 _value_to_check = _data[i + 1] - _data[i] if _first_value == _last_value: result.append("{0}".format(_first_value)) elif _value_to_check != 1: result.appen...
6f36638b617424a77cec4893d7e52f98e1995437
VittorioYan/Leetcode-Python
/133.py
1,500
3.5
4
# Definition for a Node. class Node: def __init__(self, val, neighbors): self.val = val self.neighbors = neighbors from queue import Queue class Solution: def cloneGraph(self, node: 'Node') -> 'Node': if not node: return node res_node = Node(node.val, []) or...
77b2561381785572a860005e619410904e1b5989
Aasthaengg/IBMdataset
/Python_codes/p03777/s347643368.py
84
3.828125
4
a,b=input().split() x= a=="H" y= b=="H" if x^y: print("D") else: print("H")
bbd6755979e7e6a9aa7a478b49b7c16b94c10fdf
shedolkar12/DS-Algo
/strings/paragraph.py
577
3.703125
4
# make sentences in paragraph # ASSUMING n > maximum length of word containing sentences def para(A, n): print len(A), A start = 0 end = n while start < len(A): while end < len(A) and A[end]!= ' ': end -= 1 # also includeing extra space print A[start:end + 1] ...
2a3fcf822b7a604fca4807b5ba4b334e7a6ad318
mallika2321/checkers
/checkers/internals.py
8,896
3.71875
4
RED = "red" BLACK = "black" players = [BLACK, RED] opponent = {BLACK: RED, RED: BLACK} class CheckersException(Exception): """The base exception type for the chess game.""" def __init__(self, message): Exception.__init__(self, message) class InvalidMoveException(CheckersException): """Repre...
e3741eb25ab72c06f843f6c356b8add2abbead6f
tzyl/leetcode-python
/medium/386.py
2,607
3.5
4
class Solution(object): def lexicalOrder(self, n): lex_order = [] current = 1 for _ in xrange(n): lex_order.append(current) current = self.get_next(current, n) return lex_order def get_next(self, x, n): if 10 * x <= n: retur...
85dd3f1b7e0cf8005b116a5f9ff08fc6808df9f9
alifa2try/Python-How-To-Program
/CHAPTER FOUR/Temperature.py
989
4.03125
4
''' Author: Faisal Ali Garba ( Malware Analyst ), Date: 29/11/2017 Exercise 4.3: Temperature Program from Python How To Pogram by Deitel Implement the following function fahrenheit to return the Fahrenheit equivalent of a Celsius temperature. F = (9/5) * C + 32 Use this function to write a program that prints a...
1d8503e56eebe274687cca921fd5da398cff8358
marquesarthur/programming_problems
/interviewbit/interviewbit/sample.py
285
3.921875
4
def read_input(): numbers_count = int(input()) numbers = [] for _ in range(numbers_count): numbers_item = int(input()) numbers.append(str(numbers_item)) list.reverse(numbers) print('\n'.join(numbers)) if __name__ == '__main__': read_input()
04482d8419ab57a697cf4974f3e39419ceaec84c
liangqs961105/Practice
/1.千峰基础/Day13-文件操作/10-面向对象相关的方法.py
991
4.15625
4
class Person(object): def __init__(self, name, age): self.name = name self.age = age class X(object): pass class Student(Person, X): pass p1 = Person('张三', 18) p2 = Person('张三', 18) s = Student('jack', 20) # 获取两个对象的内存地址 id(p1) == id(p2) print(p1 is p2) # is 身份运算符运算符是用来比较是否是同一个对象 ...
ae8fbfdb341e2f70ce78a2d307b3b3da3377404d
alejandromarinculcha/MisionTIC_Ciclo1
/Area_circulo.py
364
4.125
4
""" def area(r): return 3.1416*r**2 r = int(input("Ingrese radio del círculo: ")) print(area(r)) """ import math def area(r): return math.pi*r**2 # El programa empieza desde aquí ya que es lo principal y ... # apenas ve una función va y la busca arriba. radio = float(input("Ingrese radi...
dc4d6ddc6019a4226235a39cf2d16f03669af703
JiaJia555/PythonCourses
/PrimaryCourses/Day09/9_面向对象.py
3,740
3.734375
4
'''面向过程''' # def stu_info(name,age,gender): # print(name,age,gender) # # stu_info("oldli","18","male") # stu_info("ellen","18","male") # stu_info("bruin","18","male") '''面向对象''' # class Students(object): # def stu_info(self,name, age, gender): # print(name, age, gender) # # s = Students() ...
9438f02a60c790c91d30bce69426a884629cdb72
pwang867/LeetCode-Solutions-Python
/0060. Permutation Sequence.py
1,765
3.78125
4
# method 2, iteration, O(n^2) due to nums.pop(i) import math class Solution(object): def getPermutation(self, n, k): factorial = math.factorial(n) k -= 1 res = [] nums = [str(i) for i in range(1, n+1)] while n > 0: factorial /= n # don't put this line after n -...
d4585fc14fa0b73855f9581afcf5cd1f17312ddb
Rajan1812/Reduce_image_size
/main.py
316
3.59375
4
from PIL import Image import os size=(500,500) def reducesize(): for file in os.listdir('.'): if file.endswith('g'): i = Image.open(file) fname, extn = os.path.splitext(file) i.thumbnail(size) i.save('smaller/{}{}'.format(fname,extn)) if __name__== "__main__": reducesize()
e40ee87ab5e2a63d1bcc63b161a50924b8045e12
charlescheung3/Intro-HW
/Charles Cheung PS 47.py
404
4.28125
4
#Name: Charles Cheung #Email: charles.cheung24@myhunter.cuny.edu #Date: April 14, 2020 #This program makes a turtle walk 100 times. Each "walk" is 20 steps forward and the turtle can turn 0, 5, 10, 15,..., 360 degrees (chosen randomly) at the beginning of each walk. import turtle import random trey = turtle.T...
7b120dce93056bb0ac1e2ae1636beea0c27d1c54
hanchen826/PythonCrashCourse2016
/CH10: Files and Exceptions/10-6 addition.py
209
4
4
try: input0 = int(input("Enter a number: ")) input1 = int(input("Enter a number: ")) except ValueError: print("Sorry but it seems you have not entered a number.") else: print(input0 + input1)
2cda6a84cb330fdc361e85a8e99f4f165f060927
ShadyXV/python-zero
/imageManipulation/OpenCV/Basic/main.py
326
3.546875
4
import cv2 # #Read Image img = cv2.imread('images/input/my_screenshot.png') # #Display Image cv2.imshow('image',img) # cv2.waitKey(0) # cv2.destroyAllWindows() #Applying Grayscale filter to image gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) #Saving filtered image to new file cv2.imwrite('images/output/outputGrey.png'...
09ec236e93e3a68b33ed2d8b8b3b29edf91fddd9
Joeytimbreza/Game
/The Test.py
12,792
3.65625
4
import string import time import os import random values = dict() def inputtxt(): last="" first=input("") if last==first: last="" first="NULL" else: last=first main(first) def test1(): for index, letter in enumerate(string.ascii_lowercase): values[letter] = in...
39d41d796218b25729b4f148c46d7bacf0f3a4c9
ainnes84/DATA520_HW_Notes
/time_searches.py
1,653
3.8125
4
# time_searches.py part 1 import time import linear_search_1 import linear_search_2 import linear_search_3 def time_it(search, L, v): """ (function, object, list) -> number Time how long it takes to run function search to find value v in list L. """ t1 = time.perf_counter() search(L, v) t2 =...
14d50af15d61588243c5f0c84e0db8b71462b748
Mark7E/coding_dojo
/python/fundamentals/fundamentals/for_loop.py
1,142
4.0625
4
''' Basic - Print all integers from 0 to 150. Multiples of Five - Print all the multiples of 5 from 5 to 1, 000 Counting, the Dojo Way - Print integers 1 to 100. If divisible by 5, print "Coding" instead. If divisible by 10, print "Coding Dojo". Whoa. That Sucker's Huge - Add odd integers from 0 to 500, 000, and print ...
4e2a92254b5570b862bed4c617f29daeda488815
calkikhunt/CODE_CHEF
/CPN12019.py
133
3.890625
4
for i in range(int(input())): s=input() ans=s.count("MUJ") if ans>=1: print("YES") else: print("NO")
a5f68ed12db6c5a6906f3f8717e526b43912d04f
PabPerez/CIS2348_HW3
/lab11_22.py
145
3.578125
4
#Pablo Perez #PSID: 177045 user_words = input() word_list = user_words.split(" ") for word in word_list: print(word, word_list.count(word))
a1f58445cacf46403cb1d048a4484b58b2579b10
somupalai/m_tech_work
/secondary_consolidation.py
316
3.546875
4
import math print "the value of Cs" Cs = float(input()) print "the value of Ho" Ho = float(input()) print "the value of eo" eo = float(input()) print "the value of t1" t1 = float(input()) print "the value of t2" t2 = float(input()) #print "the value of Ss" Ss = (Cs*Ho*(math.log((t2/t1),10)))/(1+eo) print Ss
88a3552c1735282ddd0f63c34ad926b42f1a3641
abhikrish06/PythonPractice
/LC_n_Misc/LC_890_FindNRepPattrn.py
954
3.53125
4
class Solution: def findAndReplacePattern(self, words, pattern): """ :type words: List[str] :type pattern: str :rtype: List[str] """ res = [] for i in range(len(words)): dct = {} val = True for j in range(len(pattern)): ...
24e3a1ebf8aa762eeaf0f3a6df6574e1db78e5c0
RushikeshSP/Yay-Python-Basics
/Assignment1/A1_problem5.py
320
3.953125
4
''' Print the following.... if n = 5 1 12 123 1234 12345 ''' n = int(input("Enter number : " )) for i in range(n): for j in range(i+1): print(j+1,end=' ') print() # n= int(input("Enter number:")) # list3= [ ] # for i in range(1, n+1 ): # if i!=0 : # list3.append(i) # print(*list3)
cd73ad64fd6c73f1920274c97fb02bfecea9dfd4
bvsbrk/Algos
/src/Practice/Datastructures/Trees/binary_trees/reverse_level_order_efficient.py
1,077
3.59375
4
from collections import deque from sample_tree import get_tree_root def get_sequenced_que(root): que = deque([]) sequenced_que = deque([]) que.append(root) que.append(None) while len(que) is not 0: node = que.popleft() sequenced_que.append(node) if node is None: ...
80ee4760bf6f18b6e9079870a9f94db99e4d97d5
Sue9/Leetcode
/Python Solutions/814 Binary Tree Pruning.py
1,090
3.6875
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 17 14:42:41 2019 @author: Sue 814. Binary Tree Pruning """ # 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 ha...
1da0beb9ce7b2c609253032f870543db607a3141
damnit1989/python
/dict.py
305
4.15625
4
# -*- coding: utf-8 -*- #可变数据类型,当赋值给另一个变量时,其实是做了一次引用,两个变量指向同一对象 a = {'one':1,'two':2} b = a b['three'] = 3 print(b,a) c = ['one','two'] d = c d.append('three') print(d,c) str = '-' str = ''.join(c) print(str)