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
7f09177a29dbd5b1adcb2e99d190681ac352cc69
NeonNatural/CA341-Comparative-Programming-Languages
/Assignment 2/oo_tree.py
2,453
3.765625
4
class Node: def __init__(self, val): self.val = val self.right = None self.left = None class Btree: def __init__(self, root = None): self.root = Node(root) def insert(self, ptr, x): if ptr.val != None: if x > ptr.val: if ptr.right != Non...
4aa40c45dae7fd6c350b85ddd78e9005887328f7
sinhdev/python-demo
/basic-programming/file-io/input-function.py
86
3.578125
4
#!/usr/bin/python str = input("Enter your input: ") print("Received input is : ", str)
a8c4dc878b82448fc9695befcae7a43b25164897
maxmacdon/Automate
/chpt6/myZombies.py
3,386
3.671875
4
#! python3 import zombiedice, random class randomZombie: def __init__(self, name): # All zombies must have a name: self.name = name def turn(self, gameState): # gameState is a dict with info about the current state of the game. # You can choose to ignore it in your code. ...
cfd9644ca1e2b598a089188b2ae3681918c7d7e9
maxmacdon/Automate
/chpt7/dateDetection.py
1,302
4.09375
4
#! python3 import re # Find dates within text def dateFind(inputDate): dateRegex = re.compile(r'((\d{2})/(\d{2})/(\d{4}))') print(dateRegex.search(inputDate)) for groups in dateRegex.findall(inputDate): dateValidate(groups[0], int(groups[1]), int(groups[2]), int(groups[3])) # Check date is valid ...
3b48c4c88c3dfe76b210d9ce68bef01a6e5c6251
kshv1994/Parking-Lot
/views.py
2,395
3.65625
4
from models import * def create_parking_lot(args): """Takes in input param and and initialize the lot""" total_slots = int(args[1]) status = ParkingLot.initialize(total_slots) if status == 'SUCCESS': print(f'Created parking of {total_slots} slots') def park_vehicle(args): """Checks avail...
63410419c608011e23a7ced290170e9191737623
Nehanavgurukul/function_ques
/unique_list.py
216
3.828125
4
def unique(list1): list=[] index=0 while(index<len(list1)): if(list1[index] not in list): list.append(list1[index]) index=index+1 return list print(unique([1,2,3,3,3,4,5]))
ec34c7771a17c18797104bfa771a86da23292814
Nehanavgurukul/function_ques
/more_ques_2.py
421
3.796875
4
num_of_students=int(input("enter the student")) kharcha_of_student=int(input("enter the kharcha")) i=1 kharcha_of_oneday = num_of_students*kharcha_of_student monthly_kharcha=0 while(i<=30): # kharcha_of_students=int(input("enter the kharcha")) monthly_kharcha=monthly_kharcha+kharcha_of_oneday i=i+1 if(mont...
991215b404c060178ed1f1eafc798c167a661f79
Nehanavgurukul/function_ques
/voter.py
138
4.09375
4
def voter(): if(age>18): print("this is voter") else: print(" not voter") age=int(input("enter the age")) voter()
d4c1ebd6c6fe65925b989bfdf33e82a9de3a3fd7
Nehanavgurukul/function_ques
/name_function.py
338
3.953125
4
def function_name(name1,name2): if(len(name1)==len(name2)): print(name1) print(name2) elif(len(name1)>len(name2)): print(name1) elif(len(name1)<len(name2)): print(name2) user1_string=input("enter the string") user2_string=input("enter the string") function_name(user1_str...
5c21e32c4c207f9ec6c2798701f4efc2df4fa6f1
Nehanavgurukul/function_ques
/check_numbers_list.py
338
3.625
4
def check_numbers(num1,num2): i=0 c=[] while(i<len(num1)): j=i while(j<=i): if(num1[i]%2==0 and num2[j]%2==0): print("dono even hai") else: print("dono even nahi") j=j+1 i=i+1 x=[98,65,54,35,85] y=[34,55,78,87,98] ...
7831440204f7f402b0b6326dc82234ca749e85a0
maya-sb/RelogioCorrida
/geral.py
9,445
3.984375
4
import Time import Distancias #Função que questiona o uso de pausa ou não def considerarPausa(): op3 = input("Deseja considerar pausas? [s/n]: ") print() if op3 == "S" or op3 == "s": return True elif op3 == "N" or op3 == "n": return False else: print("Opção inválida!") ...
3e692480affd7dfcb5b94e1b754851d890e79f16
jgthomas/dbase
/dbase.py
7,451
3.515625
4
import sqlite3 import re import csv import json class Database: """ Wrapper and utility methods for sqlite. db : Name of the database file. trace : An optional callback function to log or print each SQL statement as executed. """ def __init__(self, db, trace=None): ...
b5f440d156a987289efabf6d1a634cfc9b1079b6
mlesigues/Python
/everyday challenge/day_43.py
1,175
3.5
4
#Task: Largest Time for Given Digits from Leetcode class Solution: def largestTimeFromDigits(self, A: List[int]) -> str: #src: https://www.youtube.com/watch?v=sn6r0ZV_2y4 res = "" for i in range(len(A)): for j in range(len(A)): for k in range(len(A)): ...
39818628463ce7f4c310d7b36e06eeae43d9abca
mlesigues/Python
/everyday challenge/day_41.py
2,123
3.90625
4
#Task: Find the Percentage from Hackerrank if __name__ == '__main__': n = int(input()) student_marks = {} for _ in range(n): name, *line = input().split() scores = list(map(float, line)) student_marks[name] = scores query_name = input() #some strategies: #know what the q...
9c86124bc1733189f8edab9712a4d79e3e074345
mlesigues/Python
/everyday challenge/day_19.py
1,916
4.125
4
#Task: Vertical Order Traversal of a Binary Tree from Leetcode #src:https://www.geeksforgeeks.org/print-binary-tree-vertical-order-set-2/ #src:https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree/discuss/253965/Python-8-lines-array-and-hashmap-solutions # Definition for a binary tree node. # class T...
8e807f241a256536c3290125a2fb58b0be9ec117
mlesigues/Python
/everyday challenge/day_15.py
916
3.921875
4
class Solution: #function returns true if the given string is a palindrome, otherwise false empty string as valid palindrome from Leetcode! def isPalindrome(self, s: str) -> bool: empStr = '' #creates empty string #src: https://www.cnblogs.com/zuoyuan/p/3765882.html #the given str...
b23b4dead3fdf01ccff15ad5f88a269967266e3a
mlesigues/Python
/everyday challenge/day_47.py
2,102
4.03125
4
#Task: String Validators from Hackerrank if __name__ == '__main__': s = input() """ for elem in s: #if any(elem == elem.isalnum()): # print(elem.isalnum()) any(s.isalnum()) if elem == elem.isalpha(): print(elem.isalpha()) if elem == elem.isdigit(): ...
551824b92a522ebbaa8d8efb5b2a790953662133
mlesigues/Python
/everyday challenge/day_13.py
1,713
4.125
4
#TASK: Given a full name, your task is to capitalize the name appropriately. #input: s is the full name # Complete the solve function below. def solve(s): #s[0] = s.capitalize() #cap = s.capitalize() # for i in len(range(s)): # if s[i] == " ": # s[i+1] = s.capitalize() # for i in ra...
b64e52b6e5fd7d810458d2759490c8b073fc80e7
mlesigues/Python
/everyday challenge/day9.py
1,603
3.921875
4
#TASK: A left rotation operation on an array of size n shifts each of the #array's elements 1 unit to the left. Given an array of n integers and a #number, d, perform d left rotations on the array. Then print the updated #array as a single line of space-separated integers. #!/bin/python3 import math import os import...
bb90261d608f0ff0bdf77e6ffdb733bf84b58ece
mlesigues/Python
/everyday challenge/day_55.py
738
3.53125
4
#Task: MaximumSubarray from Leetcode #src: (for kadane's algo understanding) https://www.geeksforgeeks.org/largest-sum-contiguous-subarray/ from sys import maxsize class Solution: def maxSubArray(self, nums: List[int]) -> int: #kadane's algorithm max_so_far = -maxsize - 1 max_end_here = 0 ...
de9ec51edcb596512edceb92f9662c04d94a2cb2
mlesigues/Python
/everyday challenge/day_51.py
3,189
3.75
4
#Task: Insert Interval from Leetcode #src: https://www.youtube.com/watch?v=NWM4e4yda0w class Solution: def insert(self, intervals: List[List[int]], newInterval: List[int]) -> List[List[int]]: result = [] for x in intervals: if x[1] < newInterval[0]: result.append...
af661261451dfc51dfff7abf814161ac97d93616
DamianS6/kiwi-flights
/find_combinations.py
4,023
3.96875
4
#!/usr/bin/env python # TODO: Dictreader # TODO: Click import sys import csv from datetime import datetime def find_combinations(): """ Find all combinations of flights for passengers with no bags, one bag or two bags are able to travel, having 1 to 4 hours for each transfer between flights. Take in input d...
1a410a35d570bbc4faa1da475180e7225a5b4d0a
necmik/PythonRepo
/print_now.py
302
3.875
4
from datetime import datetime import pytz utc = pytz.utc # utc is Coordinated Universal Time ist = pytz.timezone('Asia/Istanbul') #IST is Indian Standard Time now = datetime.now(tz=utc) # this is the current time in UTC ist_now = now.astimezone(ist) # this is the current time in IST. print(ist_now)
a93a1f211b1050a48f3480e4b3c2e8e1183861f6
loco-lab/hera-display-games
/src/hera_display_games/count_pixels/__init__.py
868
3.515625
4
#! /usr/bin/env python # -*- coding: utf-8 -*- """A simple simulation of a random walk""" import click from hera_display_games.core import board, map_dict, sprites import time @click.command() @click.option("-s", "--speed", type=float, default=1, help="Speed of sprite") @click.option( "-x", "-X", "--use-s...
39bf0c2f21215a79ab5ff9b43a21b140e519fb9a
Muhammad-Ahmad-AI/Library-Management-System-in-Python
/Add_Student.py
2,860
3.5
4
from tkinter import * from tkinter import messagebox from tkinter import filedialog import os import sys import mysql.connector from mysql.connector import Error py = sys.executable #creating window class Add(Tk): def __init__(self): super().__init__() self.iconbitmap(r'libico.ico') self.ma...
47feb1fadee0bccedf0ce15c773c2eea6bebef23
IsabellaJoseph99/Elements-of-Software-Design
/Convex Hull/ConvexHull.py
5,657
3.859375
4
# File: ConvexHull.py # Description: Convex Hull formed from points inputted # Student Name: Isabella Joseph # Student UT EID: ij2799 # Partner Name: Kaitlyn Ng # Partner UT EID: kn8685 # Course Name: CS 313E # Unique Number: 50205 # Date Created: 9/26/2019 # Date Last Modified: 9/26/2019 import mat...
145020fd82f3fc2528a841fee8340f6e26bfb54c
IsabellaJoseph99/Elements-of-Software-Design
/Binary Trees/TestBinaryTree (6).py
5,011
4.03125
4
# File: TestBinaryTree.py # Description: Program that adds functions to determine if trees are similar, prints nodes on the same level, gets the height of the tree, and the number of nodes # Student Name: Isabella Joseph # Student UT EID: ij2799 # Partner Name: Kaitlyn Ng # Partner UT EID: kn8685 ...
d84a60f761d40c7a217d771e99383733255a3be6
KAndQ/pytoys
/md5_checker.py
1,290
3.578125
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # MD5 校验工具 # 输入一个文件名是获得该文件的 MD5 值; # 输入两个文件名是比对两个文件的 MD5 值是否相同; import sys, os from os import path import hashlib def getFileMD5(file): try: f = open(file, "rb") f.seek(0, 0) f.seek(0, 2) endPos = f.tell() f.seek(0, 0) m ...
a4cb8e784fc4e2b88bab2ef7af837c90b2d428e8
marcialpuchi/algorithms
/findAnagrams.py
736
4.03125
4
""" Given a string s and a non-empty string p, find all the start indices of p's anagrams in s. :type s: str :type p: str :rtype: List[int] """ from collections import defaultdict def findAnagrams(s, p): print('Test:', s, ' - ', p) anagrams = defaultdict(list) windowSize = len(p) for i in range(l...
39d7da55cde932067fe414f5229abfd07fc8711c
marcialpuchi/algorithms
/substracDiagonals.py
431
4.09375
4
# Get the sum of the two main diagonals # and substract the two values. # The result should be an integer. def subsDiagonals(array): diag1=0 diag2=0 size=len(array)-1 for r, row in enumerate(array): diag1 += array[r][r] diag2 += array[r][size-r] print diag1, diag2 subtraction = abs(diag1 - diag2) ret...
407845504f44fc97568ac0bd70aa5eae5205593e
lvsazf/python_test
/variable.py
348
3.828125
4
# -*- coding: utf-8 -*- ''' Created on 2017年6月29日 @author: Administrator list:有序列表,可变 ''' classmates = ["Michael","Boy","Tracy"] print(classmates) #list长度 print(len(classmates)) ''' tuple 元组 一旦初始化完,就不能修改 ''' print("---------------tuple---------------------") t = (1,2) print(t)
6405e0d7744e195d169af25937ab0212cecb0493
lvsazf/python_test
/characteristic/generator.py
1,338
3.859375
4
# -*- coding: utf-8 -*- ''' Created on 2017年7月3日 @author: Administrator ''' '生成器' #method 1,把列表生成式的[]改为() g = (x for x in range(10)) print(g) #next()获取generator的下一个返回值 print(next(g)) #一般用for来遍历generator # for n in g: # print(n) #斐波拉契数列 1,1,2,3,5,8,13... def fib(m): n,a,b = 0,0,1; while n...
a25e8ded48e2989414af196523a2a42f5f0d92e6
garyleecf/mmab
/agents/q_agents.py
2,093
3.515625
4
import random import numpy as np from agents import Agent # In what follows, I have implemented a "smarter" agent that actually learns from past actions and observations. # This uses concepts related to "Q Learning" -- we will touch on this in subsequent weeks! # However, if you're curious, read on, try and figu...
4218d7d8637182c7236812fbc869d5df9f2252dd
mangel2500/Programacion
/Práctica 6 Python/Exer-9.py
395
3.609375
4
# -*- coding: cp1252 -*- num=int(input("Dime cuantas palabras va a tener tu lista: ")) lista1=[] for i in range (num): num1=raw_input('Dime la palabra %d: ' % (i+1)) lista1.append(num1) print 'La lista creada es ',lista1 for i in range(len(lista1)-1,-1,-1): if lista1[i] in lista1[:i]: ...
71e1d68ab2f1c5eef9d95877d24c11eba9997b78
mangel2500/Programacion
/Práctica 1 Python/Area triangulo.py
140
3.859375
4
# -*- coding: cp1252 -*- b=input('Cual es la altura? ') h=input('Cual es la base? ') a=(b*h)/2 print 'El area del triangulo es',a,
bc4bbe31282a164f7490f19f8809323a04e551c7
mangel2500/Programacion
/Práctica 7 Python/Exer-2.py
603
4.1875
4
'''MIGUEL ANGEL MENA ALCALDE - PRACTICA 7 EJERCICIO 2 Escribe un programa que lea el nombre y los dos apellidos de una persona (en tres cadenas de caracteres diferentes), los pase como parmetros a una funcin, y sta debe unirlos y devolver una nica cadena. La cadena final la imprimir el pr...
e2cd8888794c4a385b982a4c8c62ab0dfeeb1357
mangel2500/Programacion
/Práctica 6 Python/Exer-3.py
446
3.65625
4
# -*- coding: cp1252 -*- num=int(input("Dime cuantas palabras va a tener tu lista: ")) lista=[] for i in range (num): num1=raw_input('Dime una palabra %d: ' % (i+1)) lista.append(num1) print 'La lista creada es ' +str(lista) busc=raw_input('Sustituir la palabra: ') sust=raw_input('Por la palab...
ed7ea1612c7160c9aee9e36fb392d6ab40d3fb9c
mangel2500/Programacion
/Práctica 5 Python/Exer-11.py
522
3.59375
4
import random import time random.seed(time.time()) minim=int(raw_input("Valor minim:")) maxim=int(raw_input("Valor maxim:")) secret=random.randint(minim, maxim) print "A veure si endivines un nombre sencer entre",minim,"i", maxim print "Dame un numero:" n=input() if (n<secret): print "Es demasia...
329b7e03d44ef2415740fb7887c6c6a5a57855a3
mangel2500/Programacion
/Práctica 5 Python/Exer-9.py
311
3.796875
4
print 'Dame un nombre: ' nom = raw_input() lista = [] lista1 = [] while nom!="": lista.append(nom) print('Dame un telefono: ') telef=int(input()) lista.append(telef) lista1.append(lista) print('Dame otro nombre: ') nom = raw_input() lista = [] print lista1
075270bd61155ffd44569821c8bebf875894ee6e
nara21-meet/Meet-yl1
/facebook.py
1,887
3.703125
4
class Post(): def __init__(self,text,picture,video): self.text=text self.picture=picture self.video=video def post(self): global post self.posts.append(text) print(self.name+"has posted"+text) class User(): def __init__(self,name,email,password,friends_list...
9ff529f2174568f4258433f5e5a9afa56d02f895
shashank0791/ops-workload-framework
/heat_workload/tools/prettyoutput.py
1,291
3.5
4
from prettytable import PrettyTable class Prettyoutput(): def __init__(self,list_output): self.list_output = list_output def display(self): TABLE_LIST = [] TOTAL_MIN = 0 TOTAL_MAX = 0 TOTAL_AVG = 0 for dict in self.list_output: ...
ece505a202ad37c9ca990f3b84f121cc076f5a02
amrishparmar/countdown-solver
/countdown.py
2,941
4.25
4
import argparse import sys def load_words(filename): """Load all words (9 letters or less) from dictionary into memory :param filename: A string, the filename to load :return: A set, all relevant words in the file """ valid_words = set() with open(filename, 'r') as word_file: for...
c77766a42c2ad2c69e0dbb57ae284d8aa04f5a64
robinyms78/My-Portfolio
/Exercises/Python/Learning Python_5th Edition/Chapter 4_Introducing Python Object Types/Examples/Dictionaries/Nesting Revisited/Example1/Example1/Example1.py
375
4.46875
4
rec = {"name": {"first": "Bob", "last": "Smith"}, "jobs": ["dev","mgr"], "age": 40.5} # "name" is a nested dictionary print(rec["name"]) # Index the nested dictionary print(rec["name"]["last"]) # "jobs" is a nested list print(rec["jobs"]) # Index the nested list print(rec["jobs"][-1]) # Expand Bob's job descripti...
6c90fd3eff161f94ff5a873d5d2f348ee9180a38
robinyms78/My-Portfolio
/Exercises/Python/Learning Python_5th Edition/Chapter 8_Lists & Dictionaries/Examples/List in action/Example2/Example2/Example2.py
329
4.0625
4
# Membership print(3 in [1,2,3]) # Iteration for x in [1,2,3]: print(x, end = " ") # List comprehension res = [c * 4 for c in "SPAM"] print(res) # List comprehension equivalent res = [] for c in "SPAM": res.append(c * 4) print(res) # Map a function across a sequence x = list(map(abs, [-1, -2, 0, 1, 2])) pr...
efc1dab7b8a7d6fc1aa3fc9eb8f6dc41e313f49b
robinyms78/My-Portfolio
/Exercises/Python/Learning Python_5th Edition/Chapter 9_Tuples, Files & Everything Else/Examples/Built-in Type/Assignment/EG2/EG2/EG2.py
139
3.828125
4
L = [1, 2, 3] # Embed a copy of L (or list(L), or L.copy()) # Changes only L, not M M = ["X", L[:], "Y"] L[1] = 0 print(L) print(M)
7b91ad7f8e1a0b0e1d1a16c496dd31801febf2e2
robinyms78/My-Portfolio
/Exercises/Python/Learning Python_5th Edition/Chapter 5_Numeric Types/Examples/Other Numeric Types/Decimals/Example2/Example2/Example2.py
250
3.78125
4
from decimal import Decimal print(Decimal("0.1") + Decimal("0.1") + Decimal("0.1") - Decimal("0.3")) print(Decimal("0.1") + Decimal("0.10") + Decimal("0.10") - Decimal("0.30")) print(Decimal(0.1) + Decimal(0.1) + Decimal(0.1) - Decimal(0.3))
c8dcd1b123c5e001c6b7f97f75147a172ac5f1f9
robinyms78/My-Portfolio
/Exercises/Python/Learning Python_5th Edition/Chapter 7_String Fundamentals/Examples/Strings in Action/Changing Strings/Example1/Example1/Example1.py
346
3.828125
4
S = "spam" # Raises an error #S[0] = "x" # To change a string, make a new one S = S + "SPAM!" print(S) S = S[:4] + "Burger" + S[-1] print(S) # Replace method S = "splot" S = S.replace("pl", "pamal") print(S) # Format expression print("That is %d %s bird!" %(1, "dead")) # Format method print("That is {0} {1} bir...
3f18a36edc85ef280dd675fa34d760c1a8b41a4b
robinyms78/My-Portfolio
/Exercises/Python/Learning Python_5th Edition/Chapter 5_Numeric Types/Examples/Other Numeric Types/Fractions/Example2/Example2/Example2.py
124
3.5625
4
from fractions import Fraction print(Fraction(".25")) print(Fraction("1.25")) print(Fraction(".25") + Fraction("1.25"))
a11af764de4b8d227f149f5c519e69492f003b4c
robinyms78/My-Portfolio
/Projects/Python/Machine Learning System/Unsupervised Learning/Test3/Test3/kMeans.py
2,527
3.5
4
import csv import numpy as np import matplotlib.pyplot as plt from sklearn.cluster import KMeans from sklearn import metrics def kMeans(): # Load data from input file input_file = "Sales_Transactions_Dataset_Weekly.csv" file_reader = csv.reader(open(input_file, "r"), delimiter=",") X = [] for coun...
ede91605b3fcca516a87ccc26e38557e441be649
robinyms78/My-Portfolio
/Exercises/Python/Learning Python_5th Edition/Chapter 13_while & for Loops/Examples/main/main/file_scanners.py
1,208
3.84375
4
class Files(): def example1(self): file = open("Test/test.txt", "r") # Let Python collect results print(file.read()) def example2(self): file = open("Test/test.txt") while True: char = file.read(1) # Read by character if not char: # Emp...
79019cf47f430191c888f17e00b7c18c01491ecb
robinyms78/My-Portfolio
/Exercises/Python/Learning Python_5th Edition/Chapter 11_Assignments, Expressions & Prints/Examples/main/main/expression_statements.py
538
3.9375
4
class Expression(): # Expression statements def example1(self): x = print("spam") # print is a function call expression in 3.X print("Example1\n") print(x) # But it is coded as an expression statement # Append is an in-place change def example2(self): ...
228429e5f02f48857fd664aad70c8844e17aa1bd
robinyms78/My-Portfolio
/Exercises/Python/Learning Python_5th Edition/Chapter 8_Lists & Dictionaries/Examples/Dictionaries/Dictionaries in Action/Dictionary Changes/EG1/EG1/EG1.py
632
4.09375
4
# Zip together keys and values L =list(zip(["a", "b", "c"], [1, 2, 3])) print(L) # Make a dict from zip result D = dict(zip(["a", "b", "c"], [1, 2, 3])) print(D) D = {k: v for (k,v) in zip(["a", "b", "c"], [1, 2, 3])} print(D) # Or: range(1,5) D = {x: x ** 2 for x in [1, 2, 3, 4]} print(D) D = {c.lower(): c + "!" ...
b33290275e92b990c6feee390ddf5d2944b58c53
robinyms78/My-Portfolio
/Exercises/Python/Learning Python_5th Edition/Chapter 4_Introducing Python Object Types/Examples/Dictionaries/Mapping Operations/Example2/Example2/Example2.py
113
3.90625
4
# Create keys by assignments D = {} D["name"] = "Bob" D["job"] = "dev" D["age"] = 40 print(D["name"]) print(D)
f82acca33c03dd34185463ed3b979144e52c2742
robinyms78/My-Portfolio
/Exercises/Python/Learning Python_5th Edition/Chapter 6_The Dynamic Typing Interlude/Examples/Shared References/Shared References/EG2/EG2/EG2.py
134
3.71875
4
L1 = [2,3,4] # Make a copy of L1(or list(L1), copy.copy(L1), etc) L2 = L1[:] L1[0] = 24 print(L1) # L2 is not changed print(L2)
2d56a2727c5a2e39ec4fcd660f4befae4101b265
robinyms78/My-Portfolio
/Exercises/Python/Learning Python_5th Edition/Chapter 9_Tuples, Files & Everything Else/Examples/Core Types Review/References vs Copies/EG1/EG1/EG1.py
158
4
4
# Embed references to X's object X = [1, 2, 3] L = ["a", X, "b"] D = {"x": X, "y": 2} # Changes all three references X[1] = "surprise" print(L) print(D)
f91aa47777579cbe88a72dd15daebb2323574bbb
robinyms78/My-Portfolio
/Exercises/Python/Learning Python_5th Edition/Chapter 9_Tuples, Files & Everything Else/Examples/Records Revisited/Example2/Example2/Example2.py
250
3.984375
4
# Dictionary record bob = dict(name = "Bob", age = 40.5, jobs = ["dev", "mgr"]) print(bob) # Access by key print(bob["name"], bob["jobs"]) # Values to tuple X = tuple(bob.values()) print(X) # Items to tuple list Y = list(bob.items()) print(Y)
a111bb35decaada627767cb32cf2e35a485a336c
robinyms78/My-Portfolio
/Exercises/Python/Learning Python_5th Edition/Chapter 14_Iterations & Comprehensions/Examples/main/main/list_comprehensions.py
3,189
3.90625
4
class Comprehensions(): def example1(self): print("\n") L = [1, 2, 3, 4, 5] for i in range(len(L)): L[i] += 10 print(L) def example2(self): print("\n") L = [1, 2, 3, 4, 5] L = [x + 10 for x in L] print(L) # List Comprehension Basi...
773b8414e48952f4146c4d05098ff8336216c42a
robinyms78/My-Portfolio
/Exercises/Python/Learning Python_5th Edition/Chapter 7_String Fundamentals/Examples/Strings in Action/Basic Operation/Example2/Example2/Example2.py
228
3.890625
4
myjob = "hacker" # Step through items, print each for c in myjob: print(c, end = " ") # Found print("k" in myjob) # Not found print("1" in myjob) # Substring search, no position returned print("spam" in "abcspamdef")
fcc80cff46c45edae35e4b7dc5b747e28a30c18b
robinyms78/My-Portfolio
/Exercises/Python/Learning Python_5th Edition/Chapter 7_String Fundamentals/Examples/Strings in Action/String Conversion/Example2/Example2/Example2.py
105
3.625
4
S = "42" I = 1 # S + I # Force addition print(int(S) + 1) # Force concatenation print(S + str(I))
74be36f513960917c33de2fe52aa31dfc207e8f9
eduardAndrei99/University
/Semester1/Fundamentals of Programming/laborator 3 FP/phy1.py
6,959
3.53125
4
""" Programul afiseaza cea mai lunga secventa Cu proprietatea ca in oricare 3 elemente consecutive Exista o valoare care se repeta Evident, lungimea listei trebuie sa fie un numar natural > 0 In cazul in care lungimea listei este 1, se va afisa el In cazul in care lungimea listei este 2, se vor afisa cele doua valori I...
35f6a60819b3cbd2593879cf1b85737ed3030aa6
Sophie521/Shiyanlouplus_python
/calculator002.py
2,360
3.578125
4
#!/usr/bin/env python3 ''' input : 工号1(num):工资金额(income)1 工号2(num):工资金额(income)2…… def :思路:1.税后工资 = 工资金额 - 各项社会保险 - 应纳税额(Tax_payable) 1.1 工资金额→输入的,直接获取,用sys.argv[ ] 1.2 各项社会保险(insurance)→0.165*工资金额 1.3 应纳税额 (tax_payable) = 应纳税所得额(taxable_income)× 税率 - 速算扣...
fa1b5cdf8b6ff4993dbf4b8b29f5746a8be6781c
OmarKaempfer/highway-billboard-dynamic-programming
/SampleGenerator.py
1,963
3.515625
4
import argparse from billboard_problem.HighwaySampleGenerator import HighwaySampleGenerator from billboard_problem.HighwaySampleReader import HighwaySampleReader def main(): parse_args() exit(0) def parse_args(): parser = argparse.ArgumentParser() parser.add_argument("file_path", help="The path of ...
a46f8fe1a60adcdc5d19bcf8236bd0bb65f0b4b3
GeekSchool-Alexander/python_group_3
/methodologies/tic-tac-toe.py
2,878
3.96875
4
import random PLAYER_ICON = "" BOT_ICON = "" def instruction(): print("Welcome to GeekSchool TicTacToe!") print("Cells are numbered as follows:") brd_front = \ """------- |0|1|2| ------- |3|4|5| ------- |6|7|8| -------""" print(brd_front) def choose_icon(): global PLAYER_ICON, BOT_ICON while True: choose...
fbabe356111641eee0ebe5e9472bc0e9bfb15f00
GeekSchool-Alexander/python_group_3
/homework/homework5.1.py
317
3.828125
4
sumator = 0 continue_flag = True while continue_flag: inputed_number = int(input("Введите число: ")) if inputed_number >= 0: sumator += inputed_number print("Текущее значение счетчика: ", sumator) else: continue_flag = False print("Программа завершена.")
9050b5d8a9ad46ef48ff61ba61a407574b3b348d
HugoGustavo/Python
/strings.py
5,542
4.28125
4
#from string import maketrans; var1 = 'Hello World!'; var2 = "Python Programming"; print("var1[0]: ", var1[0]); print("var2[1:5]: ", var2[1:5]); print(); print("Updated String :- ", var1[:6] + "Python"); print(); a = "Hello"; print(a[1:4]); print(); print('My name is %s and weight is %d kg!' % ('Zara', 21)); print...
c500f18a487d7d06c4a905562901af582025cd58
johnelliott/learntoprogram
/exercises/week5/q6.py
1,542
3.796875
4
def while_version(L): """ (list of number) -> number >>> while_version([1, 3, 2, 3]) 4 """ i = 0 total = 0 while i < len(L) and L[i] % 2 != 0: total = total + L[i] i = i + 1 return total def for_version1(L): """ (list of number) -> number ...
1f9d1f6a8c5d0500b052dd08fa50e78e0f39e6a5
johnelliott/learntoprogram
/assignments/assignment3/test.py
149
3.734375
4
## is_valid_word wordlist = ['ANT', 'BOX', 'SOB', 'TO'] word = 'TO' for word in wordlist: return word == wordlist[word] return false
0aae712807e717a27c8d290a10039a59b60bf722
johnelliott/learntoprogram
/exercises/week6/q13.py
570
3.78125
4
def write_to_file(file, sentences): """ (file open for writing, list of str) -> NoneType Write each sentence from sentences to file, one per line. Precondition: the sentences contain no newlines. """ # CODE MISSING HERE #fail# for s in sentences: ## file.write(s) ## file.w...
2d619a672d31758a8ca00d86893f908b756d9a6f
dineshkumarkummara/my-basic-programs-in-java-and-python
/folders/python/instagram/21tuplevslist.py
110
3.515625
4
A=[1,2,3,4,5,6] #[]----list B=1,2,3,4,5,6 #() or without braces ----tuple print(type(A)) print(type(B))
48ddf1f9d923a38d11ad02654aff29cc454a4367
dineshkumarkummara/my-basic-programs-in-java-and-python
/folders/python/javatpoint/quadratic.py
204
3.71875
4
import cmath a=(float(input("enter a: "))) b=(float(input("enter b: "))) c=(float(input("enter c: "))) d=(b**2-(4*a*c)) print(d) x=(-b+cmath.sqrt(d)/(2*a)) y=(-b-cmath.sqrt(d)/(2*a)) print(x) print(y)
659100441ef04f781e771180a2272d00cb8286a8
dineshkumarkummara/my-basic-programs-in-java-and-python
/folders/python/geeksforgeeks/lists/dupplicates.py
429
3.71875
4
def Repeat(x): size = len(x) #13 repeated = [] for i in range(size): #0 in 13 k = i + 1 #0+1 for j in range(k, size): #1 in 1,13 if x[i] == x[j] and x[i] not in repeated: #10 == 20 and 10 not in repeated.append(x[i]) return repeated # Driver Code...
efab02a71633660bb62f137cadb9587444e14405
dineshkumarkummara/my-basic-programs-in-java-and-python
/folders/python/instagram/64lambda.py
288
4.03125
4
#Lambdas (or inline functions) are very handy if the function body is short and simple. #You don't need to create a full function using the "def" keyword. #Use "lambda" instead, followed by the argument and the function body. sqr=lambda x:x**2 for i in range(1,4): print(sqr(i))
9f45c3b01c6280f17960939be2a173d5ea7c14a7
dineshkumarkummara/my-basic-programs-in-java-and-python
/folders/python/geeksforgeeks/lists/even.py
177
3.6875
4
l=[1,2,3,4,5,6,7,8,9,10] odds=list(filter(lambda x:(x%2!=0),l)) print(odds) for x in l: if(x%2!=0): print(x) elif (x%2==0): print("even numbers are",x)
5cc139c20c6e66120f9ccf8043685b18034eea84
dineshkumarkummara/my-basic-programs-in-java-and-python
/folders/python/datascience/file1_Day6.py
348
3.75
4
#Example 1 ''' a=10 if ( a == 10 ): print ("True") else: print ("False") ''' #Example 2 ''' a=[1,2,3,4,5] if 10 in a: print ("Existing") else: print ("Not Existing") ''' #Example 3 ''' usr=int(input("Enter the input")) username=[123,256,526] if usr in username: print ("Access Approved") else: p...
4a2accd4718deb3abc990330b625bfbce01c229b
dineshkumarkummara/my-basic-programs-in-java-and-python
/folders/python/others/armstrong.py
310
3.5625
4
n=int(input("enter any number:")) #153 a=[int(x) for x in str(n)] #[1,5,3] sum=0 i=list(map(lambda y:pow(y,len(a)),a)) #[1,125,27] for j in i: sum+=j print("armstrong number" if n==sum else "not armstrong")
461fdf8ec3a0c44f068c802e51eff664a205dc27
dineshkumarkummara/my-basic-programs-in-java-and-python
/folders/python/instagram/45while_else.py
295
4.53125
5
#In Python, you can add the "else" block after a "while" loop. # It will be executed after the loop is over. x=3 while x<=5: #change the condition to check different outputs print(x) x+=1 #if the condition is false then else statement will be executed else: print("done")
131fea2d621c3a61c365d6794793cd4ba30ba951
dineshkumarkummara/my-basic-programs-in-java-and-python
/folders/python/others/fun2.py
605
4.4375
4
def fun(*args): for i in args: print(i) args=1,2,3,4,5,6 fun(*args) #or print("----------") fun(7,8,9) #You can't provide a default for args, for example func(*args=[1,2,3]) will raise a syntax error (won't evencompile). # You can't provide these by name when calling the function, for example func(*args=...
a516c8d763aad72944dd59d8395b06a9aa1b56b6
dineshkumarkummara/my-basic-programs-in-java-and-python
/folders/python/javatpoint/factorial.py
254
4.15625
4
n=int(input("enter any number:")) factorial=1 if n<0: print("number can not be negative") elif n==0: print("the factorial of 0 is 1") else: for i in range(1,n+1): factorial*=i print("the factorial of" , n ,"is" ,factorial, "." )
40f4d5fec907a9d3cd75e03ebb3ce499dd2358b3
dineshkumarkummara/my-basic-programs-in-java-and-python
/folders/python/geeksforgeeks/lists/rangenumbers.py
181
4.0625
4
n=int(input("enter upper range")) m=int(input("enter lower range")) for x in range(m,n+1): if x>=0: print("positives are:",x) else: print("negatives are:",x)
f55f357a40eb69340520e99a21a27ee50477d37d
walterpcasas/icpc
/uri/banknotes_and_coins.py
492
3.890625
4
from decimal import Decimal notes = [100,50,20,10,5,2] coins = [1,0.5,0.25,0.1,0.05, 0.01] valor = Decimal(input()) print("NOTAS:") for note in notes: cant = int(valor//note) valor = valor-(cant*note) print("{} nota(s) de R$ {:.2f}".format(cant, note)) valor *= 100 print("MOEDAS:") for coin in coin...
9d3df23d72b2a991c1ec4e0a5e8ac03c5411ee1f
yangshimin/matplotlib_study
/2.figure 图像.py
748
3.8125
4
# !/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2020/11/19 # @Author : YangShiMin # @Email : fausty@synnex.com # @File : figure 图像.py # @Software: PyCharm import matplotlib.pyplot as plt import numpy as np """定义不同的figure窗口""" x = np.linspace(-3, 3, 50) y1 = 2 * x + 1 y2 = x**2 # 定义一个figure, num=1表明这个窗口...
5383eebbb8a2cd73361c1cdec7b92db29ec6dfb6
Nushooz/Public
/ProjectEuler/euler4.py
1,609
3.90625
4
#!/usr/bin/python ''' Created on Jul 3, 2014 @author: Mark Kaiser ''' def isPalindrome(product): test = str(product) firsthalf = '' secondhalf = '' even = False if len(str(product)) % 2 == 0: #length is even, no middle digit firsthalf, secondhalf = test[:len(test)/2], test[len(test)/2:] ...
56c5ebb22529a3d41579b23d10ecf3ffbba0a464
Aman123-stack/hacktober
/py_projects/gui_temperature_prediction/temperature.py
1,929
3.59375
4
# -*- coding: utf-8 -*- """ Created on Fri Sep 4 13:32:55 2020 @author: DELL """ import requests from tkinter import * import tkinter as tk def weather(): city_name=entry.get() api_key = "dea5a2217c08125e1395555a7c9cf8e3" base_url="http://api.openweathermap.org/data/2.5/weather?" comp...
63e1287f0ce51be9e369721e3d701c4825272beb
markdisler/Advent-of-Code-2017
/Day12-1.py
639
3.734375
4
def path_exists(start_id, goal_id, program_dict, seen): if start_id in seen: return False seen.append(start_id) if start_id == goal_id: return True for a in program_dict[start_id]: if path_exists(a, goal_id, program_dict, seen): return True return False program_associates = dict() line = input() while...
d3ec9f8db3eceae68a3392d8de84c8acd9155de2
muskanmahajan486/communication-error-checksum
/parity/index.py
409
4.40625
4
# Python3 code to get parity. # Function to get parity of number n. # It returns 1 if n has odd parity, # and returns 0 if n has even parity def getParity( n ): parity = 0 while n: parity = ~parity n = n & (n - 1) return parity # Driver program to test getParity(...
63021f4c2476a97e2ced0cca07eb0e18104ea599
yashie2011/REDIS_node
/func_test.py
2,979
3.5
4
import redis_server import argparse rs = {} # a dictionary to store redis serevr objects reliability_lev = 5 def bringUP(N, capacity, reliabilityLevel, port): #starts up somenodes with cap, and rel level global reliability_lev for i in range(0,N): redis_s = redis_server.redis_node() ret = redis_s.start_server...
bcf8ea213bfbeac3de340289c93f0eb206ba2c59
Nosnitrous1/python_training
/percents.py
288
3.703125
4
def percents(x, y): """ Определение процента x от y""" oneprc = x/100 result = y/oneprc return int(result) def print_prc(x, y): print(str(y) + " составляет " + str(percents(x, y))+" процентов от "+ str(y)) print_prc(200,50)
b10d2b9e0561c0cd7ce8bb2ba7086047f24bf6fc
jimongit/codewars
/solutions/Where_my_anagrams_at.py
159
3.734375
4
def anagrams(word, words): s_word=sorted(word) lst=[] for i in words: if(sorted(i)==s_word): lst.append(i) return lst
24aeecc9ea07d499070935c617c12ec050015019
jimongit/codewars
/solutions/Break_camelCase.py
135
3.5
4
def solution(s): s_tmp = '' for i in s: if(i.isupper()):s_tmp+=" " +i else:s_tmp+=i return s_tmp
d451806c1c993ace4ff5194d7257d1ca93460afe
StefanBratovanov/PythonCourse
/Lecture2/Task3_Initials.py
356
3.875
4
inputStr = input("Въведете име: ") if inputStr != "": name_parts = inputStr.split() print("Инициали:", end=" ") for part in name_parts: if part[0].islower(): continue print(part[0:1], end=".") else: print("Моля, въведете име с дължина поне един символ")
4ec62756ea67adec98aeaf51b03fae23978353e6
StefanBratovanov/PythonCourse
/Lecture_1/test7new.py
536
3.734375
4
import turtle side = 20 for j in range(8): for i in range(8): if (i % 2 == 0 and j % 2 == 0) or (i % 2 == 1 and j % 2 == 1): turtle.begin_fill() turtle.forward(side) turtle.left(90) turtle.forward(side) turtle.left(90) turtle.forward(side) turtle....
bebdc05d36ea9d43572cb7aa6c26615e0fda836b
StefanBratovanov/PythonCourse
/Lecture9_HTTP/weather_forecast.py
1,043
3.6875
4
import requests from datetime import datetime, timezone city = input('Въведете град: ') print('Обработваме заявката...') appid = '965acdac1ae64cf06761bb563ad34d96' resp = requests.get('http://api.openweathermap.org/data/2.5/weather', params={'q': city, 'appid': appid}) weather_info = resp.json() print(weather_info) d...
406745a118631e18927bf000d650ea4b461aab9e
adihacks/recon-webapp
/4rd broken link checker.py
927
3.78125
4
broke link check # Import libraries from bs4 import BeautifulSoup, SoupStrainer import requests # Prompt user to enter the URL url = input("Enter your url: ") # Make a request to get the URL page = requests.get(url) # Get the response code of given URL response_code = str(page.status_code) # Display the text of ...
8d7cce1a09174565dcbc11612bf0451b54df19c8
kdsjfl/aspen.py
/aspen/http/mapping.py
2,559
3.65625
4
NO_DEFAULT = object() class Mapping(dict): """Base class for HTTP mappings. Mappings in HTTP differ from Python dictionaries in that they may have one or more values. This dictionary subclass maintains a list of values for each key. However, access semantics are asymmetric: subscript assignment c...
f3948a1c8ae9400054a33a4140d1204d635c3147
nackwon/Python_Practice01
/practice07.py
407
3.671875
4
number = input("숫자를 입력하세요. : ") sum = 0 def check_number(number): try: int(number) return True except ValueError: return print("숫자가 아닙니다.") def start(n): if n % 2 == 0: return 2 elif n % 2 == 1: return 1 if check_number(number): n = int(number) for i in...
66fa14d2fe3faa1a45ff9910861333e246487a68
jay-aye-see-kay/aoc2018
/08/main.py
1,062
3.59375
4
data = open("data.txt") for line in data: tree = [int(l) for l in line.split(" ")] def walk(index, tree, count): num_children = tree[index] index+=1 num_metadata = tree[index] index+=1 for _ in range(0, num_children): count, index = walk(index, tree, count) for _ in range(0, num_met...
706f75c1b7da25049bdc240b0620b8303fcc8e72
rahulcode22/Data-structures
/Arrays/BubbleSort.py
583
4.4375
4
''' Bubble sort is a example of sorting algorithm . In this method we at first compare the data element in the first position with the second position and arrange them in desired order.Then we compare the data element with with third data element and arrange them in desired order. The same process continuous until the ...
709312e9a2f50148b6393f5adc5bb9c59d722fb8
rahulcode22/Data-structures
/Two Pointers/RemoveElements.py
660
4.1875
4
''' Given an array and a value, remove all the instances of that value in the array. Also return the number of elements left in the array after the operation. It does not matter what is left beyond the expected length. Example: If array A is [4, 1, 1, 2, 1, 3] and value elem is 1, then new length is 3, and A is now [4...
8b48bfc5eea768dd9049ca74ca6528c3f4de80b6
rahulcode22/Data-structures
/Math/excel-column-number.py
449
4
4
# Time: O(n) # Space: O(1) # Related to question Excel Sheet Column Title # # Given a column title as appear in an Excel sheet, return its corresponding column number. # # For example: # # A -> 1 # B -> 2 # C -> 3 # ... # Z -> 26 # AA -> 27 # AB -> 28 def titleToNumber(num): res = 0 ...
808295319a6da78f0aeae112905c970aad0f7ea3
rahulcode22/Data-structures
/Dynamic-Programming/LongestCommonSubsequence.py
787
3.59375
4
#Recursive Approach def lcs(s1, s2): m = len(s1) n = len(s2) if m == 0 or n ==0 : return 0 elif s1[m-1] == s2[n-2]: return 1 + lcs(s1[:m-1], s2[:n-1]) else: return max(lcs(s1,s2[:n-1]), lcs(s1[:m-1],s2)) x = "AGGTAB" y = "GXTXAYB" print "Length of lcs is " , lcs(x, y) #Dyn...