blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
15c852d2d567f3334eb8c3dea00bf41cc1fa38e8
Zantosko/digitalcrafts-03-2021
/week_1/day5/fibonacci_sequence.py
755
4.34375
4
# Fibonacci Sequence sequence_up_to = int(input("Enter number > ")) # Inital values of the Fibacci Sequence num1, num2 = 0, 1 # Sets intial count at 0 count = 0 if sequence_up_to <= 0: print("Error endter positive numbers or greater than 0") elif sequence_up_to == 1: print(f"fib sequence for {sequence_up_to}"...
true
fb9f602648821d0c95ceaa030e7b358d58f2c68f
sergey-igoshin/pythone_start_dz2
/task_2_3.py
975
4.375
4
""" Пользователь вводит месяц в виде целого числа от 1 до 12. Сообщить, к какому времени года относится месяц (зима, весна, лето, осень). Напишите решения через list и dict. """ seasons_list = ['зима', 'весна', 'лето', 'осень'] seasons_dict = {0: 'зима', 1: 'весна', 2: 'лето', 3: 'осень'} month = int(input("Введи...
false
e6e3fb65e165ec1b9e9f584539499c22d545d2f2
nelsonje/nltk-hadoop
/word_freq_map.py
628
4.21875
4
#!/usr/bin/env python from __future__ import print_function import sys def map_word_frequency(input=sys.stdin, output=sys.stdout): """ (file_name) (file_contents) --> (word file_name) (1) maps file contents to words for use in a word count reducer. For each word in the document, a new key-value pair...
true
3ff26ff968410c3f06031903aa2035a1f5e33105
ebrandiao/fundamentos_de_python_TP1
/calculo_fatorial.py
837
4.3125
4
"""3. Escreva uma função em Python que calcule o fatorial de um dado número N usando um for. O fatorial de N=0 é um. O fatorial de N é (para N > 0): N x (N-1) x (N-2) x … x 3 x 2 x 1. Por exemplo, para N=5 o fatorial é: 5 x 4 x 3 x 2 x 1 = 120. Se N for negativo, exiba uma mensagem indicando que não é possível calcu...
false
29d58758c33b74d57e58aed9c8f84b8c157415da
alison99/python
/function.py
358
4.25
4
def print_multiples(n): i=1 output="" while i <= 6: output += str(n*i) + "\t" i += 1 print(output) #function called print_multiples #while loop looks similar #printing happens here IN the function #print_multiples(3) def print_square(): return [n**2 for n in range(10)] #for n in rang...
false
011f04127eee015c03781e4e720188933b55c993
Zurubabel/Python
/Aula8_TrabalhandoComVetores.py
555
4.34375
4
# Aula 8 - Trabalhando com arrays # Cachaça, coxinha, isqueiro, cigarro, ficha da sinuca (produtos) produtos = ["Cachaça", "Coxinha", "Isqueiro", "Cigarro", "Ficha da Sinuca"] # Endereçamento # produtos[0] = "Pingado" # produtos[5] = "Pingado" # Funções # append - Insiro um elemento no final do vetor # produtos.app...
false
c7c27bb22d9516753f2e10af5f119b245fe9948f
jamesfallon99/CA117
/week03/numcomps_031.py
1,150
4.15625
4
#!/usr/bin/env python3 import sys def three(N): return [n for n in range(1, N + 1) if n % 3 == 0] def squares(N): return[n ** 2 for n in range(1, N + 1) if n % 3 == 0] def double(N): return[n * 2 for n in range(1, N + 1) if n % 4 == 0] def three_or_four(N): return[n for n in range(1, N + 1) if n % ...
false
b8eb07e732f80f4303e5020aecb26f7711e93d1d
PederBG/sorting_algorithms
/InsertionSort.py
510
4.25
4
""" Sorting the list by iterating upwards and moving each element back in the list until it's sorted with respect on the elements that comes before. RUNTIME: Best: Ω(n), Average: Θ(n^2), Worst: O(n^2) """ def InsertionSort(A): for i in range(1, len(A)): key = A[i] j = i - 1 while j > ...
true
04715d6ba832e058a54c07f454e90218cb1c4650
quynhanh299/abcd
/baiconrua.py
324
4.21875
4
# from turtle import* # shape("turtle") # for i in range (3): # forward(200) # left(90) # forward(200) # left(90) # forward(200) # left(90) # forward(200) # left(90) # mainloop() # # bai tap ve 9 hinh tron from turtle import* shape("turtle") for i in range (9): circle(40) right(...
false
708c3f290a705b46dc828a704a3d4e2a431fee51
zadadam/algorithms-python
/sort/bubble.py
1,066
4.125
4
import unittest def bubble_sort(list): """Sort list using Bubble Sort algorithm Arguments: list {integer} -- Unsorted list Returns: list {integer} -- Sorted list """ swap=True test ="It is a bad code"; while swap: swap = False for n in range(len(li...
true
109ec4c8b4316cc46479ab9cfe93f2fe7a9f817d
vishul/Python-Basics
/openfile.py
500
4.53125
5
# this program opens a file and prints its content on terminal. #files name is entered as a command line argument to the program. #this line is needed so we can use command line arguments in our program. from sys import argv #the first command line argument i.e program call is saved in name and the #second CLA is stor...
true
2e3924cd0819ea47b3d5081e4d24647a31ea19fa
bsextion/CodingPractice_Py
/MS/Fast Slow Pointer/rearrange_linkedlist.py
1,332
4.15625
4
class Node: def __init__(self, value, next=None): self.value = value self.next = next def print_list(self): temp = self while temp is not None: print(str(temp.value) + " ", end='') temp = temp.next print() def reorder(head): middle = find_middle(head) reversed_middle = reverse_...
true
4c5761f987c88512f2b4f0a3240f71ae39f10101
bsextion/CodingPractice_Py
/Google/L1/challenge.py
1,215
4.34375
4
# Due to the nature of the space station's outer paneling, all of its solar panels must be squares. # Fortunately, you have one very large and flat area of solar material, a pair of industrial-strength scissors, # and enough MegaCorp Solar Tape(TM) to piece together any excess panel material into more squares. # For ex...
true
8513c30cfd6b8fc19b6bd992e27bbd8e04160ad7
wandershow/Python
/ex059.py
1,237
4.21875
4
# crie um programa que leia dois numeros e mostre um menu na tela #[1] somar #[2] multiplicar #[3] maior #[4] novos numeros #[5] sair do programa #seu programa devera realizar a operação solicitada em cada caso n1 = int(input('Digite o 1º numero: ')) n2 = int(input('Digite o 2º numero: ')) opcao = 0 while opcao != 5: ...
false
314e30531c946c80ffbe95d6b5aa36eb93dbf972
wandershow/Python
/ex075.py
1,490
4.125
4
'''Desenvolva um programa que leia 4 valores do teclado e guarde os em uma tupla e mostre quantas vezes apareceu o valor 9 Em que posição foi digitado o valor 3 pela primeira vez Quais foram os numeros pares ''' cont = 0 pos = 0 par = 0 numero = (int(input('Digite um numero: ')), int(input('Digite outro numero: ')), in...
false
31f6f4032e451f0e784c6c4a7ce5d7a6090bd438
Lalesh-code/PythonLearn
/String Operation.py
1,739
4.15625
4
name = 'Lalesh' print(name) name = "Garud" print(name) name = str("Welcome") print(name) #id function to get the memory location ID: name1="welcome" name2="python" print(id(name1)) # 16157312 print(id(name2)) # 16157376 name3 = name2 + "my area" print(id(name3)) # 15764880 # Operations on Strings: + for addition...
false
a32fa47fe2f8e571a862e53e89d76ab67efebc21
Lalesh-code/PythonLearn
/Oops_Encapsulation.py
1,484
4.4375
4
# Encapsulation: this restrict the access to methods and variables. This can prevent the data from being get modified accidently or by security point of view. This is achived by using the private methods and variables. # Private methods denoted by "__" sign. # Public methods can be accessed from anywhere but Private me...
true
b9104f7316d95eaa733bbbd4926726472855046e
emma-rose22/practice_problems
/HR_arrays1.py
247
4.125
4
'''You are given a space separated list of nine integers. Your task is to convert this list into a 3x3 NumPy array.''' import numpy as np nums = input().split() nums = [int(i) for i in nums] nums = np.array(nums) nums.shape = (3, 3) print(nums)
true
33ba46d849eec7e9d1021641558606a24904b40a
qimanchen/Algorithm_Python
/python_interview_program/合并两个有序序列.py
779
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 合并两个有序列表 """ def recursion_merge_sort(l1, l2, tmp): """ :param l2: list :param l1: list :param tmp: sorted list :return: list """ if len(l1) == 0 or len(l2) == 0: tmp.extend(l1) tmp.extend(l2) return tmp else: if l1[0] < l2[0]: tmp.append(l1[0]) ...
false
4239aaee9e02cf22c29b61d6e60efabf702abcb5
asiapiorko/Introduction-to-Computer-Science-and-Programming-Using-Python
/Unit 1 Exercise 1.py
1,616
4.1875
4
""" In this problem you'll be given a chance to practice writing some for loops. 1. Convert the following code into code that uses a for loop. prints 2 prints 4 prints 6 prints 8 prints 10 prints Goodbye! """ # First soultion for count in range(2,11,2): print(count) print("Goodbye!") # F...
true
84fce63f043d3b48c019739dce5d9a58df6c0198
arcstarusa/prime
/StartOutPy4/CH7 Lists and Tuples/drop_lowest_score/main.py
678
4.21875
4
# This program gets a series of test scores and # calculates the average of the scores with the # lowest score dropped. 7-12 def main(): # Get the test scores from the user. scores = get_scores() # Get the total of the test scores. total = get_total(scores) # Get the lowest test scores. lowest...
true
18c597902f1fa9e14de3506f2cce0d357af647b0
arcstarusa/prime
/StartOutPy4/CH12 Recursion/fibonacci.py
457
4.125
4
# This program uses recursion to print numbers from the Fibonacci series. def main(): print('The first 10 numberss in the ') print('Fibonacci series are:') for number in range(1,11): print(fib(number)) # The fib function returns returns the nth number # in the Fibonacci series. def fib(n): if n...
true
1684ed5ced8288e821c464db286a72f0c1098b0a
arcstarusa/prime
/StartOutPy4/CH8 Strings/validate_password.py
420
4.15625
4
# This program gets a password from the user and validates it. 8-7 import login1 def main(): # Get a password from the user. password = input('Enter your password: ') # Validate the password. while not login1.valid_password(password): print('That password is not valid.') password = in...
true
46cba8a43cb65ece9a372e4c99c46b987d88dbd7
LesterAGarciaA97/OnlineCourses
/08. Coursera/01. Python for everybody/Module 1/Week 06/Code/4.6Functions.py
1,004
4.4375
4
#4.6 Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay should be the normal rate for hours up to 40 and #time-and-a-half for the hourly rate for all hours worked above 40 hours. Put the logic to do the computation of pay in a function called computepay() and use #the...
true
b40fd2dab0c7eebf9690850182ef28e0e4da062a
rishabhshellac/Sorting
/bubblesort.py
585
4.3125
4
# Bubble Sort """Comparing current element with adjacent element Repeatedly swapping the adjacent elements if they are in wrong order.""" def bubblesort(arr): for i in range(len(arr)): for j in range(len(arr)-1): if(arr[j] > arr[j+1]): temp = arr[j] ...
false
f8662d63b37d01fbbd154eb27cac1ec4efada389
luckeyRook/python_study
/応用編/32.最小値・最大値の取得/TEST32.py
1,241
4.21875
4
#32.最小値・最大値の取得 #min print(min([10,20,30,5,3])) print(min('Z','A','J','w')) #max print(max([10,20,30,5,3])) print(max('Z','A','J','w')) #key引数 def key_func(n): return int(n) l=[2,3,4,'111'] print(min(l,key=key_func)) print(max(l,key=key_func)) print('========================================-') def key_func2(n)...
false
0a4c4d4a80d0bd67456336c3e81b9259cac4bb4d
luckeyRook/python_study
/応用編/28.内包表記/TEST28.py
1,407
4.1875
4
#28.内包表記 #リストの内包表記 comp_list=[i for i in range(10)] print(comp_list) #以下のコードと同じ comp_list=[] for i in range(10): comp_list.append(i) print(comp_list) #本来は3行必要な処理を一行にできる comp_list=[str(i*i) for i in range(10)] print(comp_list) print('=================================') #ディクショナリの内包表記 comp_dict={str(i):i*i for i i...
false
6cb09e7a8ff19cabb2a5b2218c1fbf3b994ffa5e
Kilatsat/deckr
/webapp/engine/card_set.py
2,455
4.125
4
""" This module contains the CardSet class. """ from engine.card import Card def create_card_from_dict(card_def): """ This is a simple function that will make a card from a dictionary of attributes. """ card = Card() for attribute in card_def: setattr(card, attribute, card_def[attrib...
true
965f4117268913264e21e1924052bbb50c95712d
junawaneshivani/Python
/ML with Python/numpy_crash_course.py
1,139
4.25
4
import numpy as np # define an 1d array my_list_1 = [1, 2, 3] my_array_1 = np.array(my_list_1) print(my_array_1, my_array_1.shape) # define a 2d array my_list_2 = [[1, 2, 3], [4, 5, 6]] my_array_2 = np.array(my_list_2) print(my_array_2, my_array_2.shape) print("First row: {}".format(my_array_2[0])) print("Last row: {...
false
b1b68e288109b0b05c8b8f2217f7e95a6f744e34
luola63702168/leetcode
/primary_algorithm/r_07_design_problem/rusi_01_shuffle_array.py
1,308
4.125
4
import copy import random # 打乱一个没有重复元素的数组。 # # 示例: # # // 以数字集合 1, 2 和 3 初始化数组。 # int[] nums = {1,2,3}; # Solution solution = new Solution(nums); # // 打乱数组 [1,2,3] 并返回结果。任何 [1,2,3]的排列返回的概率应该相同。 # solution.shuffle(); # // 重设数组到它的初始状态[1,2,3]。 # solution.reset(); # // 随机返回数组[1,2,3]打乱后的结果。 # solutio...
false
22811f3d9c3624b15dc27517c1b8a98e652e3f3e
luola63702168/leetcode
/primary_algorithm/r_02_str/ll_02_整数反转.py
739
4.28125
4
def reverse(x): str_ = str(x) if x == 0: return 0 elif x > 0: x = int(str_[::-1]) else: x = int('-' + str_[::-1].rstrip("-").rstrip("0")) if -2 ** 31 < x < 2 ** 31 - 1: return x return 0 # str_= str(x) # if x == 0 or x <= -2 ** 31 or x >=...
false
9f0a9465e1d2f2328088cc53093a61101005a17c
CaseyTM/day1Python
/tuples.py
1,320
4.34375
4
# arrays (lists) are mutable (changeable) but what if you do not want them to be so, enter a tuple, a constant array (list) a_tuple = (1,3,8) print a_tuple; # can loop through them and treat them the same as a list in most cases for number in a_tuple: print number; teams = ('falcons', 'hawks', 'atl_united', 'silve...
true
921432c5dd48fa4ebfb7172bbafaaaefbd56bc8a
tingjianlau/my-leetcode
/88_merge_sorted_array/88_merge_sorted_array.py
1,592
4.1875
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- ########################################################################## # > File Name: 88_merge_sorted_array.py # > Author: Tingjian Lau # > Mail: tjliu@mail.ustc.edu.cn # > Created Time: 2016/05/31 #######################################################################...
false
864b676fbc74522541658bec2bc88d3af97b4598
csojinb/6.001_psets
/ps1.3.py
1,208
4.3125
4
import math STARTING_BALANCE = float(raw_input('Please give the starting balance: ')) INTEREST_RATE = float(raw_input('Please give the annual interest' 'rate (decimal): ')) MONTHLY_INTEREST_RATE = INTEREST_RATE/12 balance = STARTING_BALANCE monthly_payment_lower_bound = STARTING_BALAN...
true
ccb1ec3d8b7974b3ad05c38924c2856d2c5f01db
edenuis/Python
/Sorting Algorithms/mergeSortWithO(n)ExtraSpace.py
1,080
4.15625
4
#Merge sort from math import ceil def merge(numbers_1, numbers_2): ptr_1 = 0 ptr_2 = 0 numbers = [] while ptr_1 < len(numbers_1) and ptr_2 < len(numbers_2): if numbers_1[ptr_1] <= numbers_2[ptr_2]: numbers.append(numbers_1[ptr_1]) ptr_1 += 1 else: nu...
true
64fe2ed64c6fe5c801e88f8c1e266538f7d51d40
brodieberger/Control-Statements
/(H) Selection statement that breaks loops.py
345
4.25
4
x = input("Enter string: ") #prompts the user to enter a string y = input("Enter letter to break: ") #Letter that will break the loop for letter in x: if letter == y: break print ('Current Letter:', letter) #prints the string letter by letter until it reaches the letter that breaks the loop. input ...
true
0af5be1b677b7d0734e0bc071f03f74007bb960a
Chil625/FlaskPractice
/lec1/if_statements.py
1,039
4.15625
4
# should_continue = True # if should_continue == True: # print("Hello") # # people_we_know = ["John", "Anna", "Mary"] # person = input("Enter the person you know: ") # # if person in people_we_know: # print("You know {}!".format(person)) # else: # print("You don't know {}!".format(person)) def who_do_you...
false
2fd02e4ef529c04cb315456e58c2533f94ed4df6
austBrink/Tutoring
/python/Maria/targetGame.py
1,608
4.375
4
# Hit the Target Game # 02/11/23 # Maria Harrison import turtle # named constants SCREEN_WIDTH = 600 SCREEN_HEIGHT = 600 TARGET_LLEFT_X = 100 TARGET_LLEFT_Y = 250 TARGET_WIDTH = 25 FORCE_FACTOR = 30 PROJECTILE_SPEED = 1 NORTH = 90 SOUTH = 270 EAST = 0 WEST = 180 # Setup the window turtle.setup(SCREEN_WIDTH, SCREEN_HEIG...
false
ed767807eae30530f1d4e121217585aff3bcea75
austBrink/Tutoring
/python/Maria/makedb.py
2,370
4.34375
4
import sqlite3 def main(): # Connect to the database. conn = sqlite3.connect('cities.db') # Get a database cursor. cur = conn.cursor() # Add the Cities table. add_cities_table(cur) # Add rows to the Cities table. add_cities(cur) # Commit the changes. ...
true
7626635b10874cd45ef572540d1347eeff90a00e
austBrink/Tutoring
/python/Maria/databasereader.py
1,258
4.40625
4
import sqlite3 conn = sqlite3.connect('cities.db') # city id, city name, population namesByPop = conn.execute(''' SELECT CityName FROM Cities ORDER BY Population ''') for row in namesByPop: print ("ID = ", row[0]) print ("CITY NAME = ", row[1]) print ("POPULATION = ", row[2] ) namesByPopDesc = conn...
false
bf639aca06615e7a8d84d9322024c17873504c00
austBrink/Tutoring
/python/Sanmi/averageRainfall.py
1,362
4.5
4
# Write a program that uses ( nested loops ) to collect data and calculate the average rainfall over a period of two years. The outer loop will iterate once for each year. The inner loop will iterate twelve times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for tha...
true
c25780c144bbff40242092fbbe961a3b5e72c8e4
roshan1966/ParsingTextandHTML
/count_tags.py
862
4.125
4
# Ask the user for file name filename = input("Enter the name of a HTML File: ") def analyze_file(filename): try: with open (filename, "r", encoding="utf8") as txt_file: file_contents = txt_file.read() except FileNotFoundError: print ("Sorry, the file named '" + filename + "...
true
374c16f971fc2238848a91d94d43293c592e6f03
udaybhaskar8/git-project
/functions/ex4.py
322
4.125
4
import math # Calculate the square root of 16 and stores it in the variable a a =math.sqrt(16) # Calculate 3 to the power of 5 and stores it in the variable b b = 3**5 b=math.pow(3, 5) # Calculate area of circle with radius = 3.0 by making use of the math.pi constant and store it in the variable c c = math.pi * (3**2...
true
0536bf4d5ab562112a5971e9b517da0513f460dc
QWJ77/Python
/StudyPython/Python-函数的值传递和引用传递.py
950
4.1875
4
''' 值传递:传递过来的是一个数据的副本,修改副本对原件没有任何影响 引用传递:传递过来的是一个变量的地址,通过地址可以操作同一份文件 注:在Python中,只有引用传递 但是,如果数据类型是可变类型,则可以改变原件 如果数据类型是不可变类型,则不可以改变原件 可变数据类型:列表list和字典dict; 不可变数据类型:整型int、浮点型float、字符串型string和元组tuple。 ''' # 如果数据类型是不可变类型,则不可以改变原件 # def change(num): # print(id(num)) # num=666 # print(id(num)) # # b=10 # print(id...
false
ec3c637f34938d142797ed51f4184c807455335f
QWJ77/Python
/StudyPython/Python列表-常用操作-增加.py
894
4.34375
4
''' append 往列表里追加一个新元素,只追加一个元素 注意:会直接修改原列表!!! ''' # nums=[1,2,3,4,5] # print(nums) # print(nums.append(5)) # print(nums) ''' insert(index,object) 插入到index的前面 它会改变列表本身!!! ''' # nums=[1,2,3,4,5] # print(nums) # print(nums.insert(0,5)) # print(nums) ''' extend 往列表中。扩展另一个可迭代序列,把可迭代元素分解成每一个元素添加到列表 它会改变列表本身!!! ''' nums=[1...
false
890ae7b46c38ee2c77ea8b7d574f5998573efb34
Tech-nransom/dataStructuresAndAlgorithms_Python
/bubbleSort.py
460
4.4375
4
def bubbleSort(array,ascending=True): for i in range(len(array)): for j in range(i,len(array)): if ascending: if array[i] > array[j]: array[i],array[j] = array[j],array[i] else: if array[i] < array[j]: array[i],array[j] = array[j],array[i] return array # 9 2 5 1 3 7 if __name__ == '__m...
false
9affcfc38a322081ef4afeb658aa97ec03f871ab
mckennec2014/cti110
/P3HW1_ColorMix_ChristianMcKenney.py
975
4.28125
4
# CTI-110 # P3HW1 - Color Mixer # Christian McKenney # 3/17/2020 #Step-1 Enter the first primary color #Step-2 Check if it's valid #Step-3 Enter the second primary color #Step-4 Check if it's valid #Step-5 Check for combinations of colors and display that color # Get user input color1 = input('Enter t...
true
7008005de70aadea1bebd51d8a068272c7f7b6af
mckennec2014/cti110
/P5HW2_MathQuiz _ChristianMcKenney.py
2,012
4.375
4
# This program calculates addition and subtraction with random numbers # 4/30/2020 # CTI-110 P5HW2 - Math Quiz # Christian McKenney #Step-1 Define the main and initialize the loop variable #Step-2 Ask the user to enter a number from the menu #Step-3 If the user enters the number 1, add the random numbers and #...
true
7e3ff4cbf422f91773d66991a05720718ec42bd7
cs112/cs112.github.io
/recitation/rec8.py
1,585
4.1875
4
""" IMPORTANT: Before you start this problem, make sure you fully understand the wordSearch solution given in the course note. Now solve this problem: wordSearchWithIntegerWildCards Here we will modify wordSearch so that we can include positive integers in the board, like so (see board[1][1]): board = [ [ 'p'...
true
63d2eda6cbc8cbfc8c992828adb506ffd7f5a075
cs112/cs112.github.io
/challenges/challenge_1.py
759
4.15625
4
################################################################################ # Challenge 1: largestDigit # Find the largest digit in an integer ################################################################################ def largestDigit(n): n = abs(n) answer = 0 check =0 while n >0: ch...
true
ac1c189338811d43945c5e96f729085aaffe26d8
Halal-Appnotrix/Problem-Solving
/hackerrank/Problem-Solving/Algorithm/Implementation/Grading_Students.py
783
4.125
4
# # The function is expected to return an INTEGER_ARRAY. # The function accepts INTEGER_ARRAY grades as parameter. # def gradingStudents(grades): grades_array = [] for grade in grades: the_next_multiple_of_5 = (((grade // 5)+1)*5) if grade < 38: grades_array.append(grade) ...
true
b57b87613722928d3011f9bba5325e962765a403
matsalyshenkopavel/codewars_solutions
/Stop_gninnipS_My_sdroW!.py
833
4.125
4
"""Write a function that takes in a string of one or more words, and returns the same string, but with all five or more letter words reversed (like the name of this kata). Strings passed in will consist of only letters and spaces. Spaces will be included only when more than one word is present.""" def spin_words(sent...
true
ec032c38241a21a69ea74a412cc065b941fde566
eduardoorm/pythonExercises
/parte2/e10.py
407
4.125
4
# Escriba una función es_bisiesto() que determine si un año determinado es un año # bisiesto.Un año bisiesto es divisible por 4, pero no por 100. También es divisible por 400 def es_bisiesto(anio): if(anio%4==0 and anio%100!=0): return True return False anio = int(input("Por favor ingrese un año")) is...
false
72ca893a64d68df62007a37b70a597fa7f11112f
gladguy/PyKids
/project.py
2,313
4.21875
4
print("Hi i am a turtle and I can draw many shapes") import turtle def circle(radius,bob): bob.pendown() bob.circle(radius) bob.penup() def star(bob): bob.pendown() for i in range(5): bob.forward(100) bob.right(144) bob.penup() def square(bob): bob.pendown() for i i...
false
c8ba22783ac90fe69a8c3b86dab3a3fc8d905980
gladguy/PyKids
/Aamirah Fathima/Input_file.py
231
4.15625
4
print("My name is Aamirah what is your name?") name = input("Enter your name!") print(name) print("My age is 10 ?") age = input("Enter your age!") print(age) a = 6 if int(age) < a: print("You are too young to drive!")
false
e9183dc00682ac9e38bc8f01fd49f4b5f3c9fa37
Isha09/mit-intro-to-cs-python
/edx/week1/prob1.py
552
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Nov 6 14:52:43 2017 @author: esha Prog: Assume s is a string of lower case characters. Write a program that counts up the number of vowels contained in the string s. Valid vowels are: 'a', 'e', 'i', 'o', and 'u'. For example, if s = 'azcbobobegghak...
true
90fd58a60095a888058eb7788255886b6870056a
david778/python
/Point.py
1,233
4.4375
4
import math class Point(object): """Represents a point in two-dimensional geometric coordinates""" def __init__(self, x=0.0, y=0.0): """Initialize the position of a new point. The x and y coordinates can be specified. If they are not, the point defaults to the origin.""" self.move(x, ...
true
47c580cf46d2c83ebf1ca05601c7f4c05ea4d913
nitred/nr-common
/examples/mproc_example/mproc_async.py
1,442
4.15625
4
"""Simple example to use an async multiprocessing function.""" from common_python.mproc import mproc_async, mproc_func # STEP - 1 # Define a function that is supposed to simulate a computationally intensive function. # Add the `mproc_func` decorator to it in order to make it mproc compatible. @mproc_func def get_squa...
true
d6fb8c780bc46b577df3beb95265bf6addd4d2e1
ronBP95/insertion_sort
/app.py
690
4.21875
4
def insertion_sort(arr): operations = 0 for i in range(len(arr)): num_we_are_on = arr[i] j = i - 1 # do a check to see that we don't go out of range while j >= 0 and arr[j] > num_we_are_on: operations += 1 # this check will be good, because we won'...
true
7314f15c59cd41a095c2d6c9e12e824ff23f9dad
davidalanb/PA_home
/Py/dicts.py
1,188
4.4375
4
# make an empty dict # use curly braces to distinguish from standard list words = {} # add an item to words words[ 'python' ] = "A scary snake" # print the whole thing print( words ) # print one item by key print( words[ 'python' ] ) # define another dict words2 = { 'dictionary': 'a heavy book', \ 'cl...
true
aa5a664ccba0cd7dee9df189804cbcce0fd3e6d0
davidalanb/PA_home
/Py/ps4/lists.py
1,492
4.125
4
''' Lists are mutable ''' print( '----------- identical to string methods ---------------' ) # type-casting: make a list out of a string s = "Benedetto" ls = list(s) # basics print( ls ) print( len( ls ) ) print( ls[0], ls[-1] ) # one way to iterate for letter in ls: print( letter, end='.' ) print() # 2nd way...
false
e3ebb85ecd24e1377c002063691b02ac2d6d12f8
Lschulzes/Python-practice
/ex033.py
610
4.1875
4
nums = int(input('Digite 3 números: ')) un = nums // 1 % 10 dez = nums // 10 % 10 cent = nums // 100 % 10 if un > dez: if un > cent: if cent < dez: print(f'O maior número é {un} e o menor é {cent}') else: print(f'O maior número é {un} e o menor é {dez}') else: ...
false
8da467620d03b99b73ed7a1720a299a75266fdfc
Lschulzes/Python-practice
/ex009.py
309
4.1875
4
n = int(input('Digite um número inteiro: ')) n1 = n * 1 n2 = n * 2 n3 = n * 3 n4 = n * 4 n5 = n * 5 n6 = n * 6 n7 = n * 7 n8 = n * 8 n9 = n * 9 print(f'{n} * 1 = {n1}\n{n} * 2 = {n2}\n{n} * 3 = {n3}\n{n} * 4 = {n4}\n{n} * 5 = {n5}\n{n} * 6 = {n6}\n{n} * 7 = {n7}\n{n} * 8 = {n8}\n{n} * 9 = {n9}')
false
06758f00f3b1ce885899102fe093651f6d0226b4
Lschulzes/Python-practice
/ex039.py
323
4.1875
4
ano = int(input('Qual o ano do seu nascimento? ')) idade = 2021 - ano passou = idade - 18 falta = 18 - idade if idade == 18: print('Você deve se alistar neste ano!') elif idade > 18: print(f'Você deveria ter se alistado há {passou} anos!') else: print(f'Você deverá se alistar em {falta} anos!')
false
73e023a3d2ca6364b71fe2f99f19415477ff4c46
amitjpatil23/simplePythonProgram
/MatrixMultiplication.py
598
4.15625
4
# Program to multiply two matrices using nested loops # take a 3 by 3 matrix A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] # take a 3 by 4 matrix B = [[100, 200, 300, 400], [500, 600, 700, 800], [900, 1000, 1100, 1200]] result = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, ...
false
f8f481911c4d3d8b79082899528af93978e92957
amitjpatil23/simplePythonProgram
/Atharva_35.py
620
4.25
4
# Simple program in python for checking for armstrong number # Python program to check if the number is an Armstrong number or not y='y' while y == 'y': # while loop # take input from the user x = int(input("Enter a number: ")) sum = 0 temp = x while temp > 0: #loop for ...
true
0c8893cdaadd507fb071816a92dd52f2c8955d65
amitjpatil23/simplePythonProgram
/palindrome_and_armstrong_check.py
630
4.21875
4
def palindrome(inp): if inp==inp[::-1]: #reverse the string and check print("Yes, {} is palindrome ".format(inp)) else: print("No, {} is not palindrome ".format(inp)) def armstrong(number): num=number length=len(str(num)) total=0 while num>0: temp=num%10 ...
true
e7c66be2e1a9bdc5d12081089678885933da93d4
SongYippee/leetcode
/String/字符串相乘.py
1,240
4.1875
4
# -*- coding: utf-8 -*- # @Time : 2019/2/13 16:51 # @Author : Yippee Song # @Software: PyCharm ''' 给定两个以字符串形式表示的非负整数 num1 和 num2,返回 num1 和 num2 的乘积,它们的乘积也表示为字符串形式。 示例 1: 输入: num1 = "2", num2 = "3" 输出: "6" 示例 2: 输入: num1 = "123", num2 = "456" 输出: "56088" 说明: num1 和 num2 的长度小于110。 num1 和 num2 只包含数字 0-9。 num1 和 nu...
false
a26e88d420464e4c075984303274738ce61db468
SongYippee/leetcode
/LinkedList/86 分片链表.py
1,529
4.15625
4
# -*- coding: utf-8 -*- # @Time : 1/14/20 10:17 PM # @Author : Yippee Song # @Software: PyCharm ''' Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the nodes in each of the two partitio...
true
553d882e8e0f8e7588b69d8ea491e2b54ecf4689
SongYippee/leetcode
/String/翻转字符串里的单词.py
881
4.15625
4
# -*- coding: utf-8 -*- # @Time : 2019/2/13 16:54 # @Author : Yippee Song # @Software: PyCharm ''' 给定一个字符串,逐个翻转字符串中的每个单词。 示例: 输入: "the sky is blue", 输出: "blue is sky the". 说明: 无空格字符构成一个单词。 输入字符串可以在前面或者后面包含多余的空格,但是反转后的字符不能包括。 如果两个单词间有多余的空格,将反转后单词间的空格减少到只含一个。 进阶: 请选用C语言的用户尝试使用 O(1) 空间复杂度的原地解法。 ''' class Solution...
false
04a19b417325d45e3b776f200eed3d80042a2159
uran001/Small_Projects
/Hot_Potato_Game/hot_potato_classic.py
1,236
4.125
4
# Note the import of the Queue class from queue import ArrayQueue def hot_potato(name_list, num): """ Hot potato simulator. While simulating, the name of the players eliminated should also be printed (Note: you can print more information to see the game unfolding, for instance the list of players to w...
true
474cc9eb3ba257339e9b726479cfa10f03c14e29
rbarrette1/Data-Structures
/LinkedList/LinkedList.py
2,055
4.21875
4
from Node import * # import Node class head = "null" # first node of the linked list class LinkedList(): def __init__(self): self.head = None # set to None for the time being # insert after a specific index def insert_after_index(self, index, new_node): node = self.head # get the first no...
true
642410d99d761e9565cd2829893d08bf901e7c7b
Johnscar44/code
/python/notes/elif.py
331
4.125
4
secret_num = "2" guess = input("guess the number 1 - 3: ") if guess.isdigit() == False: print("answer can only be a digit") elif guess == "1": print("Too Low") elif guess == "2": print("You guessed it!") elif guess == "3": print("Too high") else: print("Guess not in rage 1 - 3") print("please t...
true
a2b2da73552e61cc2a3fbae380186374984d0b0f
Johnscar44/code
/compsci/moon.py
1,207
4.1875
4
phase = "Full" distance = 228000 date = 28 eclipse = True # - Super Moon: the full moon occurs when the moon is at its closest approach to earth (less than 230,000km away). # - Blue Moon: the second full moon in a calendar month. In other words, any full moon on the 29th, 30th, or 31st of a month. # - Blood Moon: a lu...
true
6d2ddc65b018e810f4e4e6dc4424cc6025853faa
Johnscar44/code
/compsci/newloop.py
562
4.375
4
mystery_int_1 = 3 mystery_int_2 = 4 mystery_int_3 = 5 #Above are three values. Run a while loop until all three #values are less than or equal to 0. Every time you change #the value of the three variables, print out their new values #all on the same line, separated by single spaces. For #example, if their values were ...
true
570a915a233eee00cc23b34d7ce3cf2c78940d75
Johnscar44/code
/compsci/forloop.py
957
4.71875
5
#In the designated areas below, write the three for loops #that are described. Do not change the print statements that #are currently there. print("First loop:") for i in range(1 , 11): print(i) #Write a loop here that prints the numbers from 1 to 10, #inclusive (meaning that it prints both 1 and 10, and all #the...
true
1505e0d9e27d1b20670da4c4667fc9189fe151a5
Fernando23296/l_proy
/angle/ayuda_1.py
461
4.21875
4
from turtle import * from math import * import math a = float(input("enter the value for a: ")) b = float(input("enter the value for b: ")) c = float(input("enter the value for c: ")) if (a + b >= c) and (b + c >= a) and (c + a >= b): print("it's a triangle") A = degrees(acos((b**2 + c**2 - a**2)/(2*b*c))) ...
false
691d922adfbb58996dabc180a1073ef06afa000a
choprahetarth/AlgorithmsHackerRank01
/Python Hackerrank/oops3.py
827
4.25
4
# Credits - https://www.youtube.com/watch?v=JeznW_7DlB0&ab_channel=TechWithTim # class instantiate class dog: def __init__(self,name,age): self.referal = name self.age = age # getter methods are used to print # the data present def get_name(self): return self.referal de...
true
5960a9e747851838f2823ab0b3b5027275d12b97
choprahetarth/AlgorithmsHackerRank01
/Old Practice/linkedList.py
1,093
4.46875
4
# A simple python implementation of linked lists # Node Class class Node: # add an init function to start itself def __init__(self,data): self.data = data self.next = None # initialize the linked list with null pointer # Linked List Class class linkedList: # add an init function to initial...
true
b499e6ecc7e711bf74441b89fec4fcc49712b4a3
Mohini-2002/Python-lab
/Method(center,capitalize,count,encode,decode)/main.py
702
4.28125
4
#Capitalize (capital the first of a string and its type print) ST1 = input("Enter a string :") ST1 = ST1.capitalize() print("After capitalize use : ", ST1, type(ST1)) #Center (fill the free space of a string and and its type print) ST2 = input("ENter a string :") ST2 = ST2.center(20, "#") print("After center u...
true
718d8989750b21513fff2c0eea78016432b90a4d
asimihsan/challenges
/epi/ch12/dictionary_word_hash.py
2,509
4.15625
4
#!/usr/bin/env python # EPI Q12.1: design a hash function that is suitable for words in a # dictionary. # # Let's assume all words are lower-case. Note that all the ASCII # character codes are adjacent, and yet we want a function that # uniformly distributes over the space of a 32 bit signed integer. # # We can't simp...
true
70e759634d967837b0faed377ced9807c4a604f8
xct/aoc2019
/day1.py
920
4.125
4
#!/usr/bin/env python3 ''' https://adventofcode.com/2019/day/1 Fuel required to launch a given module is based on its mass. Specifically, to find the fuel required for a module, take its mass, divide by three, round down, and subtract 2. ''' data = [] with open('data/day1.txt','r') as f: data = f.readlines() #...
true
3f26a0de9a124b493c1dc5734a2f9e9d30ef6114
vaishalibhayani/Python_example
/Python_Datatypes/sequence_types/dictionary/dictionary1.py
516
4.28125
4
emp={ 'course_name':'python', 'course_duration':'3 Months', 'course_sir':'brijesh' } print(emp) print(type(emp)) emp1={1:"vaishali",2:"dhaval",3:"sunil"} print(emp1) print(type(emp1)) #access value using key print("first name inside of the dictionary:" +emp1[2]) #access value using ...
true
0d392a51311a1da24c84669dc57a50610bccb111
Daroso-96/estudiando-python
/index.py
1,168
4.1875
4
if 5 > 3: print('5 es mayor que 3') x = 5 y = 'Sashita feliz' #print(x,y) email = 'sashita@feliz.com' #print(email) inicio = 'Hola' final = 'mundo' #print(inicio + final) palabra = 'Hola mundo' oracion = "Hola mundo con comillas dobles" lista = [1,2,3] lista2 = lista.copy() lista.append('Sashita feliz jugan...
false
52c255ca2ffcc9b42da2427997bcfa6b539127d2
NaveenSingh4u/python-learning
/basic/python-oops/python-other-concept/generator-ex4.py
1,121
4.21875
4
# Generators are useful in # 1. To implement countdown # 2. To generate first n number # 3. To generate fibonacci series import random import time def fib(): a, b = 0, 1 while True: yield a a, b = b, a + b for n in fib(): if n > 1000: break print(n) names = ['sunny', 'bunny'...
true
bbb15cfc351270d4c09f884ac0e9debb4804aae5
NaveenSingh4u/python-learning
/basic/python-oops/book.py
920
4.125
4
class Book: def __init__(self, pages): self.pages = pages def __str__(self): return 'The number of pages: ' + str(self.pages) def __add__(self, other): total = self.pages + other.pages b = Book(total) return b def __sub__(self, other): total = self.page...
true
062f3ee72daa4387656af289b2ee3bef90e70a1f
NaveenSingh4u/python-learning
/basic/python-oops/outer.py
494
4.21875
4
class Outer: def __init__(self): print('Outer class object creation') def m2(self): print('Outer class method') class Inner: def __init__(self): print('Inner class object creation') def m1(self): print('Inner class method') # 1st way o = Outer() ...
false
c1a3ee82f1c10cc499283df4e4e95f00df71dc1b
Dhanshree-Sonar/Interview-Practice
/Guessing_game.py
808
4.3125
4
##Generate a random number between 1 and 9 (including 1 and 9). Ask the user to guess the number, ##then tell them whether they guessed too low, too high, or exactly right. # Used random module to generate random number import random def guessing_game(): while True: num = 0 while num not in range...
true
226843bbc68bab71fbe2cfb3416925baa898a273
simplex06/clarusway-aws-devops
/ozkan-aws-devops/python/coding-challenges/cc-003-find-the-largest-number/largest_number.py
270
4.25
4
# The largest Number of a list with 5 elements. lst = list() for i in range(5): lst.append(int(input("Enter a number: "))) largest_number = lst[0] for j in lst: if j > largest_number: largest_number = j print("The largest number: ", largest_number)
true
b6baf7354123f5584dde6cb4b45b2647c5ef49f8
joaovicentefs/cursopymundo2
/exercicios/ex0037.py
805
4.34375
4
num = int(input('Digite um número interiro: ')) #Colocando três aspas simples no print é possível fazer múltiplas linhas print('''Escolha uma das bases para conversão: [ 1 ] converter para BINÁRIO [ 2 ] converter para OCTAL [ 3 ] converter para HEXADECIMAL''') options = int(input('Sua opção: ')) '''Utilizado o conhecim...
false
b86d5d0f2b570cfad3678ce341c44af297399e32
N-eeraj/perfect_plan_b
/armstrong.py
343
4.15625
4
import read num = str(read.Read(int, 'a number')) sum = 0 #variable to add sum of numbers for digit in num: sum += int(digit) ** len(num) #calculating sum of number raised to length of number if sum == int(num): print(num, 'is an amstrong number') #printing true case else : print(num, 'is not an amstrong number'...
true
4b20faae3875ba3a2164f691a4a32e61ca944a27
harishassan85/python-assignment-
/assignment3/question2.py
226
4.21875
4
# Write a program to check if there is any numeric value in list using for loop mylist = ['1', 'Sheraz', '2', 'Arain', '3', '4'] for item in mylist: mynewlist = [s for s in mylist if s.isdigit()] print(mynewlist)
true
df6c709986d91d8d96b4a67e1e20307e05a09521
albertsuwandhi/Python-for-NE
/Week2/Tuples.py
329
4.1875
4
#!/usr/bin/env python3 # Tuples are immutables my_tuple = (1, 'whatever',0.5) print("Type of my_tuples : ", type(my_tuple)) for i in my_tuple: print(i) #convert tuples to list my_list = list(my_tuple) print("Type of my_list : ", type(my_list)) for i in my_list: print(i) #list element can be changed my_list[0] =...
false
07669066a5ce7a1561da978fc173c710f3ec7e3a
neonblueflame/upitdc-python
/homeworks/day2_business.py
1,836
4.21875
4
""" Programming in Business. Mark, a businessman, would like to purchase commodities necessary for his own sari-sari store. He would like to determine what commodity is the cheapest one for each type of products. You will help Mark by creating a program that processes a list of 5 strings. The format will be the na...
true
cdc3ed9862e362dc21b899ef3b059a6a9889d6ee
RobSullivan/cookbook-recipes
/iterating_in_reverse.py
938
4.53125
5
# -*- coding: utf-8 -*- """ This is a quote from the book: Reversed iteration only works if the object in question has a size that can be determined or if the object implements a __reversed__() special method. If neither of these can be satisfied, you’ll have to convert the object into a list first. Be aware th...
true
b4ff9851641f8baea2c54f7dd16f206db16827de
isachard/console_text
/web.py
1,633
4.34375
4
"""Make a program that takes a user inputed website and turn it into console text. Like if they were to take a blog post what would show up is the text on the post Differents Links examples: https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world https://www.stereogum.com/2025831/frou-frou-reu...
true
d89df8cc1bffb63dd1f867650b54c55e141602ed
yuch7/CSC384-Artificial-Intelligence
/display_nonogram.py
2,535
4.125
4
from tkinter import Tk, Canvas def create_board_canvas(board): """ Create a Tkinter Canvas for displaying a Nogogram solution. Return an instance of Tk filled as a grid. board: list of lists of {0, 1} """ canvas = Tk() LARGER_SIZE = 600 # dynamically set the size of each square base...
true
9d7c458469e1303571f12dfa15fa71133c5d2355
suterm0/Assignment9
/Assignment10.py
1,439
4.34375
4
# Michael Suter # Assignment 9 & 10 - checking to see if a string is the same reversable # 3/31/20 def choice(): answer = int(input("1 to check for a palindrome, 2 to exit!>")) while answer != 1 and 2: choice() if answer == 1: punc_string = input("enter your string>") return punc_s...
true
0f185d16ad186bc44dca5dd7d7dc338c2243f583
chng3/Python_work
/第五章练习题/5-2.py
703
4.15625
4
#5-1 条件测试 myday = 'Thursday' print("Is mayday == 'Thursday'? I predict True.") print(myday == 'Thursday') print("\nIs myday == 'Sunday'? I predict False.") print(myday == 'Sunday') print("\n") #5-2 year_0 = 12 year_1 = 13 print(year_0 == year_1) print(year_0 != year_1) print(year_0 > year_1) print(year_0 < year_1)...
false
3c3bbefb54ddf8e30798a9115ba4de97aca0d396
chng3/Python_work
/第四章练习题/4-12.py
719
4.46875
4
#4-10 my_foods = ['pizza', 'falafel', 'carrot cake', 'chocolate'] print("The first three items in the list are:") print(my_foods[:3]) print("Three items from the middle of the list are:") print(my_foods[1:3]) print("The last items in the list are:") print(my_foods[-3:]) #4-11 你的披萨和我的披萨 pizzas = ['tomato', 'banana'...
true