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
f35975071907f644a8436b8c635160f93f5aa7dc
Laharisikakollu/graph
/main.py
656
3.78125
4
import functions from collections import defaultdict #dic = defaultdict(list) dic={} '''node = list(input("Enter the nodes ").split()) for i in node: lis=[] lis=input("Enter the nodes linked to node "+i).split() dic[i]=lis print(functions.edges(dic))''' while True: n=int(input("1-insert edge\n2-delete edge\n3-d...
892ba5dc80b77da4916db1e1afb0f0b4a06c75ba
ibndiaye/odd-or-even
/main.py
321
4.25
4
print("welcome to this simple calculator") number = int(input("Which number do you want to check? ")) divider = int(input("what do you want to divide it by? ")) operation=number%divider result=round(number/divider, 2) if operation == 0: print(f"{result} is an even number") else: print(f"{result} is an odd number")...
0d9931f78fdf6c8e8a60c71cfccbc4302cc7bc8f
DomWeldon/SecretSanta
/naughty.py
577
3.5
4
"""The Naughty Way This is a very bad way of implementing a Secret Santa that has a very high likelihood of allocating someone to buy a gift for themself. """ from random import sample # remember shuffle is in place from christmas import merry_christmas, EVERYONE, secret_santa num_people = len(EVERYONE) # 🎅 Santa...
b89978b1b0c1f895f3d4df12b972f069cfcf13d9
chithrasasidharan/pyth
/pyth/1_gui.py
1,923
3.625
4
from tkinter import * from tkinter.ttk import * from tkinter import messagebox window = Tk() window.title("Calculator") window.geometry('300x200') lbl1= Label(window,text = "Number1 ") lbl1.grid(column = 0,row = 0) num1 = Entry(window, width = 10) num1.focus() num1.grid(column = 1,row = 0) lbl2 = Label(window, text...
e8b080a9d35a664263ce66b9fa525aff36898d80
kennanseno/DIT
/4th Year - 1st Semester/Adv Security 1/Lab 1/lab1-part2.py
692
3.78125
4
print "--------------------------------Q1-------------------------------------" def fence(p, k): fence = [[None] * len(p) for n in range(k)] rails = range(k - 1) + range(k - 1, 0, -1) for n, x in enumerate(p): fence[rails[n % len(rails)]][n] = x return [c for rail in fence for c in rail if c is...
4345c78d39cf7a4345e448d1164be30986c09b82
kennanseno/DIT
/4th Year - 1st Semester/Adv Security 1/Lab 2/lab2-q3-4.py
2,356
3.671875
4
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def translate(message, key, mode): translated = [] # store message string index = 0 key = key.upper() for char in message: # loop through chars in message position = LETTERS.find(char.upper()) if position != -1: if mode == 'encrypt': ...
976f0ca719f81c2366a4a4d7018f35e0889662c8
MahmoudOsama97/Intelligent-Mancala-with-alpha-beta-pruning
/mancala.py
4,112
3.703125
4
from utilities import * from move import takeAiMove, takePlayerMove import numpy as np from player_minmax import Player def main(): playAgain=1 while(playAgain): newGame=int(input("Do you want to start new game or continue ? (0:continue, 1:new): ")) if newGame==1: Player1 = [4, 4, ...
b51475fc1cb272b5cb3f943a1c3c820381ce1a4f
emilianocosta/programacao
/Python/exer11.py
1,308
3.703125
4
#--------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------| #Emiliano Costa Junior - RA:1260901923008 #FATEC - Automação Industrial #Programação Aplicada a Automação #Programa 11 - Seleciona o maior valor digitado #--------|---------|---------|---------|...
422258047ed05c73325d79539cd7daac9a86400b
Shakti299/Prediction-using-Supervised-ML
/Prediction using Supervised ML.py
756
3.578125
4
#!/usr/bin/env python # coding: utf-8 # In[3]: import pandas as pd import numpy as np import matplotlib.pyplot as plt # In[4]: data = pd.read_csv("student_scores.csv") data.head() # In[5]: data.plot(x="Hours", y="Scores" , style='o') plt.title("Hours vs Percentage") plt.xlabel("The Hours Studied") plt.ylabel...
e956e4568db7d37b711bfb110e71e8277cc13df7
adwardlee/leetcode_solutions
/100_Same_Tree.py
1,745
3.953125
4
''' Given the roots of two binary trees p and q, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical, and the nodes have the same value. Example 1: Input: p = [1,2,3], q = [1,2,3] Output: true Example 2: Input: p = [1,2], q = [1,nul...
d475df99c67157cfad58ce2514cae3e378ed785c
adwardlee/leetcode_solutions
/0114_Flatten_Binary_Tree_to_Linked_List.py
1,520
4.34375
4
''' Given the root of a binary tree, flatten the tree into a "linked list": The "linked list" should use the same TreeNode class where the right child pointer points to the next node in the list and the left child pointer is always null. The "linked list" should be in the same order as a pre-order traversal of the bin...
243d3c0e133178c4aefa2639c271c252f28b287d
adwardlee/leetcode_solutions
/016_3Sum_Closest.py
1,268
3.984375
4
''' Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. Example: Given array nums = [-1, 2, 1, -4], and target = 1. The sum that is closest to...
3d029921f13589c2553352f0fd5bcc18c158279c
adwardlee/leetcode_solutions
/074_Search_a_2D_Matrix.py
1,773
3.921875
4
''' Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer of each row is greater than the last integer of the previous row. Example 1: Input: matrix = [ [1, 3, 5, 7], [10, 11, 1...
4895433583b4fb20bea67de4227e155f30ac44a5
adwardlee/leetcode_solutions
/050_Pow(x, n).py
1,327
3.5
4
''' Implement pow(x, n), which calculates x raised to the power n (xn). Example 1: Input: 2.00000, 10 Output: 1024.00000 Example 2: Input: 2.10000, 3 Output: 9.26100 Example 3: Input: 2.00000, -2 Output: 0.25000 Explanation: 2-2 = 1/22 = 1/4 = 0.25 Note: -100.0 < x < 100.0 n is a 32-bit signed integer, within the ...
172e2e97dbd38b308ea3722c3cfcc2a786f62e9e
adwardlee/leetcode_solutions
/097_Interleaving_String.py
1,307
4.03125
4
''' Given strings s1, s2, and s3, find whether s3 is formed by an interleaving of s1 and s2. An interleaving of two strings s and t is a configuration where they are divided into non-empty substrings such that: s = s1 + s2 + ... + sn t = t1 + t2 + ... + tm |n - m| <= 1 The interleaving is s1 + t1 + s2 + t2 + s3 + t3 ...
4f6b13bbb3cd3e6e6c7b564cefb11582421fef3e
adwardlee/leetcode_solutions
/023_Merge_k_Sorted_Lists.py
1,293
4.0625
4
''' Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example: Input: [ 1->4->5, 1->3->4, 2->6 ] Output: 1->1->2->3->4->4->5->6 ''' # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # ...
e277d19d798c05c97539e18396fc88544cb33c1f
adwardlee/leetcode_solutions
/DFS/0301_Remove_Invalid_Parentheses.py
2,194
3.984375
4
''' Given a string s that contains parentheses and letters, remove the minimum number of invalid parentheses to make the input string valid. Return all the possible results. You may return the answer in any order. Example 1: Input: s = "()())()" Output: ["(())()","()()()"] Example 2: Input: s = "(a)())()" Output...
d5110e5ff1f8722bc9d0c09761e7cc933eecf092
adwardlee/leetcode_solutions
/0109_Convert_Sorted_List_to_Binary_Search_Tree.py
1,683
4.03125
4
''' Given the head of a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1. Example 1: Input: head = [-10...
32424e58491a1093238f57519cd332c479950fa8
adwardlee/leetcode_solutions
/077_Combinations.py
768
3.765625
4
''' Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. You may return the answer in any order. Example 1: Input: n = 4, k = 2 Output: [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ] Example 2: Input: n = 1, k = 1 Output: [[1]] Constraints: 1 <= n <= 20 1 <= k ...
ed936f5f49f560d90192d6abdde0b389aa6e786e
adwardlee/leetcode_solutions
/bfs/0444_graph_valid_treeII.py
2,193
3.84375
4
''' Description Please design a data structure which can do the following operations: void addEdge(int a, int b):add an edge between node aa and node bb. It is guaranteed that there isn't self-loop or multi-edge. bool isValidTree(): Check whether these edges make up a valid tree. Example Example 1 Input: addEdge(1,...
1185002616b6e36382672823b63ee98b22a2e761
Verawewon/fizzbuzz
/FizzBuzz.py
652
3.859375
4
def main(): # 1 # 2 for i in range(1,101): if i % 15==0: print("FizzBuzz") elif i % 3==0: print("Fizz") elif i % 5==0: print("Buzz") else: print(i) for i in range(1,101): if i==42: print("Answer to the...
63af0c400f99f51ae8c353a97cf12065416df972
martin-martin/python-crashcourse
/02_25_mon/contains.py
357
4.0625
4
locations = ["indonesia", "spain", "thailand", "mexico", "usa"] # membership operators # in # not in print('bali' not in locations) my_list = [1, 2, 3, 5, 42] even = [] for num in my_list: if num % 2 == 0: even.append(num) print(even) not_even = [] for num in my_list: if num not in even: n...
13cec58adbff373f500ba52d690f10baa0f567cd
martin-martin/python-crashcourse
/02_22_fri/bikes.py
150
3.5625
4
bikes = ['trek', 'cannondale', 'redline', 'specialized'] print(bikes[0:-1]) print(bikes[0].upper()) print(f"I like {bikes[3].capitalize()} bikes.")
7bd6486ccb57f04e090cd6b0d258e4d6d8167454
martin-martin/python-crashcourse
/03_01_fri/food.py
514
3.796875
4
class Food: def __init__(self, name, amount): self.name = name self.amount = amount def buy(self, number): self.amount += number def expire(self): self.name = f"expired {self.name}" def __str__(self): return f"{self.amount} of {self.name}" class Spice(Food): ...
f4957db29ad2be8227735877500c578e70b375d1
ashu2902/Xebia_Hackathon
/server/route_config.py
867
3.53125
4
from flask import Flask, request # app reference app = Flask(__name__) # This method executes before any API request @app.before_request def before_request(): print('before API request') # This is POST method which stores students details. parkingData = [] @app.route('/api/test', methods=['GET', 'POST']) def...
9888f5f1dab43bfff113056b8607376ff0ee85f8
felipebellini/EP_DPA_2018.2
/EP1 - felipe e jose.py
10,386
3.671875
4
import json with open("cardapio.json", "r") as arquivo: cardapio = json.loads(arquivo.read()) with open("comandas.json", "r") as arquivo: comandas = json.loads(arquivo.read()) print(""" 0 - Sair 1 - Alterar cardápio 2 - Alterar comanda """) escolha = int(input("O que deseja alterar?: ")) # Alterar car...
37834be35ef7d0779cc475d652db0674a3350216
albinjohn366/Master_Mind_Game
/Knowledge/master_mind.py
2,337
3.65625
4
# MATER MIND PUZZLE from my_logic_of_knowledge import * # Adding colors available to color list colors = ['red', 'blue', 'green', 'yellow'] symbols = [] knowledge = And() # Adding symbols to the symbols list for color in colors: for i in range(4): symbols.append(Symbol('{}_{}'.format(color, i))) # Only ...
9ada3e0e9abcf2a4d3c230b0d14686080816c1b5
YifanWu1993/python-homework
/animal jungle.py
321
3.5
4
def jungle_animal(animal, my_speed): if animal == 'zebra': return 'Try to ride a zebra!' if animal == 'cheetah': if my_speed > 115: return 'Run!' else: return 'stay calm and wait!' else: return 'Introduce yourself!' print jungle_animal('cheetah',114)...
013f3f7ae7d127ee248b47b13c79912196a107c3
r-wyatt/2017-biopython
/curateSignalPseqs.py
1,300
3.515625
4
import sys, csv, re, os intro = ''' This script will organize a directory containing three files of NCBI gene search results into files that contain only species entries for which there is an existing entry in each file. Arguments: 1: Directory of input files 2: Directory for output \n''' print intro dir = sy...
3e93f504855a96bd996881687773ba7dcca67fcb
r-wyatt/2017-biopython
/removeList.py
1,119
3.609375
4
import os, re, sys intro = ''' This script will take a file with a blacklist of fasta names, and remove sequences that are associated to that species, giveb in the form [Genus species] in the fasta name, from the specified file of fasta sequences. Arguments: 1: Text file of blacklist entries 2: Fasta file to trim...
6bf88ae9e8933f099ed1d579af505fc8ef0d04b4
Abicreepzz/Python-programs
/Decimal_to_binary.py
462
4.25
4
def binary(n): result='' while n>0: result=str(n%2)+str(result) n//=2 return int(result) binary(5) ##output= 101 # Another simple one line code for converting the decimal number to binary is followed: def f(n): print('{:04b}'.format(n)) binary(5) ##output =101 # If we want to print in the 8 bit digi...
6573ac2d6db6039e58df6adcf1b647ad92800ed3
dvdgatik/python_basico
/adivina_el_numero.py
592
3.90625
4
import random #importar un modulo def run(): #numero aleatorio entre uno y cien numero_aleatorio = random.randint(1,100) #con el punto accedemos a las funciones de un determinado modulo numero_elegido = int(input('Elige un numero del 1 al 100: ')) while numero_elegido != numero_aleatorio: if numero_elegido < nu...
24e7d078ff7b03e86e77050a9ff7203f61a2141a
dvdgatik/python_basico
/aproximacion.py
557
3.890625
4
objetivo = int(input('Escoge un numero: ')) epsilon = 0.0001 #que tan_ cerca queremos llegar de la respuesta paso = epsilon**2 #numero mas pequeño 0.01*0.01 respuesta = 0.0 #abs valor absoluto while abs(respuesta**2 - objetivo) >= epsilon and respuesta <= objetivo: #la segunda iteracion nos protege contra negativos ...
c779befb7765c79133532456846c0037a7c0de00
dvdgatik/python_basico
/break_continue.py
834
3.90625
4
def run(): #imprimir solo los pares # for contador in range(1000): # if contador % 2 != 0: # continue #lo que esta debajo de continue no se va a ejecutar y pasamos a la siguiente vuelta del ciclo # print(contador) # for i in range(0,10000) : # print(i) # if i == 10: # break #rompe el ciclo y ya no se e...
44ef356f8b23992e21d5ac5f481505ee2ead0bb3
mmartinello/ansible-users
/filter_plugins/iterator_filters.py
8,639
3.984375
4
"""iterator_filters.py Ansible custom filter to check if a given value is present into a given list of object. Filters are available to check if the value is present in different type of given objects: - a single list - a single dictionary (key or values) - a list containing multiple lists - a list containing multiple...
1871a2be6f3c1389c29cec4d5bc5569a787dc9ff
wangcaipang/coursera
/principles_of_computing_part1/week2/assignment.py
5,312
3.546875
4
""" Clone of 2048 game. """ import poc_2048_gui import random # Directions, DO NOT MODIFY UP = 1 DOWN = 2 LEFT = 3 RIGHT = 4 # Offsets for computing tile indices in each direction. # DO NOT MODIFY this dictionary. OFFSETS = {UP: (1, 0), DOWN: (-1, 0), LEFT: (0, 1), RIGHT: (0, -1)} de...
02b7dcb73697900b11c1d52e8633e5cc93d21d1f
rubychilds/ProjectEuler
/Python/EulerProb9.py
1,073
3.71875
4
import math import time def pythTriangle(): int a=0,b=0,c=0; int m,n; for m in range(15): for n in range(m+1, 30): if a+b+c != 1000: a = n*n - m*m b = 2*n*m; c = n*n + m*m print a,b,c def aythTriangle(): # condition 1: a + b = c...
be03b2e2e8620fb3739818bfeacbd991cebb08f5
wjlaboratory/myfirstpython
/twentytwo.py
680
3.5625
4
#  装饰器 # 1、首先是一个闭包 # 2、外层函数的形式参数是函数的应用 # 3、带参数的装饰器 def outer(x): def decorate(func): a = 100 print("正在装饰...") def wrapper(*args, **kwargs): nonlocal a # a += 1 print("x=%s" % x) print("正在运行装饰器...") func(args[0]) print("...
f0a3605e591e025a2b068496030a52edc043a64d
MigeruDev/IAGraph-Server
/server/HeuristicSearch.py
11,871
3.59375
4
import time from queue import PriorityQueue class HeuristicSearch(): def command(self, mydb, start, goal, algorithm): command = { 'HC': self.hc, 'BestFS': self.bfs, 'A*': self.astar, 'GS': self.gs} func = command.get(algorithm, lambda:...
ff5d4f961a0da6769d136180d15d7fe15ebcdc58
GrisoFandango/week-9
/2 - Class 2.py
465
3.96875
4
class people(): def __init__(self, name, age, gender): self.name = name self.age = age self.gender = gender def showDetails(self): print(self.name,self.age,self.gender) #creation of different class objects p1= people("John",18,"M") p2= people("Mary",25,"F") p3= people("Kevin",22...
88fb870353f8070cb4788692bd76cd41a43426f5
lauralardies/warmup
/Tarea9.py
213
3.6875
4
f = open("flag.txt", "w") f.write("This is file flag.txt") f.close f = open("flag.txt", "r") print(f.read()) # El resultado que obtenemos en la consola es el contenido del archivo flag.txt: This is file flag.txt
9f91ff2fce0e460ef5d5a111172b05236183da48
llsween95/Boxed-All-Bulk-Cart
/WebScrape/scrapeQuill.py
4,271
3.734375
4
# backwards syntax from javascript # urllib is library from python # bs4 is installed with pip import random import datetime from urllib.request import urlopen as uReq from bs4 import BeautifulSoup as soup date = datetime.datetime.now() localDate = '-'.join(date.strftime('%x').split('/')) localTime = date.strftime('%...
cca8c996edbad5867e6daa7b1dde5e4d7a8a4b68
osvaldohg/algorithms
/tarea02.py
1,106
3.75
4
print "merge_sort_oz" inv=0 def merge_sort(arreglo): if len(arreglo) >1: mid=len(arreglo)/2 left=arreglo[:mid] right=arreglo[mid:] merge_sort(left) merge_sort(right) merge(arreglo,left,right) def merge(arreglo, left, right): i,j,k=0...
29a73d40ae339e50e7ad9d6e4336e054fb8119de
osvaldohg/algorithms
/tarea01.py
591
3.5625
4
def karatsuba(num1, num2): print "iterating" if int(num1) < 100 or int(num2) <100: return int(num1)*int(num2) m=len(num1) m2=m/2 a=num1[:m2] b=num1[m2:] c=num2[:m2] d=num2[m2:] z0=karatsuba(a,c) z11=karatsuba(a,d) z12=karatsuba(b,c) z13=z11+z12...
2314c25400561bfc02144433f79b82da2baa0d99
ocxtal/adaptivebandbench
/scripts/lambda.py
661
3.5625
4
#! /usr/bin/env python # encoding: utf-8 if __name__ == '__main__': from sys import argv from math import exp m = float(argv[1]) x = float(argv[2]) p = 0.25 # const expected_score = p * m + 3 * p * x (l, high, low) = (1, 2, 0) while (high - low) > 0.001: sum = 4 * p * p * exp(l * m) + 12 * p * p * exp(l ...
768cbb7ceaa088a12a373120eb35c16fc27bc588
eliottrato/PythonBasics
/Coursework.py
11,077
3.703125
4
#F28PL - CW2 - Python #Tomasz Mosak, tpm4 #F28PL Coursework PY1 #enjoy marking this as much as I loved coding it (sarcasm) ##################################### #Question 1a print() print('Question 1') def cadd(x,y): #takes the corrisponding values and adds them return (x[0]+y[0], x[1]+y[1]) ...
a892eecf6192666a453058ebfa60fc164a77128e
Muosvr/Textbooks
/Data_Structures_&_Algorithums_in_Python_excercise/recursive-directory.py
415
3.90625
4
import os def checkSize(path): size = os.path.getsize(path) if os.path.isdir(path): for childFolder in os.listdir(path): childPath = os.path.join(path, childFolder) print("childPath", childPath) size += checkSize(childPath) return size if __name__ == "__main__...
a30b48b2e9026c53b588a0f5b503336aabc6275f
Jewel-Hong/SC-projects
/SC101Assignment/SC101_Assignment0/class_reviews.py
4,199
4.25
4
""" File: class_reviews.py Name: 洪禎蔚 ------------------------------- At the beginning of this program, the user is asked to input the class name (either SC001 or SC101). Attention: your program should be case-insensitive. If the user input -1 for class name, your program would output the maximum, minimum, and average a...
9e188e9dcd5fd64231f883943ab83e307158a5f7
Jewel-Hong/SC-projects
/SC101Lecture_code/SC101_week6/priority_queue_list.py
1,402
4.46875
4
""" File: priority_queue_list.py Name: ---------------------------------- This program shows how to build a priority queue by using Python list. We will be discussing 3 different conditions while appending: 1) Prepend 2) Append 3) Append in between """ # This constant controls when to stop the user input EXIT = '' d...
2892a5260ca14ccd1be81cff1beb7db76f4ac9db
Jewel-Hong/SC-projects
/SC101Lecture_code/SC101_week1/mouse_draw.py
614
3.53125
4
""" File: mouse_draw.py Name: ------------------------ This file shows how to use campy mouse event to draw GOval """ from campy.graphics.gobjects import GOval from campy.graphics.gwindow import GWindow from campy.gui.events.mouse import onmousedragged, onmouseclicked # This constant controls the size of the pen stro...
7ce2f22d370784db0284cac76eba4becb42f7556
Jewel-Hong/SC-projects
/SC101Lecture_code/SC101_week3/word_occurrence.py
1,397
4.21875
4
""" File: student_info_dict.py ------------------------------ This program puts data in a text file into a nested data structure where key is the name of each student, and the value is the dict that stores the student info """ # The file name of our target text file FILE = 'romeojuliet.txt' # Contains the chars we ...
40bdb2300ddc9830f2b5eedcf7fe9017e5567e3e
gourav-chalotra/PYTHON_CODE
/chapter3/02_String_slicing.py
327
3.984375
4
# greeting = 'good morning,' # name = "gourav" # print(type(name)) # print(greeting+name) # Concatenating two strings # c=greeting+name # print(c) # name = "gourav" # print(name[0:3]) # print(name[:6]) #is same as name [0:5] # print(name[1:]) #nagitive index # print(name[-1:-6]) # SKIP VALUE name = "gourav" d= name ...
bf21693d31e1fce3962d5d13c237b6591b2a5772
cxprograme/pythonDemo
/demo/day_two.py
179
3.609375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- a='xyz'; b=a; a='abc'; print(a); print(b); print ('中文测试'); s1=71; s2=85; r=(s2-s1)/s1*100; print('%.3f%%' % r);
e1ca57bb4753a90eae5c501f6caa3458962ef63a
cxprograme/pythonDemo
/demo/day_05/sort.py
163
3.546875
4
#-*-coding:utf-8-*- #排序 L=[('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)]; def sortByName(t): for x in L: return x[0]; print(sortByName(L));
191429aad53d0d7e1dd967342082ba67ed7533f5
NShah19/QuantumProgramming
/BernsteinVazirani/bernstein_vazirani.py
1,992
3.859375
4
import random import numpy as np def bernstein_vazirani(f, n): """ The Bernstein-Vazirani problem: Input: a function f : {0, 1}^n → {0, 1}. Assumption: f(x) = a × x + b. Output: a, b. Notation: {0, 1}^n is the set of bit strings of length n, a is an unknown bit string of length n, × is inn...
c01f361c7f70745928b236786ba931ebaf9d8622
Larry-Nkengbeza/ICS3U-Unit-4-05-Python
/adding_using_continue_statement.py
986
3.984375
4
# Unit4-05/usr/bin/env python3 # This program was created by Larry Nkengbeza # This program was created on December 2020 # This program is adding in for loop with conitiue statement. def main(): # Input user_input = (input("Enter a how many integer which will be added:")) user_input2 = (input("Enter a po...
b7c2bfb8e2014f910c9303da904d3303eae9e5bf
KREAL22/tms
/lesson8/lesson8.py
2,464
4.34375
4
''' Создайте класс Figure. У каждой фигуры есть имя, также можно найти площадь и периметр фигуры. Создайте классы Triangle, Circle, Rectangle производные от Figure. У класса Triangle есть 3 стороны: a, b, c; у Circle - радиус r; у Rectangle - стороны a и b. Переопределите методы нахождения площади и периметра для ка...
b4027124fb0df01dfa6b626c98aece397c3185ad
Aniezka/Python_2017-18
/hw4/hw4.py
224
3.5
4
with open("text.txt", encoding="utf-8") as f: lines = f.readlines() count = 0 for line in lines: line = line.split() if len(line) > 5: count += 1 if len(lines) == 0: print("no strings") else: print(count * 100 / len(lines))
3db8221f621ebbb939a86807b36c0905a064ad38
z13z4ck/hwa
/python/utils.py
1,075
3.671875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- Last modified: 2015-09-23 17:10:55 -*- def rem_hexdump(address, data): s = "" for c in data: if address % 16 == 0: s += '\n%04X:' % address elif address % 8 == 0: s += ' --' address += 1 s += ' %02X' % ord(c)...
48616fece75cd207c580009e7bdd1841abfd846c
juniorbraz93/Exercicios-de-python-2
/05.py
196
4.25
4
# Faça um Programa que converta metros para centímetros. metros = float(input('Digite um valor em metros: ')) cm = metros * 100 print(metros, 'metros, são o mesmo que', cm, 'centímetros.')
82400f18e008110ec91d3f82b18bc8152e51526b
Emmaweizhang/aod_needs_ax
/XX/_build/jupyter_execute/S3759607_A2_Q2.py
4,051
3.59375
4
I solemnly swear that I have not discussed my assignment solutions with anyone in any way and the solutions I am submitting are my own personal work. Full Name: Wei Zhang Student ID: S3759607 ## Question 2, Part A #!pip install --upgrade altair #!pip install vega vega_datasets First, read the csv file into the no...
becd312b3ec71c44d3589146eab1ebc4ca25fc22
Nicolas-Wursthorn/Exercicios-Python-Brasil
/EstruturaSequencial/exercicio16.py
713
4
4
# Faça um programa para uma loja de tintas. O programa deverá pedir o tamanho em metros quadrados da área a ser pintada. Considere que a cobertura da tinta é de 1 litro para cada 3 metros quadrados e que a tinta é vendida em latas de 18 litros, que custam R$80,00. Informe ao usuário a quantidades de latas de tinta a se...
3862136c1ee855f10ab4829cd87f254807934a9d
Nicolas-Wursthorn/Exercicios-Python-Brasil
/EstruturaDeRepeticao/exercicio24.py
885
4.0625
4
# Faça um programa que peça para n pessoas a sua idade, ao final o programa devera verificar se a média de idade da turma varia entre 0 e 25,26 e 60 e maior que 60; e então, dizer se a turma é jovem, adulta ou idosa, conforme a média calculada. idades = [] while True: idade = int(input('Digite sua idade (caso que...
122d28e0debb5673766de18fcdd5f27c44cdb407
Nicolas-Wursthorn/Exercicios-Python-Brasil
/EstruturaDeRepeticao/exercicio13.py
461
4.15625
4
# Faça um programa que peça dois números, base e expoente, calcule e mostre o primeiro número elevado ao segundo número. Não utilize a função de potência da linguagem. base = int(input("Digite o primeiro número: ")) expoente = int(input("Digite o segundo número: ")) count = 1 potencia = 1 while count <= expoente: ...
1d1f10c89e28ae78d11bdec00aac0b624bd458b8
Nicolas-Wursthorn/Exercicios-Python-Brasil
/EstruturaDeDecisao/exercicio14.py
1,113
3.953125
4
# Faça um programa que lê as duas notas parciais obtidas por um aluno numa disciplina ao longo de um semestre, e calcule a sua média. A atribuição de conceitos obedece à tabela abaixo: # Média de Aproveitamento Conceito # Entre 9.0 e 10.0 A # Entre 7.5 e 9.0 B # Entre 6.0 e 7.5 ...
9f97af2a66220b24f7fc849b477d455027f80960
Nicolas-Wursthorn/Exercicios-Python-Brasil
/EstruturaDeDecisao/exercicio23.py
276
4.15625
4
# Faça um Programa que peça um número e informe se o número é inteiro ou decimal. Dica: utilize uma função de arredondamento. num = float(input("Digite um número: ")) if num // 1 == num: print("Esse número é inteiro") else: print("Esse número é decimal")
a01d070dcdbc806fe0b93a311ea5660bc9b6d16a
Nicolas-Wursthorn/Exercicios-Python-Brasil
/EstruturaDeRepeticao/exercicio31.py
411
4.28125
4
# Faça um programa que calcule o fatorial de um número inteiro fornecido pelo usuário. Ex.: 5!=5.4.3.2.1=120. A saída deve ser conforme o exemplo abaixo: # Fatorial de: 5 # 5! = 5 . 4 . 3 . 2 . 1 = 120 import math numero = int(input("Fatorial de: ")) count = numero fatorial = math.factorial(numero) for i in range(n...
07e3b2a51580a2061224b64672aff89fe5ca56ea
Nicolas-Wursthorn/Exercicios-Python-Brasil
/EstruturaDeDecisao/exercicio03.py
322
4.0625
4
# Faça um Programa que verifique se uma letra digitada é "F" ou "M". Conforme a letra escrever: F - Feminino, M - Masculino, Sexo Inválido. letra = input("Digite M para Masculino e F para Feminino: ".lower()) if letra == "F": print("Feminino!") elif letra == "M": print("Masculino!") else: print("Sexo inválido.")
78f798166b198026dbd97dbb63d23802865baaee
Nicolas-Wursthorn/Exercicios-Python-Brasil
/EstruturaSequencial/exercicio17.py
1,275
4.15625
4
# Faça um Programa para uma loja de tintas. O programa deverá pedir o tamanho em metros quadrados da área a ser pintada. Considere que a cobertura da tinta é de 1 litro para cada 6 metros quadrados e que a tinta é vendida em latas de 18 litros , que custam R$80,00 ou galões de 3,6 litros, que custam R$25,00. # Informe...
130820b09e97a90829427f9aadb39288831a3106
Nicolas-Wursthorn/Exercicios-Python-Brasil
/EstruturaSequencial/exercicio08.py
378
4.03125
4
# Faça um programa que pergunte quanto você ganha por hora e o número de horas trabalhadas no mês. Calcule e mostre o total do seu salário no referido mês. porHr = float(input("Quanto você ganha por hora?: ")) hrPMes = int(input("Quantas horas você trabalha no mês?: ")) salario = porHr * hrPMes print("O total do seu sa...
6b0de621a3bfb356e46be51d40d9e5656c96d082
HnykinAndrew/Labs
/lab2/8.py
144
3.984375
4
import turtle turtle.shape('turtle') for x in range(25,5000,25): for i in range(2): turtle.forward(x) turtle.left(90)
bbf863ae8bb9d32f0cce9459e143864ee95b4473
mickael-bdias/OpenCV-projects-with-Python
/DataFlair-Projects_for_Beginners/03.DetectingContours/03-b.DetectingContours.py
2,311
4.03125
4
#!/usr/bin/env python """03-b.DetectingContours.py: Contours are outlines or the boundaries of the shape. You can build a project to detect certain types of shapes. For example: with a round shape, you can detect all the coins present in the image. The project is good to understand how to detect objects with diffe...
68c07eba11e71e3cecb3fdc639d28c01d36ae689
harinderchagger/classes
/task2.py
349
3.65625
4
import math class point(): ''' ''' blank = point() class rectangle(): "" object1 = rectangle() object1.width = 100 object1.height = 200 blank.x,blank.y = 0,0 def find_center(e,a,b,c,d): cntrX = a + 1/2*(b) cntrY = c + 1/2*(d) print(cntrX) print(cntrY) find_center(rectangle,blank.x,object1.wi...
79ca10edb2da2c9a5faa95be89297a7a318e5a26
havannaa/My-Projects
/SocialMine/misc_func.py
141
3.5625
4
def str_to_lst(mystring): alist = mystring.split(":") growth = [] print(growth) for x in alist: growth.append(int(x)) return growth
ab96cfdab762b0384bd3ea5adf120c4fb4317207
nyxtom/python-puzzles
/permutations.py
277
3.5625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import itertools def permute(values): if len(values) <= 1: yield str else: for perm in permute(values[1:]): for i in range(len(perm)+1): yield perm[:i] + values[0:1] + perm[i:]
f65cff782215b6dc5f6cd6bacbd442a0d4c29113
NelsonGomesNeto/Competitive-Programming
/Online Judges/Huxley/1054comprimentodeumarcoeareadosetor.py
156
3.8125
4
r = float(input()) a = float(input()) pi = 3.14 print(round((a * 2 * pi * r) / 360, 2)) print(round((a * pi * r * r) / 360, 2)) # 360 - pi*r� # 10 - x
96c15e0afe06420a656069e6726b467fa433cd9e
NelsonGomesNeto/Competitive-Programming
/Online Judges/Huxley/149InfixoParaPosfixo.py
821
4.03125
4
operators = {'+': 1, '-': 1, '*': 2, '/': 2, '^': 3, '(': 0, ')': 0} def solve(expression): stack = [] ans = "" for e in expression: # print(stack) if (e not in operators): ans += e elif (e == '('): stack += [e] elif (e == ')'): while (sta...
342817ed60ba65b8b4bbce63a3cfbab4bb5390d5
NelsonGomesNeto/Competitive-Programming
/Online Judges/AtCoder/Educational DP Contest/Y (Grid 2)/generator.py
269
3.640625
4
from random import randint h, w = int(1e5), int(1e5) n = int(3e3) walls = [] for _ in range(n): i, j = randint(1, h), randint(1, w) while (i, j) in walls: i, j = randint(1, h), randint(1, w) walls += [(i, j)] for i in range(n): print(*walls[i])
4613873af3d6f39760d1bc575be417ff7a51dadb
rizkyanugrahp/Belajar_Python
/00 -Template/tipeData.py
1,033
3.625
4
## tipe data # tipe data: angka satuan/tidak berkoma(integer) data_integer = 10 print("data :", data_integer) print("- bertipe : ", type(data_integer)) # disini diketahui bahwa di python tipe data integer akan # otomatis atau tidak perlu di deklarasikan. #tipe data: angka dengan koma (float) data_float = 1...
280a171944dd4cee178ae5dd1bc113ca8c5eb948
waremon9/EnglishProject_RaspberryPi_PongGame
/ball.py
1,638
4.03125
4
import pygame BLACK = (0,0,0) class Ball(pygame.sprite.Sprite): #This class represents a car. It derives from the "Sprite" class in Pygame. def __init__(self, color, width, height): # Call the parent class (Sprite) constructor super().__init__() # Pass in the color of the...
923e66f5d7af57f8cc93b7679b18e0d68ac2aa74
naina25/HactoberFest2020-1
/String Processing/string_anagram.py
875
3.96875
4
# Find if given two strings are anagram of each other. # Solution-1: s1 = 'Madam curie' s2 = 'Radium came' s1 = s1.replace(' ', '').lower() s2 = s2.replace(' ', '').lower() # Requires n log n time (since any comparison # based sorting algorithm requires at least # n log n time to sort). print(sorted(s1...
21551cc59b6ab3f34a84891e9959a4c64a30ff51
espaciomore/my-code-kata
/BioInformatics/PatternCount.py
180
3.65625
4
def PatternCount(text, pattern): count = 0 for i in range(0, len(text) - len(pattern)): if text[i:i+len(pattern)] == pattern: count = count + 1 return count
9143521aef1d08febdf5593575e52d05dfcb5c43
HighMileage/aoc_2017
/aoc_2017/day_10/day10.py
995
3.71875
4
#!/usr/bin/env python3 import sys import re from collections import deque import itertools def main(input_file): with open(input_file, 'rt') as input_file: lengths = [int(length) for length in input_file.read().split(',')] print('Your hash is: {}'.format(process(lengths))) def process(lengths): ...
40f0439383a9ca68dea606bc2eb8412ee55eab19
arup-group/MarkerBot
/tests/resources/session_1.py
1,132
3.96875
4
# -*- coding: utf-8 -*- def greet(name): i =0 # while True: # i +=1 first_name, surname = name.split(' ') return 'Hello {0}, {1}'.format(surname, first_name) def suggest_travel(distance): if distance > 5: return 'You should take the train.' elif distance > 2: return...
a569edd52911618093387bcb2b8c0b00646d6409
jgeiser47/Aircraft_Dynamics_Simulation
/atmosphere.py
1,320
3.8125
4
#################################################################################################### # Description: Atmosphere class which represents atmosphere in which aircraft are flying # Author(s): Joshua Geiser # Last Modified: 12/2018 import numpy as np import sim_math as M class Atmosphere(): rho = 1.225 ...
156e2c850fe6d669a884bd480c6ede6899ce14c2
Sergio1007692164/EjerccicosPython
/ejercicio_5.py
93
3.953125
4
numero=int(input ("digite numero")) n=0 while tabla <=9: print (numero*(n+1)) n+=1
6a70adf37dd004d379ca760f32a579d41baa4308
Sergio1007692164/EjerccicosPython
/ejercicio_8.py
231
3.84375
4
edad = int(input("digite su edad")) if edad>=18 and edad<=25: print("tiene edad entre 18 y 25") if edad>20: print("tiene mas de 20") elif edad>25: print("tiene mas de 25") else: print("tiene menos de 18")
5d3437b3e6317c6ffc08508060fa61edd6093668
ankit2saxena/code_learning
/DynamicProgramming/01_ugly_numbers.py
1,459
3.96875
4
''' Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, … shows the first 11 ugly numbers. By convention, 1 is included. Given a number n, the task is to find n(th) Ugly number. ''' def is_ugly_simple(n): while n % 2 == 0: n = n / 2 while...
b7bb56a2437d14c69b596301a550a4c8650cce53
eduardosacra/learnpython
/semana7/exercicios/3maior_elemento_lista.py
507
4.09375
4
# Exercício 3 - Maior elemento de uma lista # # Escreva a função maior_elemento que recebe como parâmetro uma lista # com números inteiros e devolve um número inteiro correspondente ao maior valor presente na lista recebida. def maior_elemento(lista): maior = lista[0] for item in lista: if(item >= mai...
d41ef497ee257f093c6889c574ebd89df66d5d8e
eduardosacra/learnpython
/semana4/desafiowhile.py
399
4.0625
4
#desafio #digitando um valor inteir realizar a soma dos numeros que compoem o numero digitando #exemplo: input 432 então 4+3+2 = 9 entrada = int(input("Entre com um valor ")) restodivisao = 0 total = 0 while entrada > 0: restodivisao = entrada % 10 entrada = entrada // 10 total += restodivisao print(...
670fcaa09b6ba4e2d93769401a7b13e8bc25884a
eduardosacra/learnpython
/semana3/exercicios/2parouimpar.py
201
4
4
#Digite um valor inteiro, verifique o resto da divisao se e igual 0 par diferente de zero impar x = int(input("Digite um numero inteiro:")) if (x % 2 == 0): print("par") else: print("impar")
3e3113cca62659ec31b03c93d19363de86bcf45b
eduardosacra/learnpython
/semana4/desafiosoma.py
479
3.921875
4
#desafio #O desafio é o seguinte, dado número inteiro, deve calcular qual a soma os numeros adjacentes #exemplo: input 12345 = 15 #exemplo: input 12234 = 12 entrada = int(input("Entre com um valor ")) total = 0 # valoranterior = 0 atual = 0 possui = True while entrada > 0: atual = entrada % 10 restodivisao ...
1a8f376fb24d0d904f58321fe0305985171afdee
eduardosacra/learnpython
/semana4/exercicios/1ex.py
139
4
4
x = int(input("entre com um numero ")) total = x while x > 1: x -= 1 total *= x if x == 0: print(1) else: print(total)
b1c4ac78934215161d9686f2d7716d67de0401cc
abhishekpandavula/Optimization_techniques
/Successive quadratic estimation method.py
1,077
3.96875
4
import numpy as np print("Enter the initial point") print("x1 = ") x1 = float(input()) print("Enter increment parameter") print("v = ") v = float(input()) x2 = x1 + v #################### # epsilon e e = 0.01 ###################### ############################ # Here is the function given in the question def f(x): ...
ecdefd6f58e7d72ab15851706979ad957a3f8c4a
c109156119/c109156119
/72.紙菸.py
300
3.671875
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 17 12:24:37 2021 @author: c109156119 """ def main(): n=int(input("請輸入n:")) k=int(input("請輸入k:")) print(cal(n,k)) def cal(a,b ,i=0): if a+i//b>0:return a +i//b+cal(a//b,b,i%b+a%b) else:return 0 main()
80f2cfaaa82a18157ebc3b8d6015ac36b3412bc4
uppala-praveen-au7/blacknimbus
/AttainU/Robin/Code_Challenges/Day2/Day2/D7CC3.py
1,984
4.21875
4
# 3) write a program that takes input from the user as marks in 5 subjects and assigns a grade according to the following rules: # Perc = (s1+s2+s3+s4+s5)/5. # A, if Perc is 90 or more # B, if Perc is between 70 and 90(not equal to 90) # C, if Perc is between 50 and 70(not equal to 90) # D, if Perc is between 30 and 50...
422eb4ee1ae57507609a1a61936976805f7b736e
uppala-praveen-au7/blacknimbus
/bubble_sort_recursion.py
524
4.09375
4
def bubble_sort(list_bubble,length): n = length swapped = False for i in range(n-1): if list_bubble[i] > list_bubble[i+1]: list_bubble[i],list_bubble[i+1] = list_bubble[i+1],list_bubble[i] swapped = True if not swapped: return list_bubble else: return bubble_sort(list...
3c981c81b8757048413ef3ca8858d3971477dba1
nitinagarwal22/Nitin-Agarwal
/usernamepassword.py
379
3.5625
4
import time import os u='123' p='321' u=input("enter the username::") c=0 if u == '123': p=input("enter the password::") while(p!='321'): print("more than two attempts") for i in range (10,0,-1): print("come back after ",i,"secs...") time.sleep(1) os.system('cls') break else: print("...
4fe871eee9a442c5b3c20350b2706af157d64090
nitinagarwal22/Nitin-Agarwal
/foundinlist.py
175
3.890625
4
l=[10,20,30,40,50] key=int(input("enter the element u want to search:")) if key in l: print("element found at loc:",l.index(key)) else: print("element not in list")
a43a612c1743fdf1af178dca8c646e2124b4bac3
Zealll/HackerRank
/Easy/Sock Merchant/sockMerchant.py
253
3.515625
4
def sockMerchant(n, ar): if n < 2: return 0 dict = {} acc = 0 for i in ar: if i not in dict: dict[i] = 1 else: dict[i] += 1 for i in dict: acc += dict[i] // 2 return acc