blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
3779d08c3d6a222fe5efb19c78067b49e966d846
Md-Monirul-Islam/Python-code
/Python-book-OOP/Sum_list has a constructor-1.py
392
3.578125
4
class SumList(object): def __init__(self, my_list): self.mylist = my_list def __add__(self, other): new_list = [x + y for x, y in zip(self.mylist, other.mylist)] return SumList(new_list) def __repr__(self): return str(self.mylist) aa = SumList([3, 6, 9, 12, 15]) bb = Sum...
2f12a0990a2de9a353bc5919340e5c8a791e708a
Md-Monirul-Islam/Python-code
/Mathematics-306/How to convert height in feet and inches to centimeters in python.py
177
3.9375
4
print('Input your Height :') h_feat = int(input("feat :")) h_inch = int(input("Inches :")) h_inch += h_feat * 12 h_cm = round(h_inch * 2.54,1) print("Your height is cm :",h_cm)
44fcca114ba0866f752bad2072d07617af364f95
Md-Monirul-Islam/Python-code
/Matplotlib/71-Bar Graph - Bar Chart-2.py
303
3.671875
4
#bar chart import matplotlib.pyplot as plt x = ["Science","commerce","Arts"] h = [100,200,300] #w = [0.1,0.2,0.3] #b = [10,20,100] plt.bar(x,h,bottom=10,color="green") plt.xlabel("Couses",color="blue") plt.ylabel("Students enrolled",color="red") plt.title("Enrolled students for the courses") plt.show()
975adf7d55e52f303c6d4424411bd195e4a71e80
Md-Monirul-Islam/Python-code
/Python-221/6.6 Comprehensions.py
396
3.84375
4
numbers = [1,5,2,12,14,7,18] double = [] for number in numbers: double.append(2*number) print(double) even_num = [] for number in numbers: if number%2==0: even_num.append(number) print(even_num) animals = ['aardvark', 'cat', 'dog', 'opossum'] vowel_animals = [] for animal in animals: if animal[0]...
001421749cdf6c081a5978bce89d7a568027ca3b
Md-Monirul-Islam/Python-code
/Pattern-Python/Right triangle shape-4.py
260
3.59375
4
n = int(input("enter the number : ")) for i in range(n): for j in range(i+1): x = 0 for k in range(j): x = x+n-k if j%2==0: print(x+i-j+1,end=' ') else: print(x+n-i,end=' ') print()
54b4d7b3ab867c5eb87908fb05c298bfc2a5cd2b
Md-Monirul-Islam/Python-code
/Python-221/6.8.1 Answer to exercise 1.py
136
4.03125
4
total = 0 number = 0 while total < 200: number += 1 total += number**2 print("Total : %d "%total) print("last number :",number)
727648f429fa7f79e1973f2a52027a53e069f739
Md-Monirul-Islam/Python-code
/Mathematics-306/How to Remove spaces from dictionary keys in python.py
228
3.734375
4
student_list = {"S 001":["Math","Phy"], "S 002":["Math","Che"]} print("Original dictionary :",student_list) student_dic = {x.translate({32:None}) : y for x,y in student_list.items()} print("Student dictionary :",student_dic)
975b2deae96961235ecc1bdb637b57dff1e8596f
Md-Monirul-Islam/Python-code
/Python-221/6.7.4 Exercise 6-3.py
1,148
4.375
4
'''' 3. Implement a simple calculator with a menu. Display the following options to the user, prompt for a selection, and carry out the requested action (e.g. prompt for two numbers and add them). each operation, return the user to the menu. Exit the program when user selects 0. If the user enters a number which is not...
c99d5259e2dba92dca70d64ec862054deac37965
Md-Monirul-Islam/Python-code
/Mathematics-306/How to Convert a string in a list in Python.py
83
3.640625
4
str1 = "I love my country and i also love my countries game" print(str1.split(' '))
8bcab34736aae7477dc24362797bed54fb3df884
Md-Monirul-Islam/Python-code
/Mathematics-306/How to Turn a list into a string in Python.py
150
3.828125
4
def concatenate(list): result = '' for element in list: result += str(element) return result print(concatenate(["Munna",1,2,3,4]))
fbc68ba5f0d22e025c168a9cbcbce3598a30032a
Md-Monirul-Islam/Python-code
/Mathematics-306/How to Add leading zeroes to a string in Python.py
121
3.671875
4
str1 = "122.22" print("Original str1 : ",str1) str1 = str1.ljust(8,'0') print(str1) str1 = str1.ljust(10,'0') print(str1)
fff9ffb1bddd3c768f9d64a19a0cf92f433f11f5
Md-Monirul-Islam/Python-code
/Python-book-OOP/Method overloading-bangla bool-2.py
227
3.8125
4
class My_num: def __init__(self,value): self.__value = value def __int__(self): return self.__value def __add__(self, other): return self.__value+int(other)*int(other) a=2 b=3 c=a+b print(c)
734c8e8adfc92859b73e00fcc0180ed3515e1ba3
Md-Monirul-Islam/Python-code
/Python-book-OOP/Exception-2.py
340
4.03125
4
def enterAge(age): if age<0: raise ValueError('only positive number is allowed.') if age % 2 == 0: print('the number is even.') else: print('the number is odd.') try: num = int(input('enter your age :')) print('enterAge(num)') except ValueError: print('only positive numb...
dd10f8d45aa2950d2fa555f4d031675b537a6036
Md-Monirul-Islam/Python-code
/Python-book-OOP/Unpickling-1.py
445
3.53125
4
import pickle class Animal: def __init__(self,number_of_legs,color): self.number_of_legs = number_of_legs self.color = color class Cat(Animal): def __init__(self,color): Animal.__init__(self,4,color) pussy = Cat('White') my_pickle_pussy = pickle.dumps(pussy) Meow = pickle.loads(my_pi...
85d1e6cc232450ba1dcf9f49ef93a7d2a6ce1618
Md-Monirul-Islam/Python-code
/Python-221/6.8.6 Answer to exercise 6 -1.py
328
4.09375
4
'''' 1. . Write a program which repeatedly prompts the user for an integer. If the integer is even, print the integer. If the integer is odd, don’t print anything. Exit the program if the user enters the integer 99. ''' for num in range(1,100): if num == 99: break if num%2== 0: continue prin...
6d5fc3ccf123ab8587774a008482f6cc5716577d
Md-Monirul-Islam/Python-code
/Pattern-Python/Right triangle shape-3.py
220
3.96875
4
num = int(input("enter the number : ")) for row in range(num): val = row+1 dec = num - 1 for col in range(row+1): print(format(val,"<4"),end=' ') val = val+dec dec = dec-1 print()
5ba261ad88101cd878f138a24b3201e582df29c3
Md-Monirul-Islam/Python-code
/Python-221/6.8.7 Answer to exercise 7.py
407
4
4
'''' 1. Modify the example above to include type conversion of the properties: age should be an integer, height and weight should be floats, and name and surname should be strings. ''' Person = {} poperties = [ ("Name",str), ("Surname",str), ("Age",int), ("Height",float), ("Weight",float) ] for prop,...
0c4cc6e815e617162f1acee245be66aed1867e5d
Md-Monirul-Islam/Python-code
/Python-221/Ex-3-1,,4.5.3--if ladder.py
388
4.1875
4
temperature = int(input("enter any temparature : ")) if temperature < 0: print("The weather is freezing.") elif temperature < 10: print("The weather is very cool.") elif temperature < 20: print("The weather is chilly.") elif temperature < 30: print("The weather is warm.") elif temperature < 40: pri...
1611491112a5b36f845750805712b83d172b08c2
Md-Monirul-Islam/Python-code
/Python-221/8.3.1 Exercise 3.py
417
4.125
4
'''' 1. Rewrite the hypotenuse function from exercise 2 so that it returns a value instead of printing it. Add exception handling so that the function returns None if it is called with parameters of the wrong type. ''' import math def hypotenuse(x,y): try: return math.sqrt(x**2 + y**2) except TypeError:...
4d26e767e32113ea1e4a9ad6e8f500c31acce788
Md-Monirul-Islam/Python-code
/Advance-python/Thread Synchronization Semaphore and BoundedSemaphore in Python-1.py
908
3.625
4
from threading import * class Flight: def __init__(self,available_seat): self.available_seat = available_seat self.l = Semaphore(2) #BoundeSemaphore(2) print(self.l) def reserve(self,need_seat): self.l.acquire() print(self.l._value) print("Available seat->>",sel...
42ed72ca40f92c0fd5eab822f1ef67ec8e8eb1d2
Md-Monirul-Islam/Python-code
/Matplotlib/62-Sine and Cosine Graph-1.py
341
3.59375
4
import matplotlib.pyplot as plt import numpy as np t = [0,30,45,60,90] x = [i*(np.pi/180) for i in t] plt.plot(x,np.sin(x),marker="+",markersize=15,label="sin") plt.plot(x,np.cos(x),marker="*",markersize=15,label="cos") #plt.xticks(t) plt.title("sin and cos graph") plt.xlabel("angle") plt.ylabel("sin and cos value") pl...
3d785698a7628e78e285c92d22fcda7f98e5cdc0
Md-Monirul-Islam/Python-code
/Mathematics-306/How to print yesterday, today, tomorrow in Python.py
225
3.984375
4
import datetime today = datetime.datetime.today() yesterday = today - datetime.timedelta(days=1) tomorrow = today + datetime.timedelta(days=1) print("Today :",today) print("Yesterday :",yesterday) print("Tomorrow :",tomorrow)
9fc46656fbd45d31d94b5dddb5dd52dc34d9b0df
Md-Monirul-Islam/Python-code
/Mathematics-306/How to Check if all items of a list is equal to a given string in Python.py
170
4.03125
4
list1 = ["White","Green","Black","Red","Orange"] list2 = ["Green",'Green','Green','Green'] print(all(x == "Green" for x in list1)) print(all(x == "Green" for x in list2))
a8151d66cd1c67800629599b13282fe2909098b4
Md-Monirul-Islam/Python-code
/Advance-python/Operator Overloading in Python-2.py
278
3.71875
4
class A: def __init__(self,x): self.x = x def __add__(self, other): return self.x + other.x class B: def __init__(self,x): self.x = x a = A(10) b = B(20) print(a+b) # A.__add__(a,b) ,,,, int.__add__(a,b),,,str__add__("a","b") print(dir(int))
9a28a1f32451cc08f9d026d86de6551fccca8b1b
Md-Monirul-Islam/Python-code
/Advance-python/date class in Python-1.py
283
3.875
4
from datetime import date d1 = date(year=2020,month=9,day=16) d2 = date(year=2019,month=9,day=16) d3 = date(2020,9,16) print(d1) print(d3) print(d1.__sub__(d2)) print(d1-d2) print(d1.year) print(d2.month) print(d3.day) print() #use today() cd = date.today() print(cd) print(cd.year)
a74286a0f5f53f89c172dfcb65dc0098ef6b385f
Md-Monirul-Islam/Python-code
/Python-221/9.3 Class attributes-2.py
198
3.640625
4
class person: pets = [] def add_pet(self,pet): self.pets.append(pet) obj_1 = person() obj_2 = person() obj_1.add_pet('Cat') obj_2.add_pet("Dog") print(obj_1.pets) print(obj_2.pets)
452a8d4152e7fe6b94b5f6e6003ba13349d9fff5
Md-Monirul-Islam/Python-code
/Mathematics-306/How to Generate all permutations of a list in Python.py
75
3.703125
4
import itertools list1 = [1,2,3] print(list(itertools.permutations(list1)))
94c4d2e6e09eadacf024c9b79b11e569d4274cee
Md-Monirul-Islam/Python-code
/Python-book-OOP/15-inheriting the constructor.py
364
3.59375
4
import random class Animal: def __init__(self,name): self.name = name class Dog(Animal): def __init__(self,name): super(Dog,self).__init__(name) self.breed = random.choice(['Doberan','German Sheperd','Beagle']) def fetch(self,thing): print('%s goes after is %s'%(self.name,th...
1692b7a36a2bbd7455d2dcec1a17dc6d213b8779
Md-Monirul-Islam/Python-code
/Advance-python/Method Overriding and Method with super in Python-1.py
222
3.734375
4
class Add: def result(self,a,b): print("Addition :",a+b) class Multi(Add): def result(self,a,b): print("Multiplication :",a*b) output = Multi() output.result(3,5) output1 = Add() output1.result(3,5)
5b6d960b881b3463ce6e1f1234a7c6f88dbf1852
Md-Monirul-Islam/Python-code
/Python-221/6.3.1 Exercise 2-5.py
413
4.03125
4
'''' 5. Rewrite the previous program so that it has two loops – one which collects and stores the numbers, and one which processes them. ''' numbers = [] for i in range(11): numbers[i] = float(input("Please enter number %d: " % (i + 1))) total = 0 product = 1 for i in numbers: total += i product = product*...
0622859084279f21c2ac6064a85ef9eb2b97be43
Md-Monirul-Islam/Python-code
/Matplotlib/85-Histogram-5.py
555
3.75
4
import matplotlib.pyplot as plt x = [1,12,22,21,20,21] y = [1,11,21,31] #plt.hist(x,y,ec="red",bottom=10) #plt.hist(x,y,ec="red",bottom=[1,3,5]) #plt.hist(x,y,ec="red",histtype="step") #plt.hist(x,y,ec="red",align="left") #by default is mid #plt.hist(x,y,edgecolor="cyan",orientation="horizontal") #by default is verti...
05ed077140e85821485868f7b32d43ab0e278471
Md-Monirul-Islam/Python-code
/Python-221/9.4 Class decorators-1.py
720
3.609375
4
class person: TITLES = ('Mr','Dr','Ms','Mrs') def __init__(self,name,surname): self.name = name self.surname = surname def fullname(self): return '%s %s' %(self.name,self.surname) @classmethod def allowed_title_starting_with(cls,startswith): return [t for t in cls.T...
0a22f02b33c551fcfb846d4ceca4f421f485c580
Md-Monirul-Islam/Python-code
/Matplotlib/10-Plot Function - pyplot module - matplotlib-8.py
236
3.5625
4
import matplotlib.pyplot as plt plt.plot([10,20,30,40],"g") #([5,10,20,30],"r*") output same gruph plt.plot([5,10,20,30],"r*") #plt.plot([10,15,25,35],"b*") plt.xlabel("x label") plt.ylabel("y label") plt.title("First plot") plt.show()
1e9dba7e390790dc479b7b80fbbb29804cdb980b
Md-Monirul-Islam/Python-code
/Mathematics-306/How to find the Biggest and Smallest of 3 numbers using lists in Python.py
109
3.875
4
list = [1,2,3,4,5,5,6] print("The biggest number is :",max(list)) print("The smallest number is :",min(list))
b0738b0f42bac7fac607952a6c6e0db5351d627e
Md-Monirul-Islam/Python-code
/Advance-python/Passing Member of one Class to another Class in Python -1.py
515
3.734375
4
class Student: #constructor def __init__(self,name,roll): self.name = name self.roll = roll #instance method def display(self): print("The student name is",self.name) print("The student roll number is",self.roll) class User: #static method @staticmethod def sh...
1d73ab719abf2c04a512d10a846249fdd5af3ed1
Md-Monirul-Islam/Python-code
/Mathematics-306/How to print positive numbers in a list in Python.py
141
3.78125
4
nums = [1,2,3,-5,4,6,-6] print("Original number in the list :",nums) new_nums_list = list(filter(lambda x : x > 0,nums)) print(new_nums_list)
0c7a5319a566dcbb0cf1ba2ca674a1bb063162f2
Md-Monirul-Islam/Python-code
/Python-221/9.3 Class attributes.py
476
4.15625
4
class person: TITLE = ("Mr.",'Ms.','Mrs.','Dr.') def __init__(self,title,name,surname): if title not in self.TITLE: raise ValueError("%s is not a valid title." % title) self.title = title self.name = name self.surname = surname # we can access a class attribute from ...
64672f5ec4da5638bbc949d2f22025afc6255036
Md-Monirul-Islam/Python-code
/Mathematics-306/How to Insert a string at the beginning of all items in a list in Python.py
80
3.65625
4
num_list = [1,2,3,4,5,6,7,8,9] print(["student{0}".format(i) for i in num_list])
c3d407c8482d09ab785d38f9c8202c4a691399ac
Md-Monirul-Islam/Python-code
/Python-221/7.2.4 The else and finally statements-2.py
238
4
4
try: age = int(input("Please enter your age: ")) except ValueError: print("Hey! That wasn't a number.") else: print("I see that your are %d years old." %age) finally: print("Really it was a good talking with you-goodbye.")
dc7ce5bda965bf2a75cc352fd989d9c116caf12c
sarsatis/PythonHundredDaysOfCode
/1_hangman/hangman.py
816
4.09375
4
import random import hangman_art words = ['sarthak', 'arch', 'divya'] stages = hangman_art.stages random_word = random.choice(words) print(f'random word is {random_word}') display = [] for _ in range(len(random_word)): display += "_" lives = len(stages) print(hangman_art.logo) while "_" in display and lives ...
e1607b294ebf75c504c3fddaa44b3470fa8986fa
ado1012/hello-world
/1_KMP.py
223
4
4
name = input("write your full name: ") nameReplacer = name.replace("-", " ") nameList = nameReplacer.split() def initials (name_list): for i in name_list: print(i[0].upper(), end = "") initials(nameList)
3e1a2cd3bd6a684140436a2f22e359f14c3e8c39
haifeich/Web-DEV-Solutions
/04-django/01-python-intro/password_with_constraints.py
901
3.796875
4
import random import string choices = string.ascii_lowercase + string.ascii_uppercase + string.digits +'-'+'_' length =random.randint(8, 12) def generator(): return [random.choice(choices) for i in range(length)] def check(): good = generator() # Recursion # if ('-'in good or '_'in good): # ...
96fed231d755c773d0d9bd3043f944b50509f923
bnovak1/data_analyst_nanodegree
/Intro_Data_Sci/subway/Visualization/P_entriesperhr_given_rain_minus_P_entriesperhr_given_dry.py
4,076
4.375
4
from pandas import * import pandasql from ggplot import * import numpy as np import matplotlib.pyplot as plt def read_csv_data(version): """ Read in csv data to data frame """ if version == 1: df = read_csv('../data/turnstile_data_master_with_weather.csv') else: df = read_csv('...
29bde2df9b94799e3fa87b6bd59ffb452e4f3694
vortex-17/file-split-Cryptography
/main.py
755
4.1875
4
#This is the main function for the file-split cryptography from split import split, recreate_file import os import pyfiglet def main(): result = pyfiglet.figlet_format("FILE SHARDER", font = "slant" ) print(result) print("Welcome to the file-split cryptography") filename = str(input("Enter the filepat...
d3a440f61a48b277beb54faad64b839f76fa5272
gabikersul/projetos-python
/Aula07/Main.py
198
4.09375
4
from Rectangle import Rectangle a = float(input("Insert Height: ")) b = float(input("Insert Width: ")) rectangle = Rectangle(a, b) rectangle.printAttributes() print(rectangle.calculate_area())
70a50f06ed182359e9647ce970f51e01c277d157
BoberSA/crtbp
/rand_crtbp.py
955
3.515625
4
# -*- coding: utf-8 -*- """ Created on Mon Jul 17 01:22:37 2017 @author: Stanislav Bober """ #import numpy as np from numpy.random import rand import math def randBallOne(): d = rand(3) * 2 - 1 while d[0]**2+d[1]**2+d[2]**2 > 1: d = rand(3) * 2 - 1 return d def randBallV(v, r): d = rand(3) *...
2303c10310ee674ff8c0a4c3344908e540e9aeb5
Sewi1808/learning_projects
/Other/simple_validation.py
759
3.640625
4
z = [] def number_input(): global a a = int(input("please provide number: \n")) if a in locals(): print("no input detected \n") number_input() elif a == 0: print("provided number is 0, provide another one \n") number_input() else: return def is_divided_by(...
3c202581bb8c0460c1d13dde4568021afbfb9a92
lopes-andre/logic-of-programming
/pt_BR/exercicio3.py
3,165
3.921875
4
# EXERCÍCIO DESENVOLVIDO NA IDE: Visual Studio Code v1.55.2 notas = {} # Cria o dicionário vazio def qtd_alunos(): """Função para receber do usuário via teclado a quantidade de alunos a ser trabalhada. Descarta o 0 e todos os números negativos e descarta qualquer entrada que não seja do tipo float""" ...
de973126f7e728ef71c1f35121cbc724f71b1203
ruiliulin/liuliu
/习题课/自主习题课—Python编程从入门到实践/自习课7 文件和异常/10-5.py
298
3.78125
4
# 关于编程的调查 filename = 'like_programme.txt' while True: i = input("请问你为何喜欢编程?(输入-1退出)") if i == str(-1): break else: with open(filename, 'a') as file_object: file_object.write("喜欢编程的缘由:{}\n".format(i))
2ad01e9950f011a9ce93b71da67de5eb4119ec3f
ruiliulin/liuliu
/习题课/自主习题课—Python编程从入门到实践/oop/user_1.py
1,637
4.125
4
"""一组关于用户信息的类""" class User(): def __init__(self, first_name, last_name, age, sex, addr): """初始化用户的属性""" self.fname = first_name self.lname = last_name self.age = age self.sex = sex self.addr = addr self.login_attempts = 0 def describe_u(self): ...
d101c542ad51f3a5b20f4dec01ae5174da70fe6a
ruiliulin/liuliu
/习题课/自主习题课—Python编程从入门到实践/自习课7 文件和异常/10-6.py
296
3.75
4
# 加法运算 print("请分别输入两个数字用于加法计算") f_num = input("第一个数为:") s_num = input("第二个数为:") try: f_num = int(f_num) s_num = int(s_num) except ValueError: print("请输入数字!") else: answer = f_num + s_num print(answer)
4aad7e13dfaaaad6928749f237495934996647bc
ruiliulin/liuliu
/习题课/自主习题课—Python编程从入门到实践/自习课7 文件和异常/10-10.py
328
4.21875
4
# 常见单词 def count_words(filename): try: with open(filename) as f_obj: f = f_obj.read() except FileNotFoundError: print("没有{}文件".format(filename)) else: t = f.lower().count("the") print(t) for i in ['little_women.txt', 'moby_dick.txt']: count_words(i)
c0ee7297bf16b371f02e96ddd0fa13248d7f29e2
ruiliulin/liuliu
/习题课/自主习题课—Python编程从入门到实践/oop/car.py
1,187
4.25
4
'''一个用于表示汽车的类''' class Car(): """一次模拟汽车的简单尝试""" def __init__(self, make, model, year): """初始化描述汽车的属性""" self.make = make self.model = model self.year = year self.odometer_reading = 0 def get_c_name(self): """返回整洁的描述性名称""" l_name = str(self.year) + '...
1395fb78013f52135e543e6e06350b0de11ec9ac
lucassouzast/AED-PYTHON
/PROJETO AED/ArvoreBinariaProjeto.py
10,682
3.734375
4
'''Aluno: Lucas Pereira de Souza''' class No(): def __init__(self, elemento): self.elemento = elemento self.esquerda = None self.direita = None self.altura = None self.pai = None class ArvoreBinaria: def __init__(self): self.raiz = None ...
ae510948b8db541e4a4cf557a41cf6c9b20cb152
sevenjames/pylab
/rand_ints_test.py
722
3.671875
4
''' 2020-01-26 random int generation timing tests https://stackoverflow.com/questions/4172131/create-random-list-of-integers-in-python conclusion: random.randint is simply an alias to a form of random.randrange random.randrange is ok numpy.random.randint is faster by 2 orders of magnitude ''' import timei...
9aa66744f762f07e651d5c1eba0c6aa18ecca2a6
sevenjames/pylab
/collatz.py
2,228
4.40625
4
""" 2020-01-31 Generate the Collatz sequence. Exercise from "Automate the Boring Stuff", chapter 3. A Write a function named collatz_next() that has one parameter named number. If even, print and return number // 2. If oddd, print and return 3 * number + 1. B Write a program that takes user input as starting value, th...
3689b08a9ec95aa6a2f799e6bfa0433365cbb5d5
sevenjames/pylab
/csvparse.py
1,807
3.859375
4
""" 2020-02-18 Parse CSV file challenge Given the file 'football.csv', print the name of the team with the smallest difference between 'goals' and 'goals allowed' """ import csv def calc_best_a(): """SKIP THE HEADER WITH A ROW POINTER AND CHECK""" with open('football.csv', newline='') as file: reade...
0394b857a0cd3d1c00fd0ea0f7461518d68d2723
zhsummersy/py_study
/6-30.py
2,504
3.984375
4
#继续巩固基础知识 #变量赋值: #从左到右依次赋值 # a,b,c=1,2,3 # print(a,b,c) # 数字、字符串、列表、元组、集合、字典 #其中,列表、集合、字典可变,其他不可变 #isinstance type #type不会认为子类是一种父类型 # class A: # pass # class B(A): # pass # print(isinstance(A(),A)) # print(type(B())==A) # l1='zhsummersyyyyyyyyyyyyyyy' # l2='上面是一个字符串' # print(type(l1)) # l3=set(l1)#set可以去重...
bc3b706cea82f6e042290f3ffe6513acdfe59dc9
Harshaa-Dhawan/npci_iiht
/Stack_To_Queue.py
2,281
3.875
4
class StackToQueue: def __init__(self): self.stack = [] def push(self, element): self.stack.append(element) def pop(self): if(not self.isEmpty()): lastElement = self.stack[-1] del(self.stack[-1]) return lastElement else: r...
5ee33b68592dae5f83efeb58afd1f1a41ff50957
thehelplessday/stepik-selenium-python-course
/get_method.py
2,143
3.5625
4
import time import math def calc(x): return str(math.log(abs(12*math.sin(int(x))))) # webdriver это и есть набор команд для управления браузером from selenium import webdriver # инициализируем драйвер браузера. После этой команды вы должны увидеть новое открытое окно браузера driver = webdriver.Chrome() # команда...
d1e45bb514e9fdb2600935ac0c275770a62d7c81
Masssssy/adventofcode2017
/4/day4.py
612
3.5625
4
def main(): inputfile = open("input") inputdata = inputfile.read() inputfile.close() splitdata = inputdata.split("\n") valid = 0 for phrase in range(0, len(splitdata)): words = splitdata[phrase].split(" ") dict = {} failed = False for word in range(0, len(words...
f3e3d92f7257573bb29b44aa7733abee7fb99c14
Masssssy/adventofcode2017
/9/day9.py
645
3.609375
4
def main(): inputfile = open("input") inputdata = inputfile.read() inputfile.close() char = 0 groupLevel = 0 inGarbage = False score = 0 garbageCount = 0 while(char < len(inputdata)-1): c = inputdata[char] if(inGarbage and c != ">" and c != "!"): garbageCount += 1 if(c == "<"): inGarbage = True...
3060b7bd2c6ec1ebe0924135964a3f39745830c1
Masssssy/adventofcode2017
/10/day10.py
679
3.546875
4
def main(): inputfile = open("input") inputdata = inputfile.read() inputfile.close() lengths = inputdata.split(",") list = range(0,256) currentPos = 0 skipSize = 0 for length in lengths: if(currentPos + int(length) > 256): gg = list[currentPos:256] gg.extend(list[0:(currentPos + int(length)) % 256]) ...
73c7a69289e455dfac8d280dcb9afcfc32f922de
cazyw/interactive-python
/Wk4_Pong.py
6,851
4.3125
4
############################################## # Implementation of classic arcade game Pong # ############################################## import simplegui import random # initialize globals - pos and vel encode vertical info for paddles WIDTH = 600 HEIGHT = 400 BALL_RADIUS = 20 PAD_WIDTH = 8 PAD_HEIGHT = 80 ...
451b8c7d7dbaf49bff9f3120f5ebf5bc3be12098
dmarakom6/Hangman
/Hangman.py
4,865
4
4
import random import Info open('wordsList.py', 'r') ##welcoming print("Hello.\nWelcome to hangman!") ##menu def menu(): ##menu options print("Select one of the three options by typing 1,2 or 3:\n") print("1.Play") print("2.How to Play") print("3.Quit") while True: selection = int((...
e99a97ec1287e5c449d3b9f45d0193b805873e1d
flik/python
/2.py
150
3.65625
4
#!/bin/python3 if 5 > 2: print("Five is greater than two!") # Comments start with a # for single line """ This is a multiline docstring. """
e0e833bfb9077df21b9a9f5856e1fc34051a4fb1
flik/python
/dict.py
704
4.40625
4
# It is same like php array thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964 } print(thisdict) #update value thisdict["year"] = 2018 for x, y in thisdict.items(): print(x, y) #remove specific item thisdict.pop("model") # same like php unset() thisdict.popitem() # remove last item # The del k...
0f149f60fdd0c058a9a6e8ffadf396cd0dcce144
daksh105/CipherSchool
/Assignment5/ReverseLinkedList.py
1,664
4.125
4
class Node: def __init__(self, data = None): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None self.tail = None self.length = 0 def add(self, data): if self.head == None: self.head = Node(data) s...
3d6482c64e8b108c8bce1eb93140375beb3a6e4c
daksh105/CipherSchool
/Assingnment6/DuplicateParanthesis.py
436
3.78125
4
from queue import LifoQueue as Stack def DuplicateParanthesis(s): st = Stack() for i in s: if i == ")": c = 0 while(st.queue[-1] != "("): c += 1 st.get() if c < 1: return "Duplicate Found" ...
193bdae276c3604f42c55e3a1f189bf29388c88c
daksh105/CipherSchool
/Assignment5/ReorderLL.py
2,123
3.921875
4
class Node: def __init__(self, data = None): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None self.tail = None self.length = 0 def add(self, data): if self.head == None: self.head = Node(data) ...
17e37a018f5257800dd839d09239f77fb8772bc8
daksh105/CipherSchool
/Assignment2/SearhElementRotatedArray.py
626
3.90625
4
def SearchElementRotatedArray(li, ele): beg = 0 end = len(li) - 1 while(beg <= end): mid = beg + (end - beg) // 2 if li[mid] == ele: return mid elif li[beg] < li[mid] and li[beg] <= ele <= li[mid]: end = mid - 1 elif li[mid] < li[end] and li[mid] <= el...
1b5b6c38938884bdcb1b0412d83ed90d50df0096
diassor/platzi_ventas
/main.py
7,495
4.09375
4
# -*- coding: utf-8 -*- """ clients = 'Edwin, Alejandro,' if __name__ == '__main__': clients += 'Juan' print(clients) """ # en este bloque incorpore la variable dentro de la funcion """ clients = 'Edwin, Alejandro,' def create_clients(clients_name): global clients clients += clients_name _add_...
bb7ca40dcd397f7ec01e6b2012e06747fe3e9d88
vitthalpadwal/Python_Program
/hackerrank/algorithm/strings/two_characters.py
2,470
4.40625
4
""" In this challenge, you will be given a string. You must remove characters until the string is made up of any two alternating characters. When you choose a character to remove, all instances of that character must be removed. Your goal is to create the longest string possible that contains just two alternating lette...
e865f8f6c3963f620bdcb3b9054ed341de397955
vitthalpadwal/Python_Program
/hackerrank/preparation_kit/search/making_candies.py
4,586
4.34375
4
""" Karl loves playing games on social networking sites. His current favorite is CandyMaker, where the goal is to make candies. Karl just started a level in which he must accumulate candies starting with machines and workers. In a single pass, he can make candies. After each pass, he can decide whether to spend so...
e882ce97e92ec8a961b7ca048d7e407716846be2
vitthalpadwal/Python_Program
/remove_third_element.py
875
3.921875
4
def removeThirdNumber(int_list): # list starts with # 0 index pos = 3 - 1 index = 0 len_list = (len(int_list)) # breaks out once the # list becomes empty while len_list > 0: index = (pos + index) % len_list print(index) # removes and prints the required #...
2455a3e8d8bd5a37e1ccb6b8ef37fbd684495c3b
vitthalpadwal/Python_Program
/hackerrank/preparation_kit/stacks_and_queues/poisonous_plants.py
3,464
4.21875
4
""" There are a number of plants in a garden. Each of these plants has been treated with some amount of pesticide. After each day, if any plant has more pesticide than the plant on its left, being weaker than the left one, it dies. You are given the initial values of the pesticide in each of the plants. Print the numb...
3bd64d83524d44d8229de0fc8be77de7f4c75201
vitthalpadwal/Python_Program
/hackerrank/python_sort.py
1,765
4.375
4
""" You are given a spreadsheet that contains a list of athletes and their details (such as age, height, weight and so on). You are required to sort the data based on the th attribute and print the final resulting table. Follow the example given below for better understanding. image Note that is indexed from to , ...
656355c3406265e54e18cff46ec72f730b75648a
vitthalpadwal/Python_Program
/other_example.py
5,713
3.796875
4
''' 0) li = [fc,dc,fd,gr] def myfun(myli = none): _myli - myli _myli.pop(-1) What will be the way to take a precaution for above example like abc or decorator? if you calling this function 10 times what will be happen? ''' #this question is like handling exception for indexing or poping non existence element usi...
d2c73e1adb7c79b91f796111499de91ec97cfe84
vitthalpadwal/Python_Program
/hackerrank/preparation_kit/search/minimum_time_required.py
2,738
4.625
5
""" You are planning production for an order. You have a number of machines that each have a fixed number of days to produce an item. Given that all the machines operate simultaneously, determine the minimum number of days to produce the required order. For example, you have to produce items. You have three machines ...
646dfefe276127bfb56fdab0bce2a995f2826fe3
vitthalpadwal/Python_Program
/hackerrank/matrix_validation.py
1,580
3.859375
4
""" Neo has a complex matrix script. The matrix script is a X grid of strings. It consists of alphanumeric characters, spaces and symbols (!,@,#,$,%,&). Capture.JPG To decode the script, Neo needs to read each column and select only the alphanumeric characters and connect them. Neo reads the column from top to bott...
d88b71fce4c48d19d3f9f50961cf829f53a2e541
vitthalpadwal/Python_Program
/hackerrank/preparation_kit/stacks_and_queues/min_max_middle.py
2,836
4.59375
5
""" Given an integer array of size , find the maximum of the minimum(s) of every window size in the array. The window size varies from to . For example, given , consider window sizes of through . Windows of size are . The maximum value of the minimum values of these windows is . Windows of size are and their mini...
a7dd5120c989b7ce60f8493554d4d263d4afc869
vitthalpadwal/Python_Program
/hackerrank/preparation_kit/recursion_and_backtracking/crossword_puzzle.py
4,078
3.84375
4
""" A Crossword grid is provided to you, along with a set of words (or names of places) which need to be filled into the grid. Cells are marked either + or -. Cells marked with a - are to be filled with the word list. The following shows an example crossword from the input grid and the list of words to fit, : Input...
f8d48a2b69a47e8bdcec980dec51fc7032aa6dca
xutpuu/ProjectEuler
/Problem43.py
2,124
3.640625
4
# The number, 1406357289, is a 0 to 9 pandigital number because it is made up of each # of the digits 0 to 9 in some order, but it also has a rather interesting sub-string divisibility property. # Let d₁ be the 1ˢᵗ digit, d₂ be the 2ⁿᵈ digit, and so on. In this way, we note the following: # d₂d₃d₄=406 is divisible by...
59f8e915c4a2322e1d8ef9f30c4943f7bdf38643
xutpuu/ProjectEuler
/Problem3.py
454
3.65625
4
# Problem 3 # The prime factors of 13195 are 5, 7, 13 and 29. # What is the largest prime factor of the number 600851475143 ? def is_prime(n): for i in range(3, n): if n % i == 0: return False return True def main(): x = 600851475143 y = 2 z = 1 while z ...
77f887db2ecb2408ae52b7b103c55bb4d5aa16ec
xutpuu/ProjectEuler
/Problem50.py
1,307
3.65625
4
# The prime 41, can be written as the sum of six consecutive primes: # 41 = 2 + 3 + 5 + 7 + 11 + 13 # This is the longest sum of consecutive primes that adds to a prime below one-hundred. # The longest sum of consecutive primes below one-thousand that adds to a prime, contains 21 terms, and is equal to 953. # Which ...
6e547d9dc960a49cb75c43447fee4bd5302cade7
xutpuu/ProjectEuler
/Problem19.py
1,407
3.78125
4
# Problem 19 # You are given the following information, but you may prefer to do some research for yourself. # 1 Jan 1900 was a Monday. # Thirty days has September, # April, June and November. # All the rest have thirty-one, # Saving February alone, # Which has twenty-eight, rain or shine. # And on leap years, twenty...
7d3e56c2b777ef3820ff596279be6a00f72a42ab
xutpuu/ProjectEuler
/Problem32.py
1,059
3.578125
4
# We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital. # The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing multiplicand, multiplier, and product is 1 through 9 pandigital. # Fin...
7f3a4026b44b19f1b8d1528078b25e98bcd32dd9
VitaliiRevenko/PytonLessonsForBeginnerBeetRootAcademy
/lesson_22/quick_sort.py
550
3.890625
4
import random def qs(array): if len(array) <= 1: return array else: r_choice = random.choice(array) print(r_choice) left = [] middle = [] right = [] for i in array: if i < r_choice: left.append(i) elif...
7044c6ba7d98d8e5a8e9ffd9cb44a22b26a3dd91
VitaliiRevenko/PytonLessonsForBeginnerBeetRootAcademy
/lesson_15/task1.py
1,498
3.921875
4
# Task 1 # # Create a class method named `validate`, which should be called from the `__init__` method to validate parameter email # , passed to the constructor. The logic inside the `validate` method could be to check if the passed email parameter is a valid email string. # Email validations: # # https://help.xm...
7928008ea70ddc608bffc0ece5c846e6cbb77b4d
VitaliiRevenko/PytonLessonsForBeginnerBeetRootAcademy
/lesson_12/task1.py
759
4.21875
4
'''Task 1 Method overloading. Create a base class named Animal with a method called talk and then create two subclasses: Dog and Cat, and make their own implementation of the method talk be different. For instance, Dog’s can be to print ‘woof woof’, while Cat’s can be to print ‘meow’. Also, create a simple generic...
56d3134ff61b48537278de576a4756a978cdf522
VitaliiRevenko/PytonLessonsForBeginnerBeetRootAcademy
/lesson_9/task1.py
493
4.0625
4
'''Task 1 Write a function called oops that explicitly raises an IndexError exception when called. Then write another function that calls oops inside a try/except state­ment to catch the error. What happens if you change oops to raise KeyError instead of IndexError?''' def oops(): a = (1, 2, 3) pri...
df44335e1bf181f9e0722066cae03987668a141d
VitaliiRevenko/PytonLessonsForBeginnerBeetRootAcademy
/lesson_16/task1.py
723
4
4
#Task 1 # # Create your own implementation of a built-in function enumerate, named `with_index`, which takes two parameters: # `iterable` and `start`, default is 0. Tips: see the documentation for the enumerate function # iterator protocol class with_index(): def __init__(self, iterable): self.it...
5435c777af133422d79a4ac98ebd43aa9ba94719
robbailiff/maths-problems
/howling_primes.py
1,333
4.40625
4
""" A howling prime is a prime number if the sum of its digits is also a prime number. For Example: Input:113 Output: true (113 is a prime number, 1+1+3=5 is also a prime number) Input: 89 Output: true (89 is a prime number, 8+9=17 is also a prime number) Input: 19 Output: false (19 is a prime number, but 1+9=10 is...
51cfe71225c89de68844139d1206f753e83146d2
robbailiff/maths-problems
/eratosthenes.py
2,051
4.28125
4
""" This is my attempt to make a prime number generator using the Sieve of Eratosthenes. For those who don't know what the Sieve of Eratosthenes is: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ (https://www.smartickmethod.com/blog/math/operations-and-algebraic-thinking/divisibility/prime-numbers-siev...
e5addad886fa99214b033e4a0b6aa438691d673c
anuroopmishra21/patterns_using_python
/pyramind_of_numbers.py
237
4.1875
4
# printing a pyramid triangle of numbers x= int(input("Enter the no. of rows: ")) m=x-1 for i in range(0,x): for k in range(0,m): print(end=" ") for j in range(0,i+1): print(j+1, end=' ') print("\r") m=m-1
ff35a1d885eb60cf4089d707007848bfe9e4b907
vitory1/data_struct_python
/bilibil/二进制1的个数.py
361
3.765625
4
class Solution: def hammingWeight(self, n: int) -> int: stack = [] count = 0 while n > 0: stack.append(n % 2) n = n // 2 while stack: if stack.pop() == 1: count = count + 1 return count if __name__ == "__main__": s = S...
be4490f41e0d0d0dcee56ee2f533183a88154957
vitory1/data_struct_python
/Sort/BubbSort/MergeSort.py
513
3.875
4
def merge_sort(alist): if len(alist) <= 1: return alist mid = len(alist) // 2 left = merge_sort(alist[:mid]) right = merge_sort(alist[mid:]) merged = [] while left and right: if left[0] <= right[0]: merged.append(left.pop(0)) else: merged.append(...
e194ac166302641a898e8e3e3a40001dc71fbcb1
Genixi/Python_mail_spec
/num_to_str.py
120
3.546875
4
l = [1,2,3,4,5] def num_to_str(l): return list(map(lambda x: str(x), l)) ls = num_to_str(l) for s in ls: print(s)
6832f76f3d7c89ba918b105d7b2ab3b967852ba9
youngseok-seo/cs-fundamentals
/Sorting/bubbleSort.py
388
3.890625
4
def bubbleSort(L: list) -> list: while True: swapped = False for j in range(len(L) - 1): if L[j] > L[j + 1]: smaller = L[j + 1] L[j + 1] = L[j] L[j] = smaller swapped = True if swapped == False: break ...
885d2efc2a964fbf1fabe234644be04af9313af4
youngseok-seo/cs-fundamentals
/Sorting/insertionSort.py
479
3.765625
4
def insertionSort(L: list) -> list: S = [L[0]] U = list(L[1:]) while len(U) > 0: print(S, U) idx = -1 for j in range(len(S)): if U[0] < S[j]: idx = j break if idx == 0: S = [U[0]] + S elif idx < 0: ...