blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
fb4576c358165780a8d1dc143b1948f5284c89b6
solareenlo/python_practice
/01_Pythonの基本/lesson05.py
605
4.25
4
"""This is a test program.""" word: str = 'python' print(word[0]) # 1番目の文字を出力 print(word[1]) # 2番目の文字を出力 print(word[-1]) # 最後の文字を出力 print(word[0:2]) # 1番目から2番目まで出力 print(word[2:3]) # 3番目から3番目まで出力 print(word[:2]) # 1番目から2番目まで出力 print(word[2:]) # 2番目から最後まで出力 # word[0] = 'j' これはできないので, 1文字目を変えたときは, word: str = 'j' + word...
false
9413a4e410b9505695284fa2b78c50e6bedaab37
solareenlo/python_practice
/09_データベース/sqlite1.py
1,514
4.1875
4
""" sqliteです. """ import sqlite3 # CONN = sqlite3.connect('test_sqlite.db') CONN = sqlite3.connect(':memory:') # メモリ上にdbを仮に作ってくれる.テストしたい時に重宝する. CURS = CONN.cursor() # persons はtable name CURS.execute('CREATE TABLE persons(id INTEGER PRIMARY KEY AUTOINCREMENT, name STRING)') CONN.commit() # dbのidとnameの様式を設定. CURS.ex...
false
c82e6d4feb26fec86aa3bf73c1ddee88f157a81c
solareenlo/python_practice
/03_制御フローとコード構造/if.py
390
4.1875
4
"""This is a test program.""" x: int = 0 if x < 0: print('negative') elif x == 0: print('zero') else: print('positive') a: int = 5 b: int = 10 # Pythonではインデントでif文の中身がどこからどこまでかを認識している # Pythonのインデントは基本スペース4つ if a > 0: print('a is positive') if b > 0: print('b is positive')
false
118b5b95935e0002ead29be79fe91f4612cc8c6c
Dqvvidq/Nauka
/listy[].py
1,565
4.1875
4
#metoda upper print("Witaj") print("Witaj".upper()) #metoda replace print("Witaj".replace("j", "m")) #tworzenie listy fruit = ["mango", "banan", "gruszka"] print(fruit) #metoda append czyli dodawanie nowego elementu na koncu listy fruit.append("pomelo") fruit.append("figa") print(fruit) #w l...
false
d8c571e90d7dd059c6822e3070af55c222013d40
Monisha1892/Practice_Problems
/pounds to kg.py
270
4.1875
4
weight = float(input("enter your weight: ")) unit = input("enter L for pounds or K for Kg: ") if unit.upper() == 'L': print("weight in kg is: ", (weight*0.45)) elif unit.upper() == 'K': print("weight in lbs is: ", (weight*2.205)) else: print("invalid unit")
true
f7b5f0ff26048662dc0f1f78774fa3de56c1a8c7
agnesazeqirii/examples
/sorting_a_list.py
642
4.34375
4
# In this program I'm going to sort the list in increasing order, # so that the numbers will be ordered from the smallest to the largest. myList = [] swapped = True num = int(input("How many elements do you want to sort: ")) for i in range(num): val = int(input("Enter a list element: ")) myList.append(val) w...
true
d768b394c739caf10b87e8bbc743f9abdaeb400e
shoaib90/Python_Problems
/Sets_Mutation.py
2,574
4.59375
5
# We have seen the applications of union, intersection, difference and symmetric difference operations, but these operations do # not make any changes or mutations to the set. # We can use the following operations to create mutations to a set: # .update() or |= # .intersection_update() or &= # .difference_update() or...
true
cd0c4829ca166148b49ed27059b791e4aebbd147
Fifthcinn/Pirple.com_py-projects
/New Clean Assignment 4.py
1,442
4.21875
4
""" # 1. guestName = enter name to check if permissable # 2. name gets entered into input # 3. function checks name # 4. if function returns true, name gets added to myUniqueList # 5. if function returns false, name gets added to myLeftovers # 6. print both lists # 7. user gets asked if they would like to enter anoth...
true
93e97c5ea1e0b4316abe797dc587bffd35f85432
GiliScharf/my_first_programs
/print_dict_in_a_chart.py
468
4.15625
4
#this function gets a dictionary of {student's_name:average_of_grades} and prints a chart of it def formatted_print(my_dictionary): list_of_students=list(my_dictionary.keys()) new_list=[] for student in list_of_students: new_list.append([my_dictionary[student],student]) new_list.sort(reverse=Tru...
true
af74ef0de38c1ac94a530d6b5cfabccc9fa3bca6
hitenjain88/algorithms
/sorting/heapsort.py
949
4.3125
4
def heap_sort(array): ''' Implementation of Heap Sort in Python. :param array: A array or a list which is supposed to be sorted. :return: The same array or list sorted in Ascending order.e ''' length = len(array) for item in range(length, -1, -1): heapify(array, item, length) f...
true
61d1db983af95bd86e051adf5eca11506c72fffb
jonesmabea/Algorithms
/fibonnaci/memo_bottom_up_fibonacci.py
823
4.1875
4
#Author: Jones Agwata import timeit def fibonacci(n): ''' This is a memoized solution using a bottom up approach to the fibonacci problem. f(n) = f(n-1)+f(n-2)...+f(n-n) where f(0) = 0, f(1) = 1 params: -------- n : int n values to calculate fibonacci numbers returns: ...
true
02a23d7c548e3ac9293194e60c98f247e1e826f0
MineSelf2016/PythonInEconomicManagement
/Part 1/Chapter 3/example 3.1 List.py
811
4.125
4
""" 通用列表: 列表元素可以是任何类型,且元素间可以没有任何关系 字符串列表: 全部列表元素均为字符串的我们简称为字符串列表,如 ['This', 'is', 'a', 'bike.'] 数字列表: 全部列表元素均为数字的我们简称为数字列表,如 [62, 65, 65, 64, 64, 63, 62, 63, 63, 63, 63, 62] """ print(['A','B','C','D','E','F','G']) print([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) print(['A', 'B', 'C', 7, 8, 9]) print([[1, 2, 3]...
false
771a449b8bc71ab78ff207c4169c894391b78c59
Antonynirmal11/Translator-using-python
/translator.py
450
4.21875
4
from translate import Translator #translate module gives us the translation of the required language fromlanguage=input("Enter your input language:") tolanguage=input("Enter the required language:") #getting input from the user and storing in a variable translator= Translator(from_lang=fromlanguage,to_lang=tolangu...
true
dd848606c2d3690a58b55afcf70015906d1327eb
Ibramicheal/Onemonth
/Onemonth/tip.py
607
4.21875
4
# this calculator is going to determines the perecentage of a tip. # gets bills from custome bill = float(input("What is your bill? ").replace("£"," ")) print("bill") # calculates the options for tips. tip_one = 0.15 * bill tip_two = 0.18 * bill tip_three = 0.20 * bill # prints out the options avaible. print(f"You bil...
true
53b71592594b6f205d087b55c2c0614b40874e31
MrozKarol/Python
/back-to-basic/transformacje danych/wyrazenia slownikowe.py
538
4.25
4
""" wyrażenie słownikowe """ names = {"Arkadiusz", "Wioletta", "Karol", "Bartłomiej", "Jakub", "Ania"} numbers = [1, 2, 3, 4, 5, 6] celcius = {'t1': -20, 't2': -15, 't3': 0, 't4': 12, 't5': 24} nameLength ={ name : len(name) for name in names if name.startswith("A") } print(nameLength) """ przemno...
false
b09be0cfe6021aaca3563e65264ff47a7dd3137b
HMGulzar-Alam/Python_Assignment
/ass3.py
1,354
4.28125
4
#!/usr/bin/env python # coding: utf-8 # In[1]: # Q:1 Program make a simple calculator # This function adds two numbers def add(x, y): return x + y # This function subtracts two numbers def subtract(x, y): return x - y # This function multiplies two numbers def multiply(x, y): return x * y # This function ...
true
80bbca4bf830c9f11d1a8e3805e48bfb6b7b3e29
dantsub/holbertonschool-higher_level_programming
/0x0B-python-input_output/4-append_write.py
460
4.375
4
#!/usr/bin/python3 """ append write module """ def append_write(filename="", text=""): """ Function that appends a string at the end of a text file (UTF8) and returns the number of characters added Args: filename (str): filename. text (str): text to append the file. Return...
true
5fff47e5d1428707dd39fe97ce34b077cc11b902
dantsub/holbertonschool-higher_level_programming
/0x0B-python-input_output/7-save_to_json_file.py
408
4.15625
4
#!/usr/bin/python3 """ save to json file module """ import json def save_to_json_file(my_obj, filename): """ Function that writes an Object to a text file, using a JSON representation Args: my_obj (object): an object. filename (str): filename. Return: Nothing """ w...
true
40438fd29ec71fba2828e959c9352a25880b5d04
Lyric912/conditionals
/secondary.py
2,419
4.59375
5
# author: Lyric Marner # date: july 22, 2021 # --------------- # Section 2 # --------------- # # ---------- # Part 1 # ---------- # print('----- Section 2 -----'.center(25)) print('--- Part 1 ---'.center(25)) # 2 - Palindrome print('\n' + 'Task 1' + '\n') # # Background: A palindrome is a word that is the same if re...
true
e6c7ac66a67510483e211f99140504732579fed1
Lamhdbk/liamhoang
/day_of_week.py
663
4.3125
4
# Python to find day of the week that given date import re # regular expression import calendar # module of python to provide useful function related to calendar import datetime # module of python to get the date and time def process_date(user_input): user_input = re.sub(r"/", " ", user_input) #substitube/...
true
9a1aecb6c84c9d2d743e72cd5770ea2305c34377
mevorahde/FCC_Python
/caculator.py
540
4.125
4
# Seventh Excises: Building a Basic Calculator # YouTube Vid: Learn Python - Full Course for Beginners # URL: https://youtu.be/rfscVS0vtbw # Ask the user for a number and store the value into the variable num1 num1 = input("Enter a number: ") # Ask the user for a second number and store the value into the variable num...
true
157f152e4ae2c05ec74055e537c65ae17c44926f
mevorahde/FCC_Python
/shape.py
294
4.21875
4
# Second Excises: Draw out a little triangle # YouTube Vid: Learn Python - Full Course for Beginners # URL: https://youtu.be/rfscVS0vtbw # Example on how print statements can show output by buidling a triangle from print statements. print(" /|") print(" / |") print(" / |") print("/___|")
true
be055d9f72ac8c00c3c4561b34b32a58e054b583
mevorahde/FCC_Python
/mad_lib_game.py
639
4.46875
4
# Eighth Excises: Building a Mad Libs Game # YouTube Vid: Learn Python - Full Course for Beginners # URL: https://youtu.be/rfscVS0vtbw # Ask the user to enter in a color and set the value to the variable color color = input("Enter a Color: ") # Ask the user to enter in a plural noun and set the value to the variable ...
true
8d0ba54ed431fcce3052153bb0567fb3a288fa3f
Marshea-M/Tech-Talent-Course-2021
/HLW1Task5.py
815
4.125
4
user_input_number_a=int(input("Please type a random number")) user_input_number_b=int(input ("Please type in another number")) input_a=int(user_input_number_a) input_b=int(user_input_number_b) user_input_operator=input("Enter a to add, t to take-away, d to divide, m to multiply, p to power of or square the numb...
true
aad595f0c3eafc41f7895625456cdd62e6ce6952
algorithmrookie/Alan
/week7/232. 用栈实现队列.py
2,655
4.375
4
class Stack(object): def __init__(self): self.stack = [] def push(self, x): # 入栈 self.stack.append(x) def pop(self): # 出栈 if self.is_empty: # 注意特殊情况 return None return self.stack.pop() @property def length(self): ...
false
32e49868f39a879034c63316aed946cfb4a9ff28
SathvikPN/learn-Tkinter
/entry_widget.py
381
4.15625
4
# Write a complete script that displays an Entry widget that’s 40 text units wide # and has a white background and black text. Use .insert() to display text in the widget # that reads "What is your name?". import tkinter as tk window = tk.Tk() txt = tk.Entry( width=40, bg="white", fg="black", ) txt.in...
true
5e13544932db20738d00d6d9687c1081398db02f
srk0515/Flask_1
/Test1.py
1,939
4.46875
4
fruits=['apples','oranges','banana','grapes'] vege=['potato' ,'carrot'] print(fruits) print(len(fruits)) print(fruits[3]) #negative index to come from reverse print(fruits[-4]) #select index print(fruits[0:3]) print(fruits[2:]) #add to end of list fruits.append('pineapple') #add to a position fruits.insert(1,'ma...
true
0e48ed8599543295330d3616dfeb12b40b8c5501
MaximJoinedGit/Algorithms-and-data-structures-on-Python
/lesson_2/homework_2.7.py
1,518
4.125
4
# 7. Написать программу, доказывающую или проверяющую, что для множества натуральных чисел выполняется равенство: # 1+2+...+n = n(n+1)/2, где n — любое натуральное число. from random import randint # Для решения задачи мы определяем две функции. Одна будет считать результат левой части уравнения, вторая - прав...
false
b503ed85131d5e92ff78e6d5bb7295a8828a5627
MaximJoinedGit/Algorithms-and-data-structures-on-Python
/lesson_3/homework_3.7.py
949
4.21875
4
# 7. В одномерном массиве целых чисел определить два наименьших элемента. # Они могут быть как равны между собой (оба минимальны), так и различаться. from random import randint # Массив и два значения для минимальных значений - для самого минимального и второго после него. nums = [randint(1, 100) for _ in range...
false
39df6a139d93b14558dcac71b883d6e5f314f1cd
Dallas-Hays/TLEN-5410
/hws/hw3/15.1.py
530
4.21875
4
""" Dallas Hays Exercise 15.1 Homework 3 """ import math class Point(object): """ Represents a point in 2-D space.""" def distance_between_points(P1, P2): """ Simply does the distance formula using the Point class c^2 = a^2 + b^2 """ a = (P1.y-P2.y)**2 b = (P1.x-P2.x)**2 c = ma...
false
4e759fb1f149c8f5e512f338a8be9ef085b72d22
bokerwere/Python-data-stracture
/python_if stm.py
265
4.21875
4
is_male=False is_tall= True if is_male and is_tall: print("you are male or tall o r both") elif is_male and not (is_tall): print('you are dwaf') elif not(is_male) and is_tall: print("you are female and tall") else: print("ur neither male nor tall")
false
5cdadf056bff7aeef9ca0c59272d9c976353b435
Ashish-Goyal1234/Python-Tutorial-by-Ratan
/ProgrammesByRatan/3_Python_Concatenation.py
494
4.125
4
# In python it is possible to concatenate only similar type of data print(10 + 20) # possible print("ratan" + "ratan") # Possible print(10.5 + 10.5) # Possible print(True + True) # Possible # print(10 + "ratan") # Not possible : We will face type error because both are di...
true
7747df62d4d274760d8b4efcd47134c888a7e195
krmiddlebrook/Artificial-Neural-Network-practice
/ANNs/ANNs.py
927
4.15625
4
# takes the input vectors x and w where x is the vector containing inputs to a neuron and w is a vector containing weights # to each input (signalling the strength of each connection). Finally, b is a constant term known as a bias. def integration(x,w,b): weighted_sum = sum(x[k] * w[k] for k in xrange(0,len(x))...
true
ba03262015d0a05c4b1eeb2824987a29dcc2f8a7
monybun/TestDome_Exercise
/Pipeline(H10).py
944
4.53125
5
''' As part of a data processing pipeline, complete the implementation of the pipeline method: The method should accept a variable number of functions, and it should return a new function that accepts one parameter arg. The returned function should call the first function in the pipeline with the parameter arg, and ca...
true
e2b4fea85d7b916ae8fc86e0886c1190e2055e9c
monybun/TestDome_Exercise
/Shipping(E15).py
2,278
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ A large package can hold 5 items, while the small package can hold only 1 item. The available number of both large and small packages is limited. All items must be placed in packages and used packages have to be filled up completely. Write a function that calculates ...
true
238363a6a8c8c3491e2e0af331513088f330216a
monybun/TestDome_Exercise
/routeplanner(H30).py
2,621
4.5
4
'''As a part of the route planner, the route_exists method is used as a quick filter if the destination is reachable, before using more computationally intensive procedures for finding the optimal route. The roads on the map are rasterized and produce a matrix of boolean values - True if the road is present or False i...
true
c59b935019ab6a665dcbe1b6f6c3fe062b6bb9ce
monybun/TestDome_Exercise
/Paragragh(E30).py
1,676
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ An insurance company has decided to change the format of its policy numbers from XXX-YY-ZZZZ to XXX/ZZZZ/YY (where X, Y and Z each represent the digits 0-9). Write a method that re-formats all policy numbers in a well-formatted paragraph ('-' may appear elsewhere in ...
true
cbc8c2cec4729218bbccf1cdf6a78d9f74e26245
PWynter/paper_scissors_stone
/paper_scissors_stone2.0.py
1,164
4.25
4
"""Paper,scissors,stone game.player selects an option,computer option is random """ # import random and the randint function to generate random numbers from random import randint # assign player an user input player = input("rock (r), paper (p) or scissor (s)? ") # print the user input, end tells python to end with ...
true
0f02b53e49e2bfc742e22830db6b2e9d42423538
archanakul/ThinkPython
/Chapter8-Strings/RotateString.py
1,526
4.34375
4
#PROGRAM - 18 """ 1. ORD() -> Given a string of length one, return an integer representing the value of the byte ord('a') -> 97 2. CHR()-> Return a character whose ASCII code is the integer i. The argument must be in the range [0..255] chr(97) -> 'a' """ def r...
true
93a1ed0d22f242ddbdb099c2ac273bc741400b10
archanakul/ThinkPython
/Chapter2-Variables/Arithmetics.py
2,210
4.40625
4
#PROGRAM - 2 # Operators are special symbols that represent computations # There are basically two types of numeric data types - integer & floating point # Comma separated sequence of data is printed out with spaces between each data print 3,-5,56.98,-45.56 # Pre-defined function(type) prints out data type for the i...
true
aadd007d43366ef0d66700a55aa411dbb37c2f1c
archanakul/ThinkPython
/Chapter10-Lists/NonRepeatedWords.py
708
4.40625
4
#PROGRAM - 27 """ Open the file & read it line by line. For each line, split the line into a list of words using the split() function. The program should build a list of words. For each word on each line check to see if the word is already in the list and if not append it to the list. When program completes, sort & p...
true
d259e7fc46a18ed2e34e87bf02599bdfdf71662d
archanakul/ThinkPython
/Chapter7-Iteration/NewtonsSquareRoot.py
1,329
4.34375
4
#PROGRAM - 16 """ 1. Suppose we need to compute square root of A with an estimate of x then a new better estimate for root of A would be determined by Newtons formula: y = (x + A/x)/2 2. Floating point values rae only approximately right; hence rational 1/3 & irrational number r...
true
7c42789a83805552f67295596a668aa60ffdfc03
archanakul/ThinkPython
/Chapter10-Lists/Anagram.py
876
4.28125
4
#PROGRAM - 30 """ Two words are anagrams if you can rearrange the letters from one to spell the other. 1. list.REMOVE(x): Removes the first appearance of x in the list. ValueError if x is not found in the list. 2. list.POP([,index]): Removes an item at a specified location or at the end ...
true
0dddfbb0e2d6d2a3e52258584021fbdc940cc6cf
hanzijun/python-OOB
/Useful records for __new(init)__ function.py
830
4.375
4
#!/usr/bin/python """ __new/init__ use case for python """ class Person(object): def __new__(cls, age): print "Person.__new__ called" return super(Person, cls).__new__(cls, age) def __init__(self, age): print "Person.__init__ called" self.age = age def fn(self): ...
false
fc6bd938ae69394a075411a723b01db7f119e569
varunbarole/cg_python_day2
/test1.py
252
4.15625
4
a= int(input("Enter any value :")) b= int(input("Enter any value :") if a<b : print (" a is less value") print("inside ifblock") else: print ("b is less") print("inside else block") print("outside else block")
false
14c6140f6a35591767c4d712c782d8235396995a
jhn--/mit-ocw-6.0001-fall2016
/ps4/ps4a.py
2,827
4.375
4
# Problem Set 4A # Name: <your name here> # Collaborators: # Time Spent: x:xx def get_permutations(sequence): ''' Enumerate all permutations of a given string sequence (string): an arbitrary string to permute. Assume that it is a non-empty string. You MUST use recursion for this part. Non-recur...
true
7d808f0e1adf7d613b2e2aa4112e70f4d6b8a4c9
carol3/python_practice
/area.py
468
4.46875
4
#this program calculates the perimeter and area of a rectangle print("calculate information about a rectangle") length=float( input("length :"))#python 3.x,input returs a string so height and length are string you need to convert them to either integers or floa width= float(input("width :")) area=length * width print("...
true
daa12bc0019384815c57854b2eb2cdf43d89f39a
tutorial0/wymapreduce
/maprq.py
1,165
4.125
4
# email: ringzero@0x557.org """this is frequency example from mapreduce""" def mapper(doc): # input reader and map function are combined import os words = [] with open(os.path.join('./', doc)) as fd: for line in fd: for word in line.split(): if len(word) > 3 and word...
true
5b664be18aef55007dc80dc42469355ba23df07b
mhmtnzly/Class5-Python-Module-Week5
/q1.py
1,597
4.5
4
# Question 1: # Create the class `Society` with following information: # `society_name`, `house_no`, `no_of_members`, `flat`, `income` # **Methods :** # * An `__init__` method to assign initial values of `society_name`, `house_no`, `no_of_members`, `income` # * `allocate_flat()` to allocate flat according to income...
false
4803daa3f6b0403bcfa273453ff17a8a82c70aa1
gsrini27/mit-intro-comp-sci
/hypotenuse-function.py
237
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Mar 19 09:56:50 2017 @author: aspen """ import math def hypotenuse(a, b): c_squared = a**2 + b**2 c = math.sqrt(c_squared) return c print(hypotenuse(2, 3))
false
14bbf3967879173105be97c07de88a9d5428f4c7
deref007/python_crwal
/python_crawl/learn5.py
1,645
4.25
4
#面向对象的编程 #类:具有某种特征的事物的集合 #对象:群体(类)里面的分体 #类是抽象的,对象是具体的 ''' 格式: class 类名: 类里面的内容 ''' '''构造函数或者称为构造方法 __init__(self,参数) 在类中的方法必须加上self 其实际意义:初始化 ''' class cla(): def __init__(self): print('I am deref') a=cla() ''' 给类加上参数:给构造函数加上参数 ''' class cla1(): def __init__(self,name,job): print('my name i...
false
793005bc597f60a2f2cc454371031ebfac601ee9
amaranmk/comp110-21f-workspace
/lessons/iterating-through-a-collection.py
326
4.125
4
"""Example of looping through all cahracters in a string.""" __author__ = "730484862" user_string: str = input("Give me a string! ") # The variable i is a common counter variable name # in programming. i is short for iteration i: int = 0 while i < len(user_string): print(user_string[i]) i = i + 1 print("Do...
true
ee18ee10aa7d4bae891647b8f256d62fab78913e
vintell/itea-py_cource
/hw_1_1.py
1,498
4.28125
4
# constants DAYS_IN_MONTH = 30 MONTHS_IN_YEAR = 12 DAY_IS_NOW = 19 MON_IS_NOW = 11 YEAR_IS_NOW = 2018 # init is_error = False # inputs f_name = input('What is your first name: ') l_name = input('What is your last name: ') print('Hey, ', f_name, ' ', l_name, '.') # day_ = 3 # mon_ = 9 # year_ = 1982 ...
false
e2bbdc6f21dadd89fddbfc0bbc4c8149b8477143
vintell/itea-py_cource
/exam/pyca.py
1,943
4.40625
4
from math import cos as mycos, sin as mysin def plus(val_1, val_2): """ This is calculate a sum for two params :param val_1: int or float :param val_2: int or float :return: int or float """ return val_1 + val_2 def minus(val_1, val_2): """ This is calculate a differ...
true
76d900d7761432964196dd76b30c739739ac9d4b
JunYou42/PY4E
/EX2_3.py
276
4.15625
4
# programm to promt the user for hours and rate per hour using # input to compute gross pay #get string type hrs = input("Enter hours:") rate = input("Enter rate per hour:") #convert to floating points hrs = float(hrs) rate = float(rate) print('Pay:',hrs*rate)
true
c07d520fd5a69db8729a6749d948ca475ee61c51
deorelaLara/PythonPruebas
/PracticasLibro/moreGuests.py
1,481
4.71875
5
""" 3-6. More Guests: You just found a bigger dinner table, so now more space is available. Think of three more guests to invite to dinner. • Start with your program from Exercise 3-4 or Exercise 3-5. Add a print statement to the end of your program informing people that you found a b...
true
d2ad1c2858888cb06bf244becbf5b63bf67dadf8
jeremymiller00/Intro-Python
/Strings/strings.py
1,492
4.5625
5
#!/usr/bin/env python """ Strings Examples This week continues where we left off working with strings. This week we will cover string slicing, and a little bit of string formatting. """ firstName = "Rose" lastName = "Tyler" areaCode = 212 exchange = 664 numSuffix = 7665 print "We can cancatinate strings with the...
true
6b5c293acad498cf0b7f26e4d1977a211b3bd076
chagan1985/PythonByExample
/ex077.py
855
4.1875
4
##### # Python By Example # Exercise 077 # Christopher Hagan ##### attendees = [] for i in range(0, 3): attendees.append(input('Enter the name of someone to invite to a party: ')) addAnother = 'y' while addAnother.lower().startswith('y'): addAnother = input('Would you like to add another guest: ') if addA...
true
a603015ffb99493e82f42df18488b22ec4ec84b8
chagan1985/PythonByExample
/ex041.py
327
4.1875
4
##### # Python By Example # Exercise 041 # Christopher Hagan ##### name = input('Please enter your name: ') repetitions = int(input('How many times should I repeat your name: ')) if repetitions < 10: textToRepeat = name else: textToRepeat = 'Too high' repetitions = 3 for i in range(0, repetitions): pr...
true
57797f4406bea4c20b5c1927b0f1430e85bc2a07
chagan1985/PythonByExample
/ex038.py
283
4.15625
4
##### # Python By Example # Exercise 038 # Christopher Hagan ##### name = input('Please enter your name: ') repetitions = int(input('How many times should I loop through the characters in' ' your name? ')) for i in range(0, repetitions): print(name[i % len(name)])
true
5bb0caaa44ae8d6285d30914d98971a9c3a73ca7
chagan1985/PythonByExample
/ex093.py
431
4.125
4
##### # Python By Example # Exercise 093 # Christopher Hagan ##### from array import * nums = array('i', []) removedNums = array('i', []) while len(nums) < 5: newNum = int(input('Enter a number to append to the array: ')) nums.append(newNum) nums = sorted(nums) print(nums) userChoice = int(input('Enter a nu...
true
3d7db392ce92cab8018a429e87054ff9f3f54e9a
chagan1985/PythonByExample
/ex142.py
510
4.34375
4
##### # Python By Example # Exercise 142 # Christopher Hagan ##### import sqlite3 with sqlite3.connect("BookInfo.db") as db: cursor = db.cursor() cursor.execute("""SELECT * FROM Authors;""") for author in cursor.fetchall(): print(author) authorBirthPlace = input('Enter the place of birth of the author(s) yo...
true
febdfec7639719ae6598e5c91a1e102382b091b4
chagan1985/PythonByExample
/ex036.py
214
4.21875
4
##### # Python By Example # Exercise 036 # Christopher Hagan ##### name = input('Please enter your name: ') repetitions = int(input('How many times should I say your name: ')) for i in range(0, repetitions): print(name)
true
b9c2acb11f8d955f59d111c5fad10ff639c5a852
Jerrybear16/MyFirstPython
/main.py
2,411
4.1875
4
#print your name print("Jeroen") #print the lyrics to a song stairway = "There's a lady who's sure, all that glitters is gold, and she's buying a stairway to heaven" print("stairway") #display several numbers x=1 print(x) x=2 print(x) x=3 print(x) #solve the equation print(64+32) #same but with variables x ...
true
e7901d6febac3de5dc79ea4048e791d3cd815f59
HarshCasper/Rotten-Scripts
/Python/Encrypt_Text/encrypt_text.py
1,237
4.34375
4
# A Python Script which can hash a string using a multitude of Hashing Algorithms like SHA256, SHA512 and more import hashlib import argparse import sys def main(text, hashType): encoder = text.encode("utf_8") myHash = "" if hashType.lower() == "md5": myHash = hashlib.md5(encoder).hexdigest() ...
true
25fd335354c8560bbd7e8442462292d8d34174fe
HarshCasper/Rotten-Scripts
/Python/Caesar_Cipher/decipher.py
1,457
4.4375
4
""" A Python Script to implement Caesar Cipher. The technique is really basic. # It shifts every character by a certain number (Shift Key) # This number is secret and only the sender, receiver knows it. # Using Such a Key, the message can be easily decoded as well. # This Script Focuses on the Decoding Part only. """ ...
true
862212ea35de8f2a361e51bdd69a5cbbdea87f8c
HarshCasper/Rotten-Scripts
/Python/Countdown_Clock_and_Timer/countdown_clock_and_timer.py
1,456
4.40625
4
# import modules like 'os' and 'time' import os import time os.system("clear") # using ctime() to show present time times = time.ctime() print("\nCurrent Time: ", times) print("\n Welcome to CountdownTimer!\n\n Let's set up the countdown timer...\n") # User input for the timer hours = int(input(" How ma...
true
51821a5fbc8054ea90f724a790a5aca64af9ed68
Rahmonova/Python
/src/material/hello_3.py
2,779
4.1875
4
"""STRING""" # greeting = "hello" # print(greeting[0]) # print(greeting[-1]) # print(greeting[2:]) # print(greeting[2:4]) # Don't add character in string # x greeting[0] = 'j' # Satr o`lchamini aniqlash # print(len(greeting)) # Satrda berilgan elementni sanash # print(greeting.count('l')) # print(greeting.count('l')...
false
4a7b213cc577665d05961141dd2b30413182313d
anurag5398/DSA-Problems
/Misc/FormingMagicSquare.py
1,987
4.3125
4
""" We define a magic square to be an matrix of distinct positive integers from to where the sum of any row, column, or diagonal of length is always equal to the same number: the magic constant. You will be given a matrix of integers in the inclusive range . We can convert any digit to any other digit in the ra...
true
875ac737696d41ca97141ba845ddfe832723e5d0
jellive/pythonstudy
/Chap02. Python basic - Struct/02-6. Set.py
1,146
4.25
4
""" Set 파이썬 2.3에서부터 지원되기 시작한 자료형. 집합에 관련된 것들을 쉽게 처리하기 위해 만들어진 자료형. 특징 1. 중복을 허용하지 않는다. 2. 순서가 없다(Unordered). """ s1 = set([1,2,3]) print(s1) # {1, 2, 3} s2 = set("Hello") print(s2) # {'e', 'H', 'l', o'}, 중복되는 건 지우고 알파벳 순으로 나열한다. # set을 list로 바꾸기 print(list(s1)) # [1, 2, 3] # set을 tuple로 바꾸기 print(tuple(s1)) # (1, ...
false
b97586756284aaf8ea4644c4d74fdfbcde9fce0e
AndresHG/UCM
/Python/Ejercicio2Python.py
1,098
4.28125
4
#Pedimos el mes por primera vez al usuario mes = input("Introduzca el nombre del mes: ") #Utilizamos un bucle while ya que en el ejemplo, se hacen varias peticiones al usuario #El bucle termina cuando pulsamos 0 while mes != "0": #Utilizamos la función lower() que nos pasa un string a todo minúsculas ...
false
c715f587787e6e1a112cf654fedcb230b5977511
fawpc/algoritmos2-2018-2
/job(lista encadeada).py
2,655
4.3125
4
"""Implementação de hoje.""" class No: """Define um no da lista encadeada.""" def __init__(self, valor): """Inicializa no.""" self.dado = valor self.proximo = None def recebe(self, valor): """bla bla bla.""" self.dado = valor def prox(self, val...
false
c8ec71ad18413c7a12d309d1a1747a391bca1cc6
joshseyda/Python-CS
/lambda0.py
413
4.15625
4
# regular function def is_even(x): if x % 2 == 0: return True else: return False # lambda function even = lambda x: x % 2 == 0 # results print('is_even(4): {}'.format(is_even(4))) print('is_even(3): {}'.format(is_even(3))) print('even(4): {}'.format(even(4))) print('even(3): {}'.format(even(...
false
56e2e07ea84d6200924c1fb9d35cbead8f960e82
Gyanesh-Mahto/Edureka-Python
/Class_Codes_Module_3&4/P9_07_Constructor_and_Destructor.py
1,804
4.71875
5
#Constructor and Destructor ''' Construtor: __init__(self) is initiation method for any class. This is also called as contructor Destructor: It is executed when we destroy any object or instance of the class. __del__(self) is destructor method for destrying the object. ''' class TestClass: def __init__(self):...
true
04230c130fceeca7db61dc11b2422b752981dedf
Gyanesh-Mahto/Edureka-Python
/Class_Codes_Module_3&4/P8_Variable_length_arguments.py
1,246
4.75
5
''' Variable-length Arguments: When we need to process a function for more arguments than you have specified while defining the function, So, variable-length arguments can be used. ''' def myFunction(arg1, arg2, arg3, *args, **kwargs): print("First Normal Argument: "+str(arg1)) print("Second Normal Argum...
true
27dad1a58b341711371a79cc7815e97b19e1d6d2
theChad/ThinkPython
/chap2/chap2.py
1,008
4.125
4
# 2.2.1 # Volume of a sphere with radius 5 r = 5 #radius of the sphere volume = 4/3*3.14159*r**3 print("2.2.1 Volume of sphere:", volume) # 2.2.2 # Textbook price cover_price = 24.95 discount = 0.4 shipping_book_one = 3 shipping_extra_book = 0.75 num_books = 60 total_shipping = shipping_book_one + shipping_extra_book*...
true
4519920c83d465d689e03c2adbba42f4b822ffd5
theChad/ThinkPython
/chap12/most_frequent.py
920
4.125
4
# Exercise 12.1 # From Exercise 11.2, just to avoid importing def invert_dict(d): """Return a dictionary whose keys are the values of d, and whose values are lists of the corresponding keys of d """ inverse = dict() for key in d: val = d[key] inverse.setdefault(val,[]).append(key) ...
true
531e4e63621e4b978f722c87b4c6a8759ebeb151
theChad/ThinkPython
/chap9/ages.py
1,358
4.28125
4
# Exercise 9.9 # I think the child is 57, and they're 17-18 years apart # I really shouldn't rewrite functions, but it's a short one and it's more convenient now. def is_reverse(word1, word2): return word1==word2[::-1] # After looking at the solutions, this should really cover reversed numbers with two different ...
true
628fdde22ad8c5816048781d068959c68fc118f5
umitkoc/python_lesson
/map.py
423
4.25
4
# map function #iterable as list or array #function as def or lambda #map(function,iterable) or numbers=[1,2,3,4,5,6] #example def Sqrt(number): return number**2 a=list(map(Sqrt,numbers)) print(a) #example b=list(map(lambda number:number**3,numbers)) print(b) #map(str,int,double variable as ...
true
12ef8b9534255a1fd3844b5a4aa6598e55e49080
bernardobruno/Methods_Python_Basics
/Methods_Python_Basics.py
2,123
4.53125
5
#!/usr/bin/env python # coding: utf-8 # In[1]: # Method - append() --- Adds an element at the end of the list names = ["Jim", "John", "Joey"] names.append("Jason") print(names) # In[2]: # Method - clear() --- Removes all the elements from the list names = ["Jim", "John", "Joey"] names.clear() print(names) # ...
true
817009a19f56b2f896ab51df41542bae0c64b533
dhautsch/etc
/jython/MyTreeFactory.py
1,144
4.4375
4
class MyTreeFactory: """ From http://www.exampleprogramming.com/factory.html A factory is a software design pattern as seen in the influential book "Design Patterns: Elements of Reusable Object-Oriented Software". It's generally good programming practice to abstract your code as much as possibl...
true
03ddc774d8ea887c8acd472096d8f211eb3ee367
danny31415/project_euler
/src/problem1.py
429
4.125
4
"""Project Euler Problem 1 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. """ from __future__ import print_function def main(): total = 0 for x in range(1000): if...
true
32dbf5f4b0b91fd3ca02d4a9b7425bec2109f6de
BootcampersCollective/Coders-Workshop
/Contributors/AdamVinueza/linked_list/linked_list.py
2,735
4.25
4
class Node(): '''A simple node class for doubly-linked lists.''' __slots__ = [ 'key', 'next', 'prev' ] def __init__(self, value): self.key = value self.next = None self.prev = None class LinkedList(): '''A doubly-linked list, with iteration and in-place reverse and rotation.'''...
true
a96fc5f29cdc10332358d2f9707e597b7a5c61da
Javierfs94/Modulo-Programacion
/Python/poo/excepciones/Ejercicio1.py
937
4.15625
4
''' Realiza un programa que pida 6 números por teclado y nos diga cuál es el máximo. Si el usuario introduce un dato erróneo (algo que no sea un número entero) el programa debe indicarlo y debe pedir de nuevo el número. @author Francisco Javier Frías Serrano @version 1.0 ''' print("Introduzca 6 números enteros...
false
5ab3c1fbdada734e9299656debd3db8f810924a5
nt3rp/Project-Euler
/completed/q14.py
1,642
4.1875
4
#The following iterative sequence is defined for the set of positive integers: #n n/2 (n is even) #n 3n + 1 (n is odd) #Using the rule above and starting with 13, we generate the following sequence: #13 -> 40 20 10 5 16 8 4 2 1 #It can be seen that this sequence (starting at 13 and finishing at 1) contains 1...
true
7605db9a9ea25bb5dd333dfbb7eafb0561916792
Puhalenthi/-MyPythonBasics
/Python/Other/BubbleSort.py
1,201
4.125
4
class IncorrectItemEnteredError(BaseException): pass def BubbleSort(): nums = [] done = False sorting = True while done == False: try: num = int(input('Give me a number to add to the sorting list: ')) except: print('Please enter a valid integer') ...
true
e2a21c706bfc25cc3dd5992095ed16ae54e16982
misoi/python
/codeacademy/accessbyindex.py
408
4.1875
4
""" The string "PYTHON" has six characters, numbered 0 to 5, as shown below: +---+---+---+---+---+---+ | P | Y | T | H | O | N | +---+---+---+---+---+---+ 0 1 2 3 4 5 So if you wanted "Y", you could just type "PYTHON"[1] (always start counting from 0!) """ fifth_letter = "MONTY"[4] print fifth_letter # ...
false
48ae6b659509b290375de9f0f4b7528eb1a91121
Mathew5693/BasicPython
/oldmcdonalds.py
308
4.15625
4
#Programming exercise 4 #Mathew Apanovich #A program to out put the sum of all cubes of n natural numbers def cude(n): x = 0 for i in range(1,n+1,1): x = x+ i**3 return x def main(): n = eval(input("Please enter natural number:")) z = cude(n) print(z)
true
867485e8e1247a70f3f6a11b8ad93b21616ad507
Mathew5693/BasicPython
/kilotomiles.py
217
4.3125
4
#A program to convert kilometers to miles #Mathew Apanovich #Kilo to miles.py def main(): k = eval(input("Please enter distance in Kilometers: ")) m = k * .621371 print(k,"Kilometers is", m,"Miles!")
false
cba67abc8d0af5f4be041c5333719662298806bc
k/Tutorials
/Python/ex3.py
773
4.375
4
print "I will now count my chickens:" # calculate and print the number of Hens print "Hens", 25 + 30 / 6 # calculate and print the number of Roosters print "Roosters", 100 - 25 * 3 % 4 print "Now I will count the eggs:" # calculate the eggs print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 print "Is it true that 3 + 2 < 5 - 7?...
true
1424c2432a573562eea0621166e1381f40ed36d5
larafonse/exploring_linked_lists
/part1.py
1,801
4.375
4
# Initializing Linked List class LinkedList: # Function to initialize the linked list class def __init__(self): self.head = None # Initialize the head of linked list as # Function to add passed in Node to start linked list def addToStart(self, data): tempNode = Node(data) # create a new...
true
c6e1466fc73cbaef1481da95dd28bf8e72789382
Laveenajethani/python_problemes
/count_word_lines_char.py
398
4.28125
4
# program for count the words,lines,chracter in text files #!/usr/bin/python3 num_lines=0 num_words=0 num_chracter=0 with open('text.txt','r') as f: for line in f: wordlist=line.split() num_lines +=1 num_words +=len(wordlist) num_chracter +=len(line) print("number of lines:") print(num_lines) print("number...
true
146d577959a3fffd95a7a04ee5f4b536927b171f
muhdnaveedkhan/module-one
/list-comprehension.py
1,712
4.5
4
# list comprehension # with the help of list comprehension we can create of list in one line # ---------------- Problem #1 : reverse the list's elements----------- # ls = ['abc', 'xyz', 'vut', 'lms'] # new_ls = [] # for el in ls: # new_ls.append(el[::-1]) # print(new_ls) # Similary, we can do the same with list ...
false
059c5b50ad5631101544c5d0e397c77b7d14c3eb
mak2salazarjr/python-puzzles
/geeksforgeeks/isomorphic_strings.py
1,337
4.4375
4
""" http://www.geeksforgeeks.org/check-if-two-given-strings-are-isomorphic-to-each-other/ Two strings str1 and str2 are called isomorphic if there is a one to one mapping possible for every character of str1 to every character of str2. And all occurrences of every character in ‘str1’ map to same character in ‘str2’ ...
true
856b2a53c2142f58a860ee7dbe59b8fa6a08b115
1337Python/StudyTime
/Objects.py
1,369
4.15625
4
class NonObject: None #This is Python syntax for noop aka no-op or 'no operation' class Object: def __init__(self): self.name = "Unamed" self.age = "-1" print("Constructed Object!") def __del__(self): print("Destructed Object!") class NamedObject: def __init__...
true
ed2d57cd72eae4a20c40656fbedf75ffb60b4bef
Afshana123/eng88_task_19052021
/Task_19052021.py
901
4.40625
4
# Promts User to enter their name and welcomes user Name = str(input("Please enter your name: ")) print("Hello " + Name) # Promts User to enter their age Age = int(input("Please enter your age: ")) # Promts user to enter their month of birth Month_of_birth = int(input("Please enter the month you were born in numerica...
false
5387e6e5ddbdd0679841add55d3c5a47899fc461
MarkMikow/CodingBat-Solutions-in-Python-2.7
/Logic-2/round_sum.py
742
4.15625
4
'''For this problem, we'll round an int value up to the next multiple of 10 if its rightmost digit is 5 or more, so 15 rounds up to 20. Alternately, round down to the previous multiple of 10 if its rightmost digit is less than 5, so 12 rounds down to 10. Given 3 ints, a b c, return the sum of their rounded values. ...
true
512ccc51d8dde88dfd52450e50fba426ee175fae
MarkMikow/CodingBat-Solutions-in-Python-2.7
/Logic-2/make_bricks.py
844
4.21875
4
''' We want to make a row of bricks that is goal inches long. We have a number of small bricks (1 inch each) and big bricks (5 inches each). Return True if it is possible to make the goal by choosing from the given bricks. This is a little harder than it looks and can be done without any loops. ''' def make_brick...
true
ba3fa9a21bed8e08360f9b39fbe3f30a63f78cfe
nolngo/Frequency-counter
/HashTable.py
1,047
4.25
4
from LinkedList import LinkedList class HashTable: def __init__(self, size): self.size = size self.arr = self.create_arr(size) def create_arr(self, size): """ Creates an array (list) of a given size and populates each of its elements with a LinkedList object """ array = [] ...
true
88ffa4e639f58584e943b7b78d5992701de6ed22
basti42/advent_of_code_2017
/day1/day1.py
1,207
4.25
4
#!/usr/bin/env python3 import sys """ Advent of Code - Day 1: Part 1 --> SOLVED Part 2 --> SOLVED """ def sum_of_matches(numbers): """calculate the sum of all numbers that match the next""" matches = 0 for i,n in enumerate(numbers): if n == numbers[i-1]: matches += int(n) ...
true