blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
ec8296cf056afef1f3ad97123c852b66f25d75cb
yosef8234/test
/pfadsai/04-linked-lists/notes/singly-linked-list-implementation.py
1,136
4.46875
4
# Singly Linked List Implementation # In this lecture we will implement a basic Singly Linked List. # Remember, in a singly linked list, we have an ordered list of items as individual Nodes that have pointers to other Nodes. class Node(object): def __init__(self,value): self.value = value self.ne...
947f48ab94c7f228048fbc575a51b17761c085b1
yosef8234/test
/pythontutor/1-inout_and_arithmetic_operations/electronic_watch.py
808
3.921875
4
# Задача «Электронные часы» # Условие # Дано число n. С начала суток прошло n минут. Определите, сколько часов и минут будут показывать электронные часы в этот момент. Программа должна вывести два числа: количество часов (от 0 до 23) и количество минут (от 0 до 59). Учтите, что число n может быть больше, чем количество...
b61d9360c7c424b4ccdb6b4cedbbe08b98d60d11
yosef8234/test
/hackerrank/python/strings/string-formatting.py
1,038
3.859375
4
# # -*- coding: utf-8 -*- # Task # Read the integer, NN and print the decimal, octal, hexadecimal, and binary values from 11 to NN with space padding so that all fields take the same width as the binary value. # Input Format # The first line contains an integer, NN. # Constraints # 1≤N≤991≤N≤99 # Output Format # Pri...
3bd4922a2df1fde8c294f2452014907cc407f0c6
yosef8234/test
/spbau/unix/cp/task4.py
165
3.953125
4
#/usr/bin/python num = int(input()) cont = True while (num != 1) and cont: if num%2 == 0: num = num/2 else: print "NO" cont = False; if cont: print "YES"
a73d349d2c72d5bbb7515109e2ec2bf5906c7937
yosef8234/test
/hackerrank/python/sets/check-subset.py
1,479
3.953125
4
# -*- coding: utf-8 -*- # You are given two sets, AA and BB. # Your job is to find whether set AA is a subset of set BB. # If set AA is subset of set BB, print True. # If set AA is not a subset of set BB, print False. # Input Format # The first line will contain the number of test cases, TT. # The first line of each...
6b9604f9d131acbe552f996a61ea1e07e329e7a5
yosef8234/test
/hackerrank/python/regex-and-parsing/hex-color-code.py
1,760
3.609375
4
# # -*- coding: utf-8 -*- # CSS colors are defined using a hexadecimal (HEX) notation for the combination of Red, Green, and Blue color values (RGB). # Specifications of HEX Color Code # ■ It must start with a '#' symbol. # ■ It can have 33 or 66 digits. # ■ Each digit is in the range of 00 to FF. (1,2,3,4,5,6,7,8,9,...
5a8ba567b13eb40704b26e4ba126931eccbd34bc
yosef8234/test
/hackerrank/algorithms/dynamic-programming/maxsubarray.py
3,919
4
4
# # -*- coding: utf-8 -*- # Given an array A={a1,a2,…,aN}A={a1,a2,…,aN} of NN elements, find the maximum possible sum of a # Contiguous subarray # Non-contiguous (not necessarily contiguous) subarray. # Empty subarrays/subsequences should not be considered. # Input Format # First line of the input has an integer TT....
85423a1df37f04f1607648a25458bbb6e0ad53f7
yosef8234/test
/hackerrank/30-days-of-code/day-20.py
3,307
3.953125
4
# -*- coding: utf-8 -*- # Objective # Today, we're discussing a simple sorting algorithm called Bubble Sort. Check out the Tutorial tab for learning materials and an instructional video! # Consider the following version of Bubble Sort: # for (int i = 0; i < n; i++) { # int numberOfSwaps = 0; # for (int j = 0...
09da1340b227103c7eb1bc9800c714907939bfde
yosef8234/test
/python_ctci/q1.4_permutation_of_palindrom.py
1,097
4.21875
4
# Write a function to check if a string is a permutation of a palindrome. # Permutation it is "abc" == "cba" # Palindrome it is "Madam, I'm Adam' # A palindrome is word or phrase that is the same backwards as it is forwards. (Not limited to dictionary words) # A permutation is a rearrangement of letters. import string...
c64e65422dac7bfdfaab60d0722a57de5692a481
yosef8234/test
/pfadsai/10-mock-interviews/large-search-engine-company/phone-screen.py
2,975
4.03125
4
# Phone Screen # This phone screen will consist of a non-technical series of questions about you and the company, and then a second half of a simple technical question to be coded out # Non-Technical Questions # Answer the following questions (2-5 minute responses) technical answers not required, more interested in h...
831e864ab7cefa790cb622fbb3d9bd91e40650ff
yosef8234/test
/python_ctci/q1.2_checkpermutation.py
334
4
4
# Given two strings, write a method to decide if one is a permutation of the other. # For example string abc is a premutation of cbc def checkPermutaion(str1, str2): if len(str1) != len(str2): return False else: return ''.join(sorted(str1)) == ''.join(sorted(str2)) print(checkPermutaion('abc',...
752adb45dc6b9e6fedded2eaa8ddce495f945e1f
yosef8234/test
/pfadsai/10-mock-interviews/social-network-company/on-site-question3.py
1,379
3.984375
4
# On-Site Question 3 - SOLUTION # Problem # Create a function that takes in a list of unsorted prices (integers) and a maximum possible price value, and return a sorted list of prices # Requirements # Your function should be able to perform this in less than O(nlogn) time. # Solution # We can actually solve this pro...
213d266ec875fbde851a72c54b9efe535f7c9851
yosef8234/test
/python_data_structure/1-queue.py
477
3.859375
4
class Queue: def __init__(self): self.items = [] def enqueue(self, item): self.items.insert(0, item) def dequeue(self): self.items.pop() def print_queue(self): print(self.items) def is_empty(self): return self.items == [] def size(self): return len...
c117f5f321a25493ee9c3811a51e6c28d6487392
imjching/playground
/python/practice_python/11_check_primality_functions.py
730
4.21875
4
# http://www.practicepython.org/exercise/2014/04/16/11-check-primality-functions.html """ Ask the user for a number and determine whether the number is prime or not. (For those who have forgotten, a prime number is a number that has no divisors.). You can (and should!) use your answer to [Exercise 4](/exercise/2014/02...
8f13963a5059a9cbb14790645f86ff0415398108
imjching/playground
/python/practice_python/14_list_remove_duplicates.py
764
4.1875
4
# http://www.practicepython.org/exercise/2014/05/15/14-list-remove-duplicates.html """ Write a program (function!) that takes a list and returns a new list that contains all the elements of the first list minus all the duplicates. Extras: Write two different functions to do this - one using a loop and constructing a...
35c0ab9c2e6bfb4eea6f3750b208495ce1407d03
imjching/playground
/python/practice_python/18_cows_and_bulls.py
1,813
4.21875
4
# http://www.practicepython.org/exercise/2014/07/05/18-cows-and-bulls.html """ Create a program that will play the 'cows and bulls' game with the user. The game works like this: Randomly generate a 4-digit number. Ask the user to guess a 4-digit number. For every digit that the user guessed correctly in the correct p...
c4b64563bb611667690703c492f26944d019d195
buryattvoydrug/crypt
/caesar.py
464
3.9375
4
def encrypt_caesar(plaintext, shift=3): import string letters = string.ascii_letters abc = letters[:len(letters)//2] ABC = letters[len(letters)//2:] cipher_letters = abc[shift:]+abc[:shift]+ABC[shift:]+ABC[:shift] table = str.maketrans(letters, cipher_letters) ciphertext = plaintext.translat...
53937a32b059e4e9613be47b492f586eff09a06d
bkhuong/LeetCode-Python
/make_itinerary.py
810
4.125
4
class Solution: ''' Given a list of tickets, find itinerary in order using the given list. ''' def find_route(tickets:list) -> str: routes = {} start = [] # create map for ticket in tickets: routes[ticket[0]] = {'to':ticket[1]} try: ...
5724f86cea467b2eb3645972d40fa40e1f5b3031
bkhuong/LeetCode-Python
/reverse_words.py
159
3.90625
4
class Solution: ''' Given a string of words, reverse all the words. ''' def rev_word(s: str) -> str: return " ".join(s.split()[::-1])
f3dd223984691fba6a54c30b80a27f5f4a95e0d2
samuellsaraiva/PythonMundo03
/Aula18.py
5,439
4.03125
4
'''Aula 18 Mundo 03 // Listas Parte 02''' ''' Desafio 84 - Faça um programa que leia nome e peso de várias pessoas, guardando tudo em uma lista. No final, mostre: 1) Quantas pessoas foram cadastradas; 2) Uma listagem com as pessoas mais pesadas; 3) Uma listagem com as pessoas mais leves. ''' # pessoas = [] #...
a5ad9e19583c5e32b33fb304830c2961dda67942
winfalcon/learnDash
/randomTesting.py
319
3.8125
4
#random value testing import random print('I want to play a game!') print('please in put a number') inputN = input() pcN = random.randint(1,10) #print(random.randint(1, 10)) print('you num is '+str(inputN)) print('pc num is '+str(pcN)) if int(pcN)>int(inputN): print('You Lose') else: print('You Win')
772258c65381b73c84536d70de8dc084516e3a77
iAnafem/Stepic_Algorithms.Theory_and_practise
/stepic/count_sort.py
576
3.53125
4
def count_sort(array, num): count = [0]*11 for i in range(0, num): count[array[i]] += 1 ind = 0 while ind < len(count) - 1: count[ind + 1] += count[ind] ind += 1 sorted_array = [0] * len(array) for j in range(len(array) - 1, -1, -1): sorted_array[count[array[j]] ...
405bf92cf7eade2627916fa77517b8a9580cbb8b
iAnafem/Stepic_Algorithms.Theory_and_practise
/stepic/inversion.py
857
3.796875
4
def binary_search(_array, item): first = 0 last = len(_array) - 1 found = False while first <= last and not found: midpoint = (first + last)//2 if _array[midpoint] == item: return midpoint else: if item < _array[midpoint]: last = midpoint ...
adc9adf02c5fd1f477992b065d9c1d16e487fa3c
simrit1/CCC-Solutions-2
/CCC-2018/Junior/Junior-2/J2.py
347
3.765625
4
# CCC 2018 Junior 2: Occupy parking # # Author: Charles Chen # # String index checking parking_spaces = int(input()) yesterday = input() today = input() counter = 0 # Counter used to track parking spaces occupied both days for i in range(parking_spaces): if yesterday[i] == today[i] == 'C': ...
07769e10a31381d8903b594370e45134ea142c1e
simrit1/CCC-Solutions-2
/CCC-2018/Junior/Junior-3/J3.py
497
3.5
4
# CCC 2018 Junior 3: Are we there yet? # # Author: Charles Chen # # Arrays and calculations distances = list(map(int, input().split())) city_positions = [0] * 5 for i in range(1, 5): city_positions[i] = city_positions[i-1] + distances[i-1] for i in range(5): for j in range(5): distance ...
9799aa9eaed603bc9a6d82202001215a7b31ea69
Jingyuan-L/DSP_LAB_Assignment
/assignment6/Demo16_ex1.py
1,928
3.609375
4
import tkinter as Tk def fun_button1(): s_button.set('You pressed button1') def fun_button2(): s_button.set('You pressed button2') def fun_click(event): s_click.set('You clicked at position (%d, %d)' % (event.x, event.y)) def fun_entry(): s_entry.set('You said: ' + E1.get()) def fun_scale(even...
70cc3581b224daa3beadfc0150d31b52c30f6284
Gachiman/Python-Course
/python-scripts/hackerrank/Medium/Find Angle MBC.py
603
4.21875
4
import math def input_length_side(val): while True: try: length = int(float(input("Enter the length of side {0} (0 < {0} <= 100): ".format(val)))) if 0 < length <= 100: return length else: raise ValueError except ValueError: ...
3d8db22b87e94e349f0049a22cf007b10934c085
joemcilheran/rockPaperScissorsWithClass
/entry_points_rock_paper_scissors/rock_paper_scissors/human.py
499
3.875
4
class human: def __init__(self): pass def give_name(self,playerName): name = input(playerName + ": what is your name? \n") return name def make_choice(self,playerName): guess = input(playerName + ": enter rock, paper, or sciss...
a1b6391a773b23a0f5fe8e0b0a4d36bc7e03b9b0
hobsond/Computer-Architecture
/white.py
1,788
4.625
5
# Given the following array of values, print out all the elements in reverse order, with each element on a new line. # For example, given the list # [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0] # Your output should be # 0 # 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # You may use whatever programming language you'd like. # Verbalize...
c8f2a6f1ba44ebc855fb1e74e0888845463fa640
HyunIm/Baekjoon_Online_Judge
/Problem/1919.py
468
3.640625
4
data1 = list(input()) data2 = list(input()) answer = 0 while data1 or data2: if data1: if data1[0] in data2: data2.remove(data1[0]) data1.remove(data1[0]) else: data1.remove(data1[0]) answer += 1 if data2: if data2[0] in data1: ...
1c571325e1eab5bc970035e37c200b6052126230
HyunIm/Baekjoon_Online_Judge
/Problem/6764.py
507
3.84375
4
def main(): fishFinder = [int(input()) for _ in range(4)] result = 0 for i in range(len(fishFinder)-1): if fishFinder[i] < fishFinder[i+1]: result += 1 elif fishFinder[i] > fishFinder[i+1]: result -= 1 if len(set(fishFinder)) == 1: print("Fish At Constant...
dfb920b452b8c60db107a3ae0e82d0bd26d20ae9
HyunIm/Baekjoon_Online_Judge
/Problem/1076.py
351
3.875
4
color = { 'black':0, 'brown':1, 'red':2, 'orange':3, 'yellow':4, 'green':5, 'blue':6, 'violet':7, 'grey':8, 'white':9 } resistance_color = [color[input()] for _ in range(3)] resistance_value = 0 resistance_value = int(str(resistance_color[0]) + str(resistance_color[1])) resistance_value *= 10**resistance_col...
e0b78588800f2e1f1aeecd0d64ad999d61a0238d
HyunIm/Baekjoon_Online_Judge
/Problem/2747.py
200
3.78125
4
fibo = {0:0, 1:1, 2:1} def calcFibo(n): if n in fibo: return fibo[n] else: fibo[n] = calcFibo(n-1) + calcFibo(n-2) return fibo[n] n = int(input()) print(calcFibo(n))
0c537044e19a0ec7df44dd1ea734d20d2b7dc87c
HyunIm/Baekjoon_Online_Judge
/Problem/1356.py
294
3.625
4
def multi(n): value = 1 data = list(map(int, n)) for i in data: value *= i return value N = input() flag = False for i in range(1, len(N)): if multi(N[:i]) == multi(N[i:]): print('YES') flag = True break if flag == False: print('NO')
96128b08e083487687c10f8213ae96baf04ba89e
HyunIm/Baekjoon_Online_Judge
/Problem/2576.py
184
3.796875
4
numbers = [int(input()) for _ in range(7)] oddNumbers = [x for x in numbers if x%2] if len(oddNumbers) == 0: print(-1) else: print(sum(oddNumbers)) print(min(oddNumbers))
bae1aa504ff7630fe1783826b31fab29c2a79767
HyunIm/Baekjoon_Online_Judge
/Problem/15025.py
149
3.625
4
l, r = map(int, input().split()) if l == r == 0: print('Not a moose') elif l == r: print('Even', max(l, r)*2) else: print('Odd', max(l, r)*2)
9cece28263bac8da17423ecf55141db89e3454b4
HyunIm/Baekjoon_Online_Judge
/Problem/14491.py
94
3.609375
4
T = int(input()) base9 = '' while T: base9 += str(T % 9) T //= 9 print(base9[::-1])
54acec508c229d277f746b255afd0e36eb1da3ed
HyunIm/Baekjoon_Online_Judge
/Problem/10707.py
454
3.5625
4
def main(): A = int(input()) B = int(input()) C = int(input()) D = int(input()) P = int(input()) XCompany = A * P YCompany = calcYCompany(B, C, D, P) chargePerMonth = min(XCompany, YCompany) print(chargePerMonth) def calcYCompany(B, C, D, P): if C >= P: return B els...
f7f5508511a161c239bf7e5dedede96d4b458b41
HyunIm/Baekjoon_Online_Judge
/Problem/2744.py
127
4.25
4
word = input() for i in word: if i.isupper(): print(i.lower(), end='') else: print(i.upper(), end='')
46a8fc2fd3176e3492bb1e86fd33700ceeb45343
HyunIm/Baekjoon_Online_Judge
/Problem/2720.py
168
3.6875
4
T = int(input()) coins = [25, 10, 5, 1] for _ in range(T): C = int(input()) for coin in coins: print(C // coin, end=' ') C %= coin print()
a2792e88ee90fa8e8c00e7cda9874369ca2656b7
HyunIm/Baekjoon_Online_Judge
/Problem/3047.py
210
3.703125
4
A, B, C = sorted(map(int, input().split())) order = input() for i in order: if i == 'A': print(A, end=' ') elif i == 'B': print(B, end=' ') elif i == 'C': print(C, end=' ')
ce9ba7650d4060d63e341caf24f610df8abb6c32
MacJei/Optimization
/conjugate_gd.py
1,079
4.03125
4
""" Description ----------- Solve a linear equation Ax = b with conjugate gradient method. Parameters ---------- A: 2d numpy.array of positive semi-definite (symmetric) matrix b: 1d numpy.array x: 1d numpy.array of initial point Returns ------- 1d numpy.array x such that Ax =...
629f3ba54080429abb4715d16682d65e155a1703
Reiyyan/network-lab
/Assignment 2/server.py
2,240
3.515625
4
# import socket module from socket import socket, AF_INET, SOCK_STREAM import sys # In order to terminate the program serverSocket = socket(AF_INET, SOCK_STREAM) # Prepare a sever socket #Fill in start # I will use localhost serverSocket.bind(('127.0.0.1', 1992)) serverSocket.listen(1) #Fill in end while True: ...
2718e25886a29226c5050afe0d83c6459bd6747b
Twest19/prg105
/Ch 10 HW/10-1_person_data.py
1,659
4.71875
5
""" Design a class that holds the following personal data: name, address, age, and phone number. Write appropriate accessor and mutator methods (get and set). Write a program that creates three instances of the class. One instance should hold your information and the other two should hold your friends' o...
b33b65d4b831bcd41fac9f4cd424a65dc4589d39
Twest19/prg105
/3-3_ticket.py
2,964
4.3125
4
""" You are writing a program to sell tickets to the school play. If the person buying the tickets is a student, their price is $5.00 per ticket. If the person buying the tickets is a veteran, their price is $7.00 per ticket. If the person buying the ticket is a sponsor of the play, the price is $2.00 per ticket. ...
20a0d53d34ba73884e14d026030289475bb6275e
Twest19/prg105
/chapter_practice/ch_9_exercises.py
2,681
4.4375
4
""" Complete all of the TODO directions The number next to the TODO represents the chapter and section in your textbook that explain the required code Your file should compile error free Submit your completed file """ import pickle # TODO 9.1 Dictionaries print("=" * 10, "Section 9.1 dictionaries",...
666efab8a625d46543dab413aadd15936594a5dd
Twest19/prg105
/4-1_sales.py
862
4.5625
5
""" You need to create a program that will have the user enter in the total sales amount for the day at a coffee shop. The program should ask the user for the total amount of sales and include the day in the request. At the end of data entry, tell the user the total sales for the week, and the average sa...
a3ace412c840aac7ff86999020c0d765a5062a5d
Twest19/prg105
/5-3_assessment.py
2,467
4.21875
4
""" You are going to write a program that finds the area of a shape for the user. """ # set PI as a constant to be used as a global value PI = 3.14 # create a main function then from the main function call other functions to get the correct calculations def main(): while True: menu() ...
828682d261d05a773c55e41dfb41005e2a6f0187
TalinM22/Forecast_openweather
/openweather_forecast.py
3,252
3.6875
4
import pandas as pd import requests ## Dummy DataFrame for testing df = pd.DataFrame( { "City": ["Buenos Aires", "Brasilia", "Santiago", "Bogota", "Caracas"], "Latitude": [-34.58, -15.78, -33.45, 4.60, 10.48], "Longitude": [-58.66, -47.91, -70.66, -74.08, -66.86], } ) # Function to con...
1b695ca0b47b53d4fc0b5f60a9aea550e58ce9cd
ring-ring097/Optimization
/work3/plactice/euler.py
832
3.59375
4
import matplotlib.pyplot as plt import networkx as nx # 3*3のグリッドを作成 GR = nx.grid_2d_graph(3,3) #奇点を二つ追加 GR.add_edges_from([((0,1), (1,2))]) nx.draw_networkx(GR, pos={v:v for v in GR.nodes()}, node_color='lightgray', node_size=1200, with_labels=Tru...
90ba0affbce490b56ad872938e8cc01713f7e66b
ring-ring097/Optimization
/work2/test_data02/file_input.py
1,057
3.71875
4
import sys import fileinput from pathlib import Path # 標準入力ファイルを数値リストに変換 if len(sys.argv) == 1: print('問題ファイルを指定してください') elif len(sys.argv) > 2: print('指定できる問題ファイルは1つです') elif Path(sys.argv[1]).exists(): ARGV = [] for line in fileinput.input(): argv = list(map(int, line.split())) ARGV.a...
ad0636523fe05660c34201f5524f2d808e46ac6d
8aqtba9y/stduy-python-Movie-Website
/source/05_use classes_profanity editor/02_Built-in Functions.py
159
3.609375
4
def what_is_your_name() : return raw_input("what_is_your_name?>> ") def hello(name) : print "Hello %s!" %name name = what_is_your_name() hello(name)
9d142c53cd2a2d51e41ffd8a91cca107fee0b6d3
ErikBavenstrand/Project-Euler
/src/017.py
2,055
3.8125
4
singleDigit = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'] teens = ['', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'] tens = ['', 'ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'] hundred = 'hu...
4d1fe278d2a3844d87c4cbe2884d8005c9d07bdb
AvEgA-ChuDoTvoreC/DbRabbDockeAvUpdateConn
/tt.py
5,183
3.703125
4
import os s = [-1, -3, -5, 3, 6] # s = list(map(lambda x: abs(x) < 3, s)) print(s) # print("---") # print("all:", all(type(i) == int for i in s)) # print("any:", any(type(i) != float for i in s)) def check_all_values_type(data: any, value_type: type): """Check if all values are the same type""" return all...
e0c6c65c9c61e0723e6c013997c2a939ae967972
hendrikjeb/Euler
/16.py
312
3.765625
4
# -*- coding: utf-8 -*- """ Problem 16: Power digit sum 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2^1000? """ from time import time start = time() som = 0 for l in str(2**1000)[:]: som += int(l) print som print 'Tijd: ', time() - start
4405337af226f30b50ebe712eca4677bd661d473
hendrikjeb/Euler
/05.py
462
3.546875
4
# -*- coding: utf-8 -*- """2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?""" doorgaan = True getal = 2520 while doorgaan == True: doorgaan = False for x...
5426c10606cc473a1008eded8474047d6d6b69be
hendrikjeb/Euler
/09.py
651
4.09375
4
# -*- coding: utf-8 -*- """ A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a^2 + b^2 = c^2 For example, 3^2 + 4^2 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. """ from time import time start = time() a = 1 b = ...
a6f2cad06f01fe0f34903c0597f47d6b1576d0d0
PradeepBaipadithaya/hactoberfest
/Vowel_count.py
612
3.875
4
#FIRST METHOD-------------- """str=input("please write a string.") count=0 for i in str: if i=='a' or i=='A' or i=='e' or i=='E' or i=='i' or i=='I' or i=='O' or i=='o'or i=='U' or i=='u': count+=1 print(count)""" #SECOND METHOD--------------- """str=input("Enter a string .only string will be acce...
7f6c3367388c570e4e97c00b1e6743888ad5ed29
Nicholas-Ferreira/Impacta
/semestre_2/Programação/Aula_5-02-09-2019/Ex3.py
190
4.09375
4
pessoas = {} for i in range(3): cpf = int(input('CPF: ')) nome = input('Nome: ') idade = int(input('Idade: ')) pessoas[cpf] = { 'nome':nome, 'idade':idade } print(pessoas)
75a916a89c4e971f57b3cb5a2a702c5471e6f224
Nicholas-Ferreira/Impacta
/semestre_2/Programação/Aula_7-16-09-2019/ac04.py
980
3.65625
4
# Atividade Contínua 04 # Aluno 01: Gabriel De Lima Birochi Sarti - RA 1802424 # Aluno 02: Nicholas Mota Ferreira - RA 1900953 # Implemente abaixo a classe Elevador, conforme descrição no enunciado da AC04 class Elevador(): total_andares = None capacidade = None quantidade_pessoas = 0 andar_atual = 0...
ad3567d92933c699aa75d0081ec99b9675bb8fe2
er-arunyadav/pythontask
/2nd Task.py
510
3.890625
4
sentance = input("Enter Your Sentance: ") sentance_split = sentance.split(' ') word_container = [] for i in sentance_split: if i not in word_container: word_container.append(i) else: continue def sorting_sentance(lst): if not lst: return [] return (sorting_sentance([x for x...
c512dc0a5eb23bc8f8b1a7d5da430518850e08cf
Givrecoeur/Behind_The_Stars
/modules/ShooterObjects/Objects.py
5,762
3.640625
4
# -*- coding: utf-8 -*- """ Created on Sat Sep 9 21:51:55 2017 @author: Benoît """ import pygame import CstSystem as csts import Math_operations as mtop #=============================================================================# #====================================================================...
ea163ab101cb6202d6ebd8b4dd743fc131a5a568
t045ter/GPIO_Learning
/interrupts-2.py
939
3.796875
4
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) GPIO.setup(11,GPIO.IN) GPIO.setup(12,GPIO.IN) def my_callback(channel): print "Rising edge detected on SW2 - even though, in the main thread," print "we are still waiting for a falling edge - how cool?\n" print "Make sure you have a button connected so ...
749f68e5e7bfcf2caaff39a06d4d1aa702ef7c1e
Xiristian/infosatc-lp-avaliativo-03
/atividade05.py
1,347
3.859375
4
idade = 0 peso = 0 horaSono = 0 dadosCadastrais = {} cadastro = "" pessoasCadastradas = 0 while pessoasCadastradas < 5: idade = int(input("Quantos anos você tem? ")) peso = int(input("Quantos quilos você tem? ")) horaSono = int(input("Aproximadamente, quantas horas de sono você teve nas últimas 24 horas? "...
933d7b4d927df7b2420a4392557b99615cb7be63
anmolrajaroraa/python-reg-sept
/diamond-pattern.py
311
3.90625
4
for i in range(20): counter = i if i==10: continue if i<10: for j in range(10 - counter): print(' ', end='') for k in range(2 * counter - 1): print('*', end='') else: for j in range(counter - 9): print(' ', end='') for k in range(((19 - counter) * 2) - 1): print('*', end='') print()
52dd577610c57f96e36b41ee06982c873f0d55af
dougiejim/Automate-the-boring-stuff
/commaCode.py
753
4.3125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #Write a function that takes a list value as an argument and returns #a string with all the items separated by a comma and a space, with #and inserted before the last item. For example, passing the previous #spam list to the function would return 'apples, bananas, tofu, ...
21dd0d084df1d2d8f568bc7a46069316dac2cefc
2016JTM2079/Assignment7
/ps2.py
546
4
4
#-------Importing Libraries------- import random import math count =0 #User Defined input for no. of points in area user_count=input("Enter number of users") for points in range(user_count): (x,y)=(random.random()*2- 1, random.random()*2-1) print(x,y) var1=math.pow(x,2) var2=math.pow(y,2) var3=var1+var2 var3=mat...
4ce67f3a9acf648133a377fdbcb61c87dbc99753
doggggie/courses
/principlescomputing1-003/proj2_2048.py
5,744
3.515625
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)} d...
9fb6d424755e5f0a7af793461a4e56d72e3ed594
sakamoto-michael/Sample-Python
/new/dates_times.py
2,205
3.953125
4
# Working with dates and times in Python import datetime import pytz # Used for timezones # Working with dates (no time) new_date = datetime.date(2020, 4, 12) today = datetime.date.today() # In 'today' can access .year, .month, and .daysett # Check the day of the week given a date today.weekday() # Returns Monday 0 -...
732a68dc8a28c98ecc93001de996919759778a2c
sakamoto-michael/Sample-Python
/new/intro_loops.py
727
4.28125
4
# Python Loops and Iterations nums = [1, 2, 3, 4, 5] # Looping through each value in a list for num in nums: print(num) # Finding a value in a list, breaking upon condition for num in nums: if num == 3: print('Found!') break print(num) # Finding a value, the continuing execution for num in nums: if n...
701ea9976f04c66564962c3bc7f64d89e1314120
vivekyadav6838/Data-Structures-and-Algorithms-for-Interviews
/Python/BinaryTree/NumberOfNonLeafNodes.py
1,524
4.3125
4
# @author # Aakash Verma # Output: # Pre Order Traversal is: 1 2 4 5 3 6 7 # Number Of non-Leaf Nodes: 3 # Creating a structure for the node. # Initializing the node's data upon calling its constructor. class Node: def __init__(self, data): self.data = data self.right = self.left = None # Def...
f09dabe6055d29828fe1a2052d3f7bd683c6ebb4
vivekyadav6838/Data-Structures-and-Algorithms-for-Interviews
/Python/Graph/CycleDetectionUsingBFS.py
1,694
3.765625
4
# @author # Aakash Verma # www.aboutaakash.in # www.innoskrit.in # Instagram: https://www.instagram.com/aakashverma1102/ # LinkedIn: https://www.linkedin.com/in/aakashverma1124/ from collections import deque # there will be a condition when node's neighbour will be visited and it might seem that there is a cycle # ...
8878c006639c546777ff2af254a979033560c15a
vivekyadav6838/Data-Structures-and-Algorithms-for-Interviews
/Python/LinkedList/StartingOfLoop.py
1,519
4.34375
4
# # # # @author # Aakash Verma # # Start of a loop in Linked List # # Output: # 5 # # Below is the structute of a node which is used to create a new node every time. class Node: def __init__(self, data): self.data = data self.next = None # None is nothing but null # Creating a class for implementing ...
cdf5408e5aacacd9dccf1a02545c5e547bca71cf
vivekyadav6838/Data-Structures-and-Algorithms-for-Interviews
/Python/Graph/DepthFirstSearch.py
1,088
3.78125
4
# # @author # aakash.verma # # Output: # 0 1 2 3 4 5 # from collections import deque class Graph: def __init__(self, vertices): self.vertices = vertices self.adjacency_list = [[] for i in range(self.vertices)] def add_edge(self, source, destination): self.adjacency_list[s...
98df0514e5c956f02a81c2323651cdcdd388f817
vivekyadav6838/Data-Structures-and-Algorithms-for-Interviews
/Python/Stack/NGER.py
676
3.703125
4
# @author # Aakash.Verma # Problem: Given an array, find an array of Next Greater Elements (NGE) for every element. # The Next Greater Element for an element x is the first greater element # on the right side of x in array. Elements for which no greater element exist, # consider next greater element as -1. ...
7775471034b1dd0de0fd9d8933667a76ac31f868
vivekyadav6838/Data-Structures-and-Algorithms-for-Interviews
/Python/TreeConstructions/TreeFromInorderPostorder.py
1,070
3.8125
4
# # @author # aakash.verma # class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: # LeetCode Code # Line 18 - 31 inorder_map = {} def solve(postorder, left, right): if left > rig...
c9e8ddfb02261e5c4a56071bc0f75bbd3351e007
vivekyadav6838/Data-Structures-and-Algorithms-for-Interviews
/Python/BFS/LevelOrderTraversal.py
1,273
3.71875
4
# @author # Aakash Verma # Output: # [1] # [2, 3] # [4, 5, 6, 7] from collections import * class Node: def __init__(self, data): self.data = data self.right = self.left = None class LevelOrderTraversal: def __init__(self): self.root = None def traverse(self, root): ...
c1fb81fb6e309bc5d55ef59bb8dcaee3379b761c
vivekyadav6838/Data-Structures-and-Algorithms-for-Interviews
/Python/DFS/LowestCommonAncestorBT.py
1,191
3.6875
4
# @author # Aakash Verma # Output: # 5 from collections import * class Node: def __init__(self, data): self.data = data self.right = self.left = None class LowestCommonAncestor: def __init__(self): self.root = None def lowestCommonAncestor(self, root, p, q): if(ro...
96ca87b2c6191ffd17b5571581f5dec816529ef2
SgtHouston/python102
/sum the numbers.py
249
4.21875
4
# Make a list of numbers to sum numbers = [1, 2, 3, 4, 5, 6] # set up empty total so we can add to it total = 0 # add current number to total for each number iun the list for number in numbers: total += number # print the total print(total)
fa08d02556f677bb3d0a0e1eb08fbd552e61b01b
CodeWithAnees/Python-Problems-with-Solutions
/Python Programs (HackerRank)/Collections.namedtuple().py
232
3.515625
4
from collections import namedtuple n, titles = int(input()), input().split() table = namedtuple('titles', titles) marks = [int(table._make(input().split()).MARKS) for _ in range(n)] print("{0:.2f}".format(sum(marks) / len(marks)))
d76c42d975894df64397e374b090d98ec1959ba8
CodeWithAnees/Python-Problems-with-Solutions
/Python Programs (HackerRank)/Collections.OrderedDict().py
196
3.71875
4
from collections import OrderedDict od = OrderedDict() sum = 0 for i in range(int(input())): item_name = list price = int(price) sum = sum + price od[item_name] = sum print(od)
4bf03ad8d51120792a854a90cc2c25d3a1f5d46a
CodeWithAnees/Python-Problems-with-Solutions
/Wipro NLTH/Alphabetic_cross_pattern.py
513
3.96875
4
# Alphabetic cross pattern # Write a program to print the following pattern. # Input Format: # Input consists of a string. # Output Format: # Refer sample output. # Sample Input: # hello # Sample Output: # h o # e l # l # e l # h o word = input() lengthOfWord = len(word) for i in range...
59dc7c3ef7118e093c9f99589c6a00dc0ac51615
edselph/gitlink-exercise-week-2
/PR/# Pr no 5.py
322
4.0625
4
# Pr no 5 The_Speed = int(input("the speed number:")) The_frequency = int(input("the frequency number:")) Lambda = The_Speed/The_frequency print("The data : ") print("The Speed :",The_Speed,str("m/s")) print("The frequency :",The_frequency,str("hz")) print("The wavelength :",Lambda,str("M")) # try v = 343 , and f = 25...
b318bf9bc8d0760352b2b551697b45f24117dcb3
starsCX/Py103
/chap0/Project/ex12-3.py
557
4.1875
4
#在Python 3.2.3中 input和raw_input 整合了,没有了raw_input age = input("How old are you?") height = input("How tall are you?") weight = input("How much do you weigh?") print ("so you are %r old ,%r tall and %r heavy." %(age,height,weight)) print ("so you are %r old ,%r tall and %r heavy." %(age,height,weight)) #python2.7 的话,pri...
91ac17f90e64c6ab6bd27605f6803ed00b16a84c
vividsky/python-programs
/fibonacci_memiozation.py
479
4.0625
4
cache = {} def fib(n): if n == 1: return 1 elif n == 2: return 1 else: return fibonacci(n-1) + fibonacci(n-2) def fibonacci(n): if n in cache: return cache[n] else: if n == 1: return 1 elif n == 2: return 1 else: ...
25ceca21258ebec39c3bb51f308a1e5f136aaca4
urmajesty/learning-python
/ex5.py
581
4.15625
4
name = 'Zed A Shaw' age = 35.0 # not a lie height = 74.0 # inches weight = 180.0 #lbs eyes = 'Blue' teeth = 'White' hair = 'Brown' print(f"Let's talk about {name}.") print(f"He's {height} pounds heavy.") print("Actually that's not too heavy.") print(f"He's got {eyes} eyes and {hair} hair.") print(f"His teeth are usua...
ad95c87916b03510e8a705c12ec5ef86664346df
ParkYeeeeeon/scriptlanguage
/7-8(스톱워치).py
607
3.578125
4
import time class StopWatch: def __init__(self): self.__startTime=time.time() def getStartTime(self):return self.__startTime def getEndTime(self):return self.__endTime def start(self): self.__startTime=time.time() def stop(self): self.__endTime=time.time() def getEla...
a9d12ac6e5905b371a2cea69224d91adeb30d580
ParkYeeeeeon/scriptlanguage
/4-1(근의개수).py
416
3.515625
4
a,b,c=eval(input("a,b,c 입력:")) print(a,b,c) determinant=b**2-4*a*c if determinant>0: r1=(-b-determinant**0.5)/2*a r2 = (-b + determinant ** 0.5) / 2 * a print("실근은 {0:.2f},{1:.2f}입니다".format(r1,r2)) elif determinant==0: r1 = (-b - determinant ** 0.5) / 2 * a print("실근은",r1,"입니다") elif determinant<0...
2c79f0ea92703c8d7948614bbe37db88574ef1e0
ParkYeeeeeon/scriptlanguage
/평균.py
421
3.640625
4
st2 = input("정수 입력") st2List = st2.split() inList2 = [eval(i) for i in st2List] sum(inList2) average = sum(inList2) / len(inList2) aboveAverageL = list(filter(lambda i:i >= average, inList2)) belowAverageL = list(filter(lambda i:i < average, inList2)) print("평균보다 높은 점수의 개수 = {0}".format(len(aboveAverageL))) print("평...
caed32f8a478c7fa3ac61bf726acc8296631299c
Ianwu0812/quickstart-python
/if.py
557
3.953125
4
number = 23 guess = int(input('Enter an integer : ')) if guess == number: # 新塊從這裡開始 print('Congratulaion, you guessd it.') print('(but you can not win any prizes!)') # 新塊在這裡結束 elif guess < number: # 另一個代碼塊 print ('No, it is a little higher than that') # 你可以在此做任何你希望在該代碼塊內進行的事情 else: pri...
39fa098278cd2735f7288dfe9e4eba16a3ce678a
KnightsTiger/tratsgnittegnohtypetisnilarulp
/2Ifstatatements.py
376
4.03125
4
#if statement x =10 if x>0: print(x) else: print(x-1) #elif y=5 if y>10: print(y) elif y>=5: print(y-1) else: print("nooo") boolval = False # not key word if not boolval: print (y) # and key word if x<10 and y>10: print(x) # or keyword if x>10 or y<5: print(y) #Ternary if con...
c9ce21bc1cef1c7dc553395727a9d3d1c49aeee3
KnightsTiger/tratsgnittegnohtypetisnilarulp
/8itaratingfunction.py
259
3.59375
4
students = [] def readNames(): try: name=open("studnets.txt","r") for student in name.readlines(): students.append(student) name.close() except Exception: print("Error occured") readNames() print(students)
1f564a468fd2c09e9ff3f3d1405157e24224047e
antoinemadec/test
/python/codewars/next_bigger_number_with_the_same_digits/next_bigger_number_with_the_same_digits.py
977
3.828125
4
#!/usr/bin/env python3 """ You have to create a function that takes a positive integer number and returns the next bigger number formed by the same digits: next_bigger(12)==21 next_bigger(513)==531 next_bigger(2017)==2071 If no bigger number can be composed using those digits, return -1: next_bigger(9)==-1 next_big...
9f61c1b701d4ecf5797e87fe88b593ef2208d9b0
antoinemadec/test
/python/codewars/the_millionth_fibonacci_kata/the_millionth_fibonacci_kata.py
467
3.5625
4
#!/usr/bin/env python3 def fib_matrix(n): v1, v2, v3 = 1, 1, 0 for rec in bin(n)[3:]: calc = v2*v2 v1, v2, v3 = v1*v1+calc, (v1+v3)*v2, calc+v3*v3 if rec=='1': v1, v2, v3 = v1+v2, v1, v2 return v2 def fib(n): sign = 1 if n < 0: n *= -1 sign = (-1,1)[n%2] ...
74ac90a14c752bbb7f61db09150bb3df3cdb7d94
antoinemadec/test
/python/codewars/middle_permutation/middle_permutation.py
1,069
4.1875
4
#!/usr/bin/env python3 f = {} def factorial(n): if n==0: f[n] = 1 elif n not in f: f[n] = n*factorial(n-1) return f[n] def factoradics(n): for k in range(n+2): if factorial(k) > n: break r = [] for k in range(k-1,-1,-1): d = n//factorial(k) r...
a7e7caf2f07187cd5e9341b408280c4613230870
antoinemadec/test
/python/codewars/happy_number/happy_number.py
2,009
3.796875
4
#!/usr/bin/env python3 """ This kata is based on a variation of Happy Numbers by TySlothrop. It is advisable to complete it first to grasp the idea and then move on to this one. Hello, my dear friend, and welcome to another Happy Numbers kata! What? You're not interested in them anymore? They are all the same? But wh...
53c52d5fb29d5f8f28c56ead8f8c31dfd6f06d98
antoinemadec/test
/python/codewars/simplifying/simplifying.py
2,602
4.5
4
#!/usr/bin/env python3 ''' You are given a list/array of example formulas such as: [ "a + a = b", "b - d = c ", "a + b = d" ] Use this information to solve a formula in terms of the remaining symbol such as: "c + a + b" = ? in this example: "c + a + b" = "2a" Notes: Variables names are case sensitive There ...
1d5eba8fd2834bb2375016ec7ed9e8cc686f1991
antoinemadec/test
/python/programming_exercises/q5/q5.py
662
4.21875
4
#!/usr/bin/env python3 print("""https://raw.githubusercontent.com/zhiwehu/Python-programming-exercises/master/100%2B%20Python%20challenging%20programming%20exercises.txt Question: Define a class which has at least two methods: getString: to get a string from console input printString: to print the string ...
0a188f0fc17e26c26a629cad0836f16919a19c20
antoinemadec/test
/python/programming_exercises/q16/q16.py
817
3.921875
4
#!/usr/bin/env python3 print("""https://raw.githubusercontent.com/zhiwehu/Python-programming-exercises/master/100%2B%20Python%20challenging%20programming%20exercises.txt Question: Write a program that computes the net amount of a bank account based a transaction log from console input. The transaction log format ...
1d03bbf7c70e7e8af48d215fbf891b65cf7f4320
antoinemadec/test
/python/codewars/roboscript_2_-_implement_the_rs1_specification/roboscript_2_-_implement_the_rs1_specification.py
4,343
4.5
4
#!/usr/bin/env python3 ''' Write an interpreter for RS1 called execute() which accepts 1 required argument code, the RS1 program to be executed. The interpreter should return a string representation of the smallest 2D grid containing the full path that the MyRobot has walked on (explained in more detail later). Initi...