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
a011e40988c64cba8460afad75abe1340cf7ead5
WillYu91/LinkedListDemo
/LinkedList.py
2,769
4.03125
4
class Node(): def __init__(self, value, next, previous): self._value = value self._next = next self._previous = previous class LinkedList(): def __init__(self): self.head = None self.tail = None self.length = 0 def append(self, value): # Empty LinkedList if self.length == 0: self.head = Node(...
4b761b72da558eeb4d22c31f4050c523b25bf517
loplio/DRILL
/draw.py
330
3.796875
4
import turtle count = 0 count_2 = 0 while(count < 6): turtle.penup() turtle.goto(0,count * 30) turtle.pendown() turtle.forward(150) count = count + 1 turtle.left(90) while(count_2 < 6): turtle.penup() turtle.goto(count_2 * 30,0) turtle.pendown() turtle.forward(150) count_2 = co...
c880500e06ed56b2c0871378711a9110d4d0f99b
mahavenkatvas/my_coding
/multiple.py
127
3.53125
4
#maha n=int(input()) l=[] for i in range(1,6): l.append(n*i) for i in range(len(l)-1): print(l[i],end=" ") print(l[-1])
250dcdc634cadee85339c29f4a63129cabe6792f
mahavenkatvas/my_coding
/p2_9.py
358
3.75
4
def prime(n): i=2 while i<n: if n%i==0: break i+=1 if n==i: return 1 n=int(input()) if n%2!=0: print(n) else: l=[2] for i in range(3,n//2): x=prime(i) if x==1: l.append(i) for i in range(len(l)): if n%l[i]==0: ...
a6e304a63176e4f0b64a4be1530b7f5c0487becd
mahavenkatvas/my_coding
/p2_1.py
92
3.796875
4
#maha k=input() m="Saturday" if k==m or k=="saturday": print("yes") else: print("no")
ceb55b681aef63180f794bee0fd1c9b0139f6769
mahavenkatvas/my_coding
/b8_5.py
107
3.59375
4
s=input() r="" x=len(s)//2 if len(s)%2==0: print(s[:x-1]+"**"+s[x+1:]) else: print(s[:x]+"*"+s[x+1:])
65f5caf835e2cbb641f83fe2fc4fd9aeb2b66be1
Crsmith89/Week1_weekend_homework_pets
/src/pet_shop.py
3,020
3.8125
4
# WRITE YOUR FUNCTIONS HERE # 1 - Get pet shop name def get_pet_shop_name(pet_shop): return pet_shop["name"] # 2 - Get total cash def get_total_cash(pet_shop): return pet_shop["admin"]["total_cash"] # 3 - Add or remove cash +10, += operator performs an addition operator and then assigns the result of the oper...
b3af6d12156b0a79ab420606f818ed6683d740b7
zecookiez/AdventOfCode2018
/day11_chronalCharge.py
1,906
3.578125
4
t0 = time() puzzle = 7165 def chronalCharge(serial): # Preprocess a table of partial sums, then bruteforce on it. O(N^3) algorithm, where N is the side length # Time: 147 ms grid = [[0] * 301 for row in range(301)] for x in range(1, 301): for y in range(1, 301): rID = x + 10 ...
edca0fe0fde2e96af3ad97a2d8de4e97294ac412
surajmapa/CodeBreakthrough
/OOP/solution-3.py
1,369
3.59375
4
from enum import Enum class Position: def __init__(self, pan, tilt, zoom): self.pan = pan self.tilt = tilt self.zoom = zoom def __str__(self): return f"Pan: {str(self.pan)}. Tilt: {str(self.tilt)}. Zoom: {str(self.zoom)}." def __eq__(self, other): return self.pan =...
b73bef7e819ba6b5be8231e216e528297104c271
funkyong13/PlotTrend
/PT_PythonBackEnd/Feature2_Stock Price Forecast/v6_2016_09_15/pt_datetime.py
2,031
3.765625
4
# PLOT TREND WEB-APP DEVELOPMENT # Script Overview for "pt_datetime.py" # Purpose: This script contains function necessary to perform date and time related operations for Plot Trend project import datetime def ctime_to_dtDate(sCtimeDate): # Function Overview for "ctime_to_dtDate" # Purpose: This funct...
e978977fdd99537d46cfcb3e287f2a829fb6b65a
achluky/boston-housing-price-prediction
/boston.py
2,770
3.59375
4
import numpy as np # load the dataset dataset = np.loadtxt('housing.csv') dataset_x = dataset[:, :-1] dataset_y = dataset[:, -1] from sklearn.model_selection import train_test_split # split the dataset into training and test datasets. training_dataset_x, test_dataset_x, training_dataset_y, test_dataset_y = train_test_...
759b332f188c853717da17cef6f4a7e59f2d746b
rahulgadre/python-files
/for.py
466
3.71875
4
# For loop city = ["Denver","Colorado Springs","Boulder","Lone Tree","Broomfield","Fort Collins"] for i in city: print(i) print(len(i)) # For loop for i in range(1, 5): print(i) # For loop with continue numbers = [1, 2, 5, 8, 11, 13, 17, 19, 20] for n in range(20): if n in numbers: continue print (n) # ...
e5778de1a44451ee53a691bd3827ad524628211b
bhvya1505/Cryptography
/Stream Ciphers/XOR/repeatedkeyXOR.py
218
4.09375
4
plaintext = raw_input("Enter plaintext ") ciphertext = "" key = raw_input("Enter key ") for i in range(len(plaintext)): k = i%len(key) ciphertext += chr(ord(plaintext[i])^ord(key[k])) print ciphertext.encode("hex")
17404714d2acef85fed4768120996bb9e9ff86c5
bhvya1505/Cryptography
/Stream Ciphers/Caesar/caesar.py
371
4.125
4
plaintext = raw_input("Enter your plaintext: ") key = input("Enter the key: ") ciphertext = "" small = "abcdefghijklmnopqrstuvwxyz" capital = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" for i in plaintext: if i in small: ciphertext += small[(small.index(i)+key)%26] elif i in capital: ciphertext += capital[(capital.index(i)+ke...
a51dd38f9a232f4e4d23e931a841cd9fe6a3addc
todorovventsi/Software-Engineering
/Programming-Fundamentals-with-Python/functions-lab/05. Calculate Rectangle Area.py
155
3.828125
4
def rectangle_area(width, height): return width * height width = int(input()) height = int(input()) area = rectangle_area(width, height) print(area)
79f62033c8ffe86b8006b8ba9c872c2889c9381e
todorovventsi/Software-Engineering
/Programming-Fundamentals-with-Python/lists-basics-exercises/04. Number Beggars.py
345
3.5
4
numbers = input() number_of_beggars = int(input()) listed_numbers = numbers.split(", ") result = [] for beggar in range(number_of_beggars): beggar_collected = 0 for index in range(beggar, len(listed_numbers), number_of_beggars): beggar_collected += int(listed_numbers[index]) result.append(beggar_c...
9022d66a016a3039b826bcae96f815bff7616175
todorovventsi/Software-Engineering
/Python-OOP-July2021/13.Iterators_and_generators-L/custom_range.py
518
3.546875
4
class custom_range: def __init__(self, start, end): self.start = start self.end = end def __iter__(self): return self def __next__(self): while self.start <= self.end: temp = self.start self.start += 1 return temp raise StopIterat...
07f33784f2e4962b190adc616d93048cac1f33ff
todorovventsi/Software-Engineering
/Programming-Fundamentals-with-Python/functions-exercises/03. Characters in Range.py
424
4.1875
4
def print_chars_in_between(char1, char2): result = "" if ord(char1) > ord(char2): for char in range(ord(char2) + 1, ord(char1)): result += chr(char) + " " else: for char in range(ord(char1) + 1, ord(char2)): result += chr(char) + " " return result first_char = i...
ad772b77b29d2c780c2361ed6041b3b8c63c0259
todorovventsi/Software-Engineering
/Python-Advanced-2021/05.Functions-advanced-E/04.Negative_vs_positive.py
444
4.15625
4
def compare_negatives_with_positives(nums): positives = sum(filter(lambda x: x > 0, nums)) negatives = sum(filter(lambda x: x < 0, nums)) print(negatives) print(positives) if positives > abs(negatives): return "The positives are stronger than the negatives" return "The negatives are stro...
46eeb4189b7dd010e0fd9a5e7e0bb12715495d60
todorovventsi/Software-Engineering
/Python-Advanced-2021/05.Functions-advanced-E/05.Odd_or_even.py
301
4.0625
4
def odd_or_even(nums, command): nums_collection = filter(mapper[command], nums) return sum(nums_collection) * len(nums) mapper = { "Odd": lambda x: x % 2 != 0, "Even": lambda x: x % 2 == 0 } comm = input() numbers = list(map(int, input().split())) print(odd_or_even(numbers, comm))
ca4b17d48d67ab96180183eb3b4068bada1dece0
todorovventsi/Software-Engineering
/Programming-Fundamentals-with-Python/lists-advanced-exercises/01.Which-are-in.py
422
4.03125
4
# first_s = input().split(", ") # second_s = input() # # resulting_s = [word for word in first_s if word in second_s] # # resulting_s = list(filter(lambda word: word in second_s, first_s)) # print(resulting_s) first_list = input().split(", ") second_list = input().split(", ") second_list_strings = "".join(second_list) ...
40cb3e65fc44a7be174cd75054f825d8f2865117
todorovventsi/Software-Engineering
/Python-Advanced-2021/03.Multidimensional-lists-L/01.Sum-matrix-elements.py
290
3.5
4
rows, columns = map(int, input().split(", ")) matrix = [] matrix_total_sum = 0 for row in range(rows): read_row = [int(i) for i in input().split(", ")] matrix_total_sum += sum(read_row) matrix.append([]) matrix[row].extend(read_row) print(matrix_total_sum) print(matrix)
da1aec1428db680418a45e7b717b8c06639d5f70
todorovventsi/Software-Engineering
/Programming-Fundamentals-with-Python/functions-lab/01. Grades.py
437
4.21875
4
def convert_grade_to_text_grade(grade_as_num): if 2 <= grade_as_num <= 2.99: return "Fail" elif 3 <= grade_as_num <= 3.49: return "Poor" elif 3.50 <= grade_as_num <= 4.49: return "Good" elif 4.50 <= grade_as_num <= 5.49: return "Very Good" elif 5.50 <= grade_as_num <=...
54759dac1009d49e79993e5dbe826cb53eef3a54
todorovventsi/Software-Engineering
/Python-OOP-July2021/Regular_Exam-Testing/project/pet_shop.py
1,231
3.859375
4
class PetShop: def __init__(self, name: str): self.name = name self.food = {} self.pets = [] def add_food(self, name: str, quantity: float): if quantity <= 0: raise ValueError('Quantity cannot be equal to or less than 0') if name not in self.food: ...
14b5941a3bc1d4746807e77eef52e8d5229b63a2
todorovventsi/Software-Engineering
/Python-Advanced-2021/Exam-preparation/Python-Advanced-Retake-Exam-14_April_2021/01.Pizza-orders.py
948
3.703125
4
from collections import deque orders = deque(map(int, input().split(', '))) employees_capacity = deque(map(int, input().split(', '))) total_pizzas = 0 orders_completed = False no_capacity = False while True: if not orders: orders_completed = True break if not employees_capacity: no_c...
d0b84c66fb2aef81ac775f81011d173c965d22b9
todorovventsi/Software-Engineering
/Programming-Fundamentals-with-Python/functions-exercises/07. Perfetct Number.py
450
3.984375
4
def perfect_or_not(integer): # Returns True if "integer" is equal to the sum of its positive divisors sum_of_divisors = 0 for num in range(1, integer): if integer % num == 0: sum_of_divisors += num if sum_of_divisors == integer: return True return False number_to_check ...
6c54c67a6f5ff31dec240dcb94f116cbcf1406e1
todorovventsi/Software-Engineering
/Python-Advanced-2021/02.Tuples-and-sets-E/06.Longest-intersection.py
973
3.703125
4
ranges_number = int(input()) longest_intersection = set() for _ in range(ranges_number): # read the ranges and stores them into sets: first_range, second_range = input().split("-") first_range = first_range.split(",") second_range = second_range.split(",") first_set = set(str(i) for i in range(int...
adab7280624e5e9f972d462f982f47a136de0c49
todorovventsi/Software-Engineering
/Python-OOP-July2021/12.Polymorphism_and_abstraction-E/vehicle.py
1,016
4.09375
4
from abc import ABC, abstractmethod class Vehicle(ABC): def __init__(self, fuel_quantity, fuel_consumption): self.fuel_quantity = fuel_quantity self.fuel_consumption = fuel_consumption @abstractmethod def drive(self, kilometers): pass @abstractmethod def refuel(self, lite...
b0edfe38a8594b166a87244e22c639657bb42045
todorovventsi/Software-Engineering
/Programming-Fundamentals-with-Python/lists-advanced-exercises/05.Electron-distribution.py
502
3.84375
4
electrons = int(input()) distribution_by_shell = [] for index in range(electrons): shell = index + 1 max_electrons = 2 * shell ** 2 if electrons > max_electrons: distribution_by_shell.append(max_electrons) electrons -= max_electrons elif electrons == max_electrons: distribution...
66ab55c048ed0734a7b84d0dea0701ba4ee23ff9
todorovventsi/Software-Engineering
/Programming-Fundamentals-with-Python/lists-basics-exercises/02. Multiples List.py
212
3.59375
4
factor = int(input()) count = int(input()) resulted_list = [] number = 1 while len(resulted_list) < count: if number % factor == 0: resulted_list.append(number) number += 1 print(resulted_list)
1efebdbb9f25948744e2bbc47a9dbe30a9ee39d8
todorovventsi/Software-Engineering
/Programming-Fundamentals-with-Python/dictionaries/03.Statistics.py
425
3.875
4
products = {} data = input() while not data == "statistics": product, value = data.split(": ") value = int(value) if product not in products: products[product] = 0 products[product] += value data = input() print("Products in stock:") for key, value in products.items(): print(f"- {key}...
8d49cc758f9584abb36219b09af67b9e4879d043
todorovventsi/Software-Engineering
/Programming-Fundamentals-with-Python/lists-advanced-exercises/04.Office-chairs.py
455
3.703125
4
n_rooms = int(input()) there_are_free_chairs = True free_chairs = 0 for room in range(1, n_rooms + 1): chairs, people = input().split(" ") difference = abs(len(chairs) - int(people)) if int(people) > len(chairs): print(f"{difference} more chairs needed in room {room}") there_are_free_chair...
cfb07eee0037d3cda7f5e4954591cfb2c4462f2b
todorovventsi/Software-Engineering
/Programming-Fundamentals-with-Python/exam-preparation/03.Man-O-War.py
2,035
3.8125
4
def index_is_valid(ind, length): if ind in range(length): return True return False pirate_ship_status = [int(i) for i in input().split(">")] warship_status = [int(i) for i in input().split(">")] max_health_for_section = int(input()) command = input() have_a_winner = False while not command == "Retir...
c21044ea78825673a9daf4ba0a2abff2eda0c62e
jaredledvina/adventofcode2017
/day2/checksum.py
1,377
4.03125
4
#! /usr/bin/env python def cleanup_input(): cleaned = [] with open('input.txt') as f: for line in f: clean_line = [ int(item) for item in line.split('\t') ] cleaned.append(clean_line) return cleaned def generate_difference(line): """ >>> generate_difference([1, 2, ...
ee25339b87009d0e25284a685f57d51580b5a3af
Bharath-96/Mbr_practice_python
/Numeric_functions.py
1,459
3.78125
4
# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ # define function for addition def sum(x,y): print("x: {}".format(x)) print("y: {}".format(y)) print("sum of x,y ") z=x+y return z # define function for difference def diff(x,y): print("x: {}".format...
5967e96c384d8d1786b37d63616141abcea33c8b
Bharath-96/Mbr_practice_python
/argument_types.py
2,293
3.6875
4
# -*- coding: utf-8 -*- """ Created on Wed Jun 30 08:43:05 2021 @author: muppabh """ #Arguments types #1. Required argument function #2. Keyowrd argument fucntion #3. Default argument function #4. Variable argument function #1. *********** Required argument function ************************* def req_ar...
1fa038e14eb6a38c69b597717f96d181e90dff10
Praneeth-AR/AI_game
/doric/map.py
1,066
3.796875
4
from math import ceil class Coordinates(object): def __init__(self, row, col): self.row = row self.col = col # set the cube coordinates of the hexagon as [x, y, z] self.cube_coords = self.even_r_to_cube(self.row, self.col) @staticmethod def even_r_to_cube(row, col): ...
8768267d8f35dc3333325a24b5ed0522e1a55609
vacuum136/CppND-Capstone
/unit2_pp/scripts/unit2_exercise.py
2,874
3.859375
4
#! /usr/bin/env python """ Dijkstra's algorithm path planning exercise Author: Roberto Zegers R. Copyright: Copyright (c) 2020, Roberto Zegers R. License: BSD-3-Clause Date: Nov 30, 2020 Usage: roslaunch unit2_pp unit2_exercise.launch """ import rospy def find_neighbors(index, width, height, costmap, orthogonal_step...
40217ff8bbd8a34d791f7f21a0856269c2b50b86
keurfonluu/My-Daily-Dose-of-Python
/Solutions/50-word-ordering-in-different-alphabetical-order.py
903
3.828125
4
#%% [markdown] # Given a list of words, and an arbitrary alphabetical order, verify that the words are in order of the alphabetical order. # # Example # ``` # Input: # words = ["abcd", "efgh"], order="zyxwvutsrqponmlkjihgfedcba" # Output: False # Input: # words = ["zyx", "zyxw", "zyxwy"], # order="zyxwvutsrqponmlkjihg...
c1436658b05474f63d7b99cf949878a9e63b5c35
keurfonluu/My-Daily-Dose-of-Python
/Solutions/42-look-and-say-sequence.py
844
4.125
4
#%% [markdown] # A look-and-say sequence is defined as the integer sequence beginning with a single digit in which the next term is obtained by describing the previous term. An example is easier to understand: # # Each consecutive value describes the prior value. # ``` # 1 # # 11 # one 1's # 21 # two 1's #...
b49eed8980e364d9dc24c28b94a037308f93227d
keurfonluu/My-Daily-Dose-of-Python
/Solutions/33-merge-overlapping-intervals.py
819
3.78125
4
#%% [markdown] # You are given an array of intervals - that is, an array of tuples (start, end). # The array may not be sorted, and could contain overlapping intervals. # Return another array where the overlapping intervals are merged. # # Example # ``` # Input: [(1, 3), (5, 8), (4, 10), (20, 25)] # Output: [(1, 3), (4...
744f4d0b7ae36b25bda8115b1a2611319411a281
keurfonluu/My-Daily-Dose-of-Python
/Solutions/11-floor-and-ceiling-of-a-binary-search-tree.py
1,255
3.71875
4
#%% [markdown] # Given an integer k and a binary search tree, find the floor (less than or equal to) of k, and the ceiling (larger than or equal to) of k. If either does not exist, then print them as None. #%% class Node: def __init__(self, value): self.left = None self.right = None self.va...
f244eed46fea41b0f301ee5b90a01bc2d2889931
keurfonluu/My-Daily-Dose-of-Python
/Solutions/27-witness-of-the-tall-people.py
655
3.984375
4
#%% [markdown] # There are n people lined up, and each have a height represented as an integer. A murder has happened right in front of them, and only people who are taller than everyone in front of them are able to see what has happened. How many witnesses are there? # # Example # ``` # Input: [3, 6, 3, 4, 1] # Outp...
f650bd9a31e3b3360bcef45ac11c5dc2cd575f81
keurfonluu/My-Daily-Dose-of-Python
/Solutions/56-running-median.py
786
3.875
4
#%% [markdown] # You are given a stream of numbers. # Compute the median for each new element. # # Example # ``` # Input: [2, 1, 4, 7, 2, 0, 5] # Output: [2, 1.5, 2, 3, 2, 2, 2] # ``` #%% def running_median(stream): # Median of a sorted array def median(x): imid = len(x) // 2 if len(x) % 2 == 0...
1cab3497b4b8ebf5e0e02f695823028c6ce5b220
keurfonluu/My-Daily-Dose-of-Python
/Solutions/30-find-the-kth-largest-element-in-a-list.py
437
4.03125
4
#%% [markdown] # Given a list, find the k-th largest element in the list. # # Example # ``` # Input: list = [3, 5, 2, 4, 6, 8], k = 3 # Output: 5 # ``` #%% def findKthLargest(nums, k): # Partial selection sort for i in range(k): for j, x in enumerate(nums[i+1:]): if x >= nums[i]: ...
3bad61184c65b83149f9fda533057aa9bffd0243
aviladiogo/Metodo-de-gauss
/Gauss.py
1,069
3.5625
4
def preencheMatriz(): x = 0 y = 0 while y < LinhasT: while x < ColunasT: Sistema[y,x] = int(input("insira o valor na linha " + str(y) + ", Coluna " + str(x) +": ")) x+=1 x = 0 y += 1 def Gauss(linha, coluna): linha1 = linha+1 cont = 0 ...
4b87e365672b59c66c16f045eb83677d59e862d9
jugshaurya/Learn-Python
/2-Programs-including-Datastructure-Python/4 - Linked List/skipNafterM_ll.py
1,582
3.71875
4
'''Delete every N nodes Send Feedback Given a linked list and two integers M and N. Traverse the linked list such that you retain M nodes then delete next N nodes, continue the same until end of the linked list. That is, in the given linked list you need to delete N nodes after every M nodes. Input format : Line 1 : L...
104cf3da661d2a8b84736b8312876bdcc912126c
jugshaurya/Learn-Python
/2-Programs-including-Datastructure-Python/5 - Stack/balanceParenthesis.py
1,003
4.21875
4
''' Balanced Paranthesis Given a string expression, check if brackets present in the expression are balanced or not. Brackets are balanced if the bracket which opens last, closes first. You need to return true if it is balanced, false otherwise. Sample Input 1 : { a + [ b+ (c + d)] + (e + f) } Sample Output 1 : true S...
345f54492b4d2de56486f3f87a4599a64cb52d8c
jugshaurya/Learn-Python
/2-Programs-including-Datastructure-Python/4 - Linked List/midPoint_ll.py
1,304
3.8125
4
class Node: def __init__(self, data): self.data = data self.next = None def midpoint_linkedlist(head): if head == None or head.next == None: return head # in case of odd length list like 5 , we return 2 (5 // 2) # in case of even length list like 6 , we return 3(6//2) , ou...
41e67785a72015e03d652903451ef5c2eb05fddf
jugshaurya/Learn-Python
/2-Programs-including-Datastructure-Python/6 - Queue/queue_use.py
1,781
3.625
4
# give input 1 3 1 4 1 63 1 21 1 9 2 3 1 7 2 2 2 3 -1 ''' output should be 3 4 4 63 21 9 ''' from queue_use import QueueUsingArr q = QueueUsingArr() li = [int(ele) for ele in input().split()] i=0 while i<len(li): choice = li[i] if choice == -1: # if choice is -1 break break elif choice == 1: # if...
e5c5d3f83b23dfd96b8d157edbec23a30fd2680f
rodmcnew/neural-backpropagation-example
/src/shallow_network_usage_example.py
791
3.546875
4
import random import numpy as np from shallow_network import ShallowNetwork from activation_functions import Sigmoid, LeakyRelu # Train the network to behave like a binary "AND" function training_data = [ [[0, 0], [0]], [[0, 1], [0]], [[1, 0], [0]], [[1, 1], [1]] ] # network = ShallowNetwork(2, 1, L...
dcfeacde8ceff36fb9d0b8e4b2e2a6d6dc675fd1
tchoedak/ProgrammingExercises
/Project Euler/Ex7_10001st_prime.py
938
4
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 25 23:22:00 2014 By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? Method: - keep record of primes by doing primes_found += 1 each time one is found - use is_prime to determine if prim...
0f5c07550550e7ec888e787fc80030ea74f9bd72
tchoedak/ProgrammingExercises
/Project Euler/Ex6_difference_of_squares.py
767
3.75
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 25 20:48:30 2014 The sum of the squares of the first ten natural numbers is, 12 + 22 + ... + 102 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)2 = 552 = 3025 Hence the difference between the sum of the squares of the first ten natura...
2765c111ba3da0b1b536b5a385b28b67ec9b4615
Kasandra686/Algoritm_python_lesson_2
/1.py
1,832
3.703125
4
# Написать программу, которая будет складывать, вычитать, умножать или делить два числа. Числа и знак операции вводятся # пользователем. После выполнения вычисления программа не должна завершаться, а должна запрашивать новые данные для # вычислений. Завершение программы должно выполняться при вводе символа '0' в качест...
2cb1e0de4e8484e1378684f9f15ba0504c3b3746
Br111t/DataCamp2021
/Python/Time_Series_Analysis_in_Python.py
41,720
4.21875
4
###Correlation and AutoCorrelation ''' Introduction to Time Series Analysis Using Python Qunatopia is place to discuss code Goals of the Course * Learn about time series models * Fit data to a time series model * Use the models to make forcasts of the future * Learn how to use the relevent statistical packages in ...
1f5eb635ccea9225e84b6304817c74df02a3965f
cjortez/MyPy
/Area.py
208
3.953125
4
#How big is this room? In feet: #length=float(input()) #width=float(input()) #area=length*width #print("Length",length,"ft") #print("Width",width,"ft") #print("This room is",area, "Square Feet")
71ca6b5e69d5183519fa252e5882327dae827159
cjortez/MyPy
/mealcost.py
164
3.90625
4
tax=1.08 tip=1.18 meal=input("How much was the food?") meal=float(meal) cost_of_meal=[tax, tip] subtotal=meal*tax totalcost=subtotal*tip print(totalcost)
67601147a8b88309baf61fdc1f5f81a769b8dc0c
solomonbolleddu/LetsUpgrade--Python
/LU Python Es Day-4 assignment.py
1,471
4.4375
4
#!/usr/bin/env python # coding: utf-8 # # Assignment - 4 Day - 4 # 1) write a program to find all the occurences of the substring in the given string along with the index value # I have used list comprehension + startswith() to find the occurences *** # In[2]: a=input("Enter The String\n") b=input("Enter The Subs...
5c5d78b7abfe292b0266f72e1b74ea1a2fc84e6f
nutthaphon/PyLearning
/test/ClassInheritance2.py
1,400
3.984375
4
class Pet(object): def __init__(self, name, species): self.name = name self.species = species def getName(self): return self.name def getSpecies(self): return self.species def __str__(self): return "%s is a %s" % (self.name, self.species) class Dog(Pet): ...
11d3206059d9b2fdd3dc4a0114d2db6fac407900
faroeq33/pythonworkshop
/exercises/chapter3/exercise55.py
314
3.890625
4
# first item in a list def first_item(my_list): return my_list[0] first_item(['cat', 'dog', 'mouse']) # mapping names = ['Magda', 'Jose', 'Anne'] lengths = [] for name in names: lengths.append(len(name)) lengths = list(map(len, names)) lengthOfYourPP = sum(lengths) / len(lengths) print(lengthOfYourPP)
e75b94db087e14187b3cac81e897957dee22484c
faroeq33/pythonworkshop
/exercises/chapter2/exercise28.py
394
3.828125
4
movie = { "title": "The Godfather", "director": "Francis Lord Coppola", "year": 1972, "rating": 9.2, } # print('year:', movie['year']) # update dictionary value movie['rating'] = (movie['rating'] + 9.3)/2 # print('rating:', movie['rating']) movieTwo = {} movieTwo['title'] = "The godfather" movieTwo['...
141b16dc2b1fef5d12a65626587f8f2c9464972e
faroeq33/pythonworkshop
/activities/chapter1/activity3.py
220
3.984375
4
# Choose a question to ask print('How would you rate your day on a scale of 1 to 10?') day_rating = input() # select an appropriate output. print('You feel like a ' + day_rating + ' today. Thanks for letting me know')
1b910ca9a264237988b97990ace3477acd382911
BeyondCy/IoT-IDS
/tests/20-bit-generator/test.py
417
3.609375
4
import time import matplotlib.pyplot as plt import numpy as np times = [] for x in range(50): start = time.time() for i in range(1, 2**20): print(i) stop = time.time() times.append(stop - start) print(times) plt.figure() plt.plot(np.linspace(1, len(times), len(times)), times, '-ro') plt.xlabe...
6f625542155e88e04703100a0d4bb605c3f82a1a
sofiia-tesliuk/Ecosystem
/task_3/imital_3.py
645
3.921875
4
from task_3.ecosystem import Ecosystem def main(): """ Main program to start simulation of ecosystem """ try: river_length = int(input("Enter river length in ecosystem: ")) number_of_iterations = int(input("Enter number of iterations: ")) assert (river_length > 0) and (number_o...
2ca971e7556ab084542e94eec0c4fb3d87c163f5
MauricioMucci/AED2
/Tarefa1/grafos.py
3,651
3.796875
4
from os import system # ------------------------------------------------------------------------------------------------------------------------------------------ # Classe que constroi o grafo por matriz de adjacencia class GrafoMatriz: def __init__(self, vertices): self.vertices = vertices self...
d9adc2d5881f4e95c1d390d7ecbfa8bcc24f5cb8
decareano/python_repo_2019
/count_islands.py
941
3.78125
4
def get_land_neighbors(i, j, grid): """ returns list of neighbor's positions """ output = [] for ni, nj in [(i+1, j),(i-1, j),(i, j+1),(i, j-1)]: if(0 <= ni < len(grid) and 0 <= nj < len(grid[0]) and grid[ni][nj]): output.append((ni, nj)) return output def islands_plot(grid): num_islands = 0 seen...
eb64252481f0ed81477e05e82455d7109655f57f
decareano/python_repo_2019
/else_if_testing.py
408
4.25
4
people = 30 cars = 40 buses = 15 if cars > people: print("we should take the cars.") elif cars < people: print("we should not take the cars") else: print("dont know what to do") if buses > cars: print("too many buses") elif buses < cars: print("maybe we can take the buses") else: print("still cannot decide") i...
7c199e1f054019bab033e0f4ee96856c119a172e
decareano/python_repo_2019
/islands_plot.py
583
3.578125
4
from get_land_neighbors import get_land_neighbors def islands_plot(a): num_islands = 0 seen = [] grid = len(a) colums = len(a[0]) for i in range(grid): for j in range(colums): if a[i][j] and (i,j) not in seen: seen.append(a[i][j]) num_islands += 1 neighbors = get_land_neighbors(i,j, grid) wh...
785b4e015b3d58ac695988ef7c95baa415ee0f8f
riccardolorenzon/AdvacedDataStructures
/StackAndQueue/brackets.py
1,008
4.09375
4
#Determine whether a given string of parentheses is properly nested. def solution(S): n = len(S) #base case: if S is empty tha is nested if n== 0: return 1 #stack initialization stack = [] #logic is: # if open bracket => ok # if close bracket => pop of last element, ...
9760cad4a095ee65cb9d38a419819206332c4494
Devil-ReaperL/Trash
/0108/study1/总结.py
389
3.921875
4
""" 环境安装 解释器CPython(64bit) path环境变量 cmd》python : path路径下打开python.exe 变量:不能数字开头,不要使用关键字命名 弱类型:类型由内容确定 控制台输入 input() 》 str 类型转换 int(str) float(str) "abc " '''aaaa''' : 识别回车 格式化 %s %d %f """ a = "ab\r\nc" a = '''ab c''' print(a)
87c9cd1d601d04d104fe23ef0b4e7c1fe18c0c69
Devil-ReaperL/Trash
/1010/study3/字典.py
1,238
4.34375
4
# 字典: key唯一值 : 若出现重复 前者key对应的值发生改变 # key 唯一 value 随意 #{key1:value1,key2:value,...} students = { "name":"张奇", "age":27, "sex":"male", "height":"1.8", "name":"王齐", "腰围":27, } print(len(students)) for i,j in students.items(): print(i,j) print(students.items(),type(students.ite...
3d2798f31123ddbadd77c0c2e3aa7ec27e48def9
Devil-ReaperL/Trash
/1010/study3/元组.py
509
4.03125
4
# 不可变的列表 nums = (1,2,3,4,5) nums = tuple((1,2,3,4,5)) nums = 1,2,3,4,5 print(nums,type(nums)) # 单元素的元组和列表 num1 = [1] print(type(num1)) num2 = (1,) print(type(num2)) #元素个数 print(len(num2)) # 重复元素 # nums.count() # 查看元素的索引 #index = nums.index() # 遍历 # 合并 num = num2+nums # del num for i in num: ...
7605cc3f3ec72fb22152026d7dbe8d22f7682dd1
Ynglylife/LeetCode
/子集划分问题/494. 目标和.py
1,599
3.546875
4
''' 给定一个非负整数数组,a1, a2, ..., an, 和一个目标数,S。现在你有两个符号 + 和 -。对于数组中的任意一个整数,你都可以从 + 或 -中选择一个符号添加在前面。 返回可以使最终数组和为目标数 S 的所有添加符号的方法数。 示例 1: 输入: nums: [1, 1, 1, 1, 1], S: 3 输出: 5 解释: -1+1+1+1+1 = 3 +1-1+1+1+1 = 3 +1+1-1+1+1 = 3 +1+1+1-1+1 = 3 +1+1+1+1-1 = 3 一共有5种方法让最终目标和为3。 注意: 数组的长度不会超过20,并且数组中的值全为正数。 初始的数组的和不会超过1000。 保证返回的最终...
f46ec33d80658c8f07b5599c742c7cac9ed4e832
Ynglylife/LeetCode
/Comp130/1019. 链表中的下一个更大节点.py
870
3.703125
4
# 本题与数组中寻找每个元素下一个更大值是一样的,只要把链表先转换为数组即可; # 数组去寻找,维护一个递减栈,每次遍历到一个元素,弹出比当前元素小的所有元素,弹出元素的下一个更大值就是当前遍历元素。 class Solution: def nextLargerNodes(self, head): temp_ptr = head ptr_index = {} i = 0 while(temp_ptr): ptr_index[temp_ptr] = i temp_ptr = temp_ptr.next ...
655461170ccda300840ad0fad127deee5381d26d
luisccf/maratona
/luis/uri-1042.py
204
3.546875
4
import fileinput numbers = [] for line in fileinput.input(): for n in line.split(): numbers.append(int(n)) for n in sorted(numbers): print(n) print() for n in line.split(): print(n)
093cd0197d1e74a0ee20f4c6bead6b84fcce7c13
tylergallen/fantasyfootballapp
/classes/team_class.py
342
3.984375
4
class Team: number_of_teams = 0 def __init__(self, code, fullName, shortName): self.code = code self.fullName = fullName self.shortName = shortName Team.number_of_teams += 1 def add_bye_week(self, byeWeek): self.byeWeek = byeWeek def display_number_of_teams(): print (f'Total number of teams in the NF...
337f36de07339d5c9ab91c87f42d6342830a6b85
tylergallen/fantasyfootballapp
/classes/player_class.py
758
3.625
4
class Player: number_of_players = 0 number_of_active_players = 0 def __init__(self, playerId, active, jersey, lname, fname, displayName, team, position, height, weight, dob, college): self.playerId = playerId self.active = active self.jersey = jersey self.lname = lname self.fname = fname self.displayNam...
f95221fd4920d6a9f11d82987fa0bf7e7984fd02
kennedynjoroge/backend_python_exercises
/functions/atm_with_functions.py
5,756
3.984375
4
"""Objective: Code to host logic for simple ATM menu display, validation and backoffice operations. Implementation Approach: Uses functions to modularize the code for simplicity, maintainability and reuse.using """ # Import libraries from random import randrange # Variables user_accounts = {} user_balances = {} user_...
38ca04c0a53e43feca4dd5fa7f0eb9ec2b9f4124
englens/cardy-cards
/game_objects/card.py
11,060
3.578125
4
from typing import List class Param: """Represents one card parameter. Can access parameter: Name Value (any type) Max Value Can also change the card value, but cards can also do this themselves to take advantage of sql speed. """ def __init__(self, sql...
895e6c8de624c1caf51406c15a49c9fa9cf4d4b8
Kulsoom-Mateen/Python-programs
/ORpractice.py
776
4.03125
4
#to comment out all lines : select all line and press CTRL/ # print("Hello") # print("OR practice file") user_input=input("Enter day :") if (user_input=="Saturday" or user_input=="saturday" or user_input=="SATURDAY" or user_input=="Sunday" or user_input=="sunday" or user_input=="SUNDAY"): print("Today is off") ...
1a07d9de0c605e998b803cc05024662ff1d6af46
Kulsoom-Mateen/Python-programs
/mutation.py
217
3.5
4
def mutate_string(string, position, character): st=list(string) st[position]=character string=''.join(st) return string s = "abracadabra" i = 5 c = "k" s_new = mutate_string(s, int(i), c) print(s_new)
51f1a39881639e51b26f893fdb5be7a3b7689d18
Kulsoom-Mateen/Python-programs
/breaking_the_records.py
823
3.6875
4
def breakingRecords(scores): minn= scores[0] min_count=0 maxx = scores[0] max_count=0 final = list() for i in range(1,len(scores)): if(scores[i]>maxx): maxx=scores[i] max_count=max_count+1 for j in range(1,len(scores)): if(scores[j]<minn): ...
428d6588af61c4b558a5f6f73187dd27043d3805
Kulsoom-Mateen/Python-programs
/Calculator.py
907
4.21875
4
num1 = int(input("Enter 1st number : ")) num2 = int(input("Enter 2nd number : ")) operand = input("Enter Operator : ") if operand == "+": result = num1 + num2 print(result) elif operand == "-": result = num1 - num2 print(result) elif operand == "*": result = num1 * num2 print(result) elif operan...
a0087d82fea425ad005c58521416c1b0b82910ad
Kulsoom-Mateen/Python-programs
/dictionary.py
1,771
4.3125
4
#student=['James',123456789,'ABC','Jones'] # dictionary is represented by curly brackets , every value should be comma separated student={ #Name,Cell no etc are keys 'Name': 'James', 'Cell Number': 123456789, #'Cell no.':[123,456] here cell no is list inside a dictionary bcz some students can ...
54d32e0e6e85911ac635f9555a01948b73e6a070
Kulsoom-Mateen/Python-programs
/variable_no_of_arguments.py
206
3.9375
4
def add(num1,num2,*numbers): total=num1+num2 for num in numbers: total+=num return total print(add(6,8,9)) #there can be no positional argument after keyword argument # print(add(num1=8
6945f73ee0dd66db503ab0bab31999861cd1c192
Kulsoom-Mateen/Python-programs
/even_odd.py
268
4.1875
4
'''number=int(input("Enter any number : ")) if number % 2 == 0: print(str(number) +" is even number") else: print(str(number) +" is odd number")''' num=int(input("Enter any number : ")) if num%2==0: print("Number is even") else: print("Number is odd")
1c92ba035346866f33df6fcd91c5cd36079c6046
Kulsoom-Mateen/Python-programs
/cats_and_mouse.py
2,377
3.84375
4
#x,y,z are positions of cat A, cat B and mouse respectively # if cat A reaches to the mouse first then print cat A # if cat B reaches to the mouse first then print cat B #if both cats reaches to the mouse at same time then mouse will escape and we have to print mouse C def catAndMouse(x, y, z): ans=() if(x<z a...
d0ae0233dfc45b5083b76cd08d8bebc84c98ed23
Kulsoom-Mateen/Python-programs
/extra_long_factorial.py
185
4.09375
4
def extraLongFactorials(n): fact=1 for i in range(n,0,-1): fact=fact*i print("Factorial of",n,"is",fact) n = int(input("Enter a number : ")) extraLongFactorials(n)
ea9b6226cf6c863f7578711d77ff7667c2ad70c6
Kulsoom-Mateen/Python-programs
/minority_vote.py
539
3.875
4
def minority_vote(vote1): counter=len(vote1) least=0 for i in vote1: count1=vote1.count(i) print(count1) if(counter>count1): counter=count1 least=i # if(counter/len(vote1)>=0.5): # least=vote1[count1+1] # else: ...
3d89a321a6986b9b2ee6840fe5edd66a3f76f546
Kulsoom-Mateen/Python-programs
/list_methods.py
402
3.875
4
lst= list() lst = ['Apple','Banana','Strawberry'] print(lst) lst.append('Mango') print(lst) lst1 = lst.copy() print(lst1) a = lst.count('Apple') print(a) lst.extend(lst1) print(lst) b = lst.index('Mango') print(b) lst.insert(2,'Orange') print(lst) lst.pop() print(lst) lst.remove('Banana') print(lst) lst.remove('Banana'...
f676f896baaa0fc664d2739ef5a96705e80010a2
Kulsoom-Mateen/Python-programs
/swap_case.py
229
3.921875
4
def swapcase(s): a="" for i in range(len(s)): if s[i].isupper(): a=a+s[i].lower() else: a=a+s[i].upper() return a ss="Hello I am from Pakistan" result=swapcase(ss) print(result)
79f4733b669473de0a81c2b90fce55c4d965fcb1
Kulsoom-Mateen/Python-programs
/abstract_method.py
608
4.15625
4
class Book(): def __init__(self,title,author): self.title=title self.author=author # @abstractmethod def display(): pass class MyBook(Book): def __init__(self,title,author,price): self.title=title self.author=author self.price=price def display(self): ...
20f52e3040bb0a81f554e851a9f88c96a78ce8bf
ashish-reddy-20-08/CLUSTERS-Iris-data-
/Iris data.py
1,818
3.59375
4
#!/usr/bin/env python # coding: utf-8 # In[46]: #importing the packages import pandas as pd import matplotlib.pylab as plt import numpy as np # In[7]: #importing the dataset iris1=pd.read_csv("Iris.csv") # In[8]: #viewing the data set iris iris1 # In[9]: iris1.info() # In[10]: #dropping the species...
c5c5772cb641b7a3b5af251a65f41816ec0083d5
tonyxiahua/PythonInstructions
/exercise10Solution.py
4,208
4.8125
5
# exercise 10: class Circle definition from turtle import * class Circle: def __init__(self, size): ''' initialize attributes of Circle object input: current object and size of object return: nothing ''' self.size = size # set size of object to input...
7732538d79598a3f152ec8bcc562c71972d957ce
tonyxiahua/PythonInstructions
/exercise8Solution.py
3,213
4.71875
5
# Exercise 8 partial solution # Q1. create a file with 3 language names # step 1: fh = open("languages.txt","w") # open file handle to languages.txt for writing # if file doesn't exist, new file is created # if file exists, it gets overwri...
8106133f79cd9097d39a8018e5243c173cc6ff33
LeslieM98/simple-Brainfck-Interpreter_Python
/Brainfck.py
3,081
3.625
4
from sys import argv from sys import exit class Memory: __maxValue = 127 __mem = [] __ptr = 0 def __init__(self): self.__mem.append(0) def go_right(self): if len(self.__mem) <= self.__ptr+1: self.__mem.append(0) self.__ptr+=1 def go_left(self, iptr): ...
c821cb94c264fe9ac3ba070c5c0996b553ed5ca7
bfilejecki/advent-of-code-2019
/3/ex2.py
1,484
3.5625
4
import sys def read_input(): tmp_val = [] with open('input.txt') as input_file: for line in input_file.readlines(): tmp_val.append([(x[:1], int(x[1:])) for x in line.split(',')]) return tmp_val def convert_moves_to_list_of_points(): wires = [] moves = read_input() f...
d5232da0659247cab6286a083acdfed80a7da757
oliviaspark0825/TIL
/algorithm/practice/0220/연습.py
1,762
3.703125
4
#일단 후위연산자로 만들고 -> 어제 쓴거로 계산하게 하면 됨 data = '(6+5*(2-8)/2)' # 6528-*2/+ ope=('+','*','-','/') point={'(':0, '+':1, '-':1, '*':2, '/':2} stack = [] result = [] for i in range(len(data)): #숫자가 나오면 result에 집어넣고 if data[i].isdigit(): result.append(data[i]) # (가 나오면 일단 괄호랑 괄호 안에 있는 연산자를stack에 넣...
4821234d7246088ac90d06221865ee96247dce10
oliviaspark0825/TIL
/algorithm/PycharmProjects/0312/combination 갯수.py
220
3.671875
4
def combination(n,r,q): if r == 0: return 1 elif n<r: return 0 else: return combination(n-1, r-1, q) + combination(n-1,r,q) A = [1,2,3,4] T = [0] * 3 print(combination(4,3,3))
472e01be0a1b01a6c62d658ee25273b7810e0dd2
IRS-PM/IRS-PM-2020-01-18-IS02PT-GRP11-TripAtUs
/System Code/Service_Scripts/LocationVisitLP.py
7,504
3.578125
4
# -*- coding: utf-8 -*- """ Created on Tue Apr 21 10:41:41 2020 @author: vidish """ """ Linear Programming to decide on the locations to visit ================== Problem Definition ================== Objective function --> Maximise the Likeability score (Likeability score is determined by su...