blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
b8bd7096aa800ba40dfd70bdcb94e63c47b78043
niranjan2822/Interview1
/program to print odd numbers in a List.py
1,328
4.53125
5
# program to print odd numbers in a List ''' Example: Input: list1 = [2, 7, 5, 64, 14] Output: [7, 5] Input: list2 = [12, 14, 95, 3, 73] Output: [95, 3, 73] ''' # Using for loop : Iterate each element in the list using for loop and check if num % 2 != 0. # If the condition satisfies, then only print the number. # ...
true
8a0fcc9d999434e6952ca9bb6c5d2d2f2ca36e6c
niranjan2822/Interview1
/Uncommon elements in Lists of List.py
2,104
4.5
4
# Uncommon elements in Lists of List ''' Input: The original list 1 : [[1, 2], [3, 4], [5, 6]] output : [[3, 4], [5, 7], [1, 2]] # The uncommon of two lists is : [[5, 6], [5, 7]] ''' # Method 1 : Naive Method # This is the simplest method to achieve this task and uses the brute force approach of executing a loop a...
true
6fc03e029814d1e7f48e0c65921d19a276c15b06
CHilke1/Tasks-11-3-2015
/Fibonacci2.py
586
4.125
4
class Fibonacci(object): def __init__(self, start, max): self.start = start self.max = max def fibonacci(self, max): if max == 0 or max == 1: return max else: return self.fibonacci(max - 1) + self.fibonacci(max - 2) def printfib(self, start, max): for i in range(start, max): print("Fibonac...
true
e0ec66c76e6f734caf5262867aac6245414ba8e9
bvo773/PythonFun
/tutorialspy/basic/listPy.py
557
4.40625
4
# (Datatype) List - A container that stores ordered sequence of objects(values). Can be modified. # listName = [object1, object2, object3] def printFruits(fruits): for fruit in fruits: print(fruit) print("\n") fruits = ["Apple", "Orange", "Strawberry"] fruits[0] #Accessing a list fruits[1] = "Mango"...
true
6dfc3a9d06ee4401a3d78ddb27e8bacd01884138
rwankurnia/fundamental-python
/Dictionary/dictionary.py
2,195
4.15625
4
# # DICTIONARY # # Menggunakan kurung kurawal {} # # Tidak menggunakan index, melainkan property # # Nama property ditulis menggunakan kutip (seperti string) # price = { # "apple" : 10000, # "grape" : 15000, # "orange" : 15000 # } # price["grape"] // 15000 # print(price["grape"]) ## 15000 # ===========...
false
2e21c5f9cde84b02370c12f0c17daa41d5c56b10
sseun07/pythonBasic
/Lecture3.py
1,369
4.71875
5
''' Where do you use for-loop? RANGE-함수 - range(a,b) *a is optional (is inclusive) // a 보다 크거나 같고, b 보다는 작은것 - create list ''' for each in range(16,25): print(each) l=[1,2,3,7,10,20,35] print(l[0]) for each in range(len(l)): print(l[each]) ''' len=length of the list ''' ''' NEGATIVE INDEX l[-1] : 뒤에서 첫번째 ...
false
575a0095523dd275b7e6a5f89266f4feae0afdbb
UCD-pbio-rclub/Pithon_JohnD
/July_18_2018/Problem_1.py
803
4.125
4
# Problem 1 # Write a function that reports the number of sequences in a fasta file import string import re import glob def fastaCount(): files = glob.glob('*') filename = input('Enter the name of the fasta file if unsure, enter ls for \ current directory listings: ') if filename == 'ls': for i in...
true
4cae14c7bc79058cc405ab09c1d622b1e07e2f2a
reginald1992/PythonFoundation
/PythonBasis/FunctionalProgrammingPartialFunction.py
1,316
4.46875
4
""" 偏函数--functools.partial的作用:把一个函数的某些参数给固定住(也就是设置默认值),返回一个新的函数,调用这个新函数会更简单。 """ import functools print(int('123456')) print(int('123456', base=8)) print(int('123456', 16)) print(int('101001', 2)) def int2(x, base=2): return int(x, base) print(int2('100000')) print(int2('101010101')) ''' functools.partial就是帮助我...
false
402fbd754c53584ec8400f07a3c697f5c07e1b94
Atul-Bhatt/Advanced-Python
/itertools.py
1,304
4.28125
4
# advanced iterator functions in ther itertools package import itertools def testFunction(x): if x > 40: return False return True def main(): # TODO: cycle iterator can be used to cycle over a collection names = ["John", "Casey", "Nile"] cycle_names = itertools.cycle(names) print(nex...
true
0a2ec74b681d34d78fff26dad5ee7599e538e590
weida8/Practice
/TreeConvert.py
2,460
4.15625
4
# File: TreeConvert.py # Description: HW 9 # Student's Name: Wei-Da Pan # Student's UT EID: wp3479 # Course Name: CS 313E # Unique Number: 50595 # # Date Created: 11/19/15 # Date Last Modified: 11/20/15 #class that create a binary tree class BinaryTree(object): def __init__(self, initVal): ...
true
f356cdb6113fd2cc22d315f8cba8875327760c12
rivwoxx/python-Le
/exs/bi7.py
501
4.25
4
''' Escribir un programa que determine si un año es bisiesto. Un año es bisiesto si es múltiplo de 4 (por ejemplo 1984). Los años múltiplos de 100 no son bisiestos, salvo si ellos son también múltiplos de 400 (2000 es bisiesto, pero; 1800 no lo es). ''' def is_leap(year): if (year % 100 != 0 or year % 400 == ...
false
55e3fdb3e74b84f64e6bfc288f4a68b43001a38b
CharlieRider/project_euler
/problem4/problem4.py
960
4.40625
4
""" A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99 Find the largest palindrome made from the product of two 3-digit numbers. """ def is_numeric_palindrome(n): str_n = str(n) if len(str(n)) % 2 == 0: first_split_reve...
true
e3b2ea406823f0843bf6abb13b4acc0f8f07843a
sabinzero/various-py
/operations/main.py
254
4.1875
4
a=input("enter first number: ") b=input("enter second number: ") c=input("enter third number: ") S=a+b+c print "sum of the numbers = %d" % S P=a*b*c print "product of the numbers = %d" % P A=(a+b+c)/3 print "average of the numbers = %f" % A
true
a090f50bee3b3f2a57726d560582ae0e97524071
sabinzero/various-py
/prime number/main.py
210
4.15625
4
from math import sqrt num = input("enter number: ") x = int(sqrt(num)) for i in range(2, x + 1): if num % i == 0: print "number is not prime" exit(0) print "number is prime"
true
1d4dbbd05c87e7e6c175bf0c3950f6f9d444f3ed
KKrishnendu1998/NUMERICAL_METHODS_ASSIGNEMENT
/fibonacci_module.py
566
4.28125
4
'''it is a module to print first n fibonacci numbers creator : Krishnendu Maji ''' def fibonacci(n): # defining the function to print 1st n fibonacci numbers# a = 0 #the value of 1st number# b = 1 #the value of second number# i = 0 print('first '+str(n)+' ...
true
170f02f6857b192722fb5a7aa1682ca982ff0444
neelesh98965/code-freak
/python/Red Devil/FizzBuzz.py
538
4.3125
4
""" Write a function called fizz_buzz that takes a number. 1. If the number is divisible by 3, it should return “Fizz”. 2. If it is divisible by 5, it should return “Buzz”. 3. If it is divisible by both 3 and 5, it should return “FizzBuzz”. 4. Otherwise, it should return the same number. """ def fizz_buzz(n):...
true
a3aac3528312d90213978df624bd7bb84f088e43
YChaeeun/WTM_learningPython
/1_input/0509_input.py
1,619
4.125
4
# 0509 # 자료형 이해하기 & 파이썬 입출력 연습하기 # 자료형 # 문제 1 : 3.14를 문자열, 정수, 실수로 출력하기 num = 3.14 numTostring = str(num) floatToint = int(num) intTofloat = float(floatToint) print(numTostring, type(numTostring)) print(floatToint, type(floatToint)) print(intTofloat, type(intTofloat)) print() # 줄 한 칸 띄기 # 입출력 # 문제 1 : 실수를 입력받아 ...
false
9705a09929ca2aeb3b1547f5560b7f8bb8e3aa13
NeilNjae/szyfrow
/szyfrow/support/text_prettify.py
2,075
4.3125
4
"""Various functions for prettifying text, useful when cipher routines generate strings of letters without spaces. """ import string from szyfrow.support.segment import segment from szyfrow.support.utilities import cat, lcat, sanitise def prettify(text, width=100): """Segment a text into words, then pack into li...
true
d9ef06541e511a83aefdc6cb947720a5414079d1
keitho18/tkinter_freecodecamp_course
/tkinter_tutorials/grid.py
437
4.125
4
from tkinter import * root = Tk() #Creating a label widget myLabel1 = Label(root, text="Hello World") myLabel2 = Label(root, text="My name is Keith") #Putting the widgets into the GUI using the grid coordinates #If there are empty grid cells, then the GUI will skip them when the GUI is displayed myLabel1.g...
true
454b50d9a8b007d16f4f52d8f7d446e450a71275
hubbm-bbm101/lab5-exercise-solution-b2210356106
/Exercise3.py
440
4.21875
4
import random number = random.randint(0, 20) guess = 0 print("A random number is generated between 0 and 20. Please type your guess.") while guess != number: guess = int(input("Your guess = ")) if guess < number: print("Please increase your guess and try again.") elif guess > number: ...
true
1ce97a7b2be9a31028359bb93d3a12b1084f76a8
Azumait/grammar1-1
/back_python_1_basic1/1_python_grammar1/9.py
1,524
4.125
4
# [정식 클래스 만들기] class Human(): # 모델링(초기화) def __init__(self, name, weight, language): self.name = name self.weight = weight self.language = language # print시의 처리 def __str__(self): # print했을 때 클래스는 위치만 나오는데, 이걸 지정하면 이대로 나온다. return "{}은 {}키로이며, {}언어를 구사해요.".format(se...
false
4c5654b4cd2ba4ef00f930a9f94276750bf644c6
Azumait/grammar1-1
/back_python_1_basic1/1_python_grammar1_min/4.py
1,193
4.4375
4
# Method(parameter) 만들기 # 블럭 지정 후 ctrl + / = 주석처리 # definition 정의 # def add(a, b): # result = a + b # print(result) # # 호출 # add(1, 3) # def printHello(): # print('Hello') # printHello() # def add10(a): # result = a + 10 # print(result) # add10(1) # add10(10) # def addmulti(a): # result ...
false
5380f0cbaeddd4b3e88654b829628255db3c1109
Cayce2514/Python
/collatz.py
812
4.21875
4
def getNumber(): global number while number == 0: try: number = int(input("Please enter a number: ")) except ValueError: print("That doesn't seem to be a number, please enter a number") return number def collatz(number): if (number % 2 == 1): print('You picked an ...
true
8271197763e942373597f67a4cf3ab3131e01085
boini-ramesh408/week1_fellowship_peograms
/algoriths/BubbleSort.py
402
4.1875
4
from com.bridgelabz.python.utility.pythonUtil import bubble_sort list=[]#to take run time values in sorting first take one emply list and add the elements to the empty list try: num=int(input("enter the number")) for i in range(0,num): element = int(input()) list.append(element) bubbl...
true
4d7a37c3c1fa3ab8e02e8c046af3c2b006b66a9f
diparai/IS211_Assignment4
/sort_compare.py
2,389
4.1875
4
import argparse # other imports go here import time import random def get_me_random_list(n): """Generate list of n elements in random order :params: n: Number of elements in the list :returns: A list with n elements in random order """ a_list = list(range(n)) random.shuffle(a_list) ret...
true
eabb73a4092281f19c17ab551327848bcf523dc5
kahei-li/python_revision
/days-calculator/time-till-deadline.py
514
4.15625
4
from datetime import datetime user_input = input("enter your goal with a deadline separated by colon. e.g. goal:dd/mm/yyyy\n") input_list = user_input.split(":") goal = input_list[0] deadline = input_list[1] print(input_list) deadline_date = datetime.datetime.strptime(deadline, "%d/%m/%Y") # converting input date in...
true
7908203039fd811602f482efc1a9153a39d855f7
Mjk29/CS_100_H03
/Python Files/9_14_16/MattKehoe_HW01.py
1,026
4.1875
4
flowers= ['rose', 'bougainvillea','yucca', 'marigold', 'daylilly', 'lilly of the valley'] print ('potato' in flowers) thorny = flowers[:3] poisonous = flowers[-1] dangerous = thorny + poisonous print (dangerous) print (poisonous) print ( thorny) print ( flowers) xpoint = [0,10,6,7] ypoint = [0,10,6,8] radiu...
true
8804d6c08269a6939b6739d5bd6821e937735b33
asimonia/datastructures-algorithms
/Recursion/listsum.py
428
4.1875
4
""" A recursive algorithm must have a base case. A recursive algorithm must change its state and move toward the base case. A recursive algorithm must call itself, recursively. """ def listsum(numList): theSum = 0 for i in numList: theSum = theSum + i return theSum def listsum2(numList): """Recurisve version of...
true
2d2d40ad0d0e97894f8cdec6bef72a46a5544c14
mukeshsinghmanral/Python-part-2
/py/fib.py
456
4.3125
4
def fib(n): ''' this is to find fibonacci series upto some limit''' a,b=0,1 print("fibonacii series of",n,"terms is :",end=' ') print(a ,b ,end=' ') for i in range(n-2): c=a+b print(c,end=' ') a=b b=c try: n=int(input('enter number of terms: ')) if n==1: print(0) elif n<=0...
false
8df137c1bf7a5a3cd1c5009006b31f3af7b91fcf
Dinu28/Python3
/Lesson9.py
256
4.125
4
#!/usr/bin/env python #File operations ################################### #Find a word in the file fil=open("test1.txt","r") buff=fil.read() word=raw_input("Enter a word to search:") if(word in buff): print("Yes,Found it!") else: print("Not Found!")
true
c8a4dbda658b550211919b6e07a9330b1acf222a
Squareroot7/Python
/LargestPalindromNum.py
1,774
4.25
4
#Largest palindrom number #A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. #Find the largest palindrome made from the product of two 3-digit numbers. #you have to find the LARGEST, so maybe you have to start from the biggest number...
false
fffc9f5427e0bc5d91fa09b44a6c0e13ef77cf0c
somesh-paidlewar/Basic_Python_Program
/make_a_triangle.py
673
4.5
4
#To draw a Triangle with three points as input with mouse from graphics import * win = GraphWin('Make a Triangle',600,600) win.setCoords(0.0,0.0,10.0,10.0) message = Text(Point(5,0.5), 'Click any three points to draw a Triangle') message.draw(win) #Get and draw three vertices of the Triangle p1 = win.getMouse() p1....
true
2a134c9eb2849803e9b6265b619288a47511652f
kanika011/Python-Code-Questions
/IsomorphicStrings.py
1,145
4.125
4
#Isomorphic strings #Given two strings s and t, determine if they are isomorphic. #Two strings are isomorphic if the characters in s can be replaced to get t. #All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same charact...
true
b2fce549968e6dfcb39beaf39acbcc7ed0481a90
somenbg/algorithm
/binary_search_recursive.py
920
4.21875
4
def binary_search_recursive(list_to_search: list, start_index: int, end_index: int, element_to_search: int): ''' Usage: list = [1,2,3,4,5,6] binary_search_recursive(list, 0, len(list1)-1, 1) Output: "Element '1' is at index '0'" ''' if start_index <=...
true
3bbdb091f3f0afd7ee58958a94ba72895fb3aa8e
AAlfaro29/Phyton
/list_exer.py
702
4.25
4
#foods = ["orange", "apple", "banana", "strawberry", "grape", "blueberry",["carrot", "cauliflower","pumpkin"], "passionfruit", "mango", "kiwifruit"] #print(foods[0]) #print(foods[2]) #print(foods[-1]) #print(foods[0:3]) #print(foods[7:12]) #print(foods[-5]) - Needs to ask #names= ["Chilli","Roary", "Remus", "Prince Th...
false
39113ba692269c24d4eaf98ee6d54fe100b75365
mworrall1101/code-from-school
/summer16/Week09/string_stuff.py
427
4.15625
4
# string_stuff.py # # # # B. Bird - 06/28/2016 S = ' Pear, Raspberry, Peach ' #The .split() method of a string splits the string #by the provided separator and returns a list #of the resulting tokens. for token in S.split(','): print("Token: '%s'"%token) #The .strip() method of a string removes all lead...
true
e8a664bcd25858d0c99fccf359811bfff2e9f26d
Donzellini/pythonCampinasTech
/Aula_10/listas4.py
241
4.125
4
lista_comida = ["arroz", "feijão", "carne", "batata"] #ler de trás para frente -> usa o negativo print(lista_comida[-2]) #ler de trás para frente usando o range print(lista_comida[-2:]) print(lista_comida[:-2]) print(lista_comida[1:-2])
false
d3ad6c8f300e06192cac0fa87484d1b09ed88d75
Donzellini/pythonCampinasTech
/Aula_04/listas.py
658
4.53125
5
#!/usr/bin/python list = [ 'abcd', 786 , 2.23, 'john', 70.2 ] tinylist = [123, 'john'] print(list) # Prints complete list print(list[0]) # Prints first element of the list print(list[1:3]) # Prints elements starting from 2nd till 3rd print(list[2:]) # Prints elements starting from 3rd element...
false
4553c0b52c2f8fd2721499a87a8c64872bef1c8d
agustashd/Automate-the-boring-stuff
/ch4/commaCode.py
977
4.1875
4
''' Write a function that takes a list value as an argument and returns a string with all the items separated by a comma and a space, with and inserted before the last item. For example, passing the previous spam list to the function would return 'apples, bananas, tofu, and cats'. But your function should be able to ...
true
1144eb1687350bcfbfa25102e7de4636da85d61d
sahilsoni1/geekindian
/shutil/rotatingfile.py
1,156
4.125
4
import os,shutil import time def make_version_path(path,version): """ it gives version for log file """ if version == 0: return path else: return path +"."+str(version) def rotate(path,version): """ The rotate function uses a technique common in recursive functions """ old_path =make_version_path(pat...
true
ce54ffffe84ab5c19a06282eda2c062c0586b4d3
LukeBriggsDev/GCSE-Code-Tasks
/p02.1/even_squares.py
584
4.1875
4
""" Problem: The function even_squares takes in a number. If the number is: * even - print out the number squared * odd - print out the number Tests: >>> even_squares(20) 400 >>> even_squares(9) 9 >>> even_squares(8) 64 >>> even_squares(73) 73 """ # This code tests your solutio...
true
42078806e06e85ff312f658f360bee67090a6494
LukeBriggsDev/GCSE-Code-Tasks
/p02.2/palindrome.py
1,177
4.6875
5
""" Problem: A palindrome is a word that is spelt the same forwards as it is backwards, such as "racecar" or "mum". The function 'is_palindrome' should test whether a word is a palindrome or not and print either "Palindrome" or "Non-palindrome" The function should be case-insensitive, so "Ra...
true
639636ad47e0e10703c90b1e623421743a3ba33c
LukeBriggsDev/GCSE-Code-Tasks
/p03.1a/more_nines.py
613
4.15625
4
""" Problem: The function print_nines takes an input, n, and should then print the first n terms in the 9 times table, exactly as in the nines problem. Test: >>> print_nines(2) 1 x 9 = 9 2 x 9 = 18 >>> print_nines(7) 1 x 9 = 9 2 x 9 = 18 3 x 9 = 27 4 x 9 = 36 5 x 9 = 4...
true
9f2d951b4fbb73d2239d1117f33a336b71fffc76
LukeBriggsDev/GCSE-Code-Tasks
/p02.4/most_frequent.py
905
4.3125
4
""" Problem: Given a list of integers, nums, and two integers, a and b, we would like to find out which one occurs most frequently in our list. If either a or b appears more often, print that number. If neither appears at all, print "Neither". If they appear the same number of times, print "Ti...
true
15af75b362e2f496104423ac33660cc60e009582
LukeBriggsDev/GCSE-Code-Tasks
/p03.1x/triangles.py
599
4.15625
4
""" Problem: The triangle numbers are: 1, 3, 6, 10, 15, 21, 28, ... They are generated by starting at 0 and going up by 1, then adding one more to the difference each time. The function triangle_numbers takes an integer n, and should then print the nth triangle number. Tests: >>> trian...
true
c2bc9cab220eece67f690d0bd3466911cb95eb87
tangxin20/study
/4_func.py
1,877
4.15625
4
#def f(x): # return x**3 #a=f(int(input("Please input a number:"))) #if a < 100: # print("result < 100") #if a < 50: # print("result < 50") #else: # print("error") #def f(): # return 1+2 #print(f()) #def f(x,y,z): # return x*y*z #a = int(input("please input first number:") ) #b = input("please inp...
false
f357f7ba592e69d95b90dac903f458d673707915
Nhlaka10/Finance-calculators
/finance_calculators.py
2,440
4.25
4
# Use import math to use math functions import math # Display the statement below so the user can know their options print( """Please choose either \'Investment\' or \'Boond\' from the menu below to proceed:\n\nInvestment - to calculate the amount of interest you will earn on intrest.\nBond ...
true
8d4740404f053c5aee554d5479b45754ca2fabbd
facamartinez/MatClas
/e02_for.py
1,026
4.15625
4
#for lets you iterate a fixed amount of times unaCadena = "esta es una cadena de texto" for letter in unaCadena: print(letter) def isVocal(letter): vocales = "aeiou" return letter in vocales for letter in unaCadena: if not isVocal(letter): print(letter) '''The range() Functio...
false
544922a19e4b926da2a05630f73d9362ec470a3c
ionuttdt/ASC
/lab1/task2.py
942
4.1875
4
""" Basic thread handling exercise: Use the Thread class to create and run more than 10 threads which print their name and a random number they receive as argument. The number of threads must be received from the command line. e.g. Hello, I'm Thread-96 and I received the number 42 """ from random im...
true
a6f759f475a64cf716cad64148a52785e5903344
mdemiral19/Python-By-Example
/Challenge 043.py
771
4.5
4
'''Challenge 043: Ask which direction the user wants to count (up or down). If they select up, then ask them for the top number nd then count from 1 to that number. If they select down, ask them to enter a number below 20 and then count down from 20 to that number. If they entered something other than up or down, displ...
true
5b011da48b6b1b24690a9a3f5afd7dc59b4b54ff
mdemiral19/Python-By-Example
/Challenge 034.py
975
4.3125
4
'''Challenge 034: Display the following message: " 1) Square 2) Triangle Enter a number: " If the user enters 1, then it should ask them for the length of one of ts sides and display the area. If they select 2, it should ask for the base andheight of the trianlge and display the area. If they type in anything else, ...
true
c084467ce703925b8d6f6ba47507bc60170bd0b0
mdemiral19/Python-By-Example
/Challenge 032.py
443
4.28125
4
'''Challenge 032: Ask for the radius and the depth of a cylinder and work out the total volume (circle area*depth) rounded to three decimal places.''' import math radius = float(input('Please enter the radius of a cylinder, preferably in cm: ')) depth = float(input('Please enter the depth of a cylinder, preferably in ...
true
43782231cb4e7c72c50cade19c0a019443e6b0c2
mulualem04/ISD-practical-7
/ISD practical7Q5.py
334
4.25
4
def count_spaces(userinput): # function definition spaces = 0 for char in userinput : if char == " " : spaces = spaces + 1 # increment return spaces # the function returns the space between words userinput = input("Enter a string: ") print(count_spaces(userinput)) # Call the function w...
true
4aa53accdfe795005d435abda989a8cfe28bb590
hwchen/thinkpython
/thinkpython4-3exercises.py
1,346
4.46875
4
#thinkpython chapter 4.3 exercises import math from swampy.TurtleWorld import * world = TurtleWorld() bob = Turtle() def square (t, length): """ Draws a square of length "length" using turtle "t" """ for i in range(4): fd(t, length) lt(t) def polygon(t,length,n): """ Draws a polygon...
false
83ec58ac871dd5136c3e2f26b273c38da989da71
cff874460349/tct
/res/gui/moveCircle.py
1,380
4.25
4
# use a Tkinter canvas to draw a circle, move it with the arrow keys try: # Python2 import Tkinter as tk except ImportError: # Python3 import tkinter as tk class MyApp(tk.Tk): def __init__(self): tk.Tk.__init__(self) self.title("move circle with arrow keys") # create a can...
true
176b9967b350927dec77cbce6c7cdcbc26cf85e6
monica141/lecture4
/classes2.py
886
4.28125
4
class Flight: #creating a new class with the innit method def __init__(self, origin, destination, duration): self.origin = origin self.destination = destination self.duration = duration #printing the information of the flight #we take self to know the object we are operating wi...
true
c86bf31fad69b37cfe9e483e05d3ba58f0b14cb2
parthpanchal123/Algorithms
/insertionsort.py
399
4.15625
4
def insertion_sort(arr): for i in range(1, len(arr)): hole = i value = arr[i] while(hole > 0 and arr[hole - 1] > value): arr[hole] = arr[hole-1] hole -= 1 arr[hole] = value return arr if __name__ == "__main__": print('Enter elements to sort') my...
false
992564ad8cbb1880feee3ea651ee605530691294
KyleRichVA/sea-c45-python
/hw/hw13/trigram.py
1,954
4.28125
4
""" Short Program That Generates Over 100 Words Of A Moby Dick Style Story Using Trigrams. """ import random # get the file used to create the trigram file = open("mobydick.txt", "r") # take the text and store in memory line by line lines = [] for line in file: lines.append(file.readline()) file.close() # Used to...
true
1cc335521cf917c62a4d914afe3390215c19acff
RyanAVelasco/Jaoventure.net_Exercises
/Chapter_7.py
2,678
4.34375
4
import random print(""" === 7.1: Exercises with classes === Use the python documentation on classes at https://docs.python.org/3/tutorial/classes.html to solve the following exercises. 1. Implement a class named "Rectangle" to store the coordinates of a rectangle given by (x1, y1) and (x2, y2). 2. Implement the clas...
true
a506b8fc0cc4b443bf6fffaf64de0840b7cc0af0
Yushgoel/Python
/agefinder.py
290
4.125
4
from datetime import datetime now = datetime.now() print now date_of_birth = raw_input("Please enter your date of birth in DD-MM-YYYY.") #date_of_birth = int(date_of_birth) birth_year = date_of_birth.year current_year = now.year age = current_year - birth_year print "age = " + age
true
14d8c42d50341ba093681093f0679d6426cbc8cd
Yushgoel/Python
/ctrsumavg.py
239
4.15625
4
n = raw_input("How many numbers do you want to enter?") n = int(n) count = 0 sums = 0 while count < n: num = raw_input("Please enter a number.") num = int(num) sums = sums + num count = count + 1 avg = sums / n print sums print avg
true
863968686f97dc5f0cb1bc620e6af53dbc497e17
Yushgoel/Python
/powers.py
264
4.15625
4
exponent = raw_input("Please enter the exponent.") exponent = int(exponent) num = 1 exponent_plus_one = exponent + 1 while num <= 10: ctr = 1 product = num while ctr <= exponent: product = product * num ctr = ctr + 1 print product num = num + 1
false
0dc6f4e34e40bdc59ed515a5349ce6a3c558d181
shashankgupta2810/Train-Ticket
/Book_train_ticket.py
1,514
4.125
4
class Train(): # create a class # def init function and pass the variable what you required to book the ticket like train name , soucre ,seats, etc. def __init__(self,train_name,train_no,source,destination,status,seats,seatNo): self.seats=seats self.train_no=train_no self.train_name= ...
true
b99e7805a06f924b0edbce4113bc4bcd2b8c4a45
nirajkvinit/python3-study
/dive-into-python3/ch3/setcompr.py
546
4.5625
5
# Set comprehensions a_set = set(range(10)) print(a_set) print({x ** 2 for x in a_set}) print({x for x in a_set if x % 2 == 0}) print({2**x for x in range(10)}) ''' 1. Set comprehensions can take a set as input. This set comprehension calculates the squares of the set of numbers from 0 to 9 . 2. Like list comprehension...
true
65373d7f63b195850dc94333f6520941c9a8bb5e
shay-d16/Python-Projects
/4. Advanced Python Concepts/os_and_open_method.py
1,103
4.125
4
# Make sure to import os so that Python will have the ability to use # and access whatever method we're using import os # Make sure that when you call on a class and you want to access # it's methods within the class, you have mention the class first, # then put a period, then the method. EX: print(os.getcwd()) def...
true
23e1259ea3b50551b6f76dd2ffef23674635780d
shay-d16/Python-Projects
/5. Object-Oriented Programming/parent_class_child_instances.py
2,889
4.5625
5
# Python 3.9.4 # # Author: Shalondra Rossiter # # Purpose: More on 'parent' and 'child' classes # ## PARENT CLASS class Organism: name = "Unknown" species = "Unknown" legs = 0 arms = 0 dna = "Sequence A" origin = "Unknown" carbon_based = True # Now that you've defined this class and set...
true
ef3e2f58e52b8fd1c8855d36ba46a7899121a6aa
shay-d16/Python-Projects
/5. Object-Oriented Programming/polymorphism_submission_assignment.py
1,888
4.34375
4
# Python 3.9.4 # # Author: Shalondra Rossiter # # Purpose: Complete and submit this assignment given to me by the # Tech Academy # # Requirements: Create two classes that inherit from another class # 1. Each child should have at least two of their own attributes # 2. The parent class should have at least one method (f...
true
6119b3691c83d69b0000ea78f73f6ef01aac41e5
rajkumargithub/pythonexercises
/forloop.py
204
4.1875
4
#cheerleading program word = raw_input("who do you go for? ") for letter in word: call = "Gimme a " + letter + "!" print letter + "!" print call print "What does that spell?" print word + "!"
true
74d20b8caf905bd6457d8e185acc130715929305
WillianPessoa/LIpE-Resolution-of-Exercises
/A01E04_area-circulo.py
472
4.46875
4
#!/usr/bin/python3 # A única vez que nomeamos uma variável com suas letras maiúsculas é quando # sabemos que essa variável não vai mudar de valor (CONSTANTE) PI = 3.14159 # int() é utilizado para converter o texto inserido em número inteiro. raio = int( input("Insira o valor do raio em cm: ") ) # Calculando a ar...
false
a2b2dd7fe076d007f6fac4de31341cc1324b5453
mukasama/portfolio
/Python Codes/lab 10.py
1,659
4.25
4
class Clock(object): def __init__(self,hours=0,minutes=0,seconds=0): h = hours m = minutes s = seconds ''' hours is the number of hours minutes is the number of minutes seconds is the number of seconds ''' self.hours = hours ...
true
3be4b3b4da244586baa07363a7ec27559c9ad41e
nandadao/Python_note
/note/download_note/first_month/day03/demo02.py
789
4.5
4
""" 选择语句 选择性的执行语句 if 条件: 满足条件执行的代码 else: 不满足条件执行的代码 if 条件1: 满足条件1执行的代码 elif 条件2: 满足条件3执行的代码 else: 以上条件都不满足执行的代码 练习:exercise01~06 """ sex = input("请输入性别:") if sex == "男": print("您好,先生!") # 否则如果 elif s...
false
a03f14911cbfb93f24b7830fbcbbdcbc8682253a
nandadao/Python_note
/note/my_note/first_month/day05/exercise06.py
660
4.1875
4
""" 练习:根据月日,计算是这一年的第几天 3月5日 31 + 28 + 5 """ # month = int(input("请输入月份:")) # day = int(input("请输入日子:")) # # days_of_month = (31,28, 31,30, 31,30, 31,31,30, 31,30,31) # # day_of_today = day # # sum求和 # day_of_today = sum(days_of_month[:month-1]) + day # # # 传统思想,其他语言也可以使用这种思想 # # for i in range(month-1): # ...
false
e2b112d234add91f30b186d31c325b237fcc9516
nandadao/Python_note
/note/my_note/first_month/day04/demo06.py
866
4.25
4
""" 通用操作 """ # name = "八戒" # print(id(name)) # name += "唐僧" # print(id(name)) # print(name) # # name02 = "唐僧" # name02 *= 2 # print(name02) # 比较:依次比较两个容器中元素大小,一旦不同则返回比较结果 # print("孙悟空" > "唐僧") # print(ord("孙"), ord("唐")) # # # # 成员比较 # print("大圣" in "我是齐天大圣") # 索引 # 0 1 2 3 。。。 len(s)-1 # -len(s) ...
false
9388c68d99efc86a53a16b8ad293d0e605d03779
nandadao/Python_note
/note/my_note/first_month/day17/exercise05.py
432
4.15625
4
""" 练习:获取list01中所有大于10的整数 """ list01 = [11, 2, "a", True, 33] # 生成器函数(写完后,给别人用) def get_bigger_than_10(): for item in list01: if type(item) is int and item > 10: yield item for item in get_bigger_than_10(): print(item) # 生成器表达式 for item in (item for item in list01 if type(item) is...
false
d2e88a5bf1e1069e8491f6285e0877c14c0aca69
nandadao/Python_note
/note/download_note/first_month/day17/demo01.py
1,423
4.25
4
""" yield 练习:exercise01 """ class MyRange: """ 可迭代对象 """ def __init__(self, stop): self.__stop = stop # 程序执行过程: # 调用不执行 # 调用__next__才执行 # 到yield暂时离开 # 再次调用__next__继续执行 # ... # 程序执行原理: "你看见的代码,实际不是这个样子" # 将yield关键字以前的代码定义到next方法中 ...
false
f262be6a1baaca368304396d1b3be983469477e7
nandadao/Python_note
/note/my_note/first_month/day04/homework_day04.py
1,435
4.125
4
# 3.(扩展) # 循环 # 一个小球从100米落下,每次弹回原高度一半, # 请计算: # 一:总共弹起多少次(最小弹起的高度0 # .01 # m) # 二:整个过程,经过多少米 # count = 0 # jump = 0 # height = 100 # while height/2 > 0.01: # height /= 2 # jump += height*2 # count += 1 # # print(height) # # print(jump) # print("总共弹了" + str(count) + "次。") # print("整个过程,经过...
false
72136b5c889d3986ac88156eebf186d5d37984b5
nandadao/Python_note
/note/download_note/first_month/day04/demo07.py
752
4.21875
4
""" 列表 list """ # 1. 创建 # -- 创建空列表 list01 = [] list02 = list() # -- list01 = [100,"悟空",True] # list(可迭代对象) list02 = list("我是齐天大圣") # 2. 添加 # -- 追加 list01.append("八戒") # -- 插入 list01.insert(1,"唐僧") print(list01) # 3. 修改 # 将唐三藏地址,赋值给列表第二个元素 list01[1] = "唐三藏" # 遍历[10,20],将每个元素赋值给切片位置的元素 list01[-2:] = [10,20] list01[...
false
ff3f00389d5bf9cea8a70f14e539a6702b148bcf
nandadao/Python_note
/note/download_note/first_month/day13/demo05.py
476
4.15625
4
""" 反向运算符(特别不重要) 作用:当前类对象与其他类对象做算数运算 """ class Vector1: def __init__(self, x=0): self.x = x def __str__(self): return "向量的分量是:" + str(self.x) def __add__(self, other): return Vector1(self.x + other) def __radd__(self, other): return Vector1(self.x + other) ...
false
ba740f93917a3481227bcd8a39abab404243a4d3
nandadao/Python_note
/note/my_note/first_month/day17/exercise04.py
921
4.28125
4
""" 练习:定义函数:my_enumerate函数,实现下列效果 """ list01 = [1, 2, 55, 3] dict01 = {"a":1, "b":2, "c":3} def my_enumerate(iterable): my_index = 0 for item in iterable: yield (my_index,item) my_index += 1 # for index, item in my_enumerate(list01): # print(index, item) # print("-----------------") ...
false
9355b32a5516f3857b35be5d74781167bb9e0f3b
bobby-palko/100-days-of-python
/07/main.py
1,568
4.3125
4
from art import logo # Alphabet list to use for our cipher alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] # Sweet ASCII art print(logo) is_finished = False def caesar(text, shift, direction): # Cut down large shift ...
true
32bf5473060c794b71de30c3d96e9d76d82af0b3
monty8800/PythonDemo
/base/42.IO编程-序列化.py
2,801
4.15625
4
# 1.序列化 - pickling ,使用pickle模块来实现 import pickle d = dict(name='mwu', age=10, score=88) print(pickle.dumps(d)) # pickle.dumps()方法把任意对象序列化成一个bytes,然后,就可以把这个bytes写入文件。 # 1.1序列化 # 或者用另一个方法pickle.dump()直接把对象序列化后写入一个file-like Object: # f = open('./demo/files/dump.txt','wb') # pickle.dump(d,f) # f.close() # 1.2反序列化 f = op...
false
47496831eb874ccad1a30d98aa88d2ddd07e9af4
monty8800/PythonDemo
/base/15.迭代器.py
2,023
4.15625
4
# 迭代器 from collections.abc import Iterable, Iterator print(isinstance([],Iterable)) # True print(isinstance({},Iterable)) # True print(isinstance('',Iterable)) # True print(isinstance((x for x in range(1,11)),Iterable)) # True print(isinstance(100,Iterable)) # False # 迭代对象(Iterable)和迭代器(Iterator) # 以上几种为True的都是迭代对象,但...
false
711991ea38eb5526374a935c5dbc8ed13e54dd64
AyebakuroOruwori/Python-Kids-Projects
/Comparing Dataset Entries-Storing Data in Variables.py
2,145
4.28125
4
#We would be using our knowledge abount booleans and comparison to compare the data of two students from a collection of grade submissions. #We'll kick it off by saving the id, average grade, and recent test score in variables for each of the two student entries. #Let's start saving the data for the first student ent...
true
e9cd0a70a1fd8d694a59377a57f0dab0f9ca53cf
mirzatuzovic/ORS-PA-18-Homework05
/task4.py
666
4.25
4
""" =================== TASK 4 ==================== * Name: Can String Be Float * * Write a script that will take integer number as * user input and return the product of digits. * The script should be able to handle incorrect * input, as well as the negative integer numbers. * * Note: Please describe in details p...
true
fb713e764b44c44aa5d91bd92d99c079ba4de8e2
NBakalov19/SoftUni_Python_Fundamentals
/01.Python_Intro_Functions_And_Debugging/newHome.py
1,233
4.1875
4
import math flowers_type = input() flowers_count = int(input()) budget = int(input()) flowers = { "Roses": 5, "Dahlias": 3.8, "Tulips": 2.8, "Narcissus": 3, "Gladiolus": 2.5 } money_needed = flowers_count * flowers[flowers_type] discount = 0 if flowers_type == 'Roses' and flow...
true
3366b1aa278766d24fd285173d621674bcd78c57
umangbhatia786/PythonPractise
/GeeksForGeeks/Strings/replace_occurences.py
248
4.28125
4
#Python Program to replace all occurrences of string with another def replace_occurrences(input_str, word, replace_with): return input_str.replace(word, replace_with) my_str = 'geeksforgeeks' print(replace_occurrences(my_str,'geeks','abcd'))
true
39bfcad28fc2da53c90e9b3ae748400ce0d4c526
umangbhatia786/PythonPractise
/GeeksForGeeks/Strings/get_uncommon_words.py
486
4.46875
4
#Python Code get list of uncommon words from 2 different strings def get_uncommon_words(input_str1, input_str2): '''Function that uses List Comprehension to get uncommon words out of two strings''' word_list_1 = input_str1.split(' ') word_list_2 = input_str2.split(' ') return [word for word in word_li...
true
977be7873ecfb430347dd0502e047f728b692e8c
umangbhatia786/PythonPractise
/GeeksForGeeks/List/second_largest.py
250
4.125
4
#Python Program to find 2nd Largest num input_list = [1,5,3,6,8,7,10] def get_second_largest(int_list): sorted_list = sorted(int_list) return sorted_list[-2] print(f'Second largest number in given list is {get_second_largest(input_list)}')
true
e7e09e72227e2aa8b496af46e1e02440c0cc8eed
umangbhatia786/PythonPractise
/General/FormatString.py
224
4.3125
4
#Method from python 2 --> 3.5 str1 = 'My name is {} and age is {}'.format('Umang', 26) print(str1) #Method from python 3.5+ # f strings name = 'Cheems' age = 26 str2 = f'My name is {name} and age is {age}' print(str2)
true
8038c7618f323f8a5dd8f47e0228e4eabea1dd20
xettrisomeman/pythonsurvival
/generatorspy/theproblem.py
1,346
4.6875
5
#lets focus on generators #generator is special functions which yields one value at a time #generator gives iterator #we need syntax that generates one item at a time , then #"yiels" a value , and waits to be called again, saving #state information #this is called generators a special case of iterator, #We need a wa...
true
d72c60c547025346f483a3b17ba2a18c2917aeed
xettrisomeman/pythonsurvival
/listcompre/usingcompre.py
552
4.59375
5
#now using list comprehension #list comprehension is shortcut #it consists of two pats within brackets []. #the first part is the value to be produced ,for example ,i. #second part of list comprehension is the for statement header. # syntax : [value for_statement_header] #example old_list = [1,2,3] #take each eleme...
true
52017324a577c708e9f4398a07225f1bcc558249
xhmmss/python2.7_exercise
/codewars/Highest_and_Lowest.py
898
4.15625
4
# In this little assignment you are given a string of space separated numbers, and have to return the highest and lowest number. # Example: # high_and_low("1 2 3 4 5") # return "5 1" # high_and_low("1 2 -3 4 5") # return "5 -3" # high_and_low("1 9 3 4 -5") # return "9 -5" # Notes: # All numbers are valid Int32, no ...
true
0755152309220626c10382ed0db8b8441e025135
xhmmss/python2.7_exercise
/codewars/Bit_Counting.py
410
4.15625
4
# Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number. You can guarantee that input is non-negative. # Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case def countBits(n):...
true
44306f1c153fc23eae0df5070e49b8e704a1191f
deenababu92/-Python-Basics-Conditional-Loops
/assigntment 1 Python Basics, Conditional Loops.py
999
4.1875
4
#!/usr/bin/env python # coding: utf-8 # In[1]: """1.Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5, between 2000 and 3200 (both included). The numbers obtained should be printed in a comma-separated sequence on a single line.""" n=[] for i in range(2000,3201): ...
true
3c0578cca5584c4cbc44002976132d01fc3b14e7
sharifh530/Learn-Python
/Beginner/Data types/12.list_slicing.py
357
4.40625
4
# List slicing is also work as a string slicing li = ["work", 5, "dinner", True] print(li) # Reverse print(li[::-1]) # String is immutable but list is not immutable we can change the values of list li[0] = "sleep" print(li) # Copy list li1 = li[:] li1[1] = "work" print(li) print(li1) # modify list li1 = li ...
true
a890d305695336c1d5d8bd65a8fcd5659dd10d41
nampng/self-study
/python/CTCI/Chapter1/p1-7.py
576
4.3125
4
# 1.7 Rotate Matrix # Given an image represented by an N x N matrix, where each pixel in the image is # represented by an integer, write a method to rotate the image by 90 degrees. # Can you do this in place? # Super uneligant. Must optimize and also find a way to do it in place. def Rotate(image): array = [] ...
true
0053c1ad24ed7f0443333f1fc41b78bc3eb5d46a
phani-1995/bridgelabzMumbaiWeek1
/testingprograms/sqrt.py
952
4.28125
4
# import math def sqrt(c,epsilon): t=c while abs(t - c/t) > epsilon*t: t= ((c/t)+t)/2 return t epsilon=1 * 10 ** (-15) c=int(input("Enter a positive integer: ")) if (c<=0): print("number cant be negative or zero") c = int(input("Enter a positive integer: ")) print("Square root of number ...
false
65c7ab612f9546a57e475e8c93fe9feadf4eb33d
cbohara/python_cookbook
/data_struct_and_algos/counter.py
788
4.375
4
#!/usr/local/bin/python3 from collections import Counter # determine the most frequent occuring item in a sequence words = [ 'look', 'into', 'my', 'eyes', 'look', 'into', 'my', 'eyes', 'the', 'eyes', 'the', 'eyes', 'the', 'eyes', 'not', 'around', 'the', 'eyes', "don't", 'look', 'around', 'the', 'eyes', 'lo...
true
a590ad2c64004662cceed2b509b6b55ce885ddc9
joncurrier/generations
/3-Django/app/recipes/utils.py
2,816
4.21875
4
def format_duration(duration): """ Format a timedelta to be human-readable. Argument Format example < 1 minute "55 seconds" < 5 minutes "3 minutes" OR "3 minutes and 15 seconds" < 1 hour "17 minutes" else "2 hours and 14 minutes" """ if durati...
true
c98a68b64296f59da92b4cf1d1ee7c3700f82318
sadsfae/misc-scripts
/python/hugs.py
1,295
4.25
4
#!/usr/bin/env python # everybody needs hugs, track it using a dictionary # simple exercise to use python dictionary import sys # create blank dictionary of hug logistics huglist = {} # assign people needing hugs as keys huglist['wizard'] = 5 huglist['panda'] = 1 huglist['koala'] = 2 huglist['tiger'] = 0 huglist['mo...
true