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
e18e81c8986c383ac6d6cec86017d3bf948af5b3
tasver/python_course
/lab6_1.py
719
4.21875
4
#! /usr/bin/python3 # -*- coding: utf-8 -*- import math def input_par() -> list: """ This function make input of data""" a, b, c = map(float, input('Enter 3 numbers: ').split()) return [a, b, c] def check_triangle(a:list) -> bool: """ This function check exists triangle""" if (((a[0] + a[1]) > a[2]) and ((a[0] +...
d90d53e6c36ea8baebc8c65e476e7d930a9d2851
JonNData/Graphs
/objectives/graph-intro/lect_example.py
2,052
4.09375
4
class Queue: def __init__(self, ls=[]): self.size = 0 self.storage = [] def __len__(self): if self.size <= 0: return 0 else: return self.size def enqueue(self, value): self.size +=1 return self.storage.append(value) def deque...
3a5ee700dce71d3f72eb95a8d7b5900e309270ec
ahmetYilmaz88/Introduction-to-Computer-Science-with-Python
/ahmet_yilmaz_hw6_python4_5.py
731
4.125
4
## My name: Ahmet Yilmaz ##Course number and course section: IS 115 - 1001 - 1003 ##Date of completion: 2 hours ##The question is about converting the pseudocode given by instructor to the Python code. ##set the required values count=1 activity= "RESTING" flag="false" ##how many activities numact= int(input(" Enter ...
e7aeb456f723ea10f99d185e096b159e3d3de090
BigPieMuchineLearning/python_study_source_code2
/exercise_5_4.py
285
3.78125
4
mult_3=list(set(range(0,1000,3))) mult_4=list(set(range(0,1000,4))) sum=int(len(mult_3))+int(len(mult_4)) print(sum) weekday={'mon','tues','wen','thurs','fri'} weekend={'sat','sun'} n=input() def is_working_day(n): rest= n in weekend print(rest) is_working_day(n)
2eba63c46d8a4f74c5e11d165eb4f8c488dcf174
BigPieMuchineLearning/python_study_source_code2
/exercise_3_3.py
1,072
3.875
4
def print_absolute(): """절댓값을 알려주는 함수""" #독스트링 import math print('정수를 입력하세요') number = int(input()) abnumber=abs(number) print(number,'의 절댓값:',abnumber) print_absolute() help(print_absolute) def print_plus(number1,number2): """두 수를 전달받아 그 합계를 화면에 출력하는 함수""" print("두 수의 합계:",...
71cc0002a3bbdfe951d3ab035f6f3f5e17654c11
jithendra2002/LAB-15-12-2020
/L7-LinkedList_deleting_element.py
1,425
3.953125
4
class Node: def __init__(self, value): self.data = value self.next = None class LinkedList: def __init__(self): self.head = None def inputs(self,value): if self.head is None: new_node = Node(value) self.head = new_node ...
af123d78f63c5ed279e54545959ebdfa55d7d16d
ZuchniakK/PITE-Sensor-Eval
/code/Classifier.py
4,247
3.6875
4
import numpy as np import random import math from sklearn.neighbors import KNeighborsClassifier from sklearn import cross_validation class KNN(): def __init__(self,fakedatapath, sensordatapath, n_sensor_samples=None, n_fake_samples=None): """ Read the data from real sensors and simulated fake ...
0c95d6b6ebcda72fcecc1f734faf7d409936713a
Lianyihwei/RobbiLian
/Lcc/pythonrace/PYA801.py
116
3.921875
4
# TODO word = list(input()) for index,value in enumerate(word): print(f"Index of \'{value}\': {index}")
17f8483a8cec72840bc28122cfb872776e196a83
Lianyihwei/RobbiLian
/Lcc/pythonrace/PYA408.py
197
3.65625
4
# TODO evc = 0 odc = 0 for i in range(10): num = eval(input()) if num %2 == 0: evc += 1 else: odc += 1 print("Even numbers:",evc) print("Odd numbers:",odc)
ebd80b7a1750ed164559c89537b5ac64fbf01bd5
Lianyihwei/RobbiLian
/Lcc/pythonrace/PYA710.py
249
3.609375
4
#TODO from tabnanny import check dict = {} while True: key = input("Key: ") if key == "end": break value = input("Value: ") dict[key] = value search_key = input("Search key: ") print(search_key in dict.keys())
8d07696850cc5f7371069a98351c51266b77da6b
lintangsucirochmana03/bigdata
/minggu-02/praktik/src/DefiningFunction.py
913
4.3125
4
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> def fib(n): # write Fibonacci series up to n """Print a Fibonacci series up to n.""" a, b = 0, 1 while a < n: print(a, end=' ') a, b = b, a+b >>...
3e8b85dcf36442098a6cf0e1d28afb80b7abaf95
dhivya2nandha/players
/11.py
97
3.6875
4
end=['saturday','sunday'] inp=input() if(inp not in end): print("no") else: print("yes")
d760e08b472dab01b6dae64d20f84fd1ab8547ee
jmswu/learn_python
/english_dict/main.py
177
3.8125
4
from dictionary import Dictionary # make a dictionary dictionary = Dictionary() # user input user_input = input("Please enter word:") print(dictionary.translate(user_input))
d79f3a1c11d9f1afcdcb233fc0653fc70479f3c3
RoCorral/LAB_3_A
/LAB_3_A_ProcessTrees.py
7,419
3.734375
4
""" @author Rocorral ID: 80416750 Instructor: David Aguirre TA: Saha, Manoj Pravakar Assignment:Lab 3-A - AVL,RBT, word Embeddings Last Modification: 11/4/2018 Program Purpose: The purpose of this program is to practice and note the difference in computation times of insertion and retrieval between AVL Trees and Red Bl...
fa28503d8d9926d7445464844aff6e2fdd27f5a8
daibogh/lilya
/example1.py
412
3.90625
4
a = input("введите имя и фамилию через пробел: ") a = a.split(" ") print(len(a)) print(type(a))# type(a) выводит тип переменной a print(a[0]) print(a[1]) print(a[-1])# a[-1] = последний элемент a # a[0] = a[0][0].upper() + a[0][1:] # a[1] = a[1][0].upper() + a[1][1:] # print("привет, ", end= "") # print(" ".join(a), e...
7bf949a518e62547a7c76501df89cb7a28681e48
phipag/opencv-face-detection-python
/main.py
875
3.765625
4
import cv2 import argparse def main(image_path): # Load image and turn into grayscale img = cv2.imread(image_path) gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # Use the Haar Cascade classifier to detect faces face_cascade = cv2.CascadeClassifier("haarcascade_frontalface_alt.xml") faces = fac...
8dc0d965aebeaa2cbb464984a3b58cc314c8aa42
SamirSatpute/newPython
/study/study/8.py
186
3.625
4
''' Created on 29-Dec-2017 @author: samir ''' from platform import python_version print(python_version()) s2,s1 = input("Enter name").split() print("hello world") print(s1) print(s2)
8250f313bf841cebe7ae8d36dba27b3b1675502c
thoan741/lek
/Lek/mcnuggets.py
1,337
3.703125
4
d = 0 #värdet som efterfrågas n = 1 #värdet som testas counter = 0 #räknare s = 0 #variabel som enbart används för att kolla om det finns någon lösning a = 0 b = 0 c = 0 while counter < 6: #kör tills dess att vi hittar 6 tal på följd kan lösas s = 0 ...
5ed41522f413213440b7ffc675c9ffd3e4ad778c
thoan741/lek
/Laborationer/Laboration_7/calcQueue.py
1,378
3.796875
4
# -*- coding: utf-8 -*- class calcQueue: """ Här definieras en klass. I instanser av denna klass kommer värden sparas i en lista. """ def __init__(self): """ Det här är en konstruktor, och denna kommer att skapa en instans av klassen calcQueue när man t.ex. skriver x = calcQ...
e63d25776063ee323384fb7af74dcfbea5a4774c
thoan741/lek
/Laborationer/Laboration_6_copy/laboration_6_uppgift_3.py
1,073
3.734375
4
TryckString = input("Mata in trycket: ") Sort = input("Mata in sorten: ") NyaSort = input("Vad vill du omvandla till?: ") omvandlingsLista = ["mbar", float(1013), "torr", float(760), "pascal", float(101325), "atm",float(1)] def flerStegsOmvandlare(tryck, sort, newsort, ls): def NextUnit(tryck,sort,aUnit): ...
652990fdc99924c1810dddc60be12a8d81709a6e
ashwani8958/Python
/PyQT and SQLite/M3 - Basics of Programming in Python/program/module/friends.py
379
4.125
4
def food(f, num): """Takes total and no. of people as argument""" tip = 0.1*f #calculates tip f = f + tip #add tip to total return f/num #return the per person value def movie(m, num): """Take total and no. of the people as arguments""" return m/num #returns the per persons value print("The na...
18cfb77c6446b34575ea92d962e26fa5e461c7f0
ashwani8958/Python
/PyQT and SQLite/M3 - Basics of Programming in Python/program/function/5_global_vs_local_variable.py
441
3.78125
4
age = 7 def a(): print("Global varible 'age': ", globals()['age']) #now modifying the GLOBAL varible 'age' INSIDE the function. globals()['age']=27 print("Global variable 'age' modified INSIDE the function: ", globals()['age']) #now creating a LOCAL variable, 'age' INSIDE the function. age = ...
9691a4a5ae601d1584ff81a6b27139bdd19e2ca1
ashwani8958/Python
/PyQT and SQLite/M5 - Connecting to SQLite Database/assignment/assignment/main.py
509
4.03125
4
from add_record import * from search_record import * while True: print("Menu for the database\n1) Add New Record\n2) Search a existing record\n3) Exit") choice = int(input("Enter your choice : ")) if 1 == choice: print("Adding New Record to Database") new_record() elif 2 == choice: ...
12911df610c449a02f52622633078e729afc8313
ashwani8958/Python
/Image Processing/Computer_Vision_A_Z/Face Recognition/3_FaceRecognitionInImages.py
1,317
3.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun May 24 15:14:22 2020 @author: ashwani """ # https://realpython.com/face-recognition-with-python/ import cv2 # Loading the cascades face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') eye_cascade = cv2.CascadeClassifier('haarca...
0e9eca5ed6993b1e3a2c4bb9c3ca245b6dd5c5e3
ashwani8958/Python
/PyQT and SQLite/M5 - Connecting to SQLite Database/assignment/some try/original_search_record.py
2,784
3.984375
4
import sqlite3 import re def search_record(): book_list = list() #Connect to existing database MyLibrary = sqlite3.connect('Library.db') #create a cursor object curslibrary = MyLibrary.cursor() while True: #Loop to check for valid Title while True: title = inp...
eda8e23a26733d5cfd1f4712cb9bf1f53294e585
ayhanbasmisirli/wdi_april_2019
/11-working-with-libraries/instructor/todo.py
543
4.0625
4
# let user specify due date for item # datetime.date class # display how much time is left until it's due # today() looks useful # e.g. _____ due in _____ days import arrow import datetime class ToDo: """ Represents an item on a to-do list """ def __init__(self, description, due_date): self.description = d...
5912bcec4dd22442c46ac13ea361eb54e44d20d5
ayhanbasmisirli/wdi_april_2019
/11-working-with-libraries/instructor/main.py
412
3.59375
4
from todo import ToDo, datetime, Arrow from arrow.arrow import Arrow print('When is this item due?') due_year = 2019 due_month = 5 due_day = 25 due_date = Arrow(due_year, due_month, due_day) todo = ToDo('buy groceries', due_date) print(todo) past_due = Arrow(2019, 5, 12) todo2 = ToDo('dishes', past_due) print(todo2...
8d33c9452fb32c5da941d4c0761f59c7f3eaa065
SURBHI17/python_daily
/src/quest_9.py
236
3.640625
4
#PF-Prac-9 def generate_dict(number): #start writing your code here new_dict={} i=1 while(i<=number): new_dict.update({i:i*i}) i+=1 return new_dict number=20 print(generate_dict(number))
95e0619eeb977cefe6214f8c50017397ec35af3b
SURBHI17/python_daily
/prog fund/src/assignment40.py
383
4.25
4
#PF-Assgn-40 def is_palindrome(word): word=word.upper() if len(word)<=1: return True else: if word[0]==word[-1]: return is_palindrome(word[1:-1]) else: return False result=is_palindrome("MadAMa") if(result): print("The given word is a Palin...
b4c480356866bb7bfebd5fc540f7cf134ef439b3
SURBHI17/python_daily
/src/quest_12.py
510
3.671875
4
#PF-Prac-12 def generate_sentences(subjects,verbs,objects): #start writing your code here sentence_list=[] sentence="" for el in subjects: for el_2 in verbs: for el_3 in objects: sentence+=el+" "+el_2+" "+el_3 sentence_list.append(sentence) ...
afdd7db2d0487b2cc2af9a6c33bcdc5c61512109
SURBHI17/python_daily
/prog fund/src/day4_class_assign.py
338
4.1875
4
def duplicate(value): dup="" for element in value: if element in dup: #if element not in value: continue # dup+=element else: # dup+=element #return dup return dup value1="popeye" print(...
40d7c2448928e437701a688d0bc3d991ba89c808
SURBHI17/python_daily
/prog fund/src/assignment21.py
789
3.78125
4
#PF-Tryout def generate_next_date(day,month,year): #Start writing your code here if(day<=29): if(month==2): if(day==28)and((year%4==0 and year%100!=0) or year%400==0): day+=1 else: day=1 month+=1 else: ...
a893a3be9c8715a178c57d1a9c2b6ecb8874ec33
SURBHI17/python_daily
/prog fund/src/exercise22.py
663
3.890625
4
#PF-Exer-22 def generate_ticket(airline,source,destination,no_of_passengers): ticket_number_list=[] count=101 #while(no_of_passengers>0): for i in range(0,no_of_passengers): ticket_number_list.append(airline+":"+source[:3:]+":"+destination[:3:]+":"+str(count)) count=count+1 ...
1105eaac5a28e722be234a440276647401a03b08
SURBHI17/python_daily
/src/quest_16.py
325
3.546875
4
#PF-Prac-16 def rotate_list(input_list,n): #start writing your code here output_list=input_list[:len(input_list)-n] rotate=input_list[len(input_list)-n:] output_list=rotate+output_list return output_list input_list= [1,2,3,4,5,6] output_list=rotate_list(input_list,4) print(output_...
8ef915f51cf5615969b047dd61e05f4054b44f10
lssergey/projecteuler
/skovorodkin/007_10001st_prime.py
577
3.78125
4
from itertools import count, islice from math import sqrt def nth(iterable, n): return next(islice(iterable, n, None)) def prime_generator(): primes = [2] def is_prime(n): for prime in primes: if prime > sqrt(n): break if n % prime == 0: ...
cdcab6d17e29620c08c0853e7b667c18e15ad1f5
mylessbennett/reinforcing_exercises_feb20
/exercise1.py
247
4.125
4
def sum_odd_num(numbers): sum_odd = 0 for num in numbers: if num % 2 != 0: sum_odd += num return sum_odd numbers = [] for num in range(1, 21): numbers.append(num) sum_odd = sum_odd_num(numbers) print(sum_odd)
d71bb614afb0a7c248734c9ce444623ef1b29686
psambalkar/Design-2
/hashset.py
1,724
3.859375
4
/ Time Complexity : O(1) // Space Complexity :O(N) // Did this code successfully run on Leetcode :Yes // Any problem you faced while coding this :No class MyHashSet(object): def __init__(self): """ Initialize your data structure here. """ self.primaryArray = [None]* 1000 ...
de41ac8aac2c33527569eb9cdcce2b0c316d6083
Mauriciods07/practica09
/p09.py
4,764
4.28125
4
#Código de la práctica 09 para comenzar el aprendizaje en Python x = 10 #variable de tipo entero cadena = "Hola Mundo" #varible de tipo cadena print(cadena, x) x = "Hola mundo!" type(x) x = y = z = 10 print(x,y,z) #Cuando una variable tiene un valor constante, por convención, el nombre se escribe...
a76c4a577bc6afdfbd0afe19478cf7eefbd0abe5
shailendrajain2892/ga-learner-dsmp-repo
/MakingYourFirstPrediction/code.py
1,614
3.5
4
# -------------- import pandas as pd import numpy as np from sklearn.cross_validation import train_test_split # code starts here df = pd.read_csv(path) df.head() # all the dependent columns X = df.iloc[:, :-1] y = df.iloc[:, -1] # split the columns into test and training data X_train, X_test, y_train, y_test = train_...
2d4105bc0b4902b24d1eab5560521a2d0c3560ae
kedro-org/kedro-viz
/tools/github_actions/extract_release_notes.py
1,069
3.5625
4
import sys def extract_section(filename, heading): with open(filename, "r") as file: lines = file.readlines() start_line, end_line = None, None for i, line in enumerate(lines): if line.startswith("# "): current_heading = line.strip("#").replace(":", "").strip() if...
5b3a302fa6960a1765a5f839d3520ca27ec24735
SergioCaler0/my_first_proyect
/main.py
2,893
3.921875
4
# Juego de adivina el número. import random def generate_random_number(): # creo la funcion que me va a dar un numero aleatorio random_number = random.randint(1, 100) # generamos un numero aleatorio del 1 al 100 y lo meto dentro de una variable return random_number ...
9868e5d6dfcc89302b2da8700b5c105f9d88149e
joshrz/joshrz.github.io
/story.py
7,619
4.25
4
import time print("This story takes place in the abandoned town of Astroworld") time.sleep(3) print('\n') print ("In Astroworld there are many cruel and uninmaginable crimes that have taken place") time.sleep(3) print('\n') print("Over the years there has been a report that over 250 crimes of missing teenagers th...
114dd9807e3e7a111c6e1f97e331a7a98e6e074a
KanuckEO/Number-guessing-game-in-Python
/main.py
1,491
4.28125
4
#number_guessing_game #Kanuck Shah #importing libraries import random from time import sleep #asking the highest and lowest index they can guess low = int(input("Enter lowest number to guess - ")) high = int(input("Enter highest number to guess - ")) #array first = ["first", "second", "third", "fourth", "fifth"] #va...
2d8603a4d21955787543691bbeca2bb8858ecb85
Caaddss/livros
/backend.py
2,283
3.609375
4
import sqlite3 import sqlite3 as sql def iniitDB(): database = "minhabiblioteca.db" conn = sqlite3.connect(database) cur = conn.cursor() cur.execute("""CREATE TABLE livros(id INTEGER PRIMARY KEY, titulo TEXT, subtitulo TEXT, editora TEXT, autor1 TEXT, autor2 TEXT, autor3 TEXT, cidade TEXT, ano TEXT, ed...
6c4d38f9bf65685d9bbae420787da7cd31cc45e2
Bouananhich/Ebec-Paris-Saclay
/user_interface/package/API/queries.py
1,949
3.5625
4
"""Queries used with API.""" def query_city( rad: float, latitude: float, longitude: float, ) -> str: """Create an overpass query to find the nearest city from the point. :param rad: Initial search radius. :param latitude: Latitude of the point. :param longitude: Longitude of ...
49a3ed95a43897bf688cb2de2eb1ee3de114f148
inambioinfo/Genomic-Scripts
/assignment6/Polk.py
4,268
3.71875
4
#!/usr/bin/env python3 """ Script that takes in amino acid sequence as input and outputs all possible DNA sequences that could encode this AA. Usage: python3 Polk.py <peptide sequence(s)> <melting temperature> """ # Importing necessary modules import sys # Initializing a list for the number of arguments inputed arg_l...
56f1e0d155213301cb7281889c529b5a3d29e9b0
DineshkumarAgrawal4/walk-through-the-subdirs
/countline.py
525
3.640625
4
import subprocess import os import sys #This is a very simple program to count the line of some files with suffix def countlines(directory,suffix): print('lines'+' '+'dir') for (thisdir,subsdir,thisfile) in os.walk(directory): for file in thisfile: if file.endswith(suffix): f...
9e776f2abda1037063a92933b4df16a421ea3392
vedaditya/Some-Common-problems
/mancunian and colored tree.py
775
3.65625
4
# -*- coding: utf-8 -*- """ Created on Wed May 13 15:11:03 2020 @author: aryavedaditya question link:- https://www.hackerearth.com/practice/data-structures/trees/binary-and-nary-trees/practice-problems/algorithm/mancunian-and-colored-tree/ """ from collections import defaultdict from sys import stdin n,c=map(int,st...
9407f6a1dacfc2dca38e6b25ec31495357d8ba3b
blankxz/LCOF
/Python语言测试/单例模式2.py
624
3.609375
4
# encoding:utf-8 __author__ = 'Fioman' __time__ = '2019/3/6 13:36' import threading class Singleton(object): _instance_lock = threading.Lock() def __init__(self, *args, **kwargs): pass def __new__(cls, *args, **kwargs): if not hasattr(cls, '_instance'): with Singleton._instan...
9e3cafdfe5db8541e85c8480f18df920bf743b7b
blankxz/LCOF
/密码锁(3602017秋招真题)/hello.py
280
3.734375
4
data = [] while 1: a = input() data.append(list(a)) if len(data) == 3: temp = data.copy() for i in range(3): data[i] = data[2-i][::-1] if temp == data: print('YES') else: print('NO') data = []
2529dedc764fcca0e923232f9dc8f56cc154ae93
blankxz/LCOF
/Python语言测试/生产消费_多进程.py
593
3.5625
4
from multiprocessing import Process, Queue import time, random def producer(queue): for i in range(10000): tem = random.randint(1,1000) queue.put(tem) print("生产了:"+str(tem)) # time.sleep(1) def consumer(queue): while True: time.sleep(5) tem = queue.get() ...
d15700d5e54ef4902dac5a4fdeab8419b868866a
blankxz/LCOF
/对称的二叉树/hello.py
637
3.921875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def isSymmetric(self, root: TreeNode) -> bool: if not root: return True return self.dfs(root.left,root.right)...
101aaa5c240aca840d1b5db161dfcec53b82c57b
blankxz/LCOF
/Python语言测试/sort_.py
795
3.78125
4
def bubble(arr): for i in range(len(arr)): for j in range(len(arr)-1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j] return arr print(bubble([3,6,8,1,2,10,5])) def select(arr): for i in range(len(arr)): min_ind = i for j in range(i+1,len(arr)...
3954ffe60b7440baa5fe64c372da8d8339c2e077
blankxz/LCOF
/重建二叉树/hello.py
703
3.734375
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def buildTree(self, preorder, inorder) -> TreeNode: if len(preorder)>0: root = TreeNode(preorder[0]) ind = inorder....
f1fa5083c061636adff9631207520c81e5681a81
paulogpafilho/machine-learning
/maker-fair-2017/resize_image.py
2,553
3.8125
4
"""Resizes all images from a source_dir to a target_dir. This program reads all images from a folder, --source_dir, resize them based on the --img_width and --img_height arguments, and save them to --target_dir. The --source_dir argument sets the folder where the images to be resized are located. The --target_dir ar...
26dc089d77ad91233b9a0d57df9cd2c47ba4f413
mohansn/dsa_assignment
/1_fib.py
257
3.875
4
#!/usr/bin/python def fib(n): """ Returns the the first 'n' Fibonacci numbers """ fibs=[] for i in range(n): if (i == 0 or i == 1): fibs.append(i) else: fibs.append(fibs[i-1]+fibs[i-2]); return fibs
9bab6ff99aa72e668524b63523c2106181049f6f
IamBiasky/pythonProject1
/SelfPractice/function_exponent.py
316
4.34375
4
# Write a function called exponent(base, exp) # that returns an int value of base raises to the power of exp def exponent(base, exp): exp_int = base ** exp return exp_int base = int(input("Please enter a base integer: ")) exp = int(input("Please enter an exponent integer: ")) print(exponent(base, exp))
ed1d712104934ccec97205a06a3daede7352dc29
IamBiasky/pythonProject1
/SelfPractice/phoneBook.py
402
4
4
def user_phonebook(user_name=None, user_age=None, user_no=None): for counter in range(3): user_name = input(str("Please enter your Name: ")) user_age = int(input("Please enter your Age: ")) user_no = int(input("Please enter your Phone Number: ")) contact = {"Name": user_name, "Age":...
7b113d95aa328c3fbe74be66f35c03508947d1b9
IamBiasky/pythonProject1
/ChapterThree/Arithmetic_Smallest_Largest_Remake.py
543
4.0625
4
number1 = int(input("Enter first integer: ")) number2 = int(input("Enter second integer: ")) number3 = int(input("Enter third integer: ")) number4 = int(input("Enter fourth integer: ")) smallest_int = min(number1, number2, number3, number4) largest_int = max(number1, number2, number3, number4) sum_int = smallest_int ...
04fb4ac9117370c5fffe9abbe435fdc1c165e0b0
BSBandme/Decaf-Compiler
/hw1/Number2.py
5,515
3.578125
4
#program submit import sys import string #mode = "test" # test mode input from file mode = "submit" # submit mode keyboard input commands = "" vari = [] value = [] result = "" def labelCheck(label,colon = False): #check label name validness #label the string to check; colon if the label end with colon ...
4cbd2d5b040711aaa6bf3c0e599d04682d177cdc
Radmaster5000/shadowrun
/shadowrun.py
7,180
3.53125
4
import time from missionText import missionText import random def roll(modifier): result = random.randint(1,6) + modifier print(result) return result # Creating the Intro screen def intro(key): # repeats until player presses 1, 2, or 3 while (key != 1 or key != 2 or key != 3): print(""" #### # # #### ##...
9f0c9a33209211c9f37bf474cdc2762f60dbf9d6
soumya62/GitCommands
/Vowel.py
166
4.1875
4
VOWELS=("a","e","i","o","u") msg=input("Enter ur msg:") new_msg="" for letter in msg: if letter not in VOWELS: new_msg+=letter print(new_msg)
2d4cf0b46c47fad8a5cc20cdf98ebf9ab379a151
sooryaprakash31/ProgrammingBasics
/OOPS/Exception_Handling/exception_handling.py
1,347
4.125
4
''' Exception Handling: - This helps to avoid the program crash due to a segment of code in the program - Exception handling allows to manage the segments of program which may lead to errors in runtime and avoiding the program crash by handling the errors in runtime. try - represents a block of code t...
8997e1b48a911acfdf53c74f7d1eb17fb294308d
sooryaprakash31/ProgrammingBasics
/Data-Structures/Linked_List/Circular/circular.py
4,266
4.3125
4
''' Circular Linked List: - A linear data structure in which the elements are not stored in contiguous memory locations. - The last node will point to the head or first node thus forming a circular list Representation: |--> data|next--> data|next--> data|next --| |--------------------------------...
79dda99fe42354f17d03eb33a1aab1ee9ebe61ab
sooryaprakash31/ProgrammingBasics
/Algorithms/Sorting/Quick/quick.py
2,027
4.25
4
''' Quick Sort: - Picks a pivot element (can be the first/last/random element) from the array and places it in the sorted position such that the elements before the pivot are lesser and elements after pivot are greater. - Repeats this until all the elements are placed in the right position - Divide and conquer strateg...
98648e9554675226787aeb68463d480b46827e7b
sooryaprakash31/ProgrammingBasics
/Algorithms/Searching/Linear/linear.py
389
3.734375
4
''' Linear Search: - Compares every element with the key and returns the index if the check is successful - Simplest searchin algorithm ''' arr=list(map(int,input("Enter array ").split())) key = int(input("Enter key ")) for i in range(len(arr)): if arr[i] == key: print("Found at {} position".format(i...
2d6f7f9ab17c96341ab645c3716579de46cc6d73
valdirsjr/learning.data
/python/jogo_nim.py
2,468
3.9375
4
def computador_escolhe_jogada(n,m): y = 0 i = 1 if n <= m: y = n else: while i <= m: if (n - i) % (m + 1) == 0: y = i i = i + 1 if y == 0: y = m if y == 1: print("O computador tirou uma peça.") else...
3188506e24c4ef4122a8c1dd30601950757f3c9c
sebastian-mutz/integrate
/course/source/exercises/E201/bme280_ssd1306_control_script.py
5,341
3.515625
4
""" author: daniel boateng (dannboateng@gmail.com) This script basically controls the measurement from BME280 sensor, store in an excel sheet (with defined columns for date, time, temperature, humidity and pressure. Not that other parmaters like dewpoint temperature can be calculated from these parameters) and also dis...
fb60a0538163955276551a694a4ae667f60023ea
melissabuist/PythonPrograms
/Python/Lab 4/lab4.py
2,944
3.890625
4
#********************************************************************** # Lab 4: <Files> # # Description: # <This program open a file and outputs data based on the file> # # # Author: <Melissa Buist, melissa.buist@mytwu.ca> # Date: <October 26, 2018> # # Input: <a data file> # Output: <average opening, av...
a6a8d6d43bd5de7b51c8bd3b0018d6c53a1652a6
BekzhanKassenov/olymp
/informatics.mccme.ru/Python/Chapter 3/C/C.py
90
3.609375
4
n = int(input()) if (n > 0): print(1) elif (n < 0): print(-1) else: print(0)
cb047338515789dcab16172208ccf171a1239f6b
GrisWoldDiablo/Data-Structure-and-Algorithm
/Python/Tree/Tree/TheTree.py
12,327
3.78125
4
""" Author: Alexandre Lepage Date: February 2020 """ from abc import ABC, abstractmethod #region TheNode class TheNode(ABC): """ Custom abstract Tree Node class """ def __init__(self,k): """ Constructor of the Class Initialize left, right and parent node as None Initial...
8c37b00a3c1d1ef62f15d3849165df8dec44a430
abhishekanand10/dataStructurePy3
/mislPy/mergeSort.py
878
3.796875
4
def mergesort(a): if len(a) == 1: return else: # tmp = [] mid = len(a) // 2 ll = a[:mid] rr = a[mid:] mergesort(ll) mergesort(rr) merge(a, ll, rr) return a def merge(a, leftlist, rightlist): ln = len(leftlist) rn = len(rightlist)...
372ecd89fd5286c2106a7d4bff590768b29121e1
bhaveshpandey29/python_3
/bill_generation.py
937
3.8125
4
while True: count_per = int(input("Please enter the number of persons : ")) total_val = [] for i in range(1,count_per +1): print("\nEnter the details of the person",i,"below:") person_starter = int(input("\nPlease enter the value of breakfast : ")) person_meal = int(input("Please ent...
155926fcbca6ae4641a76ef9498b91604f176db9
deepaksharmak92/Assignment---Tic-Tac-Toe
/TCGame_Env1.py
4,694
3.734375
4
from gym import spaces import numpy as np import random from itertools import groupby from itertools import product class TicTacToe(): def __init__(self): """initialise the board""" # initialise state as an array self.state = [np.nan for _ in range(9)] # initialises the board p...
43e64a75f4f81b31ec821ea2c4d80abfc99eb39f
SSzymkowiak/CDV_PS
/pętle.py
1,021
3.71875
4
#while licznik = 0 while (licznik < 3): licznik = licznik + 1 print("CDV") print(licznik) ############################ licznik = 0 while (licznik < 3): licznik += 1 print(licznik, end="") else: print("Koniec pętli") ############################## ########## FOR lista = ["Jan","Anna","Paweł"] ...
89f931044d2ea43a228a802a1ea214d5745c3d4c
Phantom-Eve/Python
/python/demo7/demo7_4.py
1,194
3.5
4
#!/usr/bin/evn python # -*_ coding: utf-8 -*- import functools # 装饰器Decorator print u"\n===================# 在代码运行期间动态增加功能的方式,称之为“装饰器” ===================" def log(text): def decorator(func): @functools.wraps(func) def wrapper(*args, **kw): print '%s %s():' % (text, func.__name__) ...
bda6af37cae4aba2f72394089a4353b4a8012d20
Phantom-Eve/Python
/python/demo7/demo7_1.py
2,035
3.75
4
#!/usr/bin/evn python # -*_ coding: utf-8 -*- # map/reduce接收两个参数:1.函数,2.序列 L = [1, 2, 3, 4, 5, 6, 7, 8, 9] print u"\n===================# map将传入的函数依次作用到序列的每个元素 ===================" print u"使用map把数字list转化为字符串:", map(str, L) print u"\n===================# reduce把一个函数作用在一个序列上 ===================" # 集合求和 def add(x, y): ...
aef025a22d78acf9b7ec392e11c0b2cb2f0339f5
manjoong/python_study
/out/test/python_study/queue.py
944
3.59375
4
# num = int(input()) # command = [" " for _ in range(0, num)] # for i in range(0, num): # command[i] = input() num = 1 command = ["back"] arr = [] def push(x): arr.append(x) def pop(): if len(arr) == 0: print(-1) else: print(arr[0]) del arr[0] def size(): print(len(ar...
d7253e332951b7f394a63562ff08ee304dc79b82
manjoong/python_study
/programmers_find_sosu.py
1,165
3.625
4
import itertools def prime(n): if n == 1 or n ==0: return False else: if n == 2: return True else: for i in range(2, n//2+1): if n%i ==0: return False return True def solution(numbers): answer = 0 a...
8d0231814f7b143b468ccda9ee71d62040a7a1f0
lwd19861127/Leetcode
/Leetcode/Linked List Cycle(141).{python3}/LinkedListCycle.py
691
3.921875
4
# Linked List Cycle # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def hasCycle(self, head: ListNode) -> bool: fast = slow = head while fast and fast.next: slow = slow.next fast ...
9f13a29c757c6cc2ef8f0d7dfe29b37ddec47df0
Dannikk/dfs_bfs_animation_-using-networkx-
/src/graph_reader.py
567
3.921875
4
import os DELIMITER = ':' NODES_DELIMITER = ',' def read_graph(file_path: str): """ Function that reads a graph from a text file Parameters ---------- file_path : str directory to file to read graph Returns ------- generator : yielding node (any hashable object), lis...
39bbe7fce725a7fb6fbc91def71fd88e6373b7e6
endfirst/python
/first_class_function/first_class_function00.py
511
3.515625
4
# -*- coding: utf-8 -*- # 퍼스트클래스 함수란 프로그래밍 언어가 함수 (function) 를 first-class citizen으로 취급하는 것을 뜻합니다. # 쉽게 설명하자면 함수 자체를 인자 (argument) 로써 다른 함수에 전달하거나 다른 함수의 결과값으로 리턴 할수도 있고, # 함수를 변수에 할당하거나 데이터 구조안에 저장할 수 있는 함수를 뜻합니다. def square(x): return x * x print square(5) f = square print square print f
938501b49e1f9678ac3f64094b2cf4eed46c35f6
JasmineBharadiya/pythonBasics
/task_8_guessNo.py
161
3.609375
4
import random a=int(raw_input("guess a no. between 1-10: ")) rA=random.randint(1,10) if(rA==a): print "well guessed" else : print "try again"
91d55cba2c6badcd157aae309c518f6fafcbf9c1
mildzf/zantext
/zantext/zantext.py
671
3.65625
4
# -*- coding: utf-8 -*- """ File: zantext.py Author: Mild Z Ferdinand This program generates random text. """ import random POOL = "abcdefghijklmnopqrstuvwxyz" def word(length=0): if not length or length > 26: length = random.randint(3, 10) else: length = abs(length) word = [random.choi...
4bdde3d9684f505ae85c0446465aa211a012a02d
luizfirmino/python-labs
/Python I/Assigments/Module 5/Ex-2.py
415
4.3125
4
# # Luiz Filho # 3/14/2021 # Module 5 Assignment # 2. In mathematics, the factorial of a number n is defined as n! = 1 ⋅ 2 ⋅ ... ⋅ n (as the product of all integer numbers from 1 to n). # For example, 4! = 1 ⋅ 2 ⋅ 3 ⋅ 4 = 24. Write a recursive function for calculating n! def calculateN(num): if num == 1: ...
7372b7c995d2302f29b8443656b50cae298a566b
luizfirmino/python-labs
/Python I/Assigments/Module 6/Ex-4.py
742
4.40625
4
# # Luiz Filho # 3/23/2021 # Module 6 Assignment # 4. Write a Python function to create the HTML string with tags around the word(s). Sample function and result are shown below: # #add_html_tags('h1', 'My First Page') #<h1>My First Page</h1> # #add_html_tags('p', 'This is my first page.') #<p>This is my first page....
7207ee818fe1cd157874667ae152ee4e8072de3d
luizfirmino/python-labs
/Python Databases/Assigments/Assignment 1/filho_assignment1.py
655
4
4
#!/usr/bin/env python3 # Assignment 1 - Artist List # Author: Luiz Firmino #imports at top of file import sqlite3 def main(): con = sqlite3.connect('chinook.db') cur = con.cursor() #query to select all the elements from the movie table query = '''SELECT * FROM artists''' #run the query cur....
c13619368c38c41c0dbf8649a3ca88d7f2788ee8
luizfirmino/python-labs
/Python Networking/Assignment 2/Assignment2.py
564
4.21875
4
#!/usr/bin/env python3 # Assignment: 2 - Lists # Author: Luiz Firmino list = [1,2,4,'p','Hello'] #create a list print(list) #print a list list.append(999) #add to end of list print(list) print(list[-1]) #print the last element list.pop() #remove last element pr...
51d1e3a48b954c1de3362ea295d4270a884fea98
luizfirmino/python-labs
/Python I/Assigments/Module 7/Ex-3.py
1,042
4.3125
4
# # Luiz Filho # 4/7/2021 # Module 7 Assignment # 3. Gases consist of atoms or molecules that move at different speeds in random directions. # The root mean square velocity (RMS velocity) is a way to find a single velocity value for the particles. # The average velocity of gas particles is found using the root mean s...
47d783748c562dd3c3f8b7644dda166f37b5f11e
luizfirmino/python-labs
/Python I/Assigments/Module 5/Ex-6.py
238
4.5
4
# # Luiz Filho # 3/14/2021 # Module 5 Assignment # 6. Write a simple function (area_circle) that returns the area of a circle of a given radius. # def area_circle(radius): return 3.1415926535898 * radius * radius print(area_circle(40))
6ca6fbf8e7578b72164ab17030f1c01013604b04
luizfirmino/python-labs
/Python I/Assigments/Module 5/Ex-4.py
549
4.28125
4
# # Luiz Filho # 3/14/2021 # Module 5 Assignment # 4. Explain what happens when the following recursive functions is called with the value “alucard” and 0 as arguments: # print("This recursive function is invalid, the function won't execute due an extra ')' character at line 12 column 29") print("Regardless any value...
796c8bb615635d769a16ae12d9f27f2cfce4631c
luizfirmino/python-labs
/Python I/Assigments/Module 2/Ex-2.py
880
4.53125
5
# # Luiz Filho # 2/16/2021 # Module 2 Assignment # Assume that we execute the following assignment statements # # length = 10.0 , width = 7 # # For each of the following expressions, write the value of the expression and the type (of the value of the expression). # # width//2 # length/2.0 # length/2 # ...
6c41276669d4b83b5b79074f60302f370c4eaa80
wuga214/PlanningThroughTensorFlow
/utils/argument.py
388
3.609375
4
import argparse def check_int_positive(value): ivalue = int(value) if ivalue <= 0: raise argparse.ArgumentTypeError("%s is an invalid positive int value" % value) return ivalue def check_float_positive(value): ivalue = float(value) if ivalue < 0: raise argparse.ArgumentTypeErro...
910a369c1dc5ad07e8e4c1916ef31c0c044f7430
Litao439420999/LeetCodeAlgorithm
/Python/integerBreak.py
701
3.59375
4
#!/usr/bin/env python3 # encoding: utf-8 """ @Filename: integerBreak.py @Function: 整数拆分 动态规划 @Link: https://leetcode-cn.com/problems/integer-break/ @Python Version: 3.8 @Author: Wei Li @Date:2021-07-16 """ class Solution: def integerBreak(self, n: int) -> int: if n < 4: return n - 1 ...
78098f3c8900ab45f703158bfefd790be0cfe74b
Litao439420999/LeetCodeAlgorithm
/Python/maxProfitChance.py
799
4
4
#!/usr/bin/env python3 # encoding: utf-8 """ @Filename: maxProfitChance.py @Function: 买卖股票的最佳时机 动态规划 @Link: https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock/ @Python Version: 3.8 @Author: Wei Li @Date:2021-07-16 """ from typing import List class Solution: def maxProfit(self, prices: List[int]) -...
a5dfcb4f79865d734ddfd7d9cf0c9061fcc6d187
Litao439420999/LeetCodeAlgorithm
/Python/missingNumber.py
611
3.828125
4
#!/usr/bin/env python3 # encoding: utf-8 """ @Filename: missingNumber.py @Function: 丢失的数字 @Link: https://leetcode-cn.com/problems/missing-number/ @Python Version: 3.8 @Author: Wei Li @Date:2021-07-22 """ class Solution: def missingNumber(self, nums): missing = len(nums) for i, num in enumerate(nu...
ead8d1adb57d0b887ccd55638e88586230fe2d47
Litao439420999/LeetCodeAlgorithm
/Python/maxArea.py
868
4.03125
4
#!/usr/bin/env python3 # encoding: utf-8 """ @Filename: maxArea.py @Function: 盛最多水的容器 @Link: https://leetcode-cn.com/problems/container-with-most-water/ @Python Version: 3.8 @Author: Wei Li @Date:2021-08-08 """ from typing import List class Solution: def maxArea(self, height: List[int]) -> int: left, ri...
f0df420f1b26891e1e1483da86615aa651a99815
Litao439420999/LeetCodeAlgorithm
/Python/combinationSum2.py
1,456
3.734375
4
#!/usr/bin/env python3 # encoding: utf-8 """ @Filename: combinationSum2.py @Function: 给定一个数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合 @Link: https://leetcode-cn.com/problems/combination-sum-ii/ @Python Version: 3.8 @Author: Wei Li @Date:2021-07-12 """ import collections from typing import List ...
4cf065dceacbfb09de77b2dba2d1f6879e080362
Litao439420999/LeetCodeAlgorithm
/Python/removeNthFromEnd.py
884
3.9375
4
#!/usr/bin/env python3 # encoding: utf-8 """ @Filename: removeNthFromEnd.py @Function: 删除链表的倒数第 N 个结点 @Link: https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/ @Python Version: 3.8 @Author: Wei Li @Date:2021-07-30 """ # Definition for singly-linked list. class ListNode: def __init__(self, val=0, ...
f5e0250259414bd762064edd430b574d691f7051
Litao439420999/LeetCodeAlgorithm
/Python/isPowerOfThree.py
825
4.09375
4
#!/usr/bin/env python3 # encoding: utf-8 """ @Filename: isPowerOfThree.py @Function: 3的幂 数学问题 @Link: https://leetcode-cn.com/problems/power-of-three/ @Python Version: 3.8 @Author: Wei Li @Date:2021-07-19 """ import math class Solution: def isPowerOfThree(self, n: int) -> bool: if n <= 0: ret...