blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
ea114dbb22ec2342006fb42158a6cb9fcfe0cca6
borisboychev/SoftUni
/Python_Advanced_Softuni/Functions_Advanced_Lab/operate.py
328
4.21875
4
def operate(operator, *args): result = 1 for x in args: if operator == "+": return sum(args) elif operator == "*": result *= x elif operator == "/": result /= x return result print(operate("+", 1, 2, 3)) print(operate("*", 3, 4)) print(operate("/"...
e2c8d9f432bd936f6665ae6f521f01fd63e815ad
borisboychev/SoftUni
/Python_Advanced_Softuni/Comprehensions_Exericises/venv/bunker.py
749
3.625
4
categories = {product:{} for product in input().split(', ')} n = int(input()) for _ in range(n): token = input().split(' - ') category = token[0] item = token[1] quantity = token[2].split(";")[0].split(':')[1] quality = token[2].split(";")[1].split(':')[1] categories[category][item] = (quantit...
08630bb7f2a7e3eb8e408873a6c1b91fab5627eb
borisboychev/SoftUni
/Python_Advanced_Softuni/Workshop/venv/tic_tac_toe.py
3,445
3.859375
4
#from random import randint class Player: def __init__(self , name , mark): self.name = name self.mark = mark def __str__(self): return f'Name: {self.name} , Mark: {self.mark}' def __repr__(self): return f'Name: {self.name} , Mark: {self.mark}' BOARD_SIZE = 3 game_over = ...
b01062b94b7a6f8b68b45c93fba06dcac54b3ab2
borisboychev/SoftUni
/Python_OOP_Softuni/Exam_Prep_02AprilExam/tests/test_magic_card.py
1,119
3.71875
4
import unittest from project.card.magic_card import MagicCard class TestMagicCard(unittest.TestCase): def test_set_attr(self): tc = MagicCard('card') self.assertEqual(tc.name, 'card') self.assertEqual(tc.damage_points, 5) self.assertEqual(tc.health_points, 80) self.assertE...
cf0d2d5f5122f80402610af7941f3673b1067cfb
borisboychev/SoftUni
/Python_OOP_Softuni/Testing_Lab/venv/test_person.py
592
3.765625
4
import unittest from person import Person class TestPerson(unittest.TestCase): def test_valid_name_and_valid_age_should_greet(self): name = 'testuser' age = 12 p = Person(name, age) actual = p.get_greeting() expected = f'Hello! My name is {name} and Im {age} years old!' ...
6d6258a17e168083383f049280618334328cde75
borisboychev/SoftUni
/Python_Advanced_Softuni/Error_Handling_Lab/venv/repeat_text.py
258
3.59375
4
def read_input(): text = input() times = int(input()) return (text , times) def solve(): try: (text , times) = read_input() except ValueError: return f'Value times must be an int' return text * times print(solve())
488764f3eede60a7795b4711d0b0e11834fa5f4e
borisboychev/SoftUni
/Python_Advanced_Softuni/Tuples_and_sets_Lab/venv/softuni_party.py
559
3.53125
4
def get_not_arrived(guests , guests_arrived): return set(guests) - set(guests_arrived) def print_result(result): print(len(result)) result = sorted(result) [print(guest) for guest in result if guest[0].isdigit()] [print(guest) for guest in result if not guest[0].isdigit()] n = int(input()) guests ...
64178559ee41ca297768c0a1100d8748bbf5f23c
borisboychev/SoftUni
/Python_OOP_Softuni/Defining_Classes_Lab/venv/rhombus_of_stars.py
288
3.96875
4
def generate_row(index, n): indent = ' ' * (n - index - 1) stars = '* ' * (index + 1) print(indent + stars) def print_rhombus(n): for i in range(n): generate_row(i , n) for i in range(n - 2, -1 , -1): generate_row(i , n) print_rhombus(int(input()))
773bc8d9f56f3cab2a82726d94bde1b0ee61f00c
borisboychev/SoftUni
/Python_Advanced_Softuni/Comprehensions_Lab/venv/filter_numbers.py
189
3.6875
4
def is_valid_number(num): return any([num % d == 0 for d in range(2,11)]) start = int(input()) end = int(input()) print( [x for x in range(start , end+1) if is_valid_number(x)] )
d5e7a7690c7d4a99b86e1a14d3ae9c4c63005fac
borisboychev/SoftUni
/Python_Advanced_Softuni/Functions_Advanced_Exercise/venv/odd_or_even.py
267
3.71875
4
command = input() numbers = [int(x) for x in input().split()] if command == 'Even': filtered_numbers = sum(filter(lambda x: x % 2 == 0 , numbers)) else: filtered_numbers = sum(filter(lambda x: x % 2 != 0 , numbers)) print(filtered_numbers * len(numbers))
048bab7d8fdda6a95842bb40e16594496415064c
CGenie/project_euler
/id_0107.py.~1~
3,121
3.796875
4
#!/usr/bin/python2 # ##################################################################### # id_0107.py # # Przemyslaw Kaminski <cgenie@gmail.com> # Time-stamp: <> ###################################################################### import networkx as nx class Network: def __init__(self, ss): # read the ...
0f1276cb88476ac029bd4cf73ece2fa428e37e0b
CGenie/project_euler
/id_0098.py
6,217
3.53125
4
#!/usr/bin/python2 # ##################################################################### # id_0098.py # # Przemyslaw Kaminski <cgenie@gmail.com> # Time-stamp: <> ###################################################################### from helper_py3 import memoize from math import sqrt import pickle import os.path fro...
a3f71c92eaaee10b452279aa09c894ce41a0627e
CGenie/project_euler
/id_0188.py
501
3.515625
4
#!/usr/bin/python # ##################################################################### # id_0188.py # # Przemyslaw Kaminski <cgenie@gmail.com> # Time-stamp: <> ###################################################################### from helper_py3 import memoize import sys @memoize() def hyperexp(num, pwr): if(p...
be3b6aeaff4bfa2c07e167e9ab6d492c93c099a3
CGenie/project_euler
/id_0069.py
1,331
3.75
4
#!/usr/bin/python2 # ##################################################################### # id_0069.py # # Przemyslaw Kaminski <cgenie@gmail.com> # Time-stamp: <> ###################################################################### from id_0033 import gcd from id_0003 import is_prime, prime_factors from id_0008 impo...
0de7c52562ca0e30e27b7c4e837679f5950b9def
CGenie/project_euler
/id_0071.py
948
3.703125
4
#!/usr/bin/python2 # ##################################################################### # id_0071.py # # Przemyslaw Kaminski <cgenie@gmail.com> # Time-stamp: <> ###################################################################### #from fractions import Fraction from id_0033 import gcd if __name__ == '__main__': ...
d0d55e0fbe616091e28ff699008a8b9fa163970c
HunterDuan/learning
/Ran.py
439
3.796875
4
'''result=[] for x in range(3): for y in range(3): result.append((x,y)) print result''' '''girls=['alice','bernice','clarice'] boys=['chirl','arnold','bob'] print [b+'+'+g for b in boys for g in girls if b[0]==g[0]]''' girls =['alice','bernice','clarice'] boys=['chirl','arnold','bob'] letterGirls={} for girl ...
ee2d1fdd3df05ba2891f4ab4e5f591760807bcd8
gp1204270657/python
/Project_Test/多线程/多线程优化之线程池.py
859
3.6875
4
import time import threading from multiprocessing.dummy import Pool from concurrent.futures import ThreadPoolExecutor def run(n): time.sleep(2) print(threading.current_thread().name,n) def main(): t1=time.time() for n in range(5): run(n) print(time.time()-t1) #第一种方法使用线程池的方法 def main_user_...
03afe4ccb29865fd082406c869c00e8fee62fff6
gp1204270657/python
/Project_Test/class/class_vehicle.py
1,083
4.0625
4
class Vehicle(object): tag="SUV" """ 初始化速度跟大小尺寸 """ def __init__(self,speed,size=(10,20,30)): self.speed=speed self.size=size def show_info(self): res="我的车型是{0},当前的速度是{1}KM/h,尺寸大小是{2}".format(self.tag,self.speed,self.size) print(res) return res #设置新的移...
1cf26b676974d115c22bb148d9c6be0dbfa7abc2
akivab/axi-waterpost
/testscripts/current_session.py
394
3.515625
4
# coding: utf-8 import axi turtle = axi.Turtle() print 'pen up' turtle.penup() print 'going to 8,3' turtle.goto(8, 3) print 'pen going down' #turtle.pendown() turtle.circle(1, 360) turtle.penup() turtle.goto(10, 3) #turtle.pendown() turtle.circle(1, 360) turtle.penup() turtle.goto(5,5) #turtle.pendown() for i in xran...
3b824ba339870c77b73b85be3bde0ed787a08bea
raqune89/CodeWars
/Regex validate PIN code.py
431
4
4
# ATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but exactly 4 digits or exactly 6 digits. # If the function is passed a valid PIN string, return true, else return false. # Examples (Input --> Output) # "1234" --> true # "12345" --> false # "a234" --> false import re def ...
d15dd0729588cec401fb057ed49de5c6a0307061
bdugersuren/DSA_Implementations_and_Problems
/hacker_rank_practise/Alphabet Rangoli.py
793
3.546875
4
import string def print_rangoli(size): al = list(string.ascii_lowercase) b= 4*size - 3 for i in range(1,size+1): c = (b+3 - 4*i)//2 ab=al[size-i+1:size] ab='-'.join(ab) ac='' for x in ab: ac=ac+x ad=str(al[size-i]) if(i==1): pri...
02aff4bde98888a087ffd19dca31920df640e55f
bdugersuren/DSA_Implementations_and_Problems
/hacker_rank_practise/special string again.py
945
3.703125
4
#!/bin/python3 import math import os import random import re import sys # Complete the substrCount function below. def odd_count(s,x): n = len(s) if((x==0) or (x==n-1)): return 0 i = 1 j = x re = 0 c = s[j-1] while((j-i>=0) and (j+i<=n-1)): if((s[j-i] == s[j+i]) and (c==s[j...
4a1b04a54a060c4c2ed2f915af8881069db32d6f
bdugersuren/DSA_Implementations_and_Problems
/hacker_rank_practise/compress the string.py
186
3.703125
4
# Enter your code here. Read input from STDIN. Print output to STDOU from itertools import groupby s=input() l=[] for x,y in groupby(s): print(f'({len(list(y))}, {x})',end=' ')
ad46908450d005d3aae1c43d8e15af690f31da97
kingrides/aruns
/ifelse.py
150
4.1875
4
num=input("Enter an interger: ") num=int(num) if num<0: print("Enter a number greater than 0") else: print("the square of ",num,"is",num*num)
b345c4b6333c7bf9e1aaf35a0da7ef31e6df8e0e
acep-solar/ACEP_solar
/ARCTIC/foliumap.py
2,117
3.71875
4
import os import folium import pandas as pd import branca from ARCTIC import supplyinfo def read_file(file_path): all_the_text = open(file_path).read() # print type(all_the_text) return all_the_text def map(file_name,coordinate): ''' This function is used to generate a folium map with Alaska...
64621a2e1d814fe861279bf18e13fead5551b274
eoinclancy1/pythonChallenges
/telnyx_palindrome.py
1,917
3.8125
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 4 09:39:33 2018 @author: Eoin Clancy """ import pandas as pd def palindromeCheck(x): """ Check that x is read the same both forwards and backwards input: x of type int or string output: boolean """ str_x = str(x) return str_x == str_x[:...
51d8bc393f2748afb2215472cc27168a5ae35a2e
thib-s/2048-IA
/score_utility.py
5,354
3.5
4
# -*- coding: utf-8 -*- """ Created on Mon Mar 9 15:02:59 2015 Ce fichier contient toutes fonctions qui seront utilisees par score_board """ import logic import math def mono_line(value): line = value[:] val_mono = 0 monotony = '' num_of_zeros = line.count(0) for i in range(num_of_zer...
598a52e14589a2a359c2d64aa4a70c0329505629
qangdev/distance-based-models
/knn/car_evaluation/knn_classifier.py
1,861
3.640625
4
from knn.car_evaluation.utils import yieldloop from math import sqrt class KNN: K = 3 def __init__(self, k): self.k = k self.labeled_data = list() def training(self, data): self.labeled_data = data def euclidean_distance(self, point_x, point_y): # point x: e.g [0,...
2376e55a7ca1d347e35382ddec65279781e4b7f9
thecheebo/Data-Structures-and-Algorithms-in-Python-
/Algorithms/InplaceQuickSort.py
842
4.28125
4
def inplace_quick_sort(S, a, b): """Sort the list from S[a] to S[b] inclusive using the quick-sort algo""" if A >=b: return pivot = S[b] left= a right = b-1 while left <= right #scan until reaching value equal or larger than pivot while left < = right and S[left] < pivot:...
3e8f851eaf8eaab0391eadd882df763cecf3e24c
thecheebo/Data-Structures-and-Algorithms-in-Python-
/LinkedList.py
2,136
4
4
""" ╔═══════════════╗ ║ Description ║ ╚═══════════════╝ > Linked List • First In - Last Out ╔══════════════╗ ║ Attributes ║ ╚══════════════╝ > Node • Data • Next Linked Node > Linked List • Root Location • Size ╔══════════════╗ ║ Operations ║ ╚══════════════╝ ...
0c317f9b8743556b95dfcff106925f9471bb72fc
marten-voorberg/TextCompression
/listTools.py
222
3.8125
4
def ListContainsItem(list, item): """Checks if a certain list contains a specific item. The List can also be a string""" for listItem in list: if item == listItem: return True return False
025e57b0d6e3aa495c2b8298649c503ff846307e
gwworld/code
/python_100/find_diff.py
559
3.65625
4
class Solution(object): def find_diff(self, str1, str2): if str1 is None or str2 is None: raise TypeError("str1 or str2 cannot be None") long_str = str1 if len(str1) > len(str2) else str2 short_str = str2 if len(str1) > len(str2) else str1 for i in range(len(short_str)):...
33f3062cc125e15a361030191d8cd0b07e9fb732
OscarDelgadoMiranda/Python-0.1
/bottles.py
311
3.78125
4
#Funcion con la cancion def MySong(bottles): for i in range(bottles): print bottles-i, "bottles of beer on the wall,", bottles-i, "bottles of beer." print "Take one down, pass it around,", bottles-i-1, "bottles of beer on the wall." #Llamada a la funcion con el numero de bolletas que quieras MySong(99)
df4c489ebebbaf2facdcbbc5408da26fe6a4901a
vdivya51991/Codewars_solutions
/Sum Mixed Array.py
258
4.03125
4
Given an array of integers as strings and numbers, return the sum of the array values as if all were numbers. Return your answer as a number. def sum_mix(arr): #your code here result = 0 for i in arr: result += int(i) return result
e488708c54f87201c5cca6f66b054843034547fa
mvoin21/all
/hm12.py
942
3.953125
4
def fahrenheit(x): celsius = (float(x) - 32) * 5/9 return celsius def celsius(x): fahrenheit = (float(x) * 9/5) + 32 return fahrenheit while True: finish = input('Нажмите enter или введите exit для завершения: ') if finish.lower() == 'exit': print('Программа завершина.\nFrom Makers wi...
2057a5ec73050edbb9f1a3353fd70c60bf75291b
mvoin21/all
/hm10.py
138
3.609375
4
n = int(input()) squares = [] for integer in range(1, n+1): squares = integer**2 if squares > n: break print(squares)
535f41789d8e380cfb0760d46cee9403f2d5062f
mvoin21/all
/hm18.py
478
4.0625
4
year = int(input("Enter a year: ")) def years(year): if (year % 4) == 0: if (year % 100) == 0: if (year % 400) == 0: b = "{0} is a leap year".format(year) else: b = "{0} is not a leap year".format(year) return b else: ...
0872dde3c42dd117640211929bec80e06e22036a
agiridh/Web-Scanner
/main.py
1,370
3.546875
4
''' author: Aditya Giridhar To run this file type: python main.py website_name http://www.website_url.com ''' from sys import argv from domain_name import * from general import * from ip_address import * from nmap import * from robots_txt import * from whois import * # Creating root directory where scans of all the we...
7a013a6225d9f96f9d97f80623b9805ba677b2f3
kaushik853/python_fundamentals_master
/labs/05_functions/05_02_rps.py
1,987
4.4375
4
''' Code a game of rock paper scissors. ''' import random # function to get hand based on number # the function should take in a number and return the string representation of the hand def get_hand(hand): # 0 = scissor, 1 = rock, 2 = paper if hand == 0: return 'scissor' elif hand == 1: ret...
6194385ba69e20083cbf3659d00c1ca7166fe1e7
kaushik853/python_fundamentals_master
/labs/06_classes_objects_methods/06_04_inheritance.py
1,742
4.375
4
''' Build on the previous exercise. Create subclasses of two of the existing classes. Create a subclass of one of those so that the hierarchy is at least three levels. Build these classes out like we did in the previous exercise. If you cannot think of a way to build on your previous exercise, you can start from scr...
604e10b94da217d1f78403b770f598a72235835e
kaushik853/python_fundamentals_master
/labs/03_more_datatypes/2_lists/04_07_duplicates.py
193
3.9375
4
''' Write a script that removes all duplicates from a list. ''' x = ['a', 'b', 'r', 'a', 'c', 'a', 'd'] result = [] for i in x: if i not in result: result.append(i) print(result)
127b97d599b33fcd3a6da8ae14f4c2ef4a678ea6
kaushik853/python_fundamentals_master
/labs/06_classes_objects_methods/06_01_car.py
1,021
4.5
4
''' Write a class to model a car. The class should: 1. Set the attributes model, year, and max_speed in the __init__() method. 2. Have a method that increases the max_speed of the car by 5 when called. 3. Have a method that prints the details of the car. Create at least two different objects of this Car class and dem...
734b0f2086adfe224f1dc1720a65cca8bb6f74d2
kaushik853/python_fundamentals_master
/labs/python_apis_databases-master/apis/Exercise_05.py
418
3.515625
4
''' Write a program that makes a DELETE request to remove the user your create in a previous example. Again, make a GET request to confirm that information has been deleted. ''' import requests base_url = "http://demo.codingnomads.co:8080/tasks_api/users" response1 = requests.delete(base_url + "/22") print(f"respon...
f574332c052816c2a551c7be869f13d8d0e0bde6
kaushik853/python_fundamentals_master
/labs/04_conditionals_loops/03_04_prime.py
251
3.90625
4
''' Print out every prime number between 1 and 100. ''' for prime_num in range(1, 101): if prime_num > 1: for i in range(2, prime_num): if (prime_num % i) == 0: break else: print(prime_num)
1dee8c51b8e6f207d20c8f80c0341ad833cd4cc2
kaushik853/python_fundamentals_master
/labs/04_conditionals_loops/03_01_divisible.py
352
4.46875
4
''' Write a program that takes a number between 1 and 1,000,000,000 from the user and determines whether it is divisible by 3 using an if statement. Print the result. ''' user_input = input("Please enter a number between 1 and 1,000,000,000: ") if (int(user_input) % 3) == 0: print('user input is divisible by 3') e...
a6f4b12c876ad4bced3cf4ae96cee10f82fa83a6
omrawal/Games
/Level Game/project.py
5,412
4.09375
4
#Please refer to readme.md file import random import math name = input("Enter your Name : ") def level1(): print("Hello", name) print("In this level 1 game you have to choose a number between your chosen lower & upper bound.") print("\n") lower = int(input("Enter Lower bound:- ")) upper = int(in...
126d4fa06a8013f5f14036b4ef0cac718d31e395
stleznev/Traffic-Simulator
/initialize_graph.py
1,784
3.53125
4
import random as rd import networkx as nx import matplotlib.pyplot as plt import numpy as np def create_weighted_random_graph(n_nodes, n_edges, weights_from, weights_to): """ Function that creates a weighted random graph with "n_nodes" nodes, "n_edges" edges and random weight...
0270ae437996e1f13ee4fd1e806dc7847293b9bd
bshlgrs/consciousness
/src/ExampleRun.py
3,259
3.796875
4
from Agent import Agent """ This is an example set of interactions with the agent. Through this interaction, we see several of the agent's judgements about consciousness. """ RED = 10 GREEN = 0 if __name__ == "__main__": agent = Agent() print "Q: What's 2 + 2?" print agent.ask_question(("evaluate", ("+"...
4ddd3bb0df9668c1e4dfe09b15577f44510020ac
abdealijaroli/smart-agricultural-system
/code/test.py
1,112
3.640625
4
# -*- coding: utf-8 -*- import csv import numpy as np import matplotlib.pyplot as plt import pandas as pd from sklearn.linear_model import LinearRegression dataset=pd.read_csv('code/arcanut.csv') X = dataset.iloc[:, :-1].values Y = dataset.iloc[:, 3].values """Encoding categorical data Encoding the ...
0a1b4ea07257a231d5a581ba0896fcf6470c4ce8
prashantmital/project_euler
/PEproblem345.py
2,331
3.953125
4
import numpy as np _raw = """7 53 183 439 863 497 383 563 79 973 287 63 343 169 583 627 343 773 959 943 767 473 103 699 303""" _raw_data = _raw.split('\n') matrix = np.asarray([[float(ivar) for ivar in ovar.split()] for ovar in _raw_data]) _N = matrix.shape[0] running_sum = 0 while _N >= 1: # cost is a measu...
3aef53e92897051dcfc456b2793aecabc43c5f66
prashantmital/project_euler
/PEproblem3.py
571
4.21875
4
#----------Algorithm #set divisor=2 #set dividend = given number #do: # check dividend%divisor == 0 # yes : quotient = dividend/divisor; dividend = quotient; continue # no : divisor++; continue # if dividend==divisor : break; #print divisor (or dividend - as dividend = divisor at the end of the loop) dsor = 3 ddend...
a6d58b215f784e8b5b208d84320a444481b1873b
Regulus239/EyeAssistant
/Scrap Modules/Python_Email_Modules/organizeEmailData.py
1,737
3.703125
4
""" Module designed by John Neal (jsneal519@gmail.com) for EC601 class at Boston University Understanding this module comes down to playing with the recieved emailDataList and seeing how that data is organized. Each element of the emailDataList is organized in a very nonsensical way. If we take a single element of th...
5f8b311667e86d6c08bc633bb3768f4aed7d32b5
jrh154/rovSoftwareLibrary
/devices.py
555
3.515625
4
from gpiozero import Motor, Servo class rovMotor(Motor): def __init__(self, forward, backward): Motor.__init__(self, forward,backward) def setSpeed(self, setpoint): try: if setpoint > 0.05: self.forward(setpoint) elif setpoint < -0.05: ...
a7ebf4d4690ad80c4702f1c40e7b2928bfc4b0d5
stedevine/advent
/day8/memoryString.py
2,400
3.90625
4
class MemoryString : def countCharacters(stripped): # The input will be in quotes : "input" # The surrounding quotes are code characters only codeCharacters = 2 memoryCharacters = 0 # Examine the text between the quotes - look for escaped characters and ascii characters ...
4c174c576f6149d8b5fcdd16e867c37e21c8e3af
stedevine/advent
/day19/part1.py
2,046
3.78125
4
import string def get_test_input(): return list([{"start": "H", "end": "HO"}, {"start":"H", "end":"OH"},{"start":"O", "end":"HH"}]) def get_input(): input = list() f = open('input.txt','r') for line in f: words = line.split(" => ") input.append({"start" : words[0], "end" : words[1].str...
6c78ffc79d2bf9a3bd386dcb00278e3bc9ea880e
ankitt8/mahawiki
/Python Challenge/Solution3/solution_three_ankittiwari - Ankit Tiwari.py
873
4.1875
4
# Ankit Tiwari # 25/02/19 # Day 3 Write a function to return most occuring character in a String. # assuming string is given in console # Using python3 def most_recurring_1(s_input): Dict = {} for i in s_input: if i in Dict.keys(): Dict[i] += 1 # if found increment the value correspondin...
1712bbf3cd656aab7284f888b5029bb6366a7daf
ankitt8/mahawiki
/Python Challenge/Solution3/solution_three_priyabrata - Priyabrata Biswas.py
398
3.671875
4
# Python 3.6.7 import operator def max_occur(input_str): record = {} for char in input_str: if char in record: record[char] += 1; else: record[char] = 1 max_val = max(record.values()) res = [key for key in record.keys() if record[key] == max_val] return res[0] if (len(res) == 1) else res def main(): ...
0cca30db7e0ddd2bb09446b0a9fb5aaf1f851b9f
ankitt8/mahawiki
/Python Challenge/Solution1/solution_1_AdityaSrivastava - Aditya Srivastava.py
480
3.84375
4
a=list(map(int,input().split())) #standard one liner to input an array in python # i recommend to just use it or learn it if a beginner or too lazy to google # the usage of map() # every element is repeated twice except one we need to find that # exor is the ans # a^a =0 # so if we exor every element which ...
23eb2038bd7c7979cecb1812ee8a512e64ff5e88
Gurdeep123singh/mca_python
/MTCS/sum_of_diagonal.py
873
4.3125
4
# program to find sum of diagonal p = int(input("enter no of rows or columns as rows and columns are same")) matrix=[] # taking elements row wise in matrix for i in range(p): a=[] for j in range(p): print(f"enter element for{i} th row {j}th column:") c=int(input()) a.append(c) # a...
64404f90301457af47593624ec70395f99871bb8
Gurdeep123singh/mca_python
/python/practice python/fact_without_recursion.py
1,397
4.09375
4
''' program to find factorial from 1 to given no and from n to 1 using without recursion used only 2 function and without returning i/p -> 6 o/p-> 1 ! is : 1 2 ! is : 2 3 ! is : 6 4 ! is : 24 5 ! is : 120 6 ! is : 720 reverse order of factorial is : 6 ! is : 720 5 ! is : 120 4 ! is : 24 3 ! is : 6 2 ! is ...
16a4f249beb1df91a54e3abab9bf9242a56ecb8b
Gurdeep123singh/mca_python
/python/python code/PRIME_COMPOSITE(1 to n).py
1,935
4.21875
4
''' This is a program of prime and composite no where it gives length and list of prime no.'s and composite no.'s. --->>>>> HERE WE ARE TAKING N TERMS FROM WHICH WE FIND prime AND composite NO LIST ->> by dividing and by use of bool we have output ->> without using return function i/p - enter upt...
fe995ff1c577461f4a26ec459cb0e7534ee7b44b
Gurdeep123singh/mca_python
/python/classes and objects/salary.py
5,280
3.984375
4
''' program for calculating salary using classes and objects . you can describe how many employees you want to take i/p :- name,EmpID,designation,experience o/p :- name,EmpID,designation,experience and salary ''' class employee: # class count=0 ...
3a3ed5aaa5d4ca3858bc05727ea525cf4a16f784
Gurdeep123singh/mca_python
/discrete mathematics/assignment2/merge_sort.py
2,593
4.28125
4
def merge_sort_ascending(list1): if len(list1)>1: # if length is less than 1 then no more splitting mid=len(list1)//2 left_side=list1[:mid] right_side=list1[mid:] merge_sort_ascending(left_side) # recursively call till single elements splitted in list merge_so...
c97f2b3d80157c336d5654abae24362f364e39bf
Gurdeep123singh/mca_python
/python/classes and objects/2.py
5,503
4.15625
4
'''Queue class Variables: --> rear initially -1 --> front initially -1 --> size to store size of queue Functions: --> __init__ constuctor --> enqueue to add e...
bee18d72bef2ceb310c9d2ca52fdd801273f8840
Gurdeep123singh/mca_python
/discrete mathematics/assignment1/Q10. permutation of set.py
1,179
4.1875
4
''' PROGRAM TO MAKE PERMUTATIONS OF A SET USING RECURSION ''' def permutation(lst): if len(lst) == 0: # If lst is empty then there are no permutations return [] if len(lst) == 1: # If there is only one element in lst then, only return [lst] # ...
552d814c0028208951b48577388fe93736f7dc65
Gurdeep123singh/mca_python
/python/practice python/reverse_word_using_recursion.py
1,343
4.3125
4
''' program to have reverse of string using recursion by taking two list 1st list for string append and other for reverse storing and then reverse list to string i/p :- hello o/p:- olleh ''' def reverse1(list1,result): # have list1 and result as a parameter if list1!=[]: # it will ret...
ab91f7fcb4744b25c5a424e41074f1304ee2631a
Gurdeep123singh/mca_python
/python/file handling practice/5.py
547
3.734375
4
f=open('1.txt',mode='r') no=input("which no you ") index=0 p=[] for x in f: for i in x: if i=='[' : newstr=x.replace('[','') newstr.strip() print(newstr) if newstr==']': newstr1=x.replace(']','') newstr1.strip() ...
517ee1db80cf6e4e2074dc0fba44c04475a7e145
Gurdeep123singh/mca_python
/python/classes and objects/infix_to_postfix.py
2,994
3.984375
4
''' program for conversion from infix to postfix and for checking exprssion is having proper brackets or not so use import class parenthesis class from all_parenthesis filename ''' from all_parenthesis import parenthesis class conversion: def __init__(self,string,stack): # constructor self.expression=stri...
97fdf18a71a719125e5a79fd36600bae7ad8f55d
Gurdeep123singh/mca_python
/python/python code/series.py
1,127
4.1875
4
from math import * # importing maths # cos series and exponential series def main(): n = int(input("sum of n terms of series: ")) # taking n terms x = int(input("enter x :")) # taking x value print("sum of series 1", s1(n,x)) # for cos print("sum of series 2", s2(n,x)) # for exp def fact(n...
45bb16401742be76b23059c4fa7d4b12a3652123
Gurdeep123singh/mca_python
/discrete mathematics/assignment2/Q5.HAMILTONIAN_circuit.py
2,826
4.25
4
''' PROGRAM TO CHECK IF GIVEN GRAPH IS HAMILTONIAN CIRCUIT OR NOT IF IT IS HAMILTONIAN THEN IT GIVES PATH ALSO ''' def hamiltonian(path,adjacent,visited,nodes): # fn for hamiltonian and returning true or false if len(path)==len(visited) : if path[0] in nodes[path[-1]]: # checks...
008c424202cd6827a974ed190eddbe8ad7a7cb2a
Gurdeep123singh/mca_python
/discrete mathematics/assignment1/Q8. union.py
1,906
4.375
4
''' program to make union of 2 sets first i make setA and setB as list then later i have made it set object as set doesnt has duplicate items ''' set1_size= int(input("enter size of 1st set:")) set2_size= int(input("enter size of 2nd set:")) setA=[] # making setA ...
8882a611e4e610a00731b698a2b6ce44e2c62113
Gurdeep123singh/mca_python
/python/practice python/fact_recursion.py
1,415
4.375
4
''' program to find factorial from 1 to given no and from n to 1 using recursion used only 2 functions and returning list of factorials . in one fn printing of reverse factorial and calling is there and in other defining function and printing of 1 to n factorial is there.. i/p -> 6 o/p-> 1 ! is : 1 2 ! is : 2 ...
26e33cea595c76b56ce9d4ee3699d852aa8bd572
Gurdeep123singh/mca_python
/python/practice python/string_less_than_or_not.py
217
4.03125
4
text = input("enter string") length = len(text) count=0 for i in text: if i ==' ': count=count+1 print(count) a= length-count if (a)<10: print("yes less than 10") else: print(a,"not less than 10")
520303c087e446e10c31942a15674ec338d10a10
Gurdeep123singh/mca_python
/discrete mathematics/assignment2/Q4.dfs.py
2,574
3.9375
4
''' PROGRAM TO FIND DFS OF A GIVEN GRAPH ''' def dfs(adjacent,stack,output,no,nodes,visited): # fn for dfs if len(output)!=no: # it works as a base case for i in adjacent: # adjacent value goes in i one by one if i in visited: ...
2c85b44446f5cd248074f1054de8b652893f35bb
Gurdeep123singh/mca_python
/python/practice python/multiplication.py
157
3.96875
4
number = int(input("enter a no")) no = int(input("upto what no u want to multiply")) for i in range(1,no+1): c=i*number print(f"{number} X {i}={c}")
24fa57584874412504d9e8c3af33362cb12e2c3a
ami-schieber/try_git
/python/py_for_info/calc_pay.py
132
3.828125
4
hours = raw_input("Enter Hours:") rate = raw_input("Enter Rate:") pay = float(rate) * float(hours) print "Pay:" + str(round(pay,3))
2892620909f39b9ae8a408bf1abf52fffcc2c12f
ami-schieber/try_git
/python/data-science-1/fetch.py
1,984
3.671875
4
# requests for fetching html of website import requests # Make the request to a url r = requests.get('http://www.cleveland.com/metro/index.ssf/2017/12/case_western_reserve_university_president_barbara_snyders_base_salary_and_bonus_pay_tops_among_private_colleges_in_ohio.html') # Create soup from content of request c ...
4d5a715ebd3b005c11fe565e7bc3e13c680dd40e
ZhouYuanlin/python
/ball2.py
527
3.859375
4
from random import choice direction = ['left', 'center', 'right'] ysum = 0 csum = 0 for i in range(0,5): print "please input your direction" print "direction is %s"%direction you = raw_input() com = choice(direction) if you == com: print "Oops..." csum += 1 elif you != com: print "Goals!" ysum += 1 while ...
8031bb5947d0cb7321276a0678a3613982d23d4e
volkir31/university
/lab1/25_task.py
99
3.765625
4
sum = 0 count_iter = int(input()) for iter in range(count_iter): sum += int(input()) print(sum)
53df3871bc61e34e8c69ab7e206643fde50bba92
volkir31/university
/lab3/3_task.py
329
3.5
4
# import re # input_string = input() # result = re.findall(r"\w*.", input_string) # result[0], result[-1] = result[-1] + ' ', result[0] # print(''.join(result)) input_string = input() first_word, second_word = input_string[:input_string.find(' ')], input_string[input_string.find(' ') + 1:] print(second_word + ' ' + fi...
7bc5a23f0600dcff277223db1b3e1cd9139e34a5
volkir31/university
/lab4/6_task.py
461
3.84375
4
count_country = int(input()) country_dict = {} for _ in range(count_country): input_str = input().split() country_dict[input_str[0]] = input_str[1:] count_cities = int(input()) cities_list = [] for _ in range(count_cities): cities_list.append(input()) output_list = [] for city in cities_list: for countr...
f2b945bae6157c4e225d30b896899a18f60e36c2
volkir31/university
/lab3/13_task.py
174
4.09375
4
input_string = input() if len(input_string) < 3: print(input_string) elif input_string[-3:] == 'ing': print(input_string + 'ly') else: print(input_string + 'ing')
05dd52d8662196088426dbd86681b946652e53f6
volkir31/university
/lab3/1_task.py
119
3.625
4
import re input_string = input() results_of_search = re.findall(r"\w*\S", input_string) print(len(results_of_search))
174c5c0875690246b3f0a8f735433cd71bbf8265
volkir31/university
/lab5/3_task.py
870
3.6875
4
def findLongestWord(file): try: with open(file, 'r') as f: max_len = 0 for line in f: word_list = line.split() for word in word_list: word_len = 0 for alpha in word: if alpha.isalpha(): ...
0efb5e96ea4b986fd1df734c612d0b00fb3ded34
volkir31/university
/lab1/11en_task.py
70
3.96875
4
digit = int(input()) print(1 if digit > 0 else -1 if digit < 0 else 0)
7b9facc528949257ff5826d372a204f589228533
volkir31/university
/lab7/3_task.py
4,640
3.640625
4
class Teachers: common_rooms = {} result = [] key_min_item = 0 def __init__(self, file): self.file = file self.read_file(file) def read_file(self, file): with open(file) as f: for line in f: rooms = line.split() if len(rooms) > 1:...
8a9d26b80d2ef2718609e6b27f1b8adf518a2a4b
volkir31/university
/lab1/5th_task.py
186
3.890625
4
count_desks = 0 for iter in range(3): count_students = int(input()) count_desks += count_students // 2 if count_students % 2 == 0 else count_students // 2 + 1 print(count_desks)
124e3e196095eed22f58174133dddbf34cdf237b
jwhett/tag_wrap
/tag_wrap/tag_wrap.py
866
3.984375
4
"""Method that has at least two arguments and returns a string 1) tag to wrap with 2) content to wrap (anything that returns a string) 3) Optionally, you may have keyword attributes. These must come after all non-keyword submissions. """ def wrap(tag_name, *args, **kwargs): """Take a tag that will wrap the...
440ea61fd46690dac1a27a1a96793c20e90c3704
xiaoerer/python_study
/hello.py
4,503
3.8125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- print('******************基础*********************') print('hello, world 你好 中文') print(ord('A')) print(ord('中')) print(chr(66)) x=b'ABC' print(x) print(id(x)) print(len('ABC')) print('******************集合*********************') #list classmates = ['Michael', '...
a1e97ba681d5cfdfc65cb009db9754e34650dcb1
Northwestern-CS348/assignment-3-part-2-uninformed-solvers-tkwon2021
/student_code_game_masters.py
11,634
3.640625
4
from game_master import GameMaster from read import * from util import * class TowerOfHanoiGame(GameMaster): def __init__(self): super().__init__() def produceMovableQuery(self): """ See overridden parent class method for more information. Returns: A Fact...
f7dceb3ef3fa8096640b4111e6ce70b0e0a46e84
vitalyryzhkov/vitaly_ryzhkov
/home_work.py
1,395
3.828125
4
from math import * # task_1 print("task1") a = 8 b = 12 c = 7 d = a + b * (c / 2) print("При условии, что а = %d, b = %d и c = %d, результат d будет равен %g\n" % (a, b, c, d)) # print("При условии, что а =", a, ", b =", b, "и c =", c, ",", "d будет равно", d) # task_2 print("task2") a = 0.5 b = 55 c = (a**2...
7ef279b915273433c37d2ee913a8451b4fea9d5e
vitalyryzhkov/vitaly_ryzhkov
/home_work_18_20.py
666
3.84375
4
# task_18 def summ_of_unicode_symbols(first_sym, second_sym): for i in range(first_sym, second_sym): second_sym = i + second_sym return second_sym print(summ_of_unicode_symbols(ord('a'), ord('c'))) # task_19 # # import math # sum_of_all_numbers = 0 # for x in range(int(math.pow(1000000, 1/3))+1): # ...
7b631db3a6bb1e9ecee565c532247b9d51e0dad1
AnonArtist/Computing-Science-Camp
/Students.py
1,320
3.984375
4
def main(): filename = "data.txt" students = {} populate_dicts(students, filename) add_letter_grades(students) display_students(students) # This will add the student data from the file into the dictinoary that was initiailzed in the main() function def populate_dicts(students, filename): dataf...
504774a7bc802417d12938229727460463b9921c
np0805/comp4621
/rdt.py
8,021
3.5
4
""" The Hong Kong University of Science and Technology COMP4621 Project 2 This file defines the reliable data transfer protocol The implementation is basically a Go-Back-N sender. See lecture note # 3 on page 48 for details """ import threading import udt # implement rdt protocol in send(), right now it just use ud...
c3f1b878f9135ca0b25b5d8d3128b35a692727ad
leeryeongsong/baekjoon-step-by-step-python3
/step8/level2-2292-벌집.py
164
3.65625
4
# https://www.acmicpc.net/problem/2292 N = int(input()) move = 1 endRoom = 1 gap = 0 while endRoom<N: move += 1 gap += 6 endRoom += gap print(move)
4f8048475518ff70960a6a44358d2a6156408e43
leeryeongsong/baekjoon-step-by-step-python3
/step2/level3-2753-윤년.py
203
3.59375
4
# https://www.acmicpc.net/problem/2753 Year = int(input()) if Year%4==0: if Year%100==0: if Year%400==0: print("1") else: print("0") else: print("1") else: print("0")
b25fcb4cc0165e2ec57f4fac484696e7ccb1de82
leeryeongsong/baekjoon-step-by-step-python3
/step12/level5-1427-소트인사이드.py
176
3.671875
4
# https://www.acmicpc.net/problem/1427 N = input() N_list = list(map(int, N)) N_list.sort(reverse=True) N_list = list(map(str, N_list)) result = ''.join(N_list) print(result)
c948076989ce4088270e86545655ffbaa87f64e8
leeryeongsong/baekjoon-step-by-step-python3
/step12/level4-2108-통계학.py
988
3.5
4
# https://www.acmicpc.net/problem/2108 # 시간 초과 import sys def average(array:list): ave = sum(array)//len(array) print(ave) def medium(array:list): array.sort() print(array[len(array)//2]) def fre(array:list): array.sort() sorted_array = [x for x in array if x < 0] + [x for x in array if x>0]...
cf02b1e21e2a47103fd1aeaf06baf62579c8894d
mayatorcelly/games_learning
/Tennis.py
2,993
3.5
4
# Juego Tenis in Python import turtle #ventana wn = turtle.Screen() wn.title('Tenis by @Torcelly') wn.bgcolor('green') wn.setup(width=800, height=600) wn.tracer(0) #puntuacion puntuacion1 = 0 puntuacion2 = 0 # Jugador 1 Jugador_1 = turtle.Turtle() Jugador_1.speed(0) Jugador_1.shape('square') Ju...
aafe206645487baf51d595c53e17ad6b6edc3913
DZH777/Python
/Scripts/classes/user.py
746
3.515625
4
class User(): def __init__(self, login, passwd): self.login = login self.passwd = passwd self.privs = ['entrance', 'exit', 'read'] def get_user_info(self): info = str(self.login) + ' ' + str(self.passwd) return info def get_user_privs(self): priv_list = '' ...