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
5909012fe66ea5ecec140dec3bc796be7059bbf1
Fantendo2001/FORKERD---University-Stuffs
/CSC1001/hw/hw_1/q2.py
667
3.78125
4
def isPrime(x): # determine primality if x < 2 or type(x) != int: return False for num in range(2, int(x / 2)): if x % num == 0: return False return True def getNEmirps(n): x = 12 i = 0 while i != n: rev_x = int(str(x)[::-1]) # reversed number ...
6d37230e6bf85c711e5a3a4ded00b896f3e53061
Noah6544/MAD-MEAN-Calculator
/main.py
12,803
3.546875
4
#IMPORTS from termcolor import colored,cprint import time import statistics from statistics import mode import random #VARIABLES twenty = (colored("~~~~~~~~~~~~~~~~~~~~","yellow")) yes = ("yes", "YES", "Yes", "yEs", "yeS","YEs", "YeS", "YEs", "YeS", "YeS", "yES", "Y", "y") no = ("no", "No", "NO", "nO", "N", "n") VALUE...
90dc533e7acee73be7627c125f6e8cafcef73a29
Mengjiao926/Network-Analysis-of-Titanic-Facebook-Page
/Json-Pajek/Code for answers.py
1,155
3.734375
4
import networkx as net import matplotlib.pyplot as plt g = net.read_pajek('chenchupajek.net') print("Find the number of nodes in the graph?") print ("Nodes: ",len(g)) print("Find the number of components (connected subgraphs)?") print ("Number of components (Connected Subgraphs): ",len(list(net.connected_component_sub...
b0b82289495eb50db5191c439cf4f5aa2589c839
karreshivalingam/movie-booking-project
/movie ticket final.py
2,810
4.125
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: global f f = 0 #this t_movie function is used to select movie name def t_movie(): global f f = f+1 print("which movie do you want to watch?") print("1,Acharya ") print("2,vakeel saab ") print("3,chicchore") print("4,back") movie = int...
9b6bb00642326359bb31f2456c7f872373c728d5
RyanLewisJr/Python-LinkList
/LinkList1.py
2,929
3.890625
4
class LNode: def __init__(self, elem=None, next_=None): self.elem = elem self.next = next_ def append(elem): node = LNode(elem) class LinkList: def __init__(self): self.head = LNode() self.tail = None self.length = 0 def is_empty(self): return self.le...
e4b52dcab27d3a23a8f3e64abcfd6fda6e61b4f4
wlsdntyd/TIL
/python/various/testA/testst.py
63
3.5
4
a = {'a' : 1, 'b' : 2, 'c' : 3} print("".join(list(a.keys())))
047b666a20c02c0e4a378e4d5b18b80bc3894038
dstuerzer/csplsh
/rsa.py
1,638
3.578125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Apr 6 10:24:21 2018 @author: dominik """ from numpy import random as rd import numpy as np from random import randint from math import gcd def isPrime(n, k=10): # miller-rabin if n < 2: return False for p in [2,3,5,7,11,13,17,19,23,29]: ...
bc6f26dbd39e144ec2faa34ab7ee99d9a6da82d3
drda3x/teacher_book3
/application/utils/phones.py
365
3.515625
4
# -*- coding:utf-8 -*- def get_string_val(num): _n = str(num) return '+%s(%s)%s-%s-%s' % (_n[0], _n[1:4], _n[4:7], _n[7:9], _n[9:]) if len(_n) > 1 else '' def check_phone(_val): import re val = str(_val) res = re.sub('[^\w]', '', val) res = re.sub('^8', '7', res) res = ('7' if not re.sea...
fccccc340560abbb9cbaf07bee43839f5d2716e1
meenapandey500/Python_program
/ex6.py
642
4.09375
4
#wap to store name and mobile no. of employee but mobile does not less than or greater than #10 , exact 10 digit name=input("Enter Name of Employee : ") while(True): mobile=int(input("Enter Mobile No. : ")) mobile=str(mobile) #to converts int value to string value x=len(mobile) #len() to find the no. ...
3027f3d2a75a6fad46548ad001b2589aad5c5612
meenapandey500/Python_program
/program/dict.py
371
4.53125
5
#create a dictionary student={"rollno":110 ,"name" : "Anu Agrawal","Age":23,"City":"Mumbai"} print("Type of student :",type(student)) #Loop through a Dictionary student print("Keys are : ") for x in student: #only access key of dictionary stduent print(x) print("Values are : ") for x in student.values(): ...
9d637b25ff06311053039fbe2ed209875b8cedc4
meenapandey500/Python_program
/assert4.py
165
3.625
4
try: num=int(input('Enter a number: ')) assert(num >=0), "Only positive numbers accepted." print(num) except AssertionError as msg: print(msg)
db5a0e56f4fdc2bbef0b59992339459162d9ba32
meenapandey500/Python_program
/program9-11/assert1.py
107
3.890625
4
#Assertion age=int(input("enter Age : ")) assert age>18,"Age must be entered >18." print("Age : ",age)
4425a577f999deaa1e5cfc86c7a4feaf0e2b40ae
meenapandey500/Python_program
/program/excep2.py
419
3.75
4
def division(a,b): #USer defined function, passing argument but no return value try: c=((a+b)/(a-b)) except Exception as e: #Exception inbuilt error class this is general error class print(e) print("divide by zero error") else: print("Answer : ",c) #main program a=...
f2dd516208246405b8317fe8b0d6ac1144b87be6
meenapandey500/Python_program
/program9-11/select_enroll.py
750
3.6875
4
#To display particular record from table according to enroll #Call library pymysql import pymysql #to create a connection string (between python and mysqlserver) servername="localhost" username="root" password="" dbname="college1" try: con=pymysql.connect(servername,username,password,dbname) except: ...
f8d0bca1206285069f554df2fd678859dbdff8de
meenapandey500/Python_program
/readline_file1.py
398
4
4
#To open file in read mode try: t=open("content.txt","r") except FileNotFoundError: print("File not found ") else: print(t.readline()) #to show only first line means only one line print(t.readline()) #to show second line print(t.readline()) #to show third line print(t.readline()) #to s...
62f00bee8fa502f4025c07c108ca66304417a1c2
meenapandey500/Python_program
/multilevel_inh1.py
970
4.5
4
#example of multiLevel inheritance class A: #base class def __init__(self): self.__x=int(input("Enter No. x : ")) def show_x(self): print("X=",self.__x) class B(A) : #here B derived class ans inherits base class A def __init__(self): super().__init__() #call constru...
71cab3c89a27a4f35eb3493b659af23728dfbf80
meenapandey500/Python_program
/filter.py
221
3.828125
4
#filter function with lambda function #suppose create list X=[12,15,17,20,44,56,77,97] #create a new list which hold odd no. from list x result=list(filter(lambda a : a%2!=0 ,X)) print("list of odd nos. : ",result)
4086398feb54ba8c1e4cc066b8f3d15cab847484
meenapandey500/Python_program
/program/dic_multiple.py
226
3.796875
4
#to hold multiple records means to hold record of multiple students in dictionary student={ "rollno" : [110,120,130,140,150],"name":["Nita","renu","any","lalita","menu"], "Age":[23,24,21,23,24]} print(student)
11d494fc074070f97bda24ceeec3f8217de6d678
meenapandey500/Python_program
/program/dic_compre.py
139
3.828125
4
#create a dictionary which hold the square of first 10 natural number d={x:x*x for x in range(1,11)} #dictionary comprehension print(d)
ba936b609635d3ca12d8bccc989961769ce263d4
meenapandey500/Python_program
/program/employees.py
889
3.890625
4
class Employee: def getdata(self): #getdata( ) user defined function #self is a instance variable means address of object self.empid=input("Enter Employee Id ") #empid local variable self.Ename=input("Enter Employee Name : ") self.age=int(input("Enter age : ")) self.sa...
c31091af418177da7206836e40939b51c8f5afa0
meenapandey500/Python_program
/asset.py
497
4.125
4
def KelvinToFahrenheit(Temperature): assert (Temperature >= 0),"Colder than absolute zero!" return ((Temperature-273)*1.8)+32 print(KelvinToFahrenheit(273)) print(int(KelvinToFahrenheit(505.78))) print(KelvinToFahrenheit(-5)) '''When it encounters an assert statement, Python evaluates the accompanying ex...
4fe1bc8e9270ea48a9588c4b0f9c7e3519c5c449
meenapandey500/Python_program
/program9-11/read4.py
152
3.515625
4
#WAP to read data line by line from file use for loop t=open("msg.txt","r") #to open file in read mode for line in t: print(line) t.close()
cb658fb5cd9d447415a50e0ad39436daae771d1c
meenapandey500/Python_program
/lst4.py
166
4
4
'''A=[2,3,4,5,6,7,8,9] #To create a list for x in A: print(x)''' A=[2,3,4,5,6,7,8,9] #To create a list c=len(A) for i in range(0,c,1): print(A[i])
0ae980fb75a5ee73f7c7923401440aeffa2ba7f3
meenapandey500/Python_program
/l1.py
232
3.8125
4
#create list '''a=[56,78,90,34.5,79,78,50,70] print("No. of elements in list : ") print(a) print(type(a)) print("sum of elements of list : ",sum(a)) print("Maximum elements from list : ",max(a)) print("Minimum " ,min(a))'''
c1013802d48787b6f3b7b1d3f39db2267dbae083
meenapandey500/Python_program
/program/list1.py
241
3.875
4
'''A=[10,20,30,40,50,60,70,80,90] print(A) print(A[0]) print(A[1]) print(A[2]) print(A[3]) print(A[4]) print(A[5]) print(A[6]) print(A[7]) print(A[8])''' A=[10,20,30,40,50,60,70,80,90] #use for loop for x in A: print(x)
0f7883e28be5654269449d492ec93aca67da69a6
meenapandey500/Python_program
/readline_file2.py
228
3.65625
4
#To open file in read mode and data read line by line use readline() try: t=open("content.txt","r") except FileNotFoundError: print("File not found ") else: for line in t: print(line) t.close()
a3c21e359a19bda5e1c5cd3757c70dfbc6190d8f
meenapandey500/Python_program
/program9-11/college_database.py
988
3.59375
4
#Call library pymysql import pymysql #to create a connection string (between python and mysqlserver) servername="localhost" username="root" password="" dbname="college1" try: con=pymysql.connect(servername,username,password,dbname) except: print("Connectivity Error") else: print("Connect success...
88b411bf0e015f29cbb0284a9cb645f3ee151cec
meenapandey500/Python_program
/glo.py
364
3.796875
4
#Example of local and global variable b=7 #global variable Its call any function in this file def addition() : a=4 #local variable , it will not call outside the function c=a+b print("sum=",c) def subtract( ): a=8 b=2 c=a+b print("suntract=",c) #main program addition( ) #...
882d2c3472802213860abae36c9ef9f0e8d65801
meenapandey500/Python_program
/mini_cal.py
448
4.28125
4
#Write a program to create a Mini Calculator a=float(input("Enter First Number = ")) b=float(input("Enter Second Number : ")) print("Sum of 2 Nos. : ",a," + ",b," = ",(a+b)) print("Subtract of 2 Nos. : ",a, " - ", b, " = " ,(a-b)) print("Multiply of 2 Nos. : ",(a*b)) print("Divide of 2 Nos. = ",(a/b)) ...
8bb780d88987eb4798ab95a09b2013617a992584
meenapandey500/Python_program
/dic2.py
377
3.96875
4
import sys #create dictionary for multiple students students={'Name':['Anu','Seema','pankaj','rohan'],'Age':[32,43,21,56],'City':['Bhopal','Indore', 'Delhi','Mumbai']} print(sys.getsizeof(students)) for x,y in students.items(): ...
9bba99297c2a1628645a3df57b0407a7aad1f954
meenapandey500/Python_program
/program/global.py
293
3.90625
4
a=10 #global variable def show(): global a print("value of a : ",a) a=a+3 print("After increment , value of a : ",a) def show1(): global a print("value of a : ",a) a=a*2 print(a) #main program #call function show() show1() #call print("a=",a)
9b5361a98b914d3675a545d3d9c7b6897bf4348f
meenapandey500/Python_program
/arms.py
150
4.0625
4
#WAP to check the given number is Armstrong number or not . n=int(input("Enter NUmber : ")) a=str(n) x=len(a) print("Number of Digit in n : ",x)
e768773a7ff2c138c08f96c7ed948a8039d0d634
meenapandey500/Python_program
/Revision/emp_private.py
581
3.765625
4
class Employee: def getdata(self): #self instance variable self.__Emp_no=101 #private variable self.__Emp_name="Meena Pandey" #private variable self.__Salary=67000 #private variable def display(self): print("Emp no :",self.__Emp_no) print("Emp Name : ",self.__Emp_...
c01f1ae280d10c9d4a54f44a5561895a70c9489a
meenapandey500/Python_program
/mini_calculator1.py
572
4.25
4
#write a program to create a mini calculator a=float(input("Enter First Number : ")) b=float(input("Enter Second Number : ")) print("press 1 for sum") print("press 2 for subtract") print("press 3 for multiply") print("press 4 for divide") choice=int(input("Enter your choice : ")) if(choice==1): c=a+b ...
6b216ca34205629d80ca698b39d197bf465f1540
meenapandey500/Python_program
/program/cir.py
168
4.09375
4
#default parameter def area(r,pi=3.14): return pi*r*r #main program r=int(input("Enter radius : ")) #call function ar=area(r) print("area of circle : ",ar)
27be7f550bc42f91c96a34fd325832231c34919c
Maxxidt/projet_python
/apifile.py
3,522
3.8125
4
import sqlite3 from tkinter import * class api : ########################################################################## #Name: best_score #Point: gives the user's score ########################################################################## def best_score(email): connectio...
95f60abdf925fa0171c7b2d869ebff3a01c028ba
whztt07/tpclient-ogre
/sandbox/tp/client/pyscheme/pogo.py
2,196
3.8125
4
"""'pogo' defines primitives to do trampolined-style programming.""" import traceback __license__ = "MIT License" def pogo(bouncer): """A trampoline that bounces a single bouncer. See: http://www.cs.indiana.edu/hyplan/sganz/publications/icfp99/paper.pdf """ try: while True: if ...
cff79b4aeaa380d682d99ab28e754bdee5c8b2c4
tiepngo/thinkcs
/c8/count_letters.py
287
3.9375
4
def count_letter_traversing(s,c) : """Count letter c in string s""" count = 0 for i in s: if i == c: count += 1 return count def print_count_letter(s,c): """Caller of count_letter""" print(count_letter(s,c)) print_count_letter("banana","a")
43d1db46f308950f46bfa1ca74b36693acefa09b
tiepngo/thinkcs
/c8/remove_all.py
336
3.53125
4
def remove_all(sub_s, s): """Remove all substring sub_s from string s""" return s.replace(sub_s,"") def test_remove_all(): assert remove_all("an", "banana") == "ba" assert remove_all("cyc", "bicycle") == "bile" assert remove_all("iss", "Mississippi") == "Mippi" assert remove_all("eggs", "bicycl...
3a581eeeb968d24c7fab00b7531d7ce909a8e453
zeinabmostafavi/pythoncourse_TAMRIN3
/5.py
196
4
4
num = int(input("Enter your number:")) i = 1 while (True): if (num % i == 0): num /= i else: break i += 1 if (num == 1): print("Yes") else: print("No")
7efe6be1cd45a1c55f7dcce8a59f82adfdfa8d4a
Juuune/Election_Analysis
/Pypoll_Challenge.py
5,284
4.0625
4
## The data we need to retrieve. # Total number of votes cast # A complete list of candidates who received votes # Total number of votes each candidate received # Percentage of votes each candidate won # The winner of the election based on popular vote # Open and read file #Import modules import csv import os # As...
91fdc438c5e6c96b3316e7e4afd1cacc06e0daf7
harshits2808/Project-Euler
/pe401.py
781
3.546875
4
mod = 1000000000 high = 1000000000000000 def sqsum(n): a = n b = n+1 c = 2*n+1 if(a%2==0): a = a//2 if(a%3 == 0): a = a//3 elif(b%3 == 0): b = b//3 elif(c%3 == 0): c = c//3 else: b = b//2 if(a%3 == ...
6090b2cbcf5aafe05c49efef15e0be1b24a1bcdd
waseemilahi/waseem
/Misc Languages/hangman/HANGMAN.PY
2,851
3.609375
4
import string from random import randint from time import time all_letters="ABCDEFGHIJKLMNOPQRSTUVWXYZ" class Word: def __init__(self,s): if type (s)!=type (""): TypeError, "Error!" self.s=string.upper(s) self.a=[0]*len(s) for i in range (0,len(self.s)): if self.s[i]not in all_letters: ...
182803c3fbabdc05d4db21adafc2a9800732c499
victor-lima-142/Exercicios-Logica-Programacao
/Estrutura de Decisao/Exercicio 2/ProdutoBarato.py
681
4.21875
4
''' Faça um programa que pergunte o preço de três produtos e informe qual produto você deve comprar, sabendo que a decisão é sempre pelo mais barato. ''' produto1 = float(input('Qual preço do produto 1?\n')) produto2 = float(input('Qual preço do produto 2?\n')) produto3 = float(input('Qual preço do produto 3?\n')) if...
e998456e7307f4cc817f6bdac3a3b09669f221c9
victor-lima-142/Exercicios-Logica-Programacao
/Estruturas Sequenciais/Exercicio 1/MultaPeixe.py
918
3.921875
4
''' João Papo-de-Pescador, homem de bem, comprou um microcomputador para controlar o rendimento diário de seu trabalho. Toda vez que ele traz um peso de peixes maior que o estabelecido pelo regulamento de pesca do estado de São Paulo(50 quilos) deve pagar uma multa de R$ 4, 00 por quilo excedente. João precisa que você...
9847bcc11fc8fb376684ec283eb6c13eabf4e44e
nengvang/s2012
/lectures/cylinder.py
957
4.375
4
# Things we need (should know) # # print # Display a blank line with an empty print statement # print # Display a single item on a separate line # print item # Display multiple items on a line with commas (,) separated by spaces # print item1, item2, item3 # print item, # # raw_input([prom...
d454c3fcc8ad38b0183f38cd1a110f6cd95658e3
nengvang/s2012
/lectures/cs140_20120209-strings.py
320
3.703125
4
"""Four score and seven years ago our fathers brought forth on this continent a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. """ age = '' while not age.isdigit(): age = raw_input('Please enter your age: ') age = int(age) print 'You are', age, 'years old.'
f2fa60142e163202bc06e95623be5743389a74d7
Tulika-A/Hackerrank
/CTCI/Hash Tables- Ransom Note/ransomNote.py
1,703
4.03125
4
''' Problem Description: A kidnapper wrote a ransom note but is worried it will be traced back to him through his handwriting. He found a magazine and wants to know if he can cut out whole words from it and use them to create an untraceable replica of his ransom note. The words in his note are case-sensitive and he mus...
fc98bfc7c1972bb875df316e2977cc21ef626d16
adrijab/Sample_Python_Mini_Projects
/Sample Mini Project_Guess the number.py
3,300
4.25
4
#Mini-project description — “Guess the number” game #One of the simplest two-player games is “Guess the number”. The first player thinks of a secret number in some known range while the second player attempts to guess the number. After each guess, the first player answers either “Higher”, “Lower” or “Correct!” dep...
cb08751a320d315409e21091b5578e0c3192e12b
tanmay97/lpfour
/dh.py
1,384
3.671875
4
# use Python 3 print function # this allows this code to run on python 2.x and 3.x # -*- coding: encoding -*- from __future__ import print_function # Variables Used sharedPrime = 23 sharedBase = 5 aliceSecret = 6 bobSecret = 15 # Begin print( "Publicly Shared Variables:") print( "Publicly Shared Prime: " , sharedPrime ...
578de93ccb0c029d5ada5b837358451bc4612faa
stechermichal/codewars-solutions-python
/7_kyu/printer_errors_7_kyu.py
1,260
4.28125
4
"""In a factory a printer prints labels for boxes. For one kind of boxes the printer has to use colors which, for the sake of simplicity, are named with letters from a to m. The colors used by the printer are recorded in a control string. For example a "good" control string would be aaabbbbhaijjjm meaning that the p...
954696eccde542040c6abd120b33878fead05e65
stechermichal/codewars-solutions-python
/5_kyu/simple_pig_latin_5_kyu.py
453
4.3125
4
"""Move the first letter of each word to the end of it, then add "ay" to the end of the word. Leave punctuation marks untouched. Examples pig_it('Pig latin is cool') # igPay atinlay siay oolcay pig_it('Hello world !') # elloHay orldway !""" def pig_it(text): text_list = text.split() for i, value in enume...
4dcf3b27da3c70aa873fc402970a94b830a71528
stechermichal/codewars-solutions-python
/8_kyu/fake_binary_8_kyu.py
341
3.890625
4
"""Given a string of digits, you should replace any digit below 5 with '0' and any digit 5 and above with '1'. Return the resulting string.""" def fake_bin(x): x = [int(i) for i in x] for i, value in enumerate(x): if value < 5: x[i] = 0 else: x[i] = 1 return ''.join...
9d2fea9493ec44770c5c125d238a40f975c0193d
RFishwick/Python
/SearchText.py
1,046
3.953125
4
# Search for Words in a Text File import WordFinder # Begin Main Program file_i = open('theMessage.txt', 'r') # Open Input file for reading my_text = list(file_i) # Read file into string myText file_i.close() # Close input file # Print lines that contain the selected word # lineCnt = 0 # for line in my_text: # ...
e7f9f70e28903ecc2b8ab556a3ca2ba9ea33b2e6
RFishwick/Python
/Old/PrintFormatting.py
176
3.734375
4
#Print Formatting print('This is a string') print('Floating point numbers: %25.2f' %(13.144)) print('Object 1: {a}, Object 2: {b}, Object 3: {c}'.format(a=1,b='two',c=12.3))
3f5baa1f6cdbc6d10196eea25ab560e504411fea
TarunPrem/PRO-C111-SINGLE-SAMPLE-Z-TESTS
/PROJECT_C-111-main/sample.py
1,244
3.78125
4
import csv import random from numpy import average import pandas as pd import plotly.express as px import plotly.graph_objects as go import plotly.figure_factory as ff import statistics df = pd.read_csv("average.csv") data = df["average"].tolist() dataset = [] #FUNCTION TO GET THE MEAN OF GIVEN DATA SAMP...
951f28ce0923f376dbbd3f48f053bf50735f3470
Retsediv/NYT_course_project
/modules/article/nyt_article.py
903
3.953125
4
class Article: """ ADT which represent article from NYT""" def __init__(self, pub_date, headline, keywords): """ Create new instance :param string pub_date: :param dict headline: :param list keywords: """ self._pub_date = pub_date self._headline ...
cf5ab960485bc12e4357508400eccf513ff680de
AnnaSamoylova/python-chat
/1_2.py
355
3.71875
4
# Найти заданное число в матрице mat = [[15,20,40,85],[20,35,80,95],[30,55,95,105],[40,80,100,120]] x=55 c=0 while c==0: for str in mat: for elem in str: if elem == x: print ('Найдено число ', x) c=1 break if c==0: print ('Числа ',x,' нет в матрице') c=1
02e23e7773a0d35b7e564f5856805e69284c873d
NickLc/Python
/Random/Random.py
715
3.515625
4
# -*- coding: utf-8 -*- import random """ Created on Sat Dec 22 19:18:10 2018 Paquete Random @author: ADMIN """ random.random() #Random float x, 0.0 <= x < 1.0 help(random.random) random.uniform(1, 25) #Random float x, 1.0 <= x < 25.0 help(random.uniform) random.randint(5, 15) #Integer(entero) x, 5<=...
6a5c2c756a91b654b8931caf1cba4378c9cb2a9f
dhairyachandra/DS-Python
/Quick_sort_Python.py
569
3.703125
4
# Partitioning Function def partition (arr,low,high): pivot=arr[high] i=low-1 for j in range (low,high): if arr[j]<=pivot: i=i+1 temp=arr[i] arr[i]=arr[j] arr[j]=temp temp=arr[i+1] arr[i+1]=arr[high] arr[high]=temp return i+1 def qui...
812554dbd93e63efa2c0535cd6341aadc0ab0406
NiteshPidiparars/Python-Tutorials
/ElseWithForLoops.py
296
3.75
4
# for x in n: # #statements # else: # #statements for i in ['C', 'O', 'D', 'E']: print(i) else: print("Statement successfully executed") khana = ["roti", "Sabzi", "chawal"] for item in khana: if item == "rotiroll": break else: print("Your item was not found")
9015fd846d824a596b3ca4bf4d87b838fdbc72c0
NiteshPidiparars/Python-Tutorials
/Polymorphism.py
183
3.734375
4
len("Python") # returns 6 as result len([1, 2, 3, 4, 5, 6, 7, 8, 9]) # returns 9 as result print(5+6) print("5" + "6") # Abstraction # Encapsulation # Inheritance # Polymorphism
c062245d21b75405560e771c16b1811bd17d76b8
NiteshPidiparars/Python-Tutorials
/PracticalProblem/problem4.py
1,081
4.3125
4
''' Problem Statement:- A palindrome is a string that, when reversed, is equal to itself. Example of the palindrome includes: 676, 616, mom, 100001. You have to take a number as an input from the user. You have to find the next palindrome corresponding to that number. Your first input should be the number of test cas...
02c738be61629a90a69afd80408a3af4c781bdd9
NiteshPidiparars/Python-Tutorials
/FunctionCaching.py
574
3.578125
4
from functools import lru_cache import time @lru_cache(maxsize=4) def myfunc(x): time.sleep(2) return x myfunc(1) # myfunc(1) takes 2 seconds and results for myfunc(1) are now cached myfunc(1) myfunc(2) myfunc(3) myfunc(4) myfunc(5) @lru_cache(maxsize=32) def some_work(n): # Some task taking n seconds...
ee4d05468717b59100f5a23a4af2e2b324c37446
dpritsos/synergeticprocessing
/synergeticprocessing/experimental/test_eventlet.py
3,504
3.59375
4
""" FROM EVENLET DEMOS: This is a simple web "crawler" that fetches a bunch of urls using a pool to control the number of outbound connections. It has as many simultaneously open connections as coroutines in the pool. The prints in the body of the fetch function are there to demonstrate that the requests are truly ...
4dbaa675cc7b8c09002af4d64a298b1329334dd1
HYEALL/Hello
/project/untitled2/project2-1.py
131
3.578125
4
a = 'My naMe is Son Chang Ha: my pin is 000125-3!!!!!!.' a = a.replace(":",",") b = a.split(" ") c = " ".join(b) print(c)
f365ca23dba3a24291c3672fea8652e90dfbeac6
EmanuelFontalba/ArkanoidPython
/Arkanoid/escenas.py
4,314
3.546875
4
#/usr/bin/env python # -*- coding: utf-8 -*- """Emanuel Galván Fontalba""" import pygame as p from comun import WIDTH, HEIGHT, PANTALLA, cargar_imagen, Texto from objetos import Jugador, Muro, Pelota from g_escenas import Escena class EscenaJuego(Escena): "Clase que define la escena principal del videojuego." ...
ff232f675bb82ddc4caa694ecf6f65d315344a96
AymoneKouame/Project
/CleanSentences.py
1,220
3.703125
4
#cleanses at the sentence-level import re import nltk from nltk.corpus import stopwords from nltk.corpus import words import string from string import punctuation from stop_words import get_stop_words #stop_words = get_stop_words('en') rwords = set(words.words()) mystopwords = [set(stopwords.words('english')),get_s...
b5e59ae88dabef206e1ca8eba2a3029d5e71d632
phriscage/coding_algorithms
/factorial/factorial.py
889
4.46875
4
#!/usr/bin/python2.7 """ return a factorial from a given number """ import sys import math def get_factorial(number): """ iterate over a given number and return the factorial Args: number (int): number integer Returns: factorial (int) """ factorial = 1 for n in range(int(numbe...
460e8b9a4d5057f068a3345b2c4c2cc52ed1bfac
phriscage/coding_algorithms
/string_search/string_search.py
1,874
4.0625
4
""" Developer: Chris Page Date: 2014-04-28 Purpose: Given a pattern and a string, find all occurances of that pattern in the string. """ import re def _check_params(pattern, unknown): """ check the parameters are valid """ try: pattern = str(pattern) unknown = str(unknown) ...
813eeb060cdc815df3faa06cd38568ef882e9815
kapunska/muhabbet
/sandbox.py
976
4.09375
4
height = int(input("enter the sandbox height: ")) width = int(input("enter the sandbox width: ")) #creates the matrix with the given height and width. Matrix = [[0 for i in range(width)] for j in range(height)] #gets the matrix inputs from the user. for i in range(height): for j in range(width): print...
9c72c441b055bd842d6925434b46929a3ead28f2
utjug/dz
/matrix_09.2020/matrixplus.py
370
3.671875
4
a=[] for i in range(3): a.append([]) for j in range(3): a[i].append(int(input("ch"))) print("a=",a) b=[] for g in range(3): b.append([]) for k in range(3): b[g].append(int(input("ch"))) print("b=",b) c=[] for l in range(3): c.append([]) for n in range(3): c[l].append(0) for i in range(3): for j in ...
e89900268a534abbed85981793625646b9c7d096
aiswaryavg/curly
/find.py
212
3.984375
4
sentence=input("Enter the string:") word=input("ENter a word to search:") if sentence.find(word) !=-1: print(word,"is Present in",sentence) b=sentence.count(word) print(b,"times") else: print("not present")
e9d0920f010c7da523bb92f05dd8825ecca6e48b
chichao89/FS104_CC
/Linkedln/gcd.py
304
3.6875
4
#Eucidln Algorithm # where 2 integers a and b where a > b, divide A by b , if the remainder r, 0, then stop:GCD is b, # otherwise set a to b, b to r , and repeat until r is 0 def gcd(a,b): while(b!=0): temp = a a = b b = temp % b return a print(gcd(20,8)) print(gcd(96,12))
0a15fd2335acaccb888b7a9ae2af40f848a3cbf8
VasanthkumarVelusamy/Python_PoCs
/Exceptions.py
237
3.59375
4
# Exceptions val1 = input('Enter divident ') val2 = input('Enter Divisor ') try: result = int(val1)/int(val2) except ZeroDivisionError as e: print('Got an exception called ', e) result = None print('The result is ',result)
41a596ef52e6ce7564915151caab2659b091515c
VasanthkumarVelusamy/Python_PoCs
/ex19.py
285
3.53125
4
def cheese_and_crackers(cheese_count, boxes_of_crackers): print(f"there are {cheese_count} number of cheese") print(f"and there are {boxes_of_crackers} boxes of crackers") cheez = 6 crackrz =7 cheese_and_crackers(cheez+10,crackrz+100) # cheez_and_crakrz(cheez+10,crackrz+100)
1d52592eecda886e448bcb093a9591288b13a2c9
VasanthkumarVelusamy/Python_PoCs
/ex16.py
684
3.875
4
from sys import argv script, file_name = argv print(f"we are going to erase file {file_name}.") print("If you dont want that, hit Ctrl+c (^c).") print("Hit enter to continue.") input('?') print("Opening the file...") target = open(file_name,'w') # print(target.read()) print("truncating the file. Gud bye!") target.trun...
784c29f0fdfa7f397351550ddd4700496dd8d321
NariddhKhean/Flight_Booking_Grid_Search
/create_sessions.py
4,125
3.578125
4
import datetime import requests import json import csv import os def create_skyscanner_sessions(departure_start_date, departure_count, arrival_start_date, arrival_count, headers, config): """Generates a nested list of crytographic session IDs from the S...
e59e60b0a4b7deca9c510bd6b9c58636c6d34c80
Chethanmanu/python-lab-programs
/chethan1.py
273
3.71875
4
l={1,2,3,4} try: print(l) s=len(l) if s>5: raise TypeError print(d[2]) except TypeError: print("Error!!!length should be less than or equals to 5") except NameError: print("index out of range") else: for i in l: print(i) finally: print("execution done!!!!!!")
84a06e5854e1919a2a621bf3c41e3b53b0b9144f
anson-vandoren/euler
/problem_6.py
569
3.9375
4
# Find the difference between the sum of the squares, and the square # of the sum of first 100 natural numbers # def square_of_sum(high_num): # s = sum(range(1, high_num + 1)) # print(f"Sum to {high_num} is {s}") # print(f"Square of sum to {high_num} is {s**2}") # return s ** 2 # def sum_of_squares(...
0f3d3f7c49c8a64a01323892672282042d66b26d
bmiraski/tlacs
/ch8.py
7,465
4.09375
4
import turtle import sys import string def test(did_pass): """ Print the result of a test. """ linenum = sys._getframe(1).f_lineno # Get the caller's line number. if did_pass: msg = "Test at line {0} ok.".format(linenum) else: msg = ("Test at line {0} FAILED.".format(linen...
4eb679fa74d8e2bf33d3e58984f4c861ad0b7827
gauravarora1005/python
/Strings Challenges 80-87.py
1,973
4.21875
4
#!/usr/bin/env python # coding: utf-8 # In[2]: first_name = input("enter your first name: ") f_len = len(first_name) print("Length of First Name ", f_len) last_name = input("Enter the last name: ") l_len = len(last_name) print("Length for last name is: ", l_len) full_name = first_name + " " + last_name full_len =...
7ad37b63d9de1cf35a0301289dc5a67c79eb1f52
simonbor/chatbot-telaviv
/Lauren/sentiment_analysis.py
3,212
3.53125
4
# -*- coding: utf-8 -*- """ Created on Thu Feb 02 14:44:42 2017 @author: ljglass """ import csv import collections import random from review import Review import pandas import numpy as np def open_csv(file_location): """ :param file_location: string :return: list of Review objects """ review_objs = [] with...
557b7d5ddf678df8b80e91109c785ab14c6465e6
bziglio/capacitacaoeletronica
/Calculadora.py
3,548
4.28125
4
def soma(): num1 = int(input("Digite o seu primeiro número. ")) num2 = int(input("Digite o seu segundo número. ")) print('') print(num1 + num2) def subtracao(): num1 = int(input("Digite o seu primeiro número. ")) num2 = int(input("Digite o seu segundo número. ")) print('') pri...
4830fce65573c12afab45690b272356399bd8242
dhuang/doctor
/doctor/parsers.py
5,101
3.671875
4
""" This is a collection of functions used to convert untyped param strings into their appropriate JSON schema types. """ import logging import simplejson as json from doctor.errors import ParseError def _parse_array(value): """Coerce value into an list. :param str value: Value to parse. :returns: lis...
d3a89701c1f2fc79da231a88cb859e5b42d8adf0
rewatiramanprasad/AutoSendEmail
/AutoSendEmail.py
2,394
3.59375
4
import smtplib import webbrowser def get_useremail(): while True: useremail=input('enter user e-mail id:') if '@' in useremail and useremail.endswith('.com'): service=['gmail','outlook','yahoo'] count=0 for i in service: if i+".com" in useremail: ...
f5e32d39662fd252f07d26707bb1f7fa8d105aa6
CaptainMexiko/APS
/TP8/TP8.py
1,121
3.5
4
#!/usr/bin/python3 import hashlib from itertools import permutations INPUT = "Lorem ipsum dolor sit amet, consectetur adipisicing elit,sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.Duis aute ...
018e6eb324fda7c6c2eed48d430adbf1c9dfc708
rohanpahwa1/hacker_rank_solutions
/Simple_array_sum.py
411
3.65625
4
def sum(ar): a=0 for w in ar: a=a+w return a if __name__=='__main__': a=int(input()) # Entering size of array i=0 while 1: if a>=0: break else : a=int(input()) # Enter size greater than equal to zero b=[] i=0 while i<a: ...
d29dfd699d38a78d7cc6a44e435cc90fb991d103
rohanpahwa1/hacker_rank_solutions
/matrix_diagonal_difference.py
497
3.59375
4
n=int(input())#Enter number of rows and columns matrix=[] for i in range(n): x=list(map(int,input().split())) matrix.append(x) sum_1=0 j=0 for i in range(n): if(matrix[i][j]==matrix[j][i]): sum_1=matrix[i][j]+sum_1 j=j+1 print(sum_1)#getting sum of diagonals from left to right sum_2=0 i=0 while ...
5babf7c2a44804bf32c79d1fabb4760eb325eb68
Bruno1402/AA-start
/inventando_cripto.py
795
3.515625
4
MODE_ENCRYPT = 1 MODE_DECRYPT = 0 def caesar(data, key, mode): alphabet = 'abcdefghijklmnopqrstuvwyzàáãâéêóôõíúçABCDEFGHIJKLMNOPQRSTUVWYZÀÁÃÂÉÊÓÕÔÍÚÇ123456789 ' new_data = '' for c in data: index = alphabet.find(c) if index == -1: new_data += c else: ...
083c345ab02fed5ff90fae1d35b9574aa0f3577c
DevUsmanGhani/cosmicWimpout
/monte2.py
14,868
3.6875
4
from random import * from collections import * def monte2(): #[This function checks the statistics for a certain number of Cosmic Wimpout turns and a certain number of rerolls.] numberOfRerolls = 20 numberOfTurns = 100 turnNumber = [0] pointTracker = [] turnTracker...
a4cad54947a04dc475cb6f94fbdcda14cb637b2e
caro401/aoc2016
/caro-python/day12.py
1,262
3.578125
4
def assemble(filename): regs = {"a": 0, "b": 0, "c": 1, "d": 0} with open(filename) as fin: lines = fin.readlines() stuff = [] for line in lines: line = line.strip("\n") line = line.split(" ") stuff.append(line) idx = 0 while idx < len(lines): bits = stuf...
d95e031490496dec7183f8f3fd21abcf9b0dd23d
fishiraki/Election_Analysis
/Python_practice.py
2,734
4.375
4
#print("Hello World") counties = ["Arapahoe","Denver","Jefferson"] #if counties[1] == 'Denver': # print(counties[1]) #if counties[3] != 'Jefferson': # print(counties[2]) #temperature = int(input("What is the temperature outside? ")) #if temperature > 80: # print("Turn on the AC.") #else: # print("Open ...
2d44b738e87fd3acc226f5c0a9d980ed58d30beb
kseet001/FCS
/Homework5/homework_qn1.py
2,248
4.125
4
# Homework 5 - Question 1 # Encrypt the following plaintext P (represented with 8-bit ASCII) using AES-ECB, # with the key of 128-bit 0. You may use an existing crypto library for this exercise. # P = SUTD-MSSD-51.505*Foundations-CS* from Crypto.Cipher import AES from binascii import hexlify, unhexlify plaintext = "...
6f853ea48aa415602e6df8163e95f82d739adb1a
kseet001/FCS
/Homework8/homework_qn4.py
1,304
3.5625
4
from Crypto.Cipher import AES from binascii import hexlify ''' Define the plaintext, IV and key ''' key = b"\x00" * 16 # 128 bits key IV = b"\x00" * 16 # 128 bits IV def main(): a = "hello world. 123".encode() print("\n=== 1. Original Message ===") encryptor = AES.new(key, AES.MODE_CBC, IV) t = enc...
b128c31a85faaa9c00bd6c3bcd7d59647f30f9ab
reynaa2/Binary-ID-2017
/Plot_code.py
4,844
3.625
4
import numpy as np from matplotlib import pyplot as plt import pandas as pd import corner def corner_hist2d(x,y,a,b,title,xlabel,ylabel): import corner xlabel = str(xlabel) y = str(ylabel) title = str(title) ## Set a figure size plt.figure(figsize=(8,8)) # Use corner 2d histogram package. C...
e15cb5d89b24fef1a6d8448891b53ae2eaabfe87
joshfullmer/work_log
/task_search.py
9,241
4.15625
4
""" Provides functions to search for tasks in a CSV of tasks Uses dataframes to search, filter, edit, and delete from the work log CSV """ import datetime import pandas as pd import work_log def filter_input(selection): """ Filters user input to the proper search function. Also reads the CSV, stores in...
c49e28120fadfc3cd81f94d1cedae5020be7125a
YvesAugusto/Deep-Learning-API
/Layers/conv.py
879
3.515625
4
import numpy as np from Layers.layer import Layer class Conv2D(Layer): def __init__(self, units=1, input_shape=(1,1,3), kernel_size=[3,3], strides=[2,2]): # input_shape may be of type (H, W, DIM). # kernel_size may be of type 3, 5, 7, ...; or (3,1), (3,5): (height, width) # the strides will...
1cf589b0ca9684bd5d8731fabf8d6ca157eafeb2
AllexBlaze/learning
/code/python/algorithms/selection_sort.py
1,976
4.0625
4
def find_smallest(user_list): """ Поиск наименьшего элемента в списке Функция получается список значений пользователя. Пробегает по всему списку и ищем минимальный элемент (путем сравнивания). В конечном итоге возвращает индекс минимального элемента. :param user_list: Список элементов пользователя...
36a75bd6fecddf9acc4b44f37dade5acd122a546
yashjshah/Hackerrank
/30 Days of Code/Day 11 - 2D Arrays/2d_arrays.py
882
4
4
#!/bin/python3 import math import os import random import re import sys def hourglass_sum(matrix, r, c): return matrix[r + 0][c + 0] + matrix[r + 0][c + 1] + matrix[r + 0][c + 2] \ + matrix[r + 1][c + 1] + \ matrix[r + 2][c + 0] + matrix[r + 2][c + 1] + matrix[r + 2][c +...