blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
41953b6c71c06435ca0cc47621ecbd2c0ea4bcda
LemonTre/python_work
/Chap08/big_shirt.py
216
3.6875
4
def make_shirt(size, message = 'I love Python'): print("\nThe shirt's size is " + size + ".") print("The message in it is: " + message + ".") make_shirt('L') make_shirt('M') make_shirt('S', 'Today is a good day')
cfa6497baa42d0662b46188a4460d47c28e878aa
LemonTre/python_work
/Chap09/eat_numbers.py
1,166
4.15625
4
class Restaurant(): def __init__(self,restaurant_name,cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type self.number_served = 0 def describe_restaurant(self): print("The name of restaurant is: " + self.restaurant_name.title() + ".") print("The type of restaurant is " + s...
1be2e16d5c8c43c3d0e1362924c018ff3e25dab3
LemonTre/python_work
/Chap10/name_list.py
291
3.65625
4
file_path = "G:\python_work\Chap10\guest_book.txt" while True: message = input("\nEnter your name(choose 'q' to quit):") if message == 'q': break else: print("Hello, " + message.title()) with open(file_path, 'a') as file: message += " had a look!" file.write(message + "\n")
6023f9055171965c27b4a4b0afa464ced56d0e28
LemonTre/python_work
/Chap03/guests.py
209
3.5
4
my_guest = ['Zhou Enlai', 'Linda', 'Jessica'] print(my_guest[0] + " , please have a dinner with me.") print(my_guest[1] + " , please have a dinner with me.") print(my_guest[2] + " , please have a dinner with me.")
869ad389bb0481096d0cd3aeddf84d40aaf36862
LemonTre/python_work
/Chap09/users.py
734
3.921875
4
class User(): def __init__(self, first_name, last_name, *list): self.first_name = first_name self.last_name = last_name self.list = list def describe_user(self): print("\nUser's name is: " + self.first_name.title() + " " + self.last_name.title() + ".") for user in self.list: print("Something about ...
d15ea087626b4d3232a5e7e31313134955ea6f97
LemonTre/python_work
/CHap04/my_foods.py
202
3.8125
4
my_foods = ('meat', 'fruit', 'vegetable', 'apple', 'pear') for food in my_foods: print(food) print("\n") my_foods = ('meat', 'orange', 'banana', 'apple', 'pear') for food in my_foods: print(food)
a787c4e2a01b88818289586d13c7332a12d8868f
omkar1117/pythonpractice
/file_write.py
993
4.3125
4
fname = input("Enter your First name:") lname = input("Enter your Last name:") email = input("Enter your Email:") if not fname and not lname and not email: print("Please enter all the details:") elif fname and lname and not email: print("Please enter a valid email") elif email and fname and not lname: pr...
9ed3b2eab7d1779bade66efc664bc134615a7b14
jbdblack/toolsdev_assignment01
/gathernews.py
2,058
3.59375
4
#Description: Scrape and Summarize News Articles #pip install nltk #pip install newspaper3k #Import the libraries import nltk import newspaper userinput = input("Please enter any keyword(press enter to continue):") #Initialize Newspapers NPR_paper = newspaper.build('https://www.npr.org/sections/news/', memoize_ar...
7c2e838c559f75d04708cc5a720a25f09d140c7a
michail82/StepikLearningPython
/step_18.py
467
3.5625
4
a = int (input ()) b = int (input ()) d = 1 while d % a != 0 or d % b != 0: d += 1 print (d) # Программа должна считывать размеры команд (два положительных целых числа a и b, # каждое число вводится на отдельной строке) и выводить наименьшее число c, # которое делится на оба этих числа без остатка.
12ef237e798697bcabd1fb38fadfa2a97727a4af
michail82/StepikLearningPython
/step_17.py
389
3.78125
4
a = int i = 0 while a != 0: a = int (input ()) i += a print (i) # Напишите программу, которая считывает со стандартного ввода целые числа, # по одному числу в строке, и после первого введенного нуля выводит сумму полученных на вход чисел.
4b9624523f87408d345bfc5ea032d3d083741d16
losacii/gitnote
/excel_openpyxl/003.binarySearh.py
1,265
3.75
4
import time def binarySearch(arr, x, left=0, right=0): right = len(arr) - 1 while left <= right: mid = int(left + (right - left) / 2) if arr[mid] == x: print('found {} in position {}'.format(x, mid)) return mid elif arr[mid] < x: left = mid + 1 ...
04e73727b8b2522251b41cf00db5a8a53d7c7861
dannyvchu/GrowBot
/Devices/temp.py
409
3.609375
4
class Temperature(): def __init__(self, pin, unit = 'F'): self.pin = pin self.unit = unit def get_temp_f(self): return 75 def get_temp_c(self): return self.get_temp_f() * 5/9 - 32 def main(): temp = Temperature(1, unit = 'F') temp_arr = [] for i in range(500...
958acaa038e688bc814f7e444048e96d518b8769
chucklesoclock/web-caesar
/helpers.py
456
3.796875
4
from string import ascii_lowercase as lowers def alphabet_position(letter): assert len(letter) == 1, 'Only give me one letter please' return lowers.index(letter.lower()) def rotate_character(char, rot=1): if char.isalpha(): origin_pos = alphabet_position(char) new_pos = (origin_pos + rot...
9fdc0b382bba2dc7b45d2e64c66d17f2f6c71099
angry77cat/mlds
/hw1/HW1-3-2.py
6,679
3.765625
4
''' Graph and Loss visualization using Tensorboard. This example is using the MNIST database of handwritten digits (http://yann.lecun.com/exdb/mnist/) Author: Aymeric Damien Project: https://github.com/aymericdamien/TensorFlow-Examples/ ''' from __future__ import print_function import tensorflow as tf import numpy a...
6b65061d3149fc21bd2567dd5929a076122c22ef
EstebanVivar/OLC2_Proyecto1_201801597
/backend/Project/Objeto/StructPrimitivo.py
465
3.59375
4
from Abstract.Objeto import Objeto,TipoObjeto from abc import ABC, abstractmethod class StructPrimitivo(Objeto): def __init__(self,nombre,valor): self.nombre=nombre self.tipo = TipoObjeto.STRUCT self.valor = valor def toString(self): return str(self.valor) def getValue(sel...
282a8840fcdb44ede71781c077cba9eec264f06f
EstebanVivar/OLC2_Proyecto1_201801597
/backend/Project/Abstract/Objeto.py
499
3.65625
4
from abc import ABC, abstractmethod from enum import Enum class TipoObjeto(Enum): ENTERO = 1 DECIMAL = 2 BOOLEANO = 3 CADENA = 4 CARACTER = 5 POTENCIA = 6 MODULO = 7 STRUCT = 8 RANGO = 9 ARREGLO=10 ENTORNO = 11 ERROR = 100 class Objeto(ABC): def __init__(s...
3bbbc848d049ff93f5ecb1ce56c8c77530ba9542
KarenFender/Notaci-n_Postfija_Algoritmo_Thomson_Python-
/infija.py
1,404
3.796875
4
#Código para expresiones regulare de Infija a Postfija lpos = [] pila = ['n'] expresion = raw_input("ingresa tu expresion regular: ") print "\n" for i in expresion: if (ord(i)>=97 and ord(i)<=122) or (ord(i)>=65 and ord(i)<=90): lpos.append(i) else: if pila == [] or pila[len(pila)-1] == "(...
b1afc2a61da354af931d70b6278d74f8afa760fb
Catering-Company/Capstone-project-2
/Part2/uk_multiple_coin_calculator.py
3,835
4.3125
4
# CODE FOR MULTIPLE COIN CALCULATOR, PROVIDED THAT THE CURRENCY IS SET TO POUNDS. # -------------------------------------------------- # General_functions contains functions that are used throughout multiple parts of the program. from general_functions import get_penny_amount ,floor_calc, uk_coins, uk_coins_dict # --...
dddb2bfd290929643eb202396aecd88df6d51e0f
Catering-Company/Capstone-project-2
/Part2/sub_set_min_coin_value.py
1,889
4.75
5
# CODE FOR SETTING THE MINIMUM COIN INPUT VALUE ( CHOICE 2 OF THE SUB-MENU ) # -------------------------------------------------- # Gets the user to input a new minimum amount of coins that the user can enter # into the Coin Calulator and Mutiple Coin Calculator. # There are restrictions in place to prevent the user ...
0e5804b9e03bd17fd8ed785de1ef42cf14df112a
nish235/PythonPrograms
/Dec08/ClassAndStaticVariables.py
296
3.515625
4
class Student: stream = 'IT' def __init__(self, name, roll): self.name = name self.roll = roll a = Student('Ram', 1) b = Student('Sham', 2) print(a.stream) print(b.stream) print(a.name) print(b.name) print(a.roll) print(b.roll) print(Student.stream)
4c5d799b228e3410f7c81599c930a5d5e3fdc137
nish235/PythonPrograms
/Oct16/PalindromeRange.py
237
3.609375
4
num = int(input("Enter The Number : ")) for i in range(1, num+1): t = i rev = 0 while t > 0: rem = t % 10 rev = (rev * 10) + rem t = t // 10 if i == rev: print(" ", i, end=" ")
59af04dc2a6662987d8aae8a26bd86ee018451af
nish235/PythonPrograms
/Oct28/03Pattern413.py
183
3.734375
4
d = 7 for x in range(4, 0, -1): for y in range(x, 5): print(" ", end="") for z in range(1, d + 1): print(chr(x + 64), end="") d -= 2 print()
98e2f9ce167a2d13920a7ddc8ea49c26f10ef760
nish235/PythonPrograms
/Oct22/10Pattern398.py
119
3.6875
4
d = 7 for x in range(4, 0, -1): for y in range(x, 5): print("", end=" ") print("*"*d) d -= 2
62d5ffa26be49462948b1e0d27264e63ca7458d6
nish235/PythonPrograms
/Oct21/list.py
206
3.671875
4
l1 = [] print(l1) l1 = [12, 13, 23, 34] print(l1) l1 = eval(input("Enter Elements : ")) l1 = list(range(0, 10, 2)) print(l1) s = "Learning Python Is very very easy" l1 = s.split() print(l1)
0ab4005981a83782aaadc501580c221cf0963686
nish235/PythonPrograms
/Nov10/SumOfAllArguments.py
109
3.59375
4
def add(*args): t = 0 for i in args: t = t + i return t print(add(2, 4, 6, 8))
b27bdc20978ca3365e8fe5b87f1f1207f7d48774
nish235/PythonPrograms
/Oct15/ArmstrongWhile.py
252
4.125
4
num = int(input("Enter a number: ")) s = 0 temp = num while temp > 0: dig = temp % 10 s = s + dig ** 3 temp = temp // 10 if s == num: print(num, "is an Armstrong number") else: print(num, "is not an Armstrong number")
fe0caa7997680ec33d4ddd1d5ad800dba2a2a63b
nish235/PythonPrograms
/Nov19/Generators2.py
172
3.96875
4
def countdown(num): print("Start Countdown") while num > 0: yield num num = num - 1 values = countdown(5) for x in values: print(x)
59c90e13bc254342ea035c914122c997f2728a77
nish235/PythonPrograms
/Nov04/SumDictionary.py
248
3.78125
4
d = {} n = int(input("Enter The Number : ")) for i in range(n): print("Enter Key : ") keys = input() print("Enter Value : ") values = int(input()) d[keys] = values print(d) s = sum(d[item] for item in d) print(s)
a22357f654e4b884b3d7422a4b7456b212db1939
siberian122/kyoupuro
/practice/871.py
148
3.5625
4
n = int(input()) ans = "No" for i in range(10): for j in range(10): if i * j == n: ans = "Yes" break print(ans)
b8f2f746520ef84dcec1b5ea9dbfb14196e27a81
siberian122/kyoupuro
/practice/String.py
152
3.640625
4
s=input() t=input() Flag=False for _ in range(len(s)): s=s[-1]+s[:-1] if s==t: Flag=True if Flag: print('Yes') else: print('No')
158234171ab254ab979f60fea682282910de5931
SergeiShumilin/Mth
/limit.py
354
3.546875
4
"""Графики логарифмической функции и график ее производной""" import math import numpy as np import matplotlib.pyplot as plt if __name__ == '__main__': x = np.arange(1, 100, 0.01) y = [math.log2(x) for x in x] dy = [math.log2(math.e) / x for x in x] plt.plot(x, y, x, dy) plt.show()
f2725f5d5f4b12d7904d271873c421c99ff2fe9f
MagRok/Python_tasks
/regex/Python_tasks/Text_stats.py
1,627
4.15625
4
# Create a class that: #• When creating an instance, it required entering the text for which it will count statistics. # The first conversion occurred when the instance was initialized. #Each instance had attributes: - lower_letters_num - which stores the number of all lowercase letters in the text #- upper_letters_num...
23e89c1ee3b518b522a699589f3813f0faf0ddb2
jsmazorra/DS-Unit-3-Sprint-2-SQL-and-Databases
/module3-nosql-and-document-oriented-databases/rpg_mongo.py
3,013
3.875
4
# How was working with MongoDB different from working with PostgreSQL? What was easier, and what was harder? # I would say MongoDB was definitely more flexible than PostgreSQL when it came to inserting the data into the # database. I still need to practice these steps for both of them, but in my opinion I feel like # M...
c5a3aa9eb3f9176820569a282d4d76ed3c605d42
abhijit786/code
/sample.py
173
3.515625
4
class Calculator: def __init__(self,a,b): self.a = a self.b = b def sum(self): return self.a+self.b c = Calculator(10,20) print(c.sum())
3c6d6abcf14a29de799cbed567ea8b07eb87991e
ozadabuk/leetcode-solutions
/AddTwoNumbers.py
983
3.6875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: q = deque([]) carry = 0 head = ListNode() curr = hea...
b646a27afc5537b5db909bccf4d9edf3afcfa8ea
nithintelkar/rectangle_union_intersection_subtraction
/rectangle_intersection_union_subtraction.py
3,745
3.78125
4
from itertools import product, tee def test(): print('Example 1:') a = Rectangle(1, 1, 8, 8) b = Rectangle(2, 2, 6, 6) print(a & b) print(a | b) print(list(a - b)) # ########################## # print('Example 2:') # b = Rectangle(3, 2, 7, 4) # print(a & b) # print(list(a ...
e3fcbaa0bc18af2072399afcf0deb5941517a59b
JuanesFranco/Fundamentos-De-Programacion
/sesion-16/ejercicio matriz.py
661
3.8125
4
# -*- coding: utf-8 -*- """ Created on Tue May 4 12:22:37 2021 @author: TORREX """ matriz1=[] filas=int(input("ingrese el numero de columnas")) print("Fila 1") for x in range(filas): datos=int(input("ingrese datos")) matriz1.append(datos) matriz2=[] print("Fila 2") for x in range(filas): datos=int(input("...
c7579283acfa4bf8656839490f7f416032b3bc4d
JuanesFranco/Fundamentos-De-Programacion
/sesion-08/ejercicio de promedio.py
346
3.75
4
# -*- coding: utf-8 -*- """ Created on Sun Feb 28 17:38:53 2021 @author: TORREX """ suma=0 med=0 cantEle=0 salida=False while(salida==False): num=int(input("digite su edad")) if (num>0): suma=suma+num cantEle=cantEle+1 else: salida=True med=suma/cantEle print("el promedio...
aaf2b7fd4c48c846a3618a948d4f21ed67bccdbd
JuanesFranco/Fundamentos-De-Programacion
/sesion-05/ejercicio 52.py
778
3.5625
4
cantidad1=0 cantidad2=0 cantidad3=0 cantidad4=0 n=int(input("ingrese la cantidad de puntos")) for f in range(n): x=int(input("ingrese el valor de x")) y=int(input("ingrese el valor de y")) if x>0 and y>0: cantidad1=cantidad1+1 else: if x<0 and y>0: cantidad2=cantidad2+1 ...
affaee53f839fd77e92c52bb03c74eca797fb2b1
JuanesFranco/Fundamentos-De-Programacion
/Programacion python/ejercicio-17.py
318
3.90625
4
num=int(input("ingrese numero de 1 y 999:")) if num<10: print("tiene un digito") else: if num<100: print("tiene dos digitos") else: if num<1000: print("tiene tres digitos") else: print("error en la entrada de digitos") print("fin del programa")
ec78545c387a09a9ad80f909280e4b4440b7746a
JuanesFranco/Fundamentos-De-Programacion
/sesion-07/Taller libro Joyanes/4.py
214
3.734375
4
#calcular la suma de los numero impares n=int(input("ingrese el limite de la suma")) impar=0 for f in range(1,n+1): if f %2==1: impar=impar+f print("la suma de los impares es:",impar)
4f0ea15fa795dd1f9d9d3a57072c743ecf0ca238
JuanesFranco/Fundamentos-De-Programacion
/sesion-07/Taller libro Joyanes/6.py
108
3.96875
4
n=int(input("ingrese numero")) for f in range(n): if f>=1 and f<=5: print("numero encontrado")
c6a6bcf1fc028012ff41bb6e7976b36b3cb4d6b8
JuanesFranco/Fundamentos-De-Programacion
/sesion-13/Listas-Mayor-Menor/mayor.py
304
3.765625
4
# -*- coding: utf-8 -*- """ Created on Tue Apr 13 16:44:26 2021 @author: TORREX """ lista=[] for x in range(5): valor=int(input("ingrese valor")) lista.append(valor) mayor=0 for x in range(1,5): if lista[x]>mayor: mayor=lista[x] print(lista) print("el mayor de la lista es:",mayor)
a6ecd6289d94b9fae2d6a3449d13407bd68d3492
JuanesFranco/Fundamentos-De-Programacion
/sesion-13/Listas/1.py
279
3.703125
4
# -*- coding: utf-8 -*- """ Created on Tue Apr 13 15:05:18 2021 @author: TORREX """ lista=[10,20,30,40,50,] suma=0 x=0 while x<len(lista): suma=suma+lista[x] x=x+1 print("los elementos de la lista son:",len(lista)) print("la suma de los elementos de la lsta es:",suma)
ae2661ed9718fb7c801e697786e765c40206fbba
JuanesFranco/Fundamentos-De-Programacion
/sesion-13/listas pareja/2.py
290
3.921875
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 14 15:41:28 2021 @author: TORREX """ lista=[] for x in range(5): nombre=str(input("ingrese nombre")) lista.append(nombre) names=lista[0] for x in range(1,5): if lista[x]<names: name=lista[x] print(lista) print(names)
1a915cdaf0fdb22b6bb60afa256452acfb3a3391
JuanesFranco/Fundamentos-De-Programacion
/sesion-15/Matrices.py
778
3.84375
4
# -*- coding: utf-8 -*- """ Created on Thu Apr 29 11:52:44 2021 @author: TORREX """ import pandas matriz=[[12,32,56,48],[8,48,18,58],[2,4,6,8]] #imprecion de la matriz print(matriz) #imprimir una matriz determinada print(matriz[0][2]) #imprecion de la fila print(matriz[0]) #Seleccion por teclado fila=int(input("ing...
b0bfefd1febe5e7b190a913c54478f0e954719b0
JuanesFranco/Fundamentos-De-Programacion
/Programacion python/ejercicio-13.py
147
3.8125
4
valor=int(input("ingrese un valor comprendido entre 1 y 99:")) if valor>=10: print("tiene dos digitos") else: print("tiene un digito")
67340b1ca8f406765082ecc8d1002add0feab247
rohitsinha54/Learning-Python
/algorithms/quicksort.py
1,153
4.09375
4
#!/usr/bin/env python """quicksort.py: Program to implement quicksort""" __author__ = 'Rohit Sinha' def quick_sort(alist): quick_sort_helper(alist, 0, len(alist) - 1) def quick_sort_helper(alist, start, end): if start < end: pivot = partition(alist, start, end) quick_sort_helper(alist, sta...
d14527439c86b7a1fcbb26265f467caef200003d
rohitsinha54/Learning-Python
/algorithms/palichecker.py
604
3.84375
4
#!/usr/bin/env python """palichecker.py: Program to check if a given string is palindrome or not""" from deque import Deque __author__ = 'Rohit Sinha' def pali_checker(string): dq = Deque() for s in string: dq.addRear(s) eq_flag = True while dq.size() > 1 and eq_flag: left = dq.r...
0bb9feb744ffe92434e2d7e10aa0c3492b02ab29
Jooonyub/python
/SQL/movies.py
373
3.84375
4
import sqlite3 as sql #sqlite3라는 module import #.connect라는 class / connect라는 method 안의 cursor라는 method conn = sql.connect('/Users/joonyubkim/workspace/python/SQL/movies/movies.db') c = conn.cursor() c.execute("SELECT title FROM movies WHERE year = 2008") #어떻게 하면 1.sql에다가 저장할 수 있을까? conn.commit() c.close() conn.clos...
f8997abf3f773c09161a2bd098aa2cb410f91981
hulaba/geekInsideYou
/heap/checkBinaryHeap.py
594
3.828125
4
def checkMinHeap(arr, n): """ This function checks whether a given tree is a min heap :param arr: tree in form of array :param n: number of nodes :return: """ for i in range((n // 2) - 1, -1, -1): if arr[i] > arr[(i * 2) + 1]: return False if (i * 2) + 2 < n: ...
32e90697a2ccfdc8a60f56f7e1d7c5b21622203d
hulaba/geekInsideYou
/string/multiplyString.py
474
4.09375
4
def multiply(a, b): """ Given two numbers as stings s1 and s2 your task is to multiply them. You are required to complete the function multiplyStrings which takes two strings s1 and s2 as its only argument and returns their product as strings. """ a = int(a) b = int(b) return str(a *...
ad88d60e5b4b5ab7c77df24182ec07525e213411
hulaba/geekInsideYou
/trie/trieSearch.py
2,112
4.125
4
class TrieNode: def __init__(self): """ initializing a node of trie isEOW is isEndOfWord flag used for the leaf nodes """ self.children = [None] * 26 self.isEOW = False class Trie: def __init__(self): """ initializing the trie data structure with...
cc4a84614e8104c4d09532c236d45dd555b636a8
hulaba/geekInsideYou
/linked list/deleteListKey.py
1,149
4
4
class Node: def __init__(self, data): """initialising data and next pointer""" self.data = data self.next = None class linkedList: def __init__(self): """initialising head node""" self.head = None def delete_key(self, key): """ deleting a given elem...
f7bcb60906ae04659291b29b2c74746e55b2656e
hulaba/geekInsideYou
/string/maxOccur.py
1,042
3.9375
4
# User function Template for python3 def getMaxOccurringChar(s): """ Your task is to return the lexicographically smallest max occurring character in given string. Function Arguments: s (given string) Return Type: char or -1. """ freqDict = {} s = list(s) le = len(s) for i in ran...
51d1968db47228dd85af41791cab10fa4c518bc2
hulaba/geekInsideYou
/array/occurenceOfOne.py
377
3.515625
4
def count_last_one(s): if '1' not in s: return -1 else: s = s[::-1] n = len(s) for i in range(n): if s[i] == '1': return n - i - 1 def main(): test_case = int(input()) for i in range(test_case): case = str(input()) print(count...
afda0697d38fd8fa33e353afa2ba4b269906a364
hulaba/geekInsideYou
/heap/heightOfHeap.py
200
3.765625
4
import math def height_heap(n): return math.ceil(math.log(n + 1, 2)) - 1 for _ in range(int(input())): n = int(input()) t = [int(i) for i in input().split()] print(height_heap(n))
44e25b0b6e03b9b3f1e15e5656f0cd8ab9728a07
hulaba/geekInsideYou
/linked list/countOccurence.py
987
3.734375
4
def count(head, search_for): # Code here current = head count = 0 while current is not None: if current.data == search_for: count += 1 current = current.next return count class Node: def __init__(self, data): self.data = data self.next = None class...
0d877b43c404c588ef0dbacd8c93c94b17534359
hulaba/geekInsideYou
/tree/levelOrderSpiralForm.py
1,421
4.1875
4
""" Write a function to print spiral order traversal of a tree. For below tree, function should print 1, 2, 3, 4, 5, 6, 7. spiral_order """ class Node: def __init__(self, key): self.val = key self.left = None self.right = None def spiralOrder(root): h = heightOfTree(root) ltr = F...
5c57fd2dceeec00e3966a0970d58d4ed861da959
hulaba/geekInsideYou
/Bit Magic/firstSetBit.py
652
3.65625
4
# { # Driver Code Starts # Initial Template for Python 3 # } Driver Code Ends # User function Template for python3 ##Complete this function def getFirstSetBit(n): # Your code here pos = 1 if n == 0: return 0 if n == 1: return 1 # counting the position of first set bit for i i...
c9177860241ba612a10c13afa03ef7f201f22fee
hulaba/geekInsideYou
/matrix/matrixSubtraction.py
477
4.1875
4
def subtractMatrix(A, B, N): """ Function to SUBTRACT two matrices N: rows and columns of matrices respectively A, B: two input matrices """ C = A[:][:] for i in range(N): for j in range(N): C[i][j] = A[i][j] - B[i][j] print(C) if __name__ == '__main__': ...
93f766cf9025243e1fe699c5e66c3b9b62ac2309
hulaba/geekInsideYou
/sorting_searching/linear_search.py
547
3.90625
4
""" In linear search, each element is traversed one by one until match is found!! """ def lsearch(arr, n, x): for i in range(0, n): if arr[i] == x: return i return -1 def main(): n = int(input()) arr = input("Enter arr separated by space") arr = arr.strip().split() x = in...
992acda092ece35378df1d6aa669fc18c1031ca1
hulaba/geekInsideYou
/BST/insertion.py
887
4.0625
4
class Node: def __init__(self, key): self.val = key self.left = None self.right = None def insert(root, key): if root is None: root = key else: if root.val < key.val: if root.right is None: root.right = key else: ...
aa353dbfb44bee18eb5e1a2cd3dd2e8d30020e9d
hulaba/geekInsideYou
/sorting_searching/sort012.py
890
3.515625
4
# User function Template for python3 def sort012(arr, n): # code here cnt_0 = cnt_1 = cnt_2 = 0 for i in range(n): if arr[i] == 0: cnt_0 += 1 elif arr[i] == 1: cnt_1 += 1 elif arr[i] == 2: cnt_2 += 1 i = 0 while (cnt_0 > 0): arr...
6bad0df59ec12852fb4e001b0c66ff0e1c827056
hulaba/geekInsideYou
/sorting_searching/insertion_sort.py
522
4
4
""" Algorithm: start from the second element * compare with the sorted subarray * shift all elements before current element if smaller & insert curent at new empty space """ def i_sort(arr, N): for i in range(1, N): key = arr[i] # current element j = i - 1 while j >= 0 and arr[j] > key: ...
8bbd84f22d9af1917de39200a00c0a8edeb81a34
hulaba/geekInsideYou
/linked list/deleteListPosition.py
1,403
4.15625
4
class Node: def __init__(self, data): """initialising the data and next pointer of a node""" self.data = data self.next = None class linkedList: def __init__(self): """initialising the head node""" self.head = None def push(self, new_data): """inserting t...
4fd64880d431212ee59b417ee661b3270a0974a2
hulaba/geekInsideYou
/math/sumNumInAlphaNum.py
226
3.59375
4
def sumNum(inputstring): sum = 0 for i in inputstring: if i.isdigit(): sum += int(i) return sum def main(): print(sumNum(inputstring='bcgeek1g45')) if __name__ == '__main__': main()
7ac4795a45ffa9a1e8c24579de5d7c5a90581d77
hulaba/geekInsideYou
/math/Kth smallest.py
267
3.90625
4
def kthsmallestNumber(arr, n, k): arr.sort() return arr[k - 1] if __name__ == '__main__': arr = [2, 35, 16, 78, 4, 31, 167] n = len(arr) k = 3 if k < n: print("The {}th smallest number is {}".format(k, kthsmallestNumber(arr, n, k)))
1d3421dd26e36e65168eebe94b1112f3551bcfdd
hulaba/geekInsideYou
/string/validateIP.py
578
3.59375
4
def isValidIP(s): # code here s = s.split('.') result = [] if len(s) != 4: result.append('0') else: for i in s: if i.startswith('0') and i != '0': result.append('0') else: if 0 <= int(i) <= 255: result.append...
310ed6e51d6b7d5f7691c15479618dc7eeac6014
MGniew/Projects
/SOLUTIONS/Python/Numbers/alarm_clock.py
1,136
3.9375
4
'''Alarm Clock - A simple clock where it plays a sound \ after X number of minutes/seconds or at a particular time.''' import argparse from datetime import datetime import time import os class TimeException(Exception): pass def alarm(hour, minute): dt1 = datetime.now() dt2 = dt1.replace(hour=hour, minu...
25531c0dba885b823b2027e63937f1ba905ea3a4
Aparee20/Algorithms
/Sorting/InsertionSort.py
309
4.03125
4
def InsertionSort(arr): size=len(arr)-1 for i in range(1,size): print(arr[i]) key = arr[i]; j =i-1 while j >= 0 and key < arr[j]: arr[j + 1] = arr[j] j -= 1 arr[j + 1] = key inp = [9,1,8, 5, 2, 3, 0] InsertionSort(inp) print(inp)
3ee8bf33991dc73be91598f76c8c14dc7a70a42c
codebhendi/auction_system
/python-cli/admin.py
2,490
3.59375
4
from seller import separate, categories, bidder_array, seller_array def add_category(): while True: separate() input_val = input('Enter category or -1 to go back: ') if input_val == '-1': break elif input_val == '': print('Incorrect value') contin...
574364dc7281a34ebf44fe29a0beb0ca0e82d059
mohilkhare1708/Competitive-Programming
/Misc/Coding/googleFoobar/gfc1.py
377
3.6875
4
def solution(x, y): oneLess = [] main = [] if len(x) > len(y): oneLess = y main = x else: oneLess = x main = y oneLess.sort() main.sort() for i in range(len(oneLess)): if main[i] != oneLess[i]: return main[i] return main[len(main)-1] ...
1f59535aa3793d20bf581d4f4fd7626cc09afad1
thelinuxuser-choice/AnonCracker
/hash.py
3,594
3.96875
4
#!/usr/bin/env python3 import hashlib hash_pass = input("\033[36mEnter the hash to crack:\033[0m ").lower() passlist = input("\033[36mEnter the dictionary :\033[0m ") def sha256(passlist): with open(passlist,'r') as f: lines = f.readlines() for word in lines: enc_wrd = word.encode() digest =...
a391cffc93ef8c75fbc67d939b4cfda54eb94908
Bhushanb55/Fake-News-Analysis-on-Twitter-using-Machine-Learning-Techniques
/prediction.py
2,470
3.625
4
# -*- coding: utf-8 -*- """ @author: BHUSHAN """ import pickle from tkinter import * from tkinter import ttk #doc_new = ['obama is running for president in 2016'] def Statment(): var =input("Please enter the news text you want to verify: ") print("You entered: " + str(var)) #function to run for p...
1a449a806200f90f50982f5cfd448b83cb3fc6e2
gnsisec/learn-python-with-the-the-hard-way
/exercise/ex45_new.py
1,410
4
4
class level(): def level_one(self): print "#### This is Level one ####" self.math_one = input("Give me number 6 * 2: ") if self.math_one == 12: print "You are right!\n" else: print "You are wrong!\n" exit(0) def level_two(self): ...
55331f5963decff52569b384fa63909dcebfc1fd
gnsisec/learn-python-with-the-the-hard-way
/exercise/ex6.py
488
4
4
# This is Python version 2.7 # Exercise 6: Strings and Text x = "There are %d types of people" % 10 binary = "binary" do_not = "don't" y = "Those know %s and those who %s." % (binary, do_not) print x print y print "I said: %r." % x print "I also said: '%s'." % y # True or False hilarious = False joke_evalutation = ...
1ebf124d42d510c2e60c3c7585c03e0efd6dad18
gnsisec/learn-python-with-the-the-hard-way
/exercise/ex14Drill.py
871
4.21875
4
# This is Python version 2.7 # Exercise 14: Prompting and Passing # to run this use: # python ex14.py matthew # 2. Change the prompt variable to something else entirely. # 3. Drill: Add another argument and use it in your script, # the same way you did in the previous exercise with first, second = ARGV. from sys imp...
884fbc8dc0a50234df5b11e5f049931d90e0fdc8
gnsisec/learn-python-with-the-the-hard-way
/exercise/ex3Float.py
609
4.0625
4
# This is Python version 2.7 # Exercise 3: Numbers and Math # Drill: Floating point print "I will now count my cell:" print "Hens", 25.23 + 30.00 / 6 print "Roosters", 100 - 25 * 3 % 4.00 print "\nNow I will count the eggs:" print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 print "\nIs it true that 3.02 + 2 < 7.01 - 2?" print...
3ca3a6b8b9b27c6598978093563c811a4553152b
MidWeekUser/AndelaForum
/forum.py
746
3.984375
4
class Forum(object): def show_available_options(): print('1. Show Users') print('2. Register') print('3. Quit') print() users = {} options = 0 '''Display the menu to the user''' show_available_options() '''Conditional statements managing menu selections''' while options != 3: optio...
8f25471b828dfba65ec46bcc1eb89ef05c43d41f
jwright0991/Graphs
/word_ladder.py
3,026
3.71875
4
import string, math import collections import sys from itertools import combinations from string import ascii_lowercase as lower #words is a list of words that are allowed to be used in the word ladder #start is initial word #end is the word that we are changing start to #returns a list of the words in the word ladder...
d9dd1db5f3cc236d8be5e34cde2527a73fd8e03e
dannyboywoop/AdventOfCode2019
/Day_07/python/Intcode.py
3,973
3.625
4
from copy import deepcopy def get_program_data(filename="input.txt"): with open(filename, "r") as file: data = [int(x) for x in file.read().split(",")] return data def pad_parameter_modes(param_modes, expected_length): param_modes += [0]*(expected_length-len(param_modes)) class Intcode_Compute...
81e9c0f70d68a1bbe92606917259d012942c02e5
aleperno/tp1tda
/test1.py
419
3.71875
4
#!/usr/bin/python import sys from Graph import * def main(): v1 = Vertex('A') v2 = Vertex('B') v3 = Vertex('C') e1 = Edge(v1,v3) e = Edge(v1,v2) print e g = Graph() g.addVertex(v1) g.addVertex(v2) g.addVertex(v3) print g.addEdge(e) print g.addEdge(e1) print g print "Will try to delete edge" print g.delE...
8b7bc3bf886640bb2d8d0a8dd13b9ff470e4e793
GARTosto/Desafios-Curso-Python-Aula-12
/desafio39.py
709
4
4
from datetime import date atual = date.today().year sexo = str(input('Informe seu sexo: ')).upper() ano = int(input('Informe o ano de seu nascimento: ')) idade = atual-ano print(f'Quem nasceu em {ano} tem {idade} anos em {atual}.') if sexo == 'FEMININO': print('O alistamento não é obrigatório para mulheres.') if ...
79e9b7d603997ea43eaa6ded44ac08d38f106738
Frankyh-9/rsa-cryptography
/keygen.py
1,832
3.53125
4
import random from random import randint import large_prime_generator from utils import printConfirmation def gcd(p, q): while q != 0: p, q = q, p % q return p def isCoPrime(p, q): return gcd(p, q) == 1 def egcd(a, b): s = 0 old_s = 1 t = 1 old_t = 0 r = b old_r = a w...
31a8eaf4a7f510b11ddbbaf39bdd22b9cee188d1
JoshuaMeza/CodePain_PE
/2daEntrega/Prototipo 3/Main.py
11,333
3.828125
4
""" Author Joshua Meza, Jonathan Gómez, and Irving Poot Date 21/04/2020 Version 1.2.0 Program who ask to the user a Country and returns the graphics of total cases and total deaths, the total numbers and the logarithmic ecuations that represents the increase of cases and deaths. """ import http.client import json impo...
e13130eac1813748dfd6b871b08031f7fb3f08f4
DoStini/FEUP-FPRO
/Play/Week6/play_min_path.py
509
3.984375
4
# -*- coding: utf-8 -*- """ Created on Wed Nov 6 16:04:50 2019 @author: morei """ def min_path(path): stack = [] for a in path: if len(stack) != 0 and opposite(a) == stack[-1]: stack.pop() else: stack.append(a) return stack def opposite(dir_): ...
ed39241b5f8b56c51fcbe4ae3dbe0393e6d250f4
DoStini/FEUP-FPRO
/Play/Week8/play.py
1,186
4.03125
4
# -*- coding: utf-8 -*- """ Created on Wed Nov 27 21:45:09 2019 @author: morei """ import math def average(a, b): return math.ceil((a + b) / 2) def mywhile1(n): if n >= 10: avg = 0 power = 0 n = mywhile2(n, power, avg) n = mywhile1(n) return n d...
5e5c6120a74aa1664285a2e3b7d3d85ca667c2e5
DoStini/FEUP-FPRO
/RE/RE13/re_04.py
357
3.96875
4
# -*- coding: utf-8 -*- """ Created on Mon Jan 6 17:21:32 2020 @author: morei """ def raise_exception(alist, value): out = [] for x in alist: try: if x <= value: raise ValueError(f'{x} is not greater than {value}') except ValueError as error: ...
531c037e9a0227a4e4802b87f34fbc3baa8d2a96
DoStini/FEUP-FPRO
/RE/RE13/re_02.py
445
3.65625
4
# -*- coding: utf-8 -*- """ Created on Mon Jan 6 12:55:05 2020 @author: morei """ def sort_by_field(filename, field, inp): # with open(filename, "r") as file: # file = file.read().split() file = inp.split("\n") # alterar isto para open file # file.pop() field = file[0].s...
ecf4e27f5b9f4ee2dffb7865dcd647ebde68c317
DoStini/FEUP-FPRO
/Play/Week11/bubble.py
373
4.09375
4
# -*- coding: utf-8 -*- """ Created on Wed Dec 11 20:56:10 2019 @author: morei """ def bubble_sort(alist): swapped = True while swapped: swapped = False for x in range(len(alist)-1): if alist[x+1] < alist[x]: alist[x], alist[x+1] = alist[x+1], alist[x] ...
02564865e0c46f85b7fea3d641d3312f8ad2634f
DoStini/FEUP-FPRO
/Play/Week6/play_lastman.py
366
3.703125
4
# -*- coding: utf-8 -*- """ Created on Wed Nov 6 18:41:48 2019 @author: morei """ def last_man_standing(alist, step): counter = 0 while len(alist) > 1: len_ = len(alist) counter += step -1 if counter >= len_: counter %= len_ print(counter, alist) ...
c16ce716bd5d44b11b07b2f3142d5784c2c5f09f
DoStini/FEUP-FPRO
/RE/RE10/re_02.py
316
3.8125
4
# -*- coding: utf-8 -*- """ Created on Mon Dec 2 09:21:08 2019 @author: morei """ def comprehensions(i, j): a = [x for x in range(i, j+1) if str(x)[-1] == "3" or str(x)[-1] == "8"] b = tuple([round(x**1/2) for x in range(i, j+1)]) c = {x: chr(x) for x in range(i, j+1)} return (a, b, c)
65406611b05b07f150628a6744165239719db541
DoStini/FEUP-FPRO
/PE01_2018/question4.py
458
3.625
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 16 20:12:03 2019 @author: morei """ tS = float(input("Swimming stage time: ")) tC = float(input("Cycling stage time: ")) tR = float(input("Running stage time: ")) time = tS + tC + tR vS = 1.5 / tS vC = 40 / tC vR = 10 / tR if time >= 4: print("Ti...
7a1c24fcb0688c5015f43270995ad2b3282a7e9d
DoStini/FEUP-FPRO
/RE/RE04/re_04.py
980
3.796875
4
# -*- coding: utf-8 -*- """ Created on Mon Oct 14 12:19:47 2019 @author: morei """ def mastermind(g1, g2, g3, c1, c2, c3): points = 0 check_1, check_2, check_3 = False, False, False if g1 == c1: points += 3 check_1 = True else: if g1 == c2: points += ...
29777266f3eebadb4b2928d7c2d6c95d03b0a9c1
DoStini/FEUP-FPRO
/RE/RE07/re_04.py
1,030
3.671875
4
# -*- coding: utf-8 -*- """ Created on Mon Nov 11 12:54:48 2019 @author: morei """ def isomorphic(astring1, astring2): pos1 = {} # possible outcomes pos2 = {} for x, val in enumerate(astring1): out1 = True if x in pos1: if pos1[val] != astring2[x]: ...
70fe443a49e2e0bc895ed614472c25877c9c2ff0
DoStini/FEUP-FPRO
/Play/Week4/play_dog.py
211
3.671875
4
# -*- coding: utf-8 -*- """ Created on Tue Oct 15 21:40:47 2019 @author: morei """ def dogs(h_age): if h_age <= 2: return(h_age * 10.5) else: return(2*10.5 + (h_age - 2) * 4)
7a239010ccb995cab928b50f2992f8906e4fe574
DoStini/FEUP-FPRO
/PE01_2018/question3.py
316
3.640625
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 16 20:05:49 2019 @author: morei """ names = ["bart", "marie", "jo"] ages = [23, 75, 19] n = 0 a = 0 for name in names: for age in ages: if n == a: print(name + "-" + str(age)) break a += 1 n += 1
e8d4ddd6692149aa04df1776b3d7fb67339edcba
DoStini/FEUP-FPRO
/Play/Week11/distance2.py
1,359
3.65625
4
# -*- coding: utf-8 -*- """ Created on Tue Dec 17 19:57:08 2019 @author: morei """ from math import sqrt def closest_pair(points): points = sorted(points, key=lambda x: x[0]) def recursive(points): min_ = 999999999999 if len(points) <= 3: for x in points: ...
a26b3b2cbbc9f8208f66682061640085cb00eb09
DoStini/FEUP-FPRO
/Play/Week6/play_rotate.py
210
4.09375
4
# -*- coding: utf-8 -*- """ Created on Wed Nov 6 11:08:07 2019 @author: morei """ def rotate_list(l): result = l.copy() for x in range(len(l)): result[x-3] = l[x] return result