blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
346d3af90d21411c4265d7e232786fc4078f82fc
Tanay-Gupta/Hacktoberfest2021
/python_notes1.py
829
4.4375
4
print("hello world") #for single line comment '''for multi line comment''' #for printing a string of more than 1 line print('''Twinkle, twinkle, little star How I wonder what you are Up above the world so high Like a diamond in the sky Twinkle, twinkle little star How I wonder what you are''') a=20 b...
true
f9f7e50a92722a94b0d387c61b00a216e556219d
KarlLichterVonRandoll/learning_python
/month01/code/day01-04/exercise03.py
1,842
4.1875
4
""" 录入商品单价 再录入数量 最后获取金额,计算应该找回多少钱 """ # price_unit = float(input('输入商品单价:')) # amounts = int(input('输入购买商品的数量:')) # money = int(input('输入你支付了多少钱:')) # # Change = money - amounts * price_unit # print('找回%.2f元' % Change) """ 获取分钟、小时、天 计算总秒数 """ # minutes = int(input('输入分钟:')) # hours = int(input('输入小时:')) # days = int(...
false
bbcf509fc54e792f44a9ff9dc57aea493cd7d89c
KarlLichterVonRandoll/learning_python
/month01/code/day14/exercise02.py
1,511
4.25
4
""" 创建Enemy类对象,将对象打印在控制台 克隆Enemy类对像 """ # class Enemy: # # def __init__(self, name, hp, atk, defense): # self.name = name # self.hp = hp # self.atk = atk # self.defense = defense # # def __str__(self): # return "%s 血量%d 攻击力%d 防御力%d" % (self.name, self.hp, self.at...
false
f284bdf3b3929131be1fe943b3bd5761119f4c2e
sydney0zq/opencourses
/byr-mooc-spider/week4-scrapy/yield.py
1,088
4.53125
5
#! /usr/bin/env python3 # -*- coding: utf-8 -*- """ The first time the for calls the generator object created from your function, it will run the code in your function from the beginning until it hits yield, then it'll return the first value of the loop. Then, each other call will run the loop you have written in the ...
true
88806f1c3ee74fe801b26a11b0f66a3c7d6c881d
Kajabukama/bootcamp-01
/shape.py
1,518
4.125
4
# super class Shape which in herits an object # the class is not implemented class Shape(object): def paint(self, canvas): pass # class canvas which in herits an object # the class is not implemented class Canvas(object): def __init__(self, width, height): self.width = width self.heigh...
true
157b4ad717a84f91e60fb5dc108bcab8b2a21a12
jwu424/Leetcode
/RotateArray.py
1,275
4.125
4
# Given an array, rotate the array to the right by k steps, where k is non-negative. # 1. Make sure k < len(nums). We can use slice but need extra space. # Time complexity: O(n). Space: O(n) # 2. Each time pop the last one and inset it into the beginning of the list. # Time complexity: O(n^2) # 3. Reverse the list t...
true
da8890ff1f941e97b8174bc6e111272b6ffa0b20
OliverMorgans/PythonPracticeFiles
/Calculator.py
756
4.25
4
#returns the sum of num1 and num 2 def add(num1, num2): return num1 + num2 def divide(num1, num2): return num1 / num2 def multiply(num1, num2): return num1 * num2 def minus (num1, num2): return num1 - num2 #*,-,/ def main(): operation = input("what do you want to do? (+-*/): ") if(operation != "+" and opera...
true
261a8ec6e763de736e722338241d2cf39a34c9b0
Rggod/codewars
/Roman Numerals Decoder-6/decoder.py
1,140
4.28125
4
'''Problem: Create a function that takes a Roman numeral as its argument and returns its value as a numeric decimal integer. You don't need to validate the form of the Roman numeral. Modern Roman numerals are written by expressing each decimal digit of the number to be encoded separately, starting with the left...
true
a7ee00fd9f9dac5ec77d96e7b1ab8c1a1dbe1b4f
Rggod/codewars
/is alphanumerical/solution.py
592
4.15625
4
''' In this example you have to validate if a user input string is alphanumeric. The given string is not nil, so you don't have to check that. The string has the following conditions to be alphanumeric: At least one character ("" is not valid) Allowed characters are uppercase / lowercase latin letters and dig...
true
9b1c1c56bdd3f47af1d3e818c85ef9601180904a
7dongyuxiaotang/python_code
/study_7_23.py
1,687
4.21875
4
# class Parent1(object): # x = 1111 # # # class Parent2(object): # pass # # # class Sub1(Parent1): # 单继承 # pass # # # class Sub2(Parent1, Parent2): # 多继承 # pass # # # print(Sub1.x) # print(Sub1.__bases__) # print(Sub2.__bases__) # ps:在python2中有经典类与新式类之分 # 新式类:继承了object类的子类,以及该子类的子类 # 经典:没有继承object类的子...
false
57813ddd83679b08db0ca6b7d29ad27d25e32252
falondarville/practicePython
/birthday_dictionary/months.py
495
4.5625
5
# In the previous exercise we saved information about famous scientists’ names and birthdays to disk. In this exercise, load that JSON file from disk, extract the months of all the birthdays, and count how many scientists have a birthday in each month. import json from collections import Counter with open("info.json",...
true
9b505fd7c9d15fedb84b90c9c8443e791d8a9e61
falondarville/practicePython
/birthday_dictionary/json_bday.py
696
4.46875
4
# In the previous exercise we created a dictionary of famous scientists’ birthdays. In this exercise, modify your program from Part 1 to load the birthday dictionary from a JSON file on disk, rather than having the dictionary defined in the program. import json with open("info.json", "r") as f: info = json.load(f...
true
fe8c35b13ecc12fd043023795917be731beda765
alexdistasi/palindrome
/palindrome.py
937
4.375
4
#Author: Alex DiStasi #File: palindrome.py #Purpose: returns True if word is a palindrome and False if it is not def checkPalindrome(inputString): backwardsStr ="" #iterate through inputString backwards for i in range(len(inputString)-1,-1,-1): #create a reversed version of inputString ...
true
353b341eb43b497f5e6618cd93a7ac169e03ccb7
JennyCCDD/fighting_for_a_job
/LC 反转字符串.py
1,064
4.125
4
# -*- coding: utf-8 -*- """ @author: Mengxuan Chen @description: 反转字符串 编写一个函数,其作用是将输入的字符串反转过来。输入字符串以字符数组 char[] 的形式给出。 不要给另外的数组分配额外的空间,你必须原地修改输入数组、使用 O(1) 的额外空间解决这一问题。 你可以假设数组中的所有字符都是 ASCII 码表中的可打印字符。 @revise log: 2021.01.11 创建程序 解题思路:双指针 """ class Solution(object): def reverseS...
false
8ebfcdfeba3a5e2a8adc7f70ea6bf85a3e423e68
abrambueno1992/Intro-Python
/src/fileio.py
526
4.40625
4
# Use open to open file "foo.txt" for reading object2 = open('foo.txt', 'r') # Print all the lines in the file # print(object) # Close the file str = object2.read() print(str) object2.close() # Use open to open file "bar.txt" for writing obj_bar = open("bar.txt", 'w') # Use the write() method to write three lines to ...
true
81cb9114c1fdd16e8b12863531fdaf860080943b
udbhavkanth/Algorithms
/Find closest value in bst.py
1,756
4.21875
4
#in this question we have a bst and #a target value and we have to find # which value in the bst is closest #to our target value. #First we will assign a variable closest #give it some big value like infinity #LOGIC: #we will find the absolute value of (target-closest) And # (target - tree value) # if th...
true
f132e65fb3e884765ab28eded1b9ededdb09a1b1
artalukd/Data_Mining_Lab
/data-pre-processing/first.py
1,964
4.40625
4
#import statement https://pandas.pydata.org/pandas-docs/stable/dsintro.html import pandas as pd #loading dataset, read more at http://pandas.pydata.org/pandas-docs/stable/io.html#io-read-csv-table df = pd.read_csv("iris.data") #by default header is first row #df = pd.read_csv("iris.data", sep=",", names=["petal_...
true
988dab09d39206865788bc0f8d7c3088b551b337
VictoriaEssex/Codio_Assignment_Contact_Book
/part_two.py
2,572
4.46875
4
#Define a main function and introduce the user to the contact book #The function is executed as a statement. def main(): print("Greetings! \nPlease make use of my contact book by completing the following steps: \na) Add three new contacts using the following format: Name : Number \nb) Make sure your contacts hav...
true
757b60fbc021114cc77faa07b7e828a12ea00072
aholyoke/language_experiments
/python/Z_combinator.py
1,285
4.28125
4
# ~*~ encoding: utf-8 ~*~ # Implementation of recursive factorial using only lambdas # There are no recursive calls yet we achieve recursion using fixed point combinators # Y combinator # Unfortunately this will not work with applicative order reduction (Python), so we will use Z combinator # Y := λg.(λx.g (x x)) (λx....
true
89c5d7aa305f0ed3de08ff8ed66075ad1863a117
heersaak/opdrachtenPython
/Opdrachten/Les 5/5_1.py
763
4.25
4
##Schrijf een functie convert() waar je een temperatuur in graden Celsius (als parameter van deze ##functie) kunt omzetten naar graden Fahrenheit. Je kunt de temperatuur in Fahrenheit berekenen met ##de formule T(°F) = T(°C) × 1.8 + 32. Dus 25 °C = 25 * 1.8 + 32 = 77 °F. ##Schrijf nu ook een tweede functie table() waa...
false
40224c5ba455fb7e03e135ff2cb35e94c150e351
lyoness1/Calculator-2
/calculator.py
1,772
4.25
4
""" calculator.py Using our arithmetic.py file from Exercise02, create the calculator program yourself in this file. """ from arithmetic import * def intergerize(str_list): """returns a list of integers from a list of strings""" return map(int, str_list) def read_string(): """reads the input to determin...
true
1e3e4a200bf8e1db120c6d21463a9186f26b19a5
ashwinimanoj/python-practice
/findSeq.py
805
4.1875
4
'''Consider this puzzle: by starting from the number 1 and repeatedly either adding 5 or multiplying by 3, an infinite amount of new numbers can be produced. How would you write a function that, given a num- ber, tries to find a sequence of such additions and multiplications that produce that number? For example, the n...
true
c71327e6285ac5f58b8fed3f95dd458037d016cb
vladimirkaldin/HomeTask
/1.2.py
613
4.4375
4
#2. Пользователь вводит время в секундах. Переведите время в часы, минуты и секунды и выведите в формате чч:мм:сс. # Используйте форматирование строк. seconds_time = int(input("Введите время в секундах")) print(f'Время {seconds_time} секунд') hours = seconds_time // 3600 minutes = int((seconds_time % 3600) / 60)...
false
bbb273a9b1dce01c6c53f0f739272490f1455859
vladimirkaldin/HomeTask
/1.1.py
609
4.28125
4
#1. Поработайте с переменными, создайте несколько, выведите на экран, запросите у пользователя несколько чисел и #строк и сохраните в переменные, выведите на экран. age = 0 age = int(input("Введите возраст")) print(f'Возраст пользователя - {age}') name = 'Имя пользователя не задано' print(name) name = input(...
false
1377c3aabb11ba82fd0337b1ef56f0baf0c6de21
yunge008/LintCode
/6.LinkedList/[E]Nth to Last Node in List.py
1,236
4.1875
4
# -*- coding: utf-8 -*- __author__ = 'yunge008' """ Find the nth to last element of a singly linked list. The minimum number of nodes in list is n. Example Given a List 3->2->1->5->null and n = 2, return node whose value is 1. """ class ListNode(object): def __init__(self, val, next=None): ...
true
846b0924cec1a3fd9dfb225af2b22404d1ca5268
yunge008/LintCode
/6.LinkedList/[M]Convert Sorted List to Balanced BST.py
1,053
4.125
4
# -*- coding: utf-8 -*- __author__ = 'yunge008' """ Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 2 1->2->3 => / \ 1 3 """ class ListNode(object): def __init__(self, val, next=None): self.val = ...
true
eb856747b12ad9296e4309679c763175f2cfc018
Marusya-ryazanova/Lesson_2
/Vasya.py
747
4.25
4
speed = float(input("Средняя скорость: ")) time = int(input("Верям в пути: ")) point = time * speed # Вычисляем точку остановки if point > 100: print("поехал по второму кругу, пройденное растояние = ", point) elif point < 0: print("велосипедист едет назад уже", point , "километров") elif point == 0: print(...
false
896841b93741f2b09cd36c09ff494f1bb6851059
simplifiedlearning/dummy
/function.py
1,739
4.375
4
######################FUNCTIONS#################### #SYNTAX #using def keyword #without parameters def greet(): print("hello") greet() ###add two number #with parameters def add1(x,y): z=x+y print(z) add1(2,3) ####default arguments def add2(b,c,a=12): print(a+b+c) add2(5,5) ####abritriy...
true
c0620531c0aea733e89fda828f42333573c5dcde
naomi-rc/PythonTipsTutorials
/generators.py
638
4.34375
4
# generators are iterators that can only be iterated over once # They are implemented as functions that yield a value (not return) # next(generator) returns the next element in the sequence or StopIteration error # iter(iterable) returns the iterable's iterator def my_generator(x): for i in range(x): yield...
true
2f7d869fdcce5a45fd4003d771984b3c871bb921
naomi-rc/PythonTipsTutorials
/enumerate.py
417
4.3125
4
# enumerate : function to loop over something and provide a counter languages = ["java", "javascript", "typescript", "python", "csharp"] for index, language in enumerate(languages): print(index, language) print() starting_index = 1 for index, language in enumerate(languages, starting_index): print(index, lang...
true
b6edcfc7160d348fedf295982a0bfdb7a421aee2
E-voldykov/python_for_beginners
/les3/hmwrk6.py
1,054
4.3125
4
""" Реализовать функцию int_func(), принимающую слово из маленьких латинских букв и возвращающую его же, но с прописной первой буквой. Например, print(int_func(‘text’)) -> Text. Продолжить работу над заданием. В программу должна попадать строка из слов, разделенных пробелом. Каждое слово состоит из латинских букв в ниж...
false
fbc9bbfbb0b4c12eb7af244cdf85a96fb726b2b2
RayGar7/AlgorithmsAndDataStructures
/Python/diagonal_difference.py
581
4.25
4
# Given a square matrix, calculate the absolute difference between the sums of its diagonals. # For example, the square matrix is shown below: # 1 2 3 # 4 5 6 # 9 8 9 # The left-to-right diagonal = 1 + 5 + 9 = 15. The right to left diagonal = 3 + 5 + 9 = 17. Their absolute difference is abs(15 - 17) = 2. def dia...
true
64466b637b49b744d34c0d37cacd212998177a0b
mohitarora3/python003
/sum_of_list.py
376
4.125
4
def sumList(list): ''' objective: to compute sum of list input parameters: list: consist of elemnts of which sum has to be found return value: sum of elements of list ''' #approach: using recursion if list == []: return 0 else: return(list[0]+sumLi...
true
5cecdc3cb4373a598efbe015f6446f84ee950501
lsalgado97/My-Portfolio
/python-learning/basics/guess-a-number.py
2,369
4.34375
4
# This is a code for a game in which the player must guess a random integer between 1 and 100. # It was written in the context of a 2-part python learning course, and is meant to introduce # basic concepts of Python: variables, logic relations, built-in types and functions, if and # for loops, user input, program ou...
true
620395a61e712ecf98438c7c2eff7b663247da51
wzz886/aaaaaa_game
/python 3 Tool/learn_def.py
2,457
4.4375
4
''' Python3 函数 函数是组织好的,可重复使用的,用来实现单一,或相关联功能的代码段。 函数能提高应用的模块性,和代码的重复利用率。 你已经知道Python提供了许多内建函数,比如print()。 但你也可以自己创建函数,这被叫做用户自定义函数。 语法: def 函数名(参数列表): 函数体 ''' # 参数 ''' 以下是调用函数时可使用的正式参数类型: 1.必需参数 2.关键字参数 3.默认参数 4.不定长参数 ''' # 必需参数 def showInfo(str): "打印任何字符串" print(str) # 调用showInfo,必须传参 showInfo("调用showInfo,必须传...
false
4ed6cf981fd362e21ff59c9abbf24035f2e765a3
manovidhi/python-the-hard-way
/ex13.py
650
4.25
4
# we pass the arguments at the runtime here. we import argument to define it here. from sys import argv script, first, second, third = argv #print("this is script", argv.script) print( "The script is called:", script ) # this is what i learnt from hard way print ("Your first variable is:", first) print ("Your se...
true
1ad2cd819e2b9ca0e38435955fdea7a29211eb75
chaerui7967/K_Digital_Training
/Python_KD_basic/List/list_3.py
277
4.3125
4
#리스트 내용 일치 list1 = [1,2,3] list2 = [1,2,3] # == , !=, <, > print(list1 == list2) # 2차원 리스트 list3 = [[1,2,3],[4,5,6],[7,8,9]] #행렬 형식으로 출력 for i in list3: print(i) for i in list3: for j in i: print(j, end="") print()
false
c01b4306131f6fa4bd8a59f7b68ec758e2b16a5c
quynguyen2303/python_programming_introduction_to_computer_science
/Chapter5/wordLength.py
708
4.40625
4
# Average Words Length # wordLength.py # Get a sentence, remove the trailing spaces. # Count the length of a sentence. # Count the number of words. # Calculate the spaces = the number of words - 1 # The average = (the length - the spaces) / the number of words def main(): # Introduction print('The program cal...
true
2afa7c968a716fcca6cdb879880091093f1d22fc
quynguyen2303/python_programming_introduction_to_computer_science
/Chapter11/sidewalk.py
510
4.125
4
# sidewalk.py from random import randrange def main(): print('This program simulates random walk inside a side walk') n = int(input('How long is the side walk? ')) squares = [0]*n results = doTheWalk(squares) print(squares) def doTheWalk(squares): # Random walk inside the Sidewalk n = len...
true
393e027c2e80d8a2ca901ef0104ac59c6887770d
quynguyen2303/python_programming_introduction_to_computer_science
/Chapter3/distance.py
467
4.21875
4
# Distance Calculation # distance.py import math def main(): # Instruction print('The program calculates the distance between two points.') # Get two points x1, y1, x2, y2 = eval(input('Enter two points x1, y1, x2, y2:'\ '(separate by commas) ')) # Calculate the dis...
true
39c742637396b520ad65097e4a6ac7fc92b16af4
quynguyen2303/python_programming_introduction_to_computer_science
/Chapter8/syracuse.py
447
4.125
4
# syracuse.py # Return a sequence of Syracuse number def main(): # Introduction print('The program returns a sequence of Syracuse number from the first input.') # Get the input x = int(input('Enter your number: ')) # Loop until it comes to 1 while x != 1: if x % 2 == 0: x = ...
true
5dd5876363aa431cb73871182406d6da8cef8503
MakeRafa/CS10-poetry_slam
/main.py
1,376
4.25
4
# This is a new python file # random library import random filename = "poem.txt" # gets the filename poem.txt and moves it here def get_file_lines(filename): read_poem = open(filename, 'r') # reads the poem.txt file return read_poem.readlines() def lines_printed_backwards(lines_list): lines_list = lines...
true
72e84ca9b62056459a760f02f775cd5b59d0d801
palashsharma891/Algorithms-in-Python
/6. Searching and Sorting/bubbleSort.py
309
4.34375
4
def bubbleSort(array): for i in range(len(array)): for j in range(0, len(array) - i - 1): if array[j] > array[j+1]: (array[j], array[j+1]) = (array[j+1], array[j]) data = [-2, 45, 0, 11, -9] bubbleSort(data) print("Sorted array is: ") print(data)
false
5b4161986fe4af26d3a588ecd8a28347212aecbf
lexboom/Testfinal
/Studentexempt.py
2,121
4.375
4
#Prompt the user to enter the student's average. stu_avg = float(input("Please enter student's average: ")) #Validate the input by using a while loop till the value #entered by the user is out of range 0 and 100. while(stu_avg < 0 or stu_avg > 100): #Display an appropriate message and again, prompt ...
true
3196064e2211728cc382913d1f6c6a0b019364c4
micajank/python_challenges
/exercieses/05factorial.py
365
4.40625
4
# Write a method to compute the `factorial` of a number. # Given a whole number n, a factorial is the product of all # whole numbers from 1 to n. # 5! = 5 * 4 * 3 * 2 * 1 # # Example method call # # factorial(5) # # > 120 # def factorial(num): result = 1 for i in range(result, (num + 1)): result = resu...
true
a21ef75e7a1ad5af81cada429876d9d06b317e17
Jose1697/crud-python
/16. OperacionesConListas.py
1,284
4.125
4
# + (suma) a = [1,2] b = [2,3] print(a+b) #[1,2,2,3] # * (multiplicacion) c = [5, 6] print(c*3) #[5, 6, 5, 6, 5, 6] #Añadir un elemento al final de la lista d = [3,5,7] d.append(9) print(d) #[3, 5, 7, 9] print(len(d)) #4 el tamaño de la lista #Para sacar el ultimo elemento de la lista, tambien se puede utilizar ...
false
ab30e8e66f9c5c70b6688770b821f85df5b1017c
LEE2020/leetcode
/coding_100/1669_mergeInBetween.py
1,889
4.625
5
''' 给你两个链表 list1 和 list2 ,它们包含的元素分别为 n 个和 m 个。 请你将 list1 中第 a 个节点到第 b 个节点删除,并将list2 接在被删除节点的位置。 下图中蓝色边和节点展示了操作后的结果: 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/merge-in-between-linked-lists 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 输入:list1 = [0,1,2,3,4,5], a = 3, b = 4, list2 = [1000000,1000001,1000002] 输出:[0,1,2,...
false
2501c35e44be4af82b2d46b48d92125109bb245f
DevYam/Python
/filereading.py
967
4.125
4
f = open("divyam.txt", "rt") # open function will return a file pointer which is stored in f # mode can be rb == read in binary mode, rt == read in text mode # content = f.read(3) # Will read only 3 characters # content = content + "20" # content += "test" # content = f.read(3) # Will read next 3 characters...
true
e7ddc640319e91b422cbee450ecb6ce69c13f534
DevYam/Python
/lec10.py
1,270
4.375
4
# Dictionary is a data structure and is used to store key value pairs as it is done in real life dictionaries d1 = {} print(type(d1)) # class dict ==> Dictionary (key value pair) d2 = {"Divyam": "test", "test2": "testing", "tech": "guru", "dict": {"a": "dicta", "b": "dictb"}} print(d2) print(d2["Divyam"]) # Keys o...
true
a42e4fce2736ca3bcf39aa3076ade26519b55472
DevYam/Python
/lec16.py
393
4.5
4
# for loop in python list1 = ["Divyam", "Kumar", "Singh"] for item in list1: print(item) # Iterating through list of lists (Unpacking list of lists) list2 = [["divyam", 23], ["kumar", 36], ["singh", 33]] for item, weight in list2: print(item, weight) dict1 = dict(list2) print(dict1) for item in dict1: ...
false
69c56249896e306fe80e40ce278505d5be077cc4
minwuh0811/DIT873-DAT346-Techniques-for-Large-Scale-Data
/Programming 1/Solution.py
928
4.25
4
# Scaffold for solution to DIT873 / DAT346, Programming task 1 def fib (limit) : # Given an input limit, calculate the Fibonacci series within [0,limit] # The first two numbers of the series are always equal to 1, # and each consecutive number returned is the sum of the last two numbers. # You should ...
true
6dbf182ee4624e998d86436c9123e497ba6343ab
Arshad221b/Python-Programming
/multipleinheritance.py
714
4.34375
4
# In python we can use mutiple inheritance class A: def __init__(self) -> None: super().__init__() self.mike = "Mike" self.name = "Class A" class B: def __init__(self) -> None: super().__init__() self.bob = "bob" self.name = "Class B" class C(A, B): #...
false
a509f3fa6ed91012ceb290f7f3e98d6acde69578
FredC94/MOOC-Python3
/UpyLab/UpyLaB 3.06 - Instructions conditionnelles.py
949
4.1875
4
""" Auteur: Frédéric Castel Date : Mars 2020 Projet : MOOC Python 3 - France Université Numérique Objectif: Écrire un programme qui imprime la moyenne géométrique \sqrt{a.b} (la racine carrée du produit de a par b) de deux nombres positifs a et b de type float lus en entrée. Si au moins un de ces...
false
dd8ec5954a400f30b2af555dc79650c1712437c7
FredC94/MOOC-Python3
/Exercices/20200430 Sudoku Checker.py
1,672
4.15625
4
# Function to check if all the subsquares are valid. It will return: # -1 if a subsquare contains an invalid value # 0 if a subsquare contains repeated values # 1 if the subsquares are valid. def valid_subsquares(grid): for row in range(0, 9, 3): for col in range(0,9,3): temp = [] for r in ra...
true
7cee4c3d7df7f1adc67ef7482d0cf9aa3a0b1093
FredC94/MOOC-Python3
/UpyLab/UpyLaB 3.18 - Boucle For.py
1,959
4.375
4
""" Date : Avril 2020 Projet : MOOC Python 3 - France Université Numérique Objectif: Écrire un programme qui lit un nombre entier strictement positif n et imprime une pyramide de chiffres de hauteur n (sur n lignes complètes, c'est-à-dire toutes terminées par une fin de ligne). La première ligne im...
false
b441d9cbcccdfa77932e707e4e9c4490cb0e4c78
Shyonokaze/mysql.py
/mysql.py
2,656
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Mar 7 12:41:02 2018 @author: pyh """ ''' This class is for creating database and table easier by using pymysql ''' import pymysql class mysql_data: def __init__(self,user_name,password): self.conn=pymysql.connect(host='127.0.0.1', ...
true
62eb7a775f5d75af407ea7dba1ea4266dab00b89
carlosfabioa/TDS_exercicios_logica_programacao
/5- Matriz de uma dimensao - aplicacao pratica/05exercicio.py
1,052
4.125
4
''' e. Ler duas matrizes do tipo vetor A com 20 elementos e B com 30 elementos. Construir uma matriz C, sendo esta a junção das duas outras matrizes. Desta forma, C deverá ter a capacidade de armazenar 50 elementos. Apresentar os elementos da matriz C em ordem decrescente. ''' TAMANHO_A = 20 TAMANHO_B = 30 a = []...
false
7fe0d3a00eb4d208cc68115f43c0aa15dc21e386
carlosfabioa/TDS_exercicios_logica_programacao
/5- Matriz de uma dimensao - aplicacao pratica/04exercicio.py
1,502
4.28125
4
''' d. Ler uma matriz A com 12 elementos. Após a sua leitura, colocar os seus elementos em ordem crescente. Depois ler uma matriz B também com 12 elementos. Colocar os elementos de B em ordem crescente. Construir uma matriz C, onde cada elemento de C é a soma do elemento correspondente de A com B. Colocar em orde...
false
342e208d29d4ab099b5efc8c79fff7f53b16dd5d
carlosfabioa/TDS_exercicios_logica_programacao
/5- Matriz de uma dimensao - aplicacao pratica/07exercicio.py
942
4.15625
4
''' g. Ler 20 elementos de uma matriz A tipo vetor e construir uma matriz B da mesma dimensão com os mesmos elementos de A acrescentados de mais 2. Colocar os elementos da matriz B em ordem crescente. Montar uma rotina de pesquisa, para pesquisar os elementos armazenados na matriz B. ''' TAMANHO = 20 a =[]; b=[] #...
false
061b1f29b6c5bc4f2717b07a554e3dd5eac13dab
metehankurucu/data-structures-and-algorithms
/Algorithms/Sorting/BubbleSort/BubbleSort.py
399
4.21875
4
def bubbleSort(arr): n = len(arr) for i in range(n): swapped = False #Every iteration, last i items sorted for j in range(n-i-1): if(arr[j] > arr[j+1]): swapped = True arr[j], arr[j+1] = arr[j+1],arr[j] # One loop without swapping mean...
true
b6940f7168dfdea5713ec979dab30c5a77d993b9
NayeemH/Data-Structure-python
/Sorting Algorithms/Merge-Sort/MergeSort.py
1,193
4.375
4
def mergeSort(arr): if len(arr)>1: # Finding the mid of the array mid = len(arr)//2 # Dividing the array elements left_array = arr[:mid] right_array = arr[mid:] # Sorting the first half mergeSort(left_array) # Sorting the second half merge...
false
fdc1e38708d2d91acaad06ea6cb73545921f6305
jonathan-pasco-arnone/ICS3U-Unit5-02-Python
/triangle_area.py
1,075
4.15625
4
#!/usr/bin/env python3 # Created by: Jonathan Pasco-Arnone # Created on: December 2020 # This program calculates the area of a triangle def area_of_triangle(base, height): # calculate area area = base * height / 2 print("The area is {}cm²".format(area)) def main(): # This function calls gets input...
true
32a7acb3d2d77e31c343d09d2f1b1d60d289d77f
asurendrababu/nehprocpy
/alphabetRangoli.py
714
4.15625
4
# You are given an integer, . Your task is to print an alphabet rangoli of size . (Rangoli is a form of Indian folk art based on creation of patterns.) # # Different sizes of alphabet rangoli are shown below: # # #size 3 # # ----c---- # --c-b-c-- # c-b-a-b-c # --c-b-c-- # ----c---- import string alphaArr = list(strin...
false
a80210552c4810d0b9d7a1b710934aaddda73b9d
lindagrz/python_course_2021
/day5_classwork.py
2,850
4.46875
4
# 1. Confusion T # he user enters a name. You print user name in reverse (should begin with capital letter) then extra # text: ",a thorough mess is it not ", then the first name of the user name then "?" Example: Enter: Valdis -> # Output: Sidlav, a thorough mess is it not V? # # # 2. Almost Hangman # Write a program t...
true
2b7a758e15f6cd2be76e6cf416a07860663da96b
emilybee3/deployed_whiteboarding
/pig_latin.py
1,611
4.3125
4
# Write a function to turn a phrase into Pig Latin. # Your function will be given a phrase (of one or more space-separated words). #There will be no punctuation in it. You should turn this into the same phrase in Pig Latin. # Rules # If the word begins with a consonant (not a, e, i, o, u), #move first letter to end...
true
55a100f8658a25e2003a382f91c430f993c11a21
findango/Experiments
/linkedlist.py
1,407
4.21875
4
#!/usr/bin/env python import sys class Node: def __init__(self, value=None, next=None): self.value = value self.next = next def __str__(self): return "[Node value=" + str(self.value) + "]" class SortedList: def __init__(self): self.head = None def insert(self, valu...
true
cdfbeaf2c417826e26dc3016f9d42916712fb341
luiscarm9/Data-Structures-in-Python
/DataStructures/LinkedList_def/Program.py
627
4.21875
4
from LinkedList_def.LinkedList import LinkedList; LList=LinkedList() #Insert Elements at the start (FATS) LList.insertStart(1) LList.insertStart(2) LList.insertStart(3) LList.insertStart(5) #Insert Elements at the end (SLOW) LList.insertEnd(8) LList.insertEnd(13) LList.insertEnd(21) LList.insertEnd(34) LList.inse...
true
243b689861bcfa9dd4fd2ce32d7912aa8ba1c8b9
Priyanshuparihar/make-pull-request
/Python/2021/1stOct_KunalJaiswal-17.py
645
4.25
4
def is_prime(num): if num > 1: for i in range(2, num // 2 + 1): if (num % i) == 0: return False else: return True else: return False def fibonacci(num): num1, num2 = 1, 1 count = 0 if num == 1: print(num1) ...
false
d5e2382900b729a2e3392882cf95a006a36e57b9
Priyanshuparihar/make-pull-request
/Python/2021/1stOct_IshaSah.py
835
4.34375
4
'''Take input the value of 'n', upto which you will print. -Print the Fibonacci Series upto n while replacing prime numbers, all multiples of 5 by 0. Sample Input : 12 27 Sample Output : 1 1 0 0 0 8 0 21 34 0 0 144 1 1 0 0 0 8 0 21 34 0 0 144 0 377 0 987 0 2584 4181 0 10946 17711 0 46368 0 121393 196418''' import mat...
true
82a0b63b6b46dbc1b0fb456cf23d1554814c3b04
Priyanshuparihar/make-pull-request
/Python/2021/1stOct_devulapallisai.py
922
4.1875
4
# First take input n # contributed by Sai Prachodhan Devulapalli Thanks for giving me a route # Program to find whether prime or not def primeornot(num): if num<2:return False else: #Just checking from 2,sqrt(n)+1 is enough reduces complexity too for i in range(2,int(pow((num),1/2)+1)): ...
true
0319816ef3a65374eaa7dd895288b6eff0f42f4a
Priyanshuparihar/make-pull-request
/Python/2021/2ndOct_RolloCasanova.py
1,276
4.3125
4
# Function to print given string in the zigzag form in `k` rows def printZigZag(s, k): # Creates an len(s) x k matrix arrays = [[' ' for x in range (len(s))] for y in range (k)] # Indicates if we are going downside the zigzag down = True # Initialize the row and column to zero col, row = 0, 0 ...
true
5a840100907d0fe49012b75d8707ee142ba80738
Priyanshuparihar/make-pull-request
/Python/2021/2ndOct_Candida18.py
703
4.125
4
rows = int(input(" Enter the no. of rows : ")) cols = int(input(" Enter the no. of columns : ")) print("\n") for i in range(1,rows+1): print(" "*(i-1),end=" ") a = i while a<=cols: print(a , end="") b = a % (rows-1) if(b==0): b=(rows-1) a+=(rows-b)*2 print(" "*((rows-b)*2-1),end=" ") print("\n") """ ...
true
d2d56f7fc126004e97d41c53f9b3704d61978473
alexsmartens/algorithms
/stack.py
1,644
4.21875
4
# This stack.py implementation follows idea from CLRS, Chapter 10.2 class Stack: def __init__(self): self.items = [] self.top = 0 self.debug = True def is_empty(self): return self.top == 0 def size(self): return self.top def peek(self): ...
true
58fa55150c3bc3735f3f63be5193eb2433eddd28
Catboi347/python_homework
/fridayhomework/homework78.py
211
4.1875
4
import re string = input("Type in a string ") if re.search("[a-z]", string): print ("This is a string ") elif re.search("[A-Z]", string): print ("This is a string") else: print ("This is an integer")
true
9bb7603cfd3c9595b0142a4f4d575b1c50d5e5bf
karngyan/Data-Structures-Algorithms
/String_or_Array/Sorting/Bubble_Sort.py
784
4.46875
4
# bubble sort function def bubble_sort(arr): n = len(arr) # Repeat loop N times # equivalent to: for(i = 0; i < n-1; i++) for i in range(0, n-1): # Repeat internal loop for (N-i)th largest element for j in range(0, n-i-1): # if jth value is greater than (j+1) value ...
false
c3358ef21e7393f7f57fb5238cea8dc63bdf5729
karngyan/Data-Structures-Algorithms
/String_or_Array/Sorting/Selection_Sort.py
423
4.3125
4
# selection sort function def selection_sort(arr): n = len(arr) for i in range(0, n): for j in range(i+1, n): # if the value at i is > value at j -> swap if arr[i] > arr[j]: arr[i], arr[j] = arr[j], arr[i] # input arr arr = [3, 2, 4, 1, 5] print('Before selectio...
false
5e0bf04f50e383157a0f4d476373353342f3385e
karngyan/Data-Structures-Algorithms
/Tree/BinaryTree/Bottom_View.py
1,305
4.125
4
# Print Nodes in Bottom View of Binary Tree from collections import deque class Node: def __init__(self, data): self.data = data self.left = None self.right = None def bottom_view(root): if root is None: return # make an empty queue for BFS q = deque() # dict to...
true
8fd74242f802dd8438d622312f8bfd0f246826cc
karngyan/Data-Structures-Algorithms
/String_or_Array/Sorting/Insertion_Sort.py
567
4.34375
4
def insertion_sort(arr): n = len(arr) for i in range(1, n): x = arr[i] j = i - 1 while j >= 0 and arr[j] > x: # copy value of previous index to index + 1 arr[j + 1] = arr[j] # j = j - 1 j -= 1 # copy the value which was at ith inde...
false
487d70507adea1986e7c35271ced0d4f702f1897
karngyan/Data-Structures-Algorithms
/String_or_Array/Searching/Linear_Search.py
480
4.125
4
# Function for linear search # inputs: array of elements 'arr', key to be searched 'x' # returns: index of first occurrence of x in arr def linear_search(arr, x): # traverse the array for i in range(0, len(arr)): # if element at current index is same as x # return the index value if a...
true
1643160b78a5aefdb07225a4fa6ab56c11bcdcc7
ashwini-8/PythonUsing_OOP_Concept
/dictionariesImplementation.py
1,183
4.28125
4
d ={101:"Ashwini", 103:"Jayashree" , 104:"Rajkumar" ,102:"Abhijit" , 105:"Patil"} #created dict print(d) print(list(d)) #print list of keys print(sorted(d)) #print keys in sorted order print(d[101]) #accessing element using key print(d[10...
false
8cd285463fa90df622467e4b634e03e3d738b052
VinicciusSantos/CeV-Python
/Mundo1/ex008.py
277
4.1875
4
# Escreva um programa que leia um valor em metros e o exiba convertido em centímetros e milímetros. m = float(input("Digite uma distância em metros: ")) print(f'{m/1000}Km') print(f'{m/100}hm') print(f'{m/10}dam') print(f'{m*10}dm') print(f'{m*100}cm') print(f'{m*1000}mm')
false
674ba225acb3cb441f1dfbd4d32a8713cfc8ba9a
VinicciusSantos/CeV-Python
/Mundo1/ex022.py
504
4.15625
4
# Crie um programa que leia o nome completo de uma pessoa e mostre: # – O nome com todas as letras maiúsculas e minúsculas. # – Quantas letras ao todo (sem considerar espaços). # – Quantas letras tem o primeiro nome. nome = str(input('Qual o seu nome? ')).strip() print(f'Seu nome em letras maiúsculas: {nome.upper()}') ...
false
d87e3ccfe1dcebc2ba0e3d030b0704c68b52d684
dominiquecuevas/dominiquecuevas
/05-trees-and-graphs/second-largest.py
1,720
4.21875
4
class BinaryTreeNode(object): def __init__(self, value): self.value = value self.left = None self.right = None def insert_left(self, value): self.left = BinaryTreeNode(value) return self.left def insert_right(self, value): self.right = BinaryTreeNode(value...
true
ad6fc102c4ad03ca32dc29b84cdffb1d6108147e
VitaliiUr/wiki
/wiki
2,978
4.15625
4
#!/usr/bin/env python3 import wikipedia as wiki import re import sys import argparse def get_random_title(): """ Find a random article on the Wikipadia and suggests it to user. Returns ------- str title of article """ title = wiki.random() print("Random article's title:") ...
true
b2b22e8264799467c43b2051c63228d1304533f6
rdcorrigan/bmiCalculatorApp
/bmi_calculator.py
1,070
4.125
4
# BMI Calculator # by Ryan # Python 3.9 using Geany Editor # Windows 10 # BMI = weight (kilograms) / height (meters) ** 2 import tkinter # toolkit interface root = tkinter.Tk() # root.geometry("300x150") // OPTIONAL root.title("BMI Calculator") # Create Function(s) def calculate_bmi(): weight = float(e...
false
80d0e021194a67ff06851523210bc9f7ca635833
jimboowens/python-practice
/dictionaries.py
1,131
4.25
4
# this is a thing about dictionaries; they seem very useful for lists and changing values. # Dictionaries are just like lists, but instead of numbered indices they have english indices. # it's like a key greg = [ "Greg", "Male", "Tall", "Developer", ] # This is not intuitive, and the placeholders give ...
true
28914773c6065a3d262aa995274281503d42cca4
Finveon/PythonLern
/lesson_2_15.py
478
4.34375
4
#1 print ("1) My name is {}".format("Alexandr")) #2 my_name = "Alexandr" print("2) My name is {}".format(my_name)) #3 print("3) My name is {} and i'm {}".format(my_name, 38)) #4 print("4) My name is {0} and i'm {1}".format(my_name, 38)) #5 print("5) My name is {1} and i'm {0}".format(my_name, 38)) #6 pi = 3.1415 p...
false
735222b563750bceca379969e5cff58224ddf83e
nlin24/python_algorithms
/BinaryTrees.py
1,982
4.375
4
class BinaryTree: """ A simple binary tree node """ def __init__(self,nodeName =""): self.key = nodeName self.rightChild = None self.leftChild = None def insertLeft(self,newNode): """ Insert a left child to the current node object Append the left chil...
true
d22dd3d84f34487598c716f13af578c3d2752bc4
aduV24/python_tasks
/Task 19/example.py
1,720
4.53125
5
#************* HELP ***************** #REMEMBER THAT IF YOU NEED SUPPORT ON ANY ASPECT OF YOUR COURSE SIMPLY LEAVE A #COMMENT FOR YOUR MENTOR, SCHEDULE A CALL OR GET SUPPORT OVER EMAIL. #************************************ # =========== Write Method =========== # You can use the write() method in order to write to a...
true
473237b007ea679c7b55f3c4c7b5895bdf150ae5
aduV24/python_tasks
/Task 11/task2.py
880
4.34375
4
shape = input("Enter the shape of the builing(square,rectangular or round):\n") if shape == "square": length = float(input("Enter the length of one side:\n")) area = round(length**2,2) print(f"The area that will be taken up by the building is {area}sqm") #====================================================...
true
3427a7d78131b4d26b633aa5f70e2dc7a7dab748
aduV24/python_tasks
/Task 17/disappear.py
564
4.78125
5
# This program asks the user to input a string, and characters they wish to # strip, It then displays the string without those characters. string = input("Enter a string:\n") char = input("Enter characters you'd like to make disappear separated by a +\ comma:\n") # Split the characters given into a list...
true
55d2392b17d505045d5d80d209dc5635c47657f6
aduV24/python_tasks
/Task 17/separation.py
298
4.4375
4
# This program asks the user for a sentence and then displays # each character of that senetence on a new line string = input("Enter a sentence:\n") # split string into a list of words words = string.split(" ") # Iterate thorugh the string and print each word for word in words: print(word)
true
28488c65d5d977cb9b48772d64be224bdce8d0bf
aduV24/python_tasks
/Task 11/task1.py
702
4.25
4
num1 =60 num2 = 111 num3 = 100 if num1 > num2: print(num1) else: print(num2) print() if num1 % 2 == 0: print("The first number is even") else: print("The first number is odd") print() print("Numbers in descending order") print("===================================") if (num1 > num2) and (num1 > num3 ): ...
false
40df8c8aa7efb4fc8707f712b94971bae08dacea
aduV24/python_tasks
/Task 21/john.py
344
4.34375
4
# This program continues to ask the user to enter a name until they enter "John" # The program then displays all the incorrect names that was put in wrong_inputs = [] name = input("Please input a name:\n") while name != "John": wrong_inputs.append(name) name = input("Please input a name:\n") print(f"Incorrect...
true
aa382979b4f5bc4a8b7e461725f59a802ffe3a4e
aduV24/python_tasks
/Task 14/task1.py
340
4.59375
5
# This python program asks the user to input a number and then displays the # times table for that number using a for loop num = int(input("Please Enter a number: ")) print(f"The {num} times table is:") # Initialise a loop and print out a times table pattern using the variable for x in range(1,13): print(f"{num}...
true
ab8491166133deadd98d2bbbbb40775f95c7091b
aduV24/python_tasks
/Task 24/Example Programs/code_word.py
876
4.28125
4
# Imagine we have a long list of codewords and each codeword triggers a specific function to be called. # For example, we have the codewords 'go' which when seen calls the function handleGo, and another codeword 'ok' which when seen calls the function handleOk. # We can use a dictionary to encode this. def handleGo(x)...
true
ee04a317415c9a0c9481f712e8219c92fb719ce0
hackettccp/CIS106
/SourceCode/Module2/formatting_numbers.py
1,640
4.65625
5
""" Demonstrates how numbers can be displayed with formatting. The format function always returns a string-type, regardless of if the value to be formatted is a float or int. """ #Example 1 - Formatting floats amount_due = 15000.0 monthly_payment = amount_due / 12 print("The monthly payment is $", monthly_payment) #F...
true
3d2c8b1c05332e245a7d3965762b2a746d6e5c3d
hackettccp/CIS106
/SourceCode/Module4/loopandahalf.py
899
4.21875
4
""" Demonstrates a Loop and a Half """ #Creates an infinite while loop while True : #Declares a variable named entry and prompts the user to #enter the value z. Assigns the user's input to the entry variable. entry = input("Enter the value z: ") #If the value of the entry variable is "z", break from the loop...
true
824f4f86eaef9c87c082c0f471cb7a68cc72a44f
hackettccp/CIS106
/SourceCode/Module2/converting_floats_and_ints.py
1,055
4.71875
5
""" Demonstrates converting ints and floats. Uncomment the other section to demonstrate the conversion of float data to int data. """ #Example 1 - Converting int data to float data #Declares a variable named int_value1 and assigns it the value 35 int_value1 = 35 #Declares a variable named float_value1 and assigns i...
true
98868a37e12fc16d5a1e0d49cb8e076a5ffb107d
hackettccp/CIS106
/SourceCode/Module10/button_demo.py
866
4.15625
4
#Imports the tkinter module import tkinter #Imports the tkinter.messagebox module import tkinter.messagebox #Main Function def main() : #Creates the window test_window = tkinter.Tk() #Sets the window's title test_window.wm_title("My Window") #Creates button that belongs to test_window that #calls the sho...
true