blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
7cdaaed456af8a41dd627feb595823b98dd3713e
YutoTakaki0626/My-Python-REVIEW
/basic/dictionary.py
529
4.28125
4
# dictionary:キーと値の組み合わせを複数保持するデータ型 fruits_colors = {'apple':'red', 'lemon': 'yellow', 'grapes': 'purple'} print(fruits_colors['apple']) fruits_colors['peach'] = 'pink' print(fruits_colors) dict_sample = {1: 'one', 'two': 2, 'three': [1, 2, 3], 'four':{'inner': 'dict'}} print(dict_sample) print(dict_sample['four']['in...
false
b3080fe028e3a62ade5b64a57da7ce9276c650ae
niksm7/March-LeetCoding-Challenge2021
/Palindromic Substrings.py
622
4.15625
4
''' Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters. Example 1: Input: "abc" Output: 3 Explanation: Three palindromic strings: "a", "b", "c". ''' ...
true
77de892bfce5df9d0d5c9bad7cde7b401e1ba38e
TheDarkKnight1939/FirstYearPython
/3.py
539
4.28125
4
#!/usr/bin/python import random #Imports the class random r=random.randint(10,66) #Uses the randint function to choose a number from 10 to 66 print(r) #Prints the random number choosen if r<35: #If loop which checks if the number is lesser than 35 print(r) print(": is less than 35 \n") exit elif r==30:#If loop whi...
true
aad35df15da4265e65defc8f609290a342e727f3
gaurav-singh-au16/Online-Judges
/Binary_Search_Problems/nth_fibonacci_no.py
916
4.1875
4
""" Nth Fibonacci Number The Fibonacci sequence goes like this: 1, 1, 2, 3, 5, 8, 13, 21, 34, ... The next number can be found by adding up the two numbers before it, and the first two numbers are always 1. Write a function that takes an integer n and returns the nth Fibonacci number in the sequence. Constraints n ...
true
86a7c2270c42fdd3e898d027dac3f0c63d07fbc8
gaurav-singh-au16/Online-Judges
/Leet_Code_problems/69. Sqrt(x).py
543
4.15625
4
""" 69. Sqrt(x) Easy 1657 2143 Add to List Share Given a non-negative integer x, compute and return the square root of x. Since the return type is an integer, the decimal digits are truncated, and only the integer part of the result is returned. Example 1: Input: x = 4 Output: 2 Example 2: Input: x = 8 Outpu...
true
d5fee0cdc323a6feca2f3b7cf95cc59f909bbfab
tsakaloss/pycalculator
/calculator.py
2,930
4.375
4
import sys from lib import operations # Manage the operations def mathing_func(a, b, sign): if sign == '+': return operations.Calculations.plus(a, b) elif sign == '-': return operations.Calculations.minus(a, b) elif sign == '*': return operations.Calculations.multiply(a, b) eli...
true
0c3925c9dfd8736a0f5836d2139fdf6d6a259a70
lightdarkx/python-snippets
/LinearSearch.py
513
4.28125
4
# Program to implement linear search in a given array/list def linearSearch(arr,search_item): print(f"search_item: {search_item}") for i in arr: if (i == search_item): return -2,i #print(f"i: {i}") return -1,-1 arr = [1,2,3,4,5] search_item...
true
e9a6d1c8de9290cf452f81f35df46f9ab2f9e48a
Meeds122/Grokking-Algorthms
/4-quicksort/quicksort.py
1,280
4.21875
4
#!/usr/bin/python3 def quickSort(arr): working_array = arr.copy() working_array_length = len(working_array) if working_array_length <= 1: # Empty element or single element case return working_array elif working_array_length == 2: # only 2 elements case if working_array[0...
true
def9cd930313f4fe0e6f5219f51e25e31ff04788
andrewswellie/Python_Rock_Paper_Scissors
/RockPaperScissors.py
1,537
4.15625
4
# Incorporate the random library import random restart = 1 while restart != "x": print("Let's Play Rock Paper Scissors!!!") options = ["r", "p", "s"] computer_choice = random.choice(options) user_choice = input("You are playing against the computer. His choice is completely random. Make your Choi...
true
368ec147cd5f547160e88580a4c11783f2f79f98
pani-vishal/String-Manipulation-in-Python
/Problem 7.txt
221
4.21875
4
#Program to count no. of letters in a sentence/word sent=input("Enter a sentence: ") sent=sent.lower() count=0 for x in sent: if (x>='a' and x<='z'): count+=1 print("Number of letters: "+str(count))
true
afa0d3861f350476303935675bd207e08272ce1c
ramalho/propython
/fundamentos/metaprog/atrib_dinamicos.py
814
4.28125
4
#!/usr/bin/env python # coding: utf-8 '''Exemplo de acesso e atribuição dinâmica de atributos de instância. >>> n = Nova() * self.__setattr__('b') >>> print repr(n.a) 1 >>> print repr(n.b) 2 >>> print repr(n.c) * self.__getattr__('c') 'c?' >>> n.a = 10 * self.__setattr__('a...
false
52a811e422306a3919e5c06cb3c2c568c2a31160
ramalho/propython
/fundamentos/funcional/curry.py
989
4.40625
4
#!/usr/bin/env python ''' Exemplo da técnica de currying. A função rectFactory é um "curry" que retorna uma função que realiza o serviço de rect fixando um dos parâmetros para que ele não precise ser fornecidos a cada invocação. Em rectFactory2 temos um exemplo que demonstra a mesma técnica implementada com o coma...
false
f91a700285537cbbd9f51fb70d8d7ae0559d1709
jeremymatt/DS2FP
/drop_illogical.py
713
4.1875
4
# -*- coding: utf-8 -*- """ Created on Thu Apr 25 22:59:05 2019 @author: jmatt """ def drop_illogical(df,var1,var2): """ Drops records from the dataframe df is var1 is greater than var2 For example, if var1 is spending on clothing and var2 is total income it is not logical that var1 is grea...
true
051d08ec216fff8651d3a096578c7fa38ba875ed
CLAHRCWessex/math6005-python
/Labs/wk1/if_statement_preview.py
1,884
4.6875
5
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Week 1 Extra Material: If-then statements A short look ahead at conditionals and if statements. We will cover these in detail in week 2. But feel free to have edit the code below to see how it works. In most Python programmes that you write you will be using if...
true
c7d99b39a0557d62a59e5607c9620f2bcfcab248
eshanmherath/neural-networks
/perceptron/simple_perceptron_OR_gate.py
2,098
4.15625
4
import numpy as np class Perceptron: def __init__(self, number_of_inputs, learning_rate): self.weights = np.random.rand(1, number_of_inputs + 1)[0] self.learning_rate = learning_rate """A step function where non-negative values are returned by a 1 and negative values are returned by a -1""" ...
true
c02c02fd344549fc4cda63bba9ea525cdd30c151
mahinhasan56/python-sqlite
/Extract.py
541
4.3125
4
import sqlite3 with sqlite3.connect("users.db") as db: cursor =db.cursor() cursor.execute('''CREATE TABLE IF NOT EXISTS user (userID INTEGER PRIMARY KEY,username VARCHAR(20) NOT NULL, firstname VARCHAR(20) NOT NULL, surname VARCHAR (20) NOT NULL, password VARCHAR(20)NOT NULL );''') cursor.execute("""IN...
false
e347dab6cada8dfd16b370d9f40f3b590b949a2e
tvocoder/learning_python
/python_functional_programming.py
1,191
4.59375
5
# Functional Programming print("---= Functional Programming =---") print("--= Map =--") # Description: Applies function to every item of an iterable and returns a list of the results. # Syntax: map(function,iterable[,...]) # -- function: Required. A function that is used to create a new list. # -- iterable: Required. ...
true
304598e5e382fad84021f4a95d5a395b957a4456
tvocoder/learning_python
/python_callable_func.py
2,317
4.5
4
print("---= Callables Operators =---") print("-- *(tuple packing) --") # Description: Packs the consecutive function positional arguments into a tuple. # Syntax: def function(*tuple): # -- tuple: A tuple object used for storing the passed in arguments. # All the arguments can be accessed within the function body the s...
true
658c711767cba340196597ba6658f855293cf73e
Python-aryan/Hacktoberfest2020
/Python/leap_year.py
253
4.125
4
def leapyear(year): if year % 4 == 0: print("Its a leap year") elif year % 100 == 0: print("Its a leap year") elif year % 400 == 0: print("Its a leap year") else: print("Its not a leap year") year = int(input("Enter a Year")) leapyear(year)
false
2690b3fb0d1b3339f9b29f8c5c81638c0eefb682
Python-aryan/Hacktoberfest2020
/Python/sum of list-elements.py
287
4.25
4
#Calculates the sum of a list of numbers number = int(input("Enter number of elements: ")) elements = [] for i in range(number): x = int(input("Enter {} number: ".format(i+1))) elements.append(x) sum=0 for i in elements: sum=sum+i print("Sum of the list elements is: ",sum)
true
bb62b6e47c6d5606a253690c003d9b72b6aea79e
docljn/python-self-study
/wesleyan_intro/module_3/name_phone.py
925
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Dec 28 15:48:51 2018 @author: DocLJN """ import sys import csv # open the csv file here filename = sys.argv[1] file = open(filename, 'w') while True: nextname = input("Enter a friend's name, press return to end: ") if nextname == "": ...
true
910ba7384503ead042945e33c9c1c48160d59003
Lxunrui/python-learn
/python-opp/ch3/list_basic.py
360
4.125
4
# 两种数据结构:列表和元组 # 列表的创建 a = [1,2,3,4] # 列表里面的元素的数据类型可以是任意的。例如 b = [1,'asd',2.0,['a','b','c']] print(a) print(b) # 列表元素的访问 print('a[0]=',a[0],a[1]) # b[a:b] a代表第几个 b-a代表到第几位 c = b[1:3] print(c,type(c)) s = 'asdzxc' print(s[1:2],s[-1]) print(b[-1])
false
4585d9c998c7312a8a2541259970987d700b45ab
Scorch116/PythonProject---Simple-calculator
/Calculator.py
1,261
4.25
4
'''Simple calculator used to perform basic calculator functions such as addition, subtraction,division and multplication''' def Addition(value1, value2): # this function will add the two numbers return value1 + value2 def subtract (value1, value2): return value1 - value2 def Divide(value1, value2): retur...
true
d6374434fb6c9d67a684c3db37d6bc34e7701fd9
abhinavmittal93/Week1_Circle_Radius
/Week1_coding.py
320
4.1875
4
import math import datetime def calc_radius(): radius = float(input('Enter the radius of the circle: ')) area = math.pi * radius**2 print(f'Area of the circle is: {area:.2f}') def print_date_time(): time = datetime.datetime.now() print(f'Today\'s date: {time}') print_date_time() calc_radius()
true
9b31816c42dc2107fdbe3af38c21992213168768
danel2005/triple-of-da-centry
/Aviel/8.3.3.py
675
4.3125
4
def count_chars(my_str): """ returns a dict that the keys are the letters and the valus are how many of them were in the string :param my_str: the string we want to count every letter :type my_str: str :return: a dict that the keys are the letters and the valus are how many of them were in the strin...
true
b37418b1873488e4cf3b9397273f344e0768fd7b
danel2005/triple-of-da-centry
/Aviel/7.3.1.py
814
4.125
4
def show_hidden_word(secret_word, old_letters_guessesd): """ Show the player his prograssion in the game :param secret_word: the word the player need to guess :param old_letters_guessesd: the letters that the player is already guessed :type secret_word: str :type old_letters_guessesd: list :...
false
1c6125e33f932902b101c449ffd44c5236788bc0
danel2005/triple-of-da-centry
/Aviel/6.4.2.py
876
4.15625
4
def try_update_letter_guessed(letter_guessed, old_letters_guessed): """ Adds the letter guessed to the array of letters that has already been guessed :param letter_guessed: the guess that the user inputing :param old_letters_guessed: all the letters the user already guessed :type letter_guessed: str...
true
2c772ed45516775c12da8c4ae9ba0d6330ab5105
danel2005/triple-of-da-centry
/Aviel/6.4.1.py
651
4.1875
4
def check_valid_input(letter_guessed, old_letters_guessed): """ Checks if the guess is valid or not :param letter_guessed: the guess that the user inputing :param old_letters_guessed: all the letters the user already guessed :type letter_guessed: string :type old_letters_guessed: array :retu...
true
c889e0e9d7f44f7c13658bfeaebdb60e6ffaea8c
danel2005/triple-of-da-centry
/Aviel/7.2.2.py
677
4.28125
4
def numbers_letters_count(my_str): """ returns a list that the first number is the numbers count and the second number is the letters count :param my_str: the string we want to check :type my_str: str :return: list that the first number is the numbers count and the second number is the letters count...
true
76cde6d34c1a99e235e6c828c1aa0495810947ec
mossi1mj/SentenceValidator
/SentenceValidator.py
882
4.21875
4
import string # take in sentence as variable sentence = input("Enter a sentence: ") # take words in sentence and place in array[] with split() function word = sentence.split()[0] # first word in array will be 0 capitalWord = word.capitalize() # capitalize() function puts first character of a string to uppercase # ...
true
e9cf929eb3f418b403cbebf5b171db97ef597d76
alejogonza/holbertonschool-higher_level_programming
/0x0A-python-inheritance/1-my_list.py
316
4.125
4
#!/usr/bin/python3 """ 1-my_list """ class MyList(list): """ prints to stdout list in order """ def print_sorted(self): """ prints the list """ sorted_list = MyList() for item in self: sorted_list.append(item) print(sorted(sorted_list))
true
9ef602b0e1df3f4111037ecd84e1d78d5994fffb
wesenu/COP3035-CGS5935-Introduction-to-Programming-Using-Python
/myPrograms/Chapter_4_exerciseSolution/ex4_14.py
903
4.21875
4
###################################################### # 4.14 # ###################################################### rows = 7 for r in range (rows): for c in range (rows-r): print ('*', end = ' ') print() ##################################################### # end = ' ' m...
true
15f146f69ea979780ba6d2a9610f064e0c327cc8
wesenu/COP3035-CGS5935-Introduction-to-Programming-Using-Python
/loopExerciseStarter.py
382
4.1875
4
inputPIN = 0 validPIN = False userPIN = 9999 # for example use only ! inputPIN = int(input("Please enter your PIN -> ")) validPIN = (inputPIN == userPIN) while not validPIN: inputPIN = int(input("Please try again. Enter your PIN -> ")) validPIN = (inputPIN == userPIN) # know complement is true...
true
b8465312a69a2fcbe6aff158dbf9ec524b4c4efb
narru888/PythonWork-py37-
/進階/資料結構/Linked_List(鏈表).py
1,588
4.25
4
""" Linked-list的資料則散落在記憶體中各處,加入或是刪除元素只需要改變pointer即可完成, 但是相對的,在資料的讀取上比較適合循序的使用,無法直接取得特定順序的值(比如說沒辦法直接知道list[3]) """ # 節點 class ListNode: def __init__(self, data): # 資料內容 self.data = data # 下一個節點位置 self.next = None # 單向鏈表 class SingleLinkedList: def __init__(self): # 鏈表頭...
false
783d97d8d3c3586668f7c39bb60093e5e69bbe7a
kuaikang/python3
/基础知识/3.面向对象/class.py
1,263
4.34375
4
class People: name = "我是类变量,所有实例共享" def __init__(self, name, age, phone): # 构造函数,在类被实例化的时候执行 self.name = name # 实例变量,为每个实例所独有 self.__age = age # 在变量前面加__,表明这是私有变量,可以通过方法访问私有变量 self.phone = phone def get_age(self): # 定义一个方法来访问私有变量 return self.__age p = People("tom", 23...
false
c22167ee72352ce55dfb2b3db6108857776f6c7c
lyannjn/codeInPlaceStanford
/Assignment2/hailstones.py
829
4.5
4
""" File: hailstones.py ------------------- This is a file for the optional Hailstones problem, if you'd like to try solving it. """ def main(): while True: hailstones() def hailstones(): num = int(input("Enter a number: ")) steps = 0 while num != 1: first_num = num # Even nu...
true
83e0cd383f22f7f9483622e7df9acf195e790103
NithinRe/slipting_current_bill
/Power_Bill.py
1,043
4.15625
4
print("----------------Electricity Bill---------------------") x = int(input("what is cost of current : ")) y = int(input("Enter Number of units used : ")) z = x/y print("Each unit is charged as : ",z) print("-----------------------------------------------------") meter1 = int(input("First floor number of units u...
true
880b3b158b1f8e2b56d01ac8e6042cbd2d4b484a
Garrison-Shoemake/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/4-print_square.py
589
4.40625
4
#!/usr/bin/python3 """ This function will print a square equal to the size given """ def print_square(size): """ This function will raise errors if an integer is not given as well as if the value is equal or less than zero. """ if not isinstance(size, int): raise TypeError("size must be an intege...
true
ab396ea8fa83578e55ee4e24db98b4830749cc27
Garrison-Shoemake/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/tests/test_models/test_square.py
1,879
4.21875
4
#!/usr/bin/python3 """ this is the unittest file for the Base class """ import unittest from models.square import Square class SqrTest(unittest.TestCase): """ These are the unit tests for the base class """ def test_basics2(self): s = Square(1) self.assertEqual(s.width, 1) s = Squar...
true
4d3a8bef55942c0f3c4142e807f539ac5cfcda46
Garrison-Shoemake/holbertonschool-higher_level_programming
/0x0B-python-input_output/2-append_write.py
247
4.28125
4
#!/usr/bin/python3 """ This function appends a string to a file! """ def append_write(filename="", text=""): """ apppends to the end of a file then returns character count """ with open(filename, 'a') as f: return f.write(text)
true
978bad038ca358c0515806600ccd6bc92e53dfad
makpe80/Boot-camp
/7 lesson. Модуль 4. Модули и пакеты/code_examples/sphinx/ex_1.py
291
4.125
4
def say(sound:str="My")->None: """Prints what the animal's sound it. If the argument `sound` isn't passed in, the default Animal sound is used. Parameters ---------- sound : str, optional The sound the animal makes (default is My) """ print(sound)
true
0ab0a052a247fbcc29ad44ca7b05740eb65cd1f8
Taranoberoi/Practise
/List Less Than Ten.py
357
4.28125
4
# Take a list, say for example this one: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] # write a program that prints out all the elements of the list that are less than 10. a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] # b = [] # for i in a: # print("Value is ",i) # if i <= 10: # b.append(i) # els...
true
463f9708d9e3cec7047f3541bc8f0b570b5b44dc
Taranoberoi/Practise
/10_LIST OVERLAP COMPREHESIONS.py
690
4.25
4
# This week’s exercise is going to be revisiting an old exercise (see Exercise 5), except require the solution in a different way. # Take two lists, say for example these two:and write a program that returns a list that contains only the elements that are # common between the lists (without duplicates). Make sure y...
true
92a0429afb21d39eb64817d068b73f229a608c09
Othielgh/Cisco-python-course
/5.1.11.7 - Palindromes.py
905
4.25
4
# Your task is to write a program which: # asks the user for some text; # checks whether the entered text is a palindrome, and prints result. # Note: # assume that an empty string isn't a palindrome; # treat upper- and lower-case letters as equal; # spaces are not taken into account during the ch...
true
a0a00cec203bbaaeee83a82db647317f2db296b3
Othielgh/Cisco-python-course
/5.1.11.11 - Sudoku.py
1,186
4.3125
4
# Scenario # As you probably know, Sudoku is a number-placing puzzle played on a 9x9 board. The player has to fill the board in a very specific way: # each row of the board must contain all digits from 0 to 9 (the order doesn't matter) # each column of the board must contain all digits from 0 to 9 (again, the...
true
bb7cdb1c3423b10371a07d519035b7ddc0ec029f
havardnyboe/ProgModX
/2019/39/Oppgaver Funksjoner/Oppgave 6.py
315
4.125
4
def fibonacci(nummer): fib_liste = [0, 1] for i in range(nummer-1): nytt_nummer = fib_liste[-1]+fib_liste[-2] fib_liste.append(nytt_nummer) i = i+1 return print("Tall nummer", i+1, "er", fib_liste[-1]) tall_nummer = int(input("Hvilket tall nummer vil du se i fibonaccifølgen?: ")) fibonacci(tall_nummer)
false
fff52176408ddc67628b6c3707bc204363824ab8
greenfox-velox/oregzoltan
/week-04/day-3/09.py
476
4.125
4
# create a 300x300 canvas. # create a square drawing function that takes 1 parameter: # the square size # and draws a square of that size to the center of the canvas. # draw 3 squares with that function. from tkinter import * root = Tk() canvas = Canvas(root, width='300', height='300') canvas.pack() def draw_square...
true
38bf2fa152fbe028217728b502544ce1f5732432
greenfox-velox/oregzoltan
/week-04/day-3/11.py
751
4.125
4
# create a 300x300 canvas. # create a square drawing function that takes 2 parameters: # the square size, and the fill color, # and draws a square of that size and color to the center of the canvas. # create a loop that fills the canvas with rainbow colored squares. from tkinter import * import random root = Tk() ca...
true
ba4b735ad6b8404b5fd529fdf62be47e237cd33d
PedroSantana2/curso-python-canal-curso-em-video
/mundo-1/ex022.py
649
4.34375
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. ''' #Recebendo informações: nome = input('Digite um nome: ') #Declarando variaveis: maiusculas = nome.u...
false
532eea4a81fa3151ea92a0f3f00d9b0dc71bccb4
PedroSantana2/curso-python-canal-curso-em-video
/mundo-1/ex008.py
379
4.15625
4
''' Escreva um programa que leia um valor em metros e o exiba convertido em centímetros e milímetros. ''' #Recebendo valores: metros = float(input('Digite o valor em metros: ')) #Declarando variaveis centimetros = metros * 100 milimetros = metros * 1000 #Informando resultado: print('{} metros é: \n{} centímetros\n{}...
false
7a9084979864dc2e1bc3a23b964d8d9790370ee5
haveano/codeacademy-python_v1
/05_Lists and Dictionaries/02_A Day at the Supermarket/13_Lets Check Out.py
1,142
4.3125
4
""" Let's Check Out! Perfect! You've done a great job with lists and dictionaries in this project. You've practiced: Using for loops with lists and dictionaries Writing functions with loops, lists, and dictionaries Updating data in response to changes in the environment (for instance, decreasing the number of bananas ...
true
97ce0591bd0ed48a9918db96043117d016f3cc06
haveano/codeacademy-python_v1
/11_Introduction to Classes/02_Classes/08_Modifying member variables.py
1,115
4.375
4
""" Modifying member variables We can modify variables that belong to a class the same way that we initialize those member variables. This can be useful when we want to change the value a variable takes on based on something that happens inside of a class method. Instructions Inside the Car class, add a method drive_c...
true
d2b8e32208cd60547fb0ce5e786064a1d4a17906
haveano/codeacademy-python_v1
/12_File Input and Output/01_File Input and Output/05_Reading Between the Lines.py
847
4.4375
4
""" Reading Between the Lines What if we want to read from a file line by line, rather than pulling the entire file in at once. Thankfully, Python includes a readline() function that does exactly that. If you open a file and call .readline() on the file object, you'll get the first line of the file; subsequent calls t...
true
e988e9f53a578404a3c6c4b81174c704f395f19c
haveano/codeacademy-python_v1
/10_Advanced Topics in Python/02_Introduction to Bitwise Operators/04_The bin() Function.py
1,150
4.65625
5
""" The bin() Function Excellent! The biggest hurdle you have to jump over in order to understand bitwise operators is learning how to count in base 2. Hopefully the lesson should be easier for you from here on out. There are Python functions that can aid you with bitwise operations. In order to print a number in its ...
true
572f9b19515b5f46c03ddafedb0f93b37b13a49e
haveano/codeacademy-python_v1
/08_Loops/02_Practice Makes Perfect/03_is_int.py
1,183
4.21875
4
""" is_int An integer is just a number without a decimal part (for instance, -17, 0, and 42 are all integers, but 98.6 is not). For the purpose of this lesson, we'll also say that a number with a decimal part that is all 0s is also an integer, such as 7.0. This means that, for this lesson, you can't just test the inp...
true
6876089ff1413f4e3bc30adecefa91b75a59e006
haveano/codeacademy-python_v1
/07_Lists and Functions/01_Lists and Functions/11_List manipulation in functions.py
594
4.34375
4
""" List manipulation in functions You can also append or delete items of a list inside a function just as if you were manipulating the list outside a function. my_list = [1, 2, 3] my_list.append(4) print my_list # prints [1, 2, 3, 4] The example above is just a reminder of how to append items to a list. Instructions...
true
15f47141d90b1e773ff194272ae57c357f3572b4
haveano/codeacademy-python_v1
/10_Advanced Topics in Python/02_Introduction to Bitwise Operators/09_This XOR That.py
1,487
4.15625
4
""" This XOR That? The XOR (^) or exclusive or operator compares two numbers on a bit level and returns a number where the bits of that number are turned on if either of the corresponding bits of the two numbers are 1, but not both. a: 00101010 42 b: 00001111 15 ================ a ^ b: 00100101 ...
true
4b1a907a1f05d61a2904551c34cfc20e1a733840
haveano/codeacademy-python_v1
/08_Loops/01_Loops/13_For your lists.py
625
4.78125
5
""" For your lists Perhaps the most useful (and most common) use of for loops is to go through a list. On each iteration, the variable num will be the next value in the list. So, the first time through, it will be 7, the second time it will be 9, then 12, 54, 99, and then the loop will exit when there are no more valu...
true
758a91bf1eefd576051c24401423f4c6578180fa
haveano/codeacademy-python_v1
/03_Conditionals and Control Flow/02_PygLatin/06_Pop Quiz.py
603
4.21875
4
""" Pop Quiz! When you finish one part of your program, it's important to test it multiple times, using a variety of inputs. Instructions Take some time to test your current code. Try some inputs that should pass and some that should fail. Enter some strings that contain non-alphabetical characters and an empty string...
true
6efae81bdbee61a5e960c0bce1039a31a48c3bb2
haveano/codeacademy-python_v1
/11_Introduction to Classes/01_Introduction to Classes/03_Classier Classes.py
967
4.46875
4
""" Classier Classes We'd like our classes to do more than... well, nothing, so we'll have to replace our pass with something else. You may have noticed in our example back in the first exercise that we started our class definition off with an odd-looking function: __init__(). This function is required for classes, an...
true
3c6f0c6039e2a9d52e415b7b235adda8f27bb3e6
haveano/codeacademy-python_v1
/03_Conditionals and Control Flow/02_PygLatin/01_Break It Down.py
677
4.25
4
""" Break It Down Now let's take what we've learned so far and write a Pig Latin translator. Pig Latin is a language game, where you move the first letter of the word to the end and add "ay." So "Python" becomes "ythonpay." To write a Pig Latin translator in Python, here are the steps we'll need to take: Ask the user...
true
26c8ad332a82464bb4e423fc0f801e8f709297f0
haveano/codeacademy-python_v1
/03_Conditionals and Control Flow/02_PygLatin/09_Move it on Back.py
672
4.21875
4
""" Move it on Back Now that we have the first letter stored, we need to add both the letter and the string stored in pyg to the end of the original string. Remember how to concatenate (i.e. add) strings together? greeting = "Hello " name = "D. Y." welcome = greeting + name Instructions On a new line after where you ...
true
ed920d881c1a5fa00c6137a741e648894730e987
haveano/codeacademy-python_v1
/10_Advanced Topics in Python/01_Advanced Topics in Python/04_Building Lists.py
672
4.625
5
""" Building Lists Let's say you wanted to build a list of the numbers from 0 to 50 (inclusive). We could do this pretty easily: my_list = range(51) But what if we wanted to generate a list according to some logic—for example, a list of all the even numbers from 0 to 50? Python's answer to this is the list comprehens...
true
87476d33bbd28688c9eca22541842eda77c5cf44
Akash2918/PPL
/Assignment1/q9.py
903
4.28125
4
print("\nFinding first 10 Harmonic Divisor Numbers :\n") """def floating(n) : x = 1 s = 0 for i in n : x = x * i for i in n: s = s + x/i print("The value of s is : ", s) return s/x """ def calculate(n) : # function that calculates harmonic sum and returns its division with total number of divisors s =...
false
e0b4e15b11963d9db6e8640a210f4740888bc11b
liuleee/python_base
/day02/10-for循环的使用.py
982
4.3125
4
# -*- coding:utf-8 -*- #获取容器类型(字符串,列表,元组,字典,set)中每个数据使用for循环最简单 # my_str = 'abc' # for value in my_str: # print(value) # my_list = ['apple','peach','banana','pearl'] # for value in my_list: # print(value) #循环遍历的时候下标和数据都需要,可以使用enumerate my_list = enumerate(['apple','peach','banana','pearl']) # for value in m...
false
eba7e07b2ee51b4c70ed829acde256362afc7494
liuleee/python_base
/day01/06-数据类型转换.py
556
4.21875
4
# -*- coding: utf-8 -*- num = 10 my_str = '10' # 把字符串转为int类型 num2 = int(my_str) # print(type(num2)) s = num + num2 # print(s) my_float_str = '3.14' print(type(my_float_str)) num3 = float(my_float_str) print(type(num3)) num4 = 4.55 # 浮点数转int型时,只取整数 num5 = int(num4) print(num5) # eval:获取字符串中的 原始 数据 my_str = '5' v...
false
2b229803bcb9a175dac4b1b85e2b712c77adba7c
ankitandel/function.py
/4h.py
311
4.1875
4
# write a python program to print the even numbers from a given list.[1,2,3,4,5,6,7,8,9] def is_even_num(b): i=0 while i<=len(b): if i%2==0: print("even number",i,end="") else: print("odd number",i) i=i+1 b=[1,2,3,4,5,6,7,8,9] is_even_num(b)
true
21cced07ce4cf5abbcf22728b0a885585101320c
kavisha-nethmini/Hacktoberfest2020
/python codes/DoubleBasePalindrome.py
733
4.15625
4
#Problem statement: The decimal number, 585 is equal to 1001001001 in binary. #And both are palindromes. Such a number is called a double-base palindrome. #Write a function that takes a decimal number n and checks if it's binary equivalent and itself are palindromes. #The function should return True if n is a double-ba...
true
c62b24ca62cf6b7a6ef94b4a774b00c2c07b3561
wancongji/python-learning
/lesson/26/duixiang.py
739
4.46875
4
class MyClass: """ A example class """ x = 'abc' # 类属性 def __init__(self): # 初始化 print('init') def foo(self): # 类属性foo,也是方法 return "foo = {}".format(self.x) class Person: x = 'abc' def __init__(self, name, age=18): self.name = name self.y = age ...
false
5e94315bfe25f3afe469c6baacb18f0d123decde
piupom/Python
/tuplePersonsEsim.py
2,212
4.71875
5
# It is often convenient to bundle several pieces of data together. E.g. if the code processes information about people, then each person's information (name, age, etc.) could be bundled. This can be done in a naive manner with e.g. a tuple (also shown below), but classes provide a more convenient way. A class definiti...
true
e8b3807b0f9d38fe7b554e73c91797fd8e13b062
piupom/Python
/classFunctionsPersonsEsim.py
1,538
4.40625
4
# Classes have also other "special" functions. One common is __str__, which defines how to represent the object in string format (e.g. what is printed out if the object is passed to the print-function). Here we transform the printPersonObject-function from above into a __str__-member function. Now Person-objects can be...
true
8b746ca827fa6e652e2d5bc47eb897abe74a0cd0
projectsMuiscas/avangers
/funcionesTuplas.py
1,604
4.21875
4
# devolviendo varios valores desde una funcion def estadisticas_basicas (operado , operando): suma = operado + operando resta = operado - operando multi = operado * operando res = (suma,resta,multi) return res mysuma , myresta , mymulti = estadisticas_basicas (2 ,2) print (mysuma , ...
false
923a822bb263814d9af788e325e228cfba233894
roblivesinottawa/intermediate_100_days
/day_twentythree/turtle_crossing/carmanager.py
1,631
4.21875
4
from turtle import Turtle import random COLORS = ["red", "orange", "yellow", "green", "blue", "purple"] STARTING_MOVE_DISTANCE = 5 MOVE_INCREMENT = 10 # create a class and methods to manage the movement of the cars class CarManager: def __init__(self): # create a variable to store all cars and set it to an empty...
true
690574f888f0c7a65aef7402f12c56e5a928e7dd
twopiharris/230-Examples
/python/basic3/nameGame.py
533
4.25
4
""" nameGame.py illustrate basic string functions Andy Harris """ userName = input("Please tell me your name: ") print ("I will shout your name: ", userName.upper()) print ("Now all in lowercase: ", userName.lower()) print ("How about inverting the case? ", userName.swapcase()) numChars = len(userName) print ...
true
7d88f2a2dff5286c80d7fcf9a03fd70b9162f42f
twopiharris/230-Examples
/python/basic3/intDiv.py
443
4.53125
5
""" integer division explains integer division in Python 3 """ #by default, dividing integers produces a floating value print("{} / {} = {}".format(10, 3, 10 / 3)) #but sometimes you really want an integer result... #use the // to force integer division: print("{} // {} = {}".format(10, 3, 10 // 3)) #integer d...
true
172bca8ed49127e5baa1a23dd7795a19c3c7d984
willl4/mathproject
/functionAnalysisProgram.py
2,532
4.15625
4
""" function = input('Enter a function: ') func = function.split('x^') for temp in func: print(temp) """ if __name__ == '__main__': data = {} data['coefficients'] = '' data['derivative'] = '' function = int(input('Choose highest power in function: ')) power = function while function >= 0: co...
false
92fc4e3107ecedca5a04673bd9b62e2c03a336e7
davidtscott/CMEECoursework
/Week2/Code/tuple.py
1,329
4.53125
5
#!/usr/bin/env python3 # Date: October 2018 """ Extracts tuples from within a tuple and outputs as seperate lines """ __appname__ = '[tuple.py]' __author__ = 'David Scott (david.scott18@imperial.ac.uk)' __version__ = '0.0.1' __license__ = "License for this code/program" birds = ( ('Passerculus sandwichensis','Sav...
true
2ee1ecec1a2b53884a259649b6f59281ffd118cc
MurilloFagundesAS/Exercicios-Resolvidos-Curso-em-Video
/Aula17-Listas1.py
1,541
4.34375
4
lista = [1,2,3] # lista vazia : lista = [] ou lista = list() print(lista) i = 1 lista2 = [] while i <= len(lista): lista2.append(lista.index(i)) lista2.append(lista[i]) i+=1 print(lista2) # lista.append('append') # Adiciona no final da lista # # print(lista) # # # # lista.insert(1,'insert') # Adiciona ...
false
c88471e4498d8ee9343434e29b1a58d1e1732715
MurilloFagundesAS/Exercicios-Resolvidos-Curso-em-Video
/Ex025-FindSilva.py
237
4.1875
4
nome = str(input("Qual o Seu nome? ")) teste = nome.find('Silva') if teste != -1: print('Você tem Silva no nome!') else: print('Você não tem Silva no nome!') #print('Você tem Silva no nome? '.format('SILVA' in nome.upper))
false
873879f49529cc6abfb81cb3258aa8fb431b1ca5
Sahana-Chandrashekar/infytq
/prg23.py
493
4.25
4
''' Write a python function to find out whether a number is divisible by the sum of its digits. If so return True,else return False. Sample Input Expected Output 42 True 66 False ''' #PF-Prac-23 def divisible_by_sum(number): temp = number s = 0 while number != 0: re...
true
ab049e9c3ef3aeba3146f3e2ee2072b9e9422353
xiaoloinzi/worksplace
/GR1/meiriyilian/day_0818.py
2,704
4.1875
4
# encoding=utf-8 # 【python每日一练】实现一个购物车功能,商品属性只需要包括名称,数量,价格, # 要求实现添加一个商品,删除一个商品,最终打印订单详情和总价格 ''' 1、写一个购物车的类,属性有商品名称,数量,价格,然后实现添加商品,删除商品、打印订单详情的方法 2、定义一个字典的数据结构进行存储数据,要判断输入的商品是否存在,存在则提示并不保存 ''' dict1 = {} class Shopping(object): def __init__(self,product_name= None,price= None,quantity= None): self.product_...
false
88ab6d0234b210119fda15fe508a7fc65d0b94ab
Brijesh739837/Mtechmmm
/arrayinput.py
242
4.125
4
from array import * arr=array('i',[]) # creates an empty array length = int(input("enter the no of students")) for i in range(length): n = int(input("enter the marks of students")) arr.append(n) for maria in arr: print(maria)
true
8b744ce1431081f48d0e6cdddd414d8a6ec1604a
Brijesh739837/Mtechmmm
/numpyoperation.py
1,016
4.15625
4
from numpy import * import time arr = array([1,2,3,4,5]) arr = arr+10 print(arr) arr =arr *5 print(arr) arr1 = array([1,2,3,4,5]) arr2 = array([1, 2, 3, 4, 5]) arr3 = arr1 + arr2 print(arr3) print(concatenate([arr1,arr2])) ''' copy an array to another arrray''' ''' aliasing ''' arr4 = arr1 print(arr4) print(id(...
false
940c2f06be34dad6d306f1ca73f664f0d496bbc0
Brijesh739837/Mtechmmm
/stringmaniexp.py
797
4.28125
4
'''x= input("enter your name") name= x a= len(name) print(a) print(name.capitalize()) print(name.lower()) print(name.upper()) print(name.swapcase()) print(name.title()) print(name.isdigit()) print(name.isalpha()) print(name.islower()) print(name.isupper()) print(name.isalnum()) str = input("enter a string") print(str) ...
false
56dfa6e4d1b0ef316cac9de3ad21287f69d0e854
omostic21/personal-dev-repo
/guesser_game.py
1,433
4.1875
4
#I wrote this code just to play around and test my skils #Author: Omolola O. Okesanjo #Creation date: December 10, 2019 print("Welcome to the Number Guessing game!!") x = input('Press 1 to play, press 2 for instructions, press 3 to exit') x = int(x) if x == 2: print("The computer will pick a number within the...
true
24a0066c1f6d87c37cf15b81eb59f28c199997f8
cgarey2014/school_python_projects
/garey3/program3_3.py
1,175
4.21875
4
# Chris Garey #2417512 # This is original work by me, there are no other collaborators. # Begin Prog # Set the initial answer counter to zero # Ask the first question, count one point if correct and no points if wrong. # Ask the second question, count one point if correct and no points if wrong. # Ask the third questio...
true
44a981d0bb30cc57c6fd15ed98e02993129563cd
sprksh/quest
/recursion/backtracking/backtracking.py
1,657
4.34375
4
""" Backtracking is when you backtrack after recursion Examples in n_queens in the bottom section """ class newNode: # Construct to create a new node def __init__(self, key): self.key = key self.left = None self.right = None self.parent = None def __repr__(self): ...
true
6a55c9c131b08c9afd042592d7b3b5db8cec153e
insomnia-soft/projecteuler.net
/004/004.py
831
4.125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # def palindrome(n): m = n p = 0 while m > 0: mod = m % 10 m /= 10 p = p * 10 + mod if p == n: return True return False def main(): """ Largest palindrome product Probl...
true
3b23e311c63ab7ecbc0c2bed101f1a9cddb86971
lbovboe/The-Lab-Python-level-1
/1.06-5.py
331
4.1875
4
age = int(input("Enter your age : ")) if(age >=10 and age <=16): ans = input("Are you a student of the lab? : ").lower() if(ans == "yes"): print("You must be smart! ") else: print("You should join the lab! ") elif(age < 10 or age >16 and age <20 ): print("That's the good age!") else: print("You are a ...
false
31c2019a419a335dba454aefb11f62735df929ae
seokhyun0220/pythonProject1
/Ch04/4_1_ List.py
940
4.21875
4
""" 날짜 : 2021/04/27 이름 : 김철학 내용 : 파이썬 자료구조 리스트 실습 교재 p84 """ #리스트 생성 list1 = [1,2,3,4,5] print('list type :', type(list)) print('list[0] :', list1[0]) print('list[2] :', list1[2]) print('list[3] :', list1[3]) list2 = [5,3.14, True, 'Apple'] print('list2 type :', type('list2')) print('list2[1] :', list2[1]) print('l...
false
43be50b95f9781fecb0bcb7a242061af8a8d461c
seokhyun0220/pythonProject1
/Ch05/5_5_FuctionList.py
1,764
4.375
4
""" 날짜 : 2021/04/29 이름 : 김철학 내용 : 파이썬 리스트함수 교재 p88 """ dataset = [1,4,3] print('1.dataset :', dataset) # List 원소 추가 dataset.append(2) dataset.append(5) print('2.dataset :', dataset) # List 정렬 dataset.sort() print('3.dataset :', dataset) # 오름차순 dataset.sort(reverse=True) # 내림차순 print('4.dataset :', dataset) # ...
false
19f2142d863f2105fd453b35dd9832bff8ffb9e5
subash319/PythonDepth
/Practice16_Functions/Prac_16_10_count_even_odd.py
374
4.28125
4
# 10. Write a function that takes in a list of integers and returns the number of even and odd numbers from that list. def count_even_odd(list_count): even_count,odd_count = 0,0 for num in list_count: if num%2 == 0: even_count += 1 else: odd_count += 1 return even_co...
true
42e99ec5b61f9ea5debb7e192cd83ff4f47cc7cc
subash319/PythonDepth
/Practice10_Loops/Practice10_1_sum_n_numbers.py
635
4.375
4
# 1. Write code to find sum of first n natural numbers using a # # (a) while loop # # (b) for loop # # (c) without any loop # a while loop n = int(input("Enter the 'n' value to find sum of n natural numbers:")) initial_n = n sum = 0 while n: sum += n n -= 1 print(f"sum of {initial_n} natural numbers:{sum}") ...
false
4410eadec793e5cfb189305a350f91052cc822e6
subash319/PythonDepth
/Practice14_List_Comprhensions/Prac_14_6_cubes_all_odd.py
292
4.53125
5
# 6. This list comprehension creates a list of cubes of all odd numbers. # # cubes = [ n**3 for n in range(5,21) if n%2!=0] # Can you write it without the if clause. cubes = [n**3 for n in range(5, 21, 2)] cubes_2 = [ n**3 for n in range(5,21) if n%2!=0] print(cubes) print(cubes_2)
true
3687ac68a5e5a98d1972ae671b90d598f2055e84
subash319/PythonDepth
/Practice17_Functions_2/Prac_17_6_kwargs.py
493
4.125
4
# def display(L, start='', end=''): # for i in L: # if i.startswith(start) and i.endswith(end): # print(i, end=' ') # # display(dir(str), 'is', 'r') # In the function definition of the function display(), # make changes such that the user is forced to send keyword arguments for the last two parameters....
true
8a8e5cc2188d84672aa8f3502c459f5a622e956b
subash319/PythonDepth
/Practice11_Loops/Prac_11_6_Insert_list.py
469
4.3125
4
# L1 = ['China', 'Brazil', 'India', 'Iran', 'Iraq', 'Russia'] # L2 = ['Italy', 'Japan', 'China', 'Russia', 'Nepal', 'France'] # Write a program that inserts all common items of these 2 lists into a third list L3. L1 = ['China', 'Brazil', 'India', 'Iran', 'Iraq', 'Russia'] L2 = ['Italy', 'Japan', 'China', 'Russia',...
false
11506ebc9da92d469b83fbe2f261e4a4ce412716
subash319/PythonDepth
/Practice13_LoopingTechniques/Prac_13_15_zip.py
1,721
4.21875
4
# 15.Write a program that displays the following output from the above data. Use zip in for loop to iterate over the # lists. # # # # John # # -------------------------------------------------- # # Physics 100 40 90 # # Chemistry 80 25 78 # # Maths 100 40 87 # # Biology 75 20 67 # # Tot...
false
2b44c016feeed5be184877be0e84ba5ff8e7f38c
VishalSinghRana/Basics_Program_Python
/Squareroot_of_Number.py
284
4.34375
4
y="Y" while(y=="y" or y=="Y"): number = int(input("Enter the number")) if number < 0: print("Please Enter a postive number") else: sqrt= number**(1/2) print("The squareroot of the numebr is ",sqrt) y=input("Do you want to continue Y/N?")
true
429a1a5a27ce1a2d1166d16de7b33bfc2b947008
patiregina89/Desafios-Prof_Guanabara
/Desafio59.py
1,191
4.34375
4
'''Crie um programa que leia dois valores e mostre um menu na tela. 1 - somar 2 - multiplicar 3 - maior 4 - novos números 5 - sair do programa O programa deverá realizar a operação solicitada em cada caso''' num1 = int(input('Informe um número: ')) num2 = int(input('Informe outro número: ')) maior = num1 op...
false
b81bf5104838515302768a79df37c945fa7a4f5a
kcwebers/Python_Fundametnals
/fundamentals/insertion.py
2,060
4.3125
4
# Build an algorithm for insertion sort. Please watch the video here to understand how insertion sort works and implement the code. # Basically, this sort works by starting at index 1, shifting that value to the left until it is sorted relative to all values to the # left, and then moving on to the next index positio...
true