blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
bccdae6959d7354f0a68014f753b98a6e7075dc0
770847573/Python_learn
/Hello/抽象类的使用.py
400
4.125
4
import abc class MyClass(metaclass=abc.ABCMeta): @abc.abstractmethod def mymethod(self): pass class My1(MyClass): def mymethod(self): print('Do something!!!') my = My1()#如果一个类继承自抽象类,而未实现抽象方法,仍然是一个抽象类 my.mymethod() #my1 = MyClass() TypeError: Can't instantiate abstract class MyClass with abs...
false
d15a8a84b1a7e7ac54f74d47180757109a17782a
KurinchiMalar/DataStructures
/Medians/FindLargestInArray.py
505
4.28125
4
__author__ = 'kurnagar' import sys # Time Complexity : O(n) # Worst Case Comparisons : n-1 # Space Complexity : O(1) def find_largest_element_in_array(Ar): max = -sys.maxint - 1 # pythonic way of assigning most minimum value #print type(max) #max = -sys.maxint - 2 #print type(max) for i in rang...
false
f2640a1412c6ee3414bf47175439aba242d5c81f
KurinchiMalar/DataStructures
/LinkedLists/SqrtNthNode.py
1,645
4.1875
4
''' Given a singly linked list, write a function to find the sqrt(n) th element, where n is the number of elements in the list. Assume the value of n is not known in advance. ''' # Time Complexity : O(n) # Space Complexity : O(1) import ListNode def sqrtNthNode(node): if node == None: return None ...
true
ec4a2fc2faea5acfea8a352c16b768c79e679104
KurinchiMalar/DataStructures
/Hashing/RemoveGivenCharacters.py
507
4.28125
4
''' Give an algorithm to remove the specified characters from a given string ''' def remove_chars(inputstring,charstoremove): hash_table = {} result = [] for char in charstoremove: hash_table[char] = 1 #print hash_table for char in inputstring: if char not in hash_table: ...
true
82ecc3e32e7940422238046cd7aa788979c51f9c
KurinchiMalar/DataStructures
/Stacks/Stack.py
1,115
4.125
4
from LinkedLists.ListNode import ListNode class Stack: def __init__(self,head=None): self.head = head self.size = 0 def push(self,data): newnode = ListNode(data) newnode.set_next(self.head) self.head = newnode self.size = self.size + 1 def pop(self): ...
true
98783f5bfd44ae9259f05242baaac5ff796008e5
KurinchiMalar/DataStructures
/Searching/SeparateOddAndEven.py
799
4.25
4
''' Given an array A[], write a function that segregates even and odd numbers. The functions should put all even numbers first and then odd numbers. ''' # Time Complexity : O(n) def separate_even_odd(Ar): even_ptr = 0 odd_ptr = len(Ar)-1 while even_ptr < odd_ptr: while even_ptr < odd_ptr...
false
30a81157968dcd8771db16cf6ac48e9cd235d713
KurinchiMalar/DataStructures
/Stacks/InfixToPostfix.py
2,664
4.28125
4
''' Consider an infix expression : A * B - (C + D) + E and convert to postfix the postfix expression : AB * CD + - E + Algorithm: 1) if operand just add to result 2) if ( push to stack 3) if ) till a ( is encountered, pop from stack and append to result. 4) if operator ...
true
22f1d817b2d292a4b3fae09a77e3013b9d45bd31
KurinchiMalar/DataStructures
/Sorting/NearlySorted_MergeSort.py
1,528
4.125
4
#Complexity O(n/k * klogk) = O(nlogk) # merging k elements using mergesort = klogk # every n/k elem group is given to mergesort # Hence totally O(nlogk) ''' k = 3 4 5 9 | 7 8 3 | 1 2 6 1st merge sort all blocks 4 5 9 | 3 8 9 | 1 2 6 Time Complexity = O(n * (n/k) log k) i.e to sort k numbers is k * log k to sort n/...
false
6d878bd6ab1e0dbecb0c2a5a2803ee41359b51b8
KurinchiMalar/DataStructures
/LinkedLists/MergeZigZagTwoLists.py
2,040
4.15625
4
''' Given two lists list1 = [A1,A2,.....,An] list2 = [B1,B2,....,Bn] merge these two into a third list result = [A1 B1 A2 B2 A3 ....] ''' # Time Complexity : O(n) # Space Complexity : O(1) import ListNode import copy def merge_zigzag(node1,node2,m,n): if node1 == None or no...
false
4277a08cf47b4f91712841ef2e3757a49090650f
IStealYourSkill/python
/les3/3_3.py
579
4.28125
4
'''3. Проверить, что хотя бы одно из чисел a или b оканчивается на 0.''' a = int(input('Введите число A: ')) b = int(input('Введите число B: ')) if ((a >= 10) or (b >= 10)) and (a % 10 == 0 or b % 10 == 0): print("Одно из чисел оканчивается на 0") else: print("Числа {}, {} без нулей".format(a, b)) ...
false
08ef8703147476759e224e66efdc7b5de5addf6e
chaoma1988/Coursera_Python_Program_Essentials
/days_between.py
1,076
4.65625
5
''' Problem 3: Computing the number of days between two dates Now that we have a way to check if a given date is valid, you will write a function called days_between that takes six integers (year1, month1, day1, year2, month2, day2) and returns the number of days from an earlier date (year1-month1-day1) to a later date...
true
562ac5cebcf516d7e40724d3594186209d79c2f4
Vyara/First-Python-Programs
/quadratic.py
695
4.3125
4
# File: quadratic.py # A program that uses the quadratic formula to find real roots of a quadratic equation. def main(): print "This program finds real roots of a quadratic equation ax^2+bx+c=0." a = input("Type in a value for 'a' and press Enter: ") b = input("Type in a value for 'b' and press...
true
852cba828e67b97d2ddd91322a827bfdc3c6a849
ridhamaditi/tops
/Assignments/Module(1)-function&method/b1.py
287
4.3125
4
#Write a Python function to calculate the factorial of a number (a non-negative integer) def fac(n): fact=1 for i in range(1,n+1): fact *= i print("Fact: ",fact) try: n=int(input("Enter non-negative number: ")) if n<0 : print("Error") else: fac(n) except: print("Error")
true
287f5f10e5cc7c1e40e545d958c54c8d01586bfb
ridhamaditi/tops
/Assignments/Module(1)-Exception Handling/a2.py
252
4.15625
4
#write program that will ask the user to enter a number until they guess a stored number correctly a=10 try: n=int(input("Enter number: ")) while a!=n : print("Enter again") n=int(input("Enter number: ")) print("Yay") except: print("Error")
true
e3eca8bce227d8d6c6b4526189945c2cd79e0c41
ridhamaditi/tops
/functions/prime.py
234
4.1875
4
def isprime(n,i=2): if n <= 2: return True elif n % i == 0: return False elif i*i > n: return True else: return isprime(n,i+1) n=int(input("Enter No: ")) j=isprime(n) if j==True: print("Prime") else: print("Not prime")
false
bcc1edf1be77b38dff101b8221497dc5baa3f2ec
ridhamaditi/tops
/modules/math_sphere.py
237
4.15625
4
import math print("Enter radius: ") try: r = float(input()) area = math.pi * math.pow(r, 2) volume = math.pi * (4.0/3.0) * math.pow(r, 3) print("\nArea:", area) print("\nVolume:", volume) except ValueError: print("Invalid Input.")
false
1d2389112a628dbf8891f85d6606ec44543fc81d
ridhamaditi/tops
/Assignments/Module(1)-Exception Handling/a4.py
791
4.21875
4
#Write program that except Clause with No Exceptions class Error(Exception): """Base class for other exceptions""" pass class ValueTooSmallError(Error): """Raised when the input value is too small""" pass class ValueTooLargeError(Error): """Raised when the input value is too large""" pass # user guess...
true
609812d3b68a77f35eb116682df3f844ab3a44c9
ridhamaditi/tops
/Assignments/Module(1)-Exception Handling/a3.py
216
4.15625
4
#Write function that converts a temperature from degrees Kelvin to degrees Fahrenheit try: k=int(input("Enter temp in Kelvin: ")) f=(k - 273.15) * 9/5 + 32 print("Temp in Fahrenheit: ",f) except: print("Error")
true
35c340635b063ecebc478a1ab8d7f527d6fe2f3f
Swapnil2095/Python
/8.Libraries and Functions/copy in Python (Deep Copy and Shallow Copy)/Shallow copy/shallow copy.py
533
4.5625
5
# Python code to demonstrate copy operations # importing "copy" for copy operations import copy # initializing list 1 li1 = [1, 2, [3, 5], 4] # using copy to shallow copy li2 = copy.copy(li1) # original elements of list print("The original elements before shallow copying") for i in range(0, len(li1)): print(li1[i]...
true
b91b8609d687dd362ac271c349fdc3c81ebfe0f3
Swapnil2095/Python
/8.Libraries and Functions/Regular Expression/findall(d).py
621
4.3125
4
import re # \d is equivalent to [0-9]. p = re.compile('\d') print(p.findall("I went to him at 11 A.M. on 4th July 1886")) # \d+ will match a group on [0-9], group of one or greater size p = re.compile('\d+') print(p.findall("I went to him at 11 A.M. on 4th July 1886")) ''' \d Matches any decimal digit, this is e...
true
2be154a4143a049477f827c9923ba19198f4a4e3
Swapnil2095/Python
/8.Libraries and Functions/copyreg — Register pickle support functions/Example.py
1,312
4.46875
4
# Python 3 program to illustrate # use of copyreg module import copyreg import copy import pickle class C(object): def __init__(self, a): self.a = a def pickle_c(c): print("pickling a C instance...") return C, (c.a, ) copyreg.pickle(C, pickle_c) c = C(1) d = copy.copy(c) print(d) p = pickle.dumps(c) print(p...
true
3dc8226bfc786cf6bbea43a20a0cf5dbbdeeb72e
Swapnil2095/Python
/5. Modules/Mathematical Functions/sqrt.py
336
4.5625
5
# Python code to demonstrate the working of # pow() and sqrt() # importing "math" for mathematical operations import math # returning the value of 3**2 print("The value of 3 to the power 2 is : ", end="") print(math.pow(3, 2)) # returning the square root of 25 print("The value of square root of 25 : ", end="") print...
true
1ca59efae74f5829e15ced1f428720e696867d9a
Swapnil2095/Python
/2.Operator/Inplace vs Standard/mutable_target.py
849
4.28125
4
# Python code to demonstrate difference between # Inplace and Normal operators in mutable Targets # importing operator to handle operator operations import operator # Initializing list a = [1, 2, 4, 5] # using add() to add the arguments passed z = operator.add(a,[1, 2, 3]) # printing the modified value print ("Va...
true
7ffe6b1ac7437b0477a969498d66163e4c4e0584
Swapnil2095/Python
/5. Modules/Time Functions/ctime.py
450
4.15625
4
# Python code to demonstrate the working of # asctime() and ctime() # importing "time" module for time operations import time # initializing time using gmtime() ti = time.gmtime() # using asctime() to display time acc. to time mentioned print ("Time calculated using asctime() is : ",end="") print (time.asctime(ti)) ...
true
9091de76643f812c44e1760f7d73e2a28c19bde6
Swapnil2095/Python
/8.Libraries and Functions/enum/prop2.py
724
4.59375
5
''' 4. Enumerations are iterable. They can be iterated using loops 5. Enumerations support hashing. Enums can be used in dictionaries or sets. ''' # Python code to demonstrate enumerations # iterations and hashing # importing enum for enumerations import enum # creating enumerations using class class Animal(enum....
true
f0a0f758c7e274508da794d35c71c52f7da7e0f9
Swapnil2095/Python
/5. Modules/Calendar Functions/firstweekday.py
486
4.25
4
# Python code to demonstrate the working of # prmonth() and setfirstweekday() # importing calendar module for calendar operations import calendar # using prmonth() to print calendar of 1997 print("The 4th month of 1997 is : ") calendar.prmonth(1997, 4, 2, 1) # using setfirstweekday() to set first week day number ca...
true
f60dcd5c7b7cc667b9e0155b722fd637570663ef
Swapnil2095/Python
/8.Libraries and Functions/Decimal Functions/logical.py
1,341
4.65625
5
# Python code to demonstrate the working of # logical_and(), logical_or(), logical_xor() # and logical_invert() # importing "decimal" module to use decimal functions import decimal # Initializing decimal number a = decimal.Decimal(1000) # Initializing decimal number b = decimal.Decimal(1110) # printing logical_and...
true
95a5a87944d4bff8b2e1b03a939d0277cd150fe1
Swapnil2095/Python
/3.Control Flow/Using Iterations/unzip.py
248
4.1875
4
# Python program to demonstrate unzip (reverse # of zip)using * with zip function # Unzip lists l1,l2 = zip(*[('Aston', 'GPS'), ('Audi', 'Car Repair'), ('McLaren', 'Dolby sound kit') ]) # Printing unzipped lists print(l1) print(l2)
true
9aebe2939010ff4b2eca5edf8f25dfc5362828c6
Swapnil2095/Python
/5. Modules/Complex Numbers/sin.py
593
4.21875
4
# Python code to demonstrate the working of # sin(), cos(), tan() # importing "cmath" for complex number operations import cmath # Initializing real numbers x = 1.0 y = 1.0 # converting x and y into complex number z z = complex(x, y) # printing sine of the complex number print("The sine value of complex number is ...
true
e7d09d8d38f4df4f2221ba3963b53467cef66cfb
bregman-arie/python-exercises
/solutions/lists/running_sum/solution.py
659
4.25
4
#!/usr/bin/env python from typing import List def running_sum(nums_li: List[int]) -> List[int]: """Returns the running sum of a given list of numbers Args: nums_li (list): a list of numbers. Returns: list: The running sum list of the given list [1, 5, 6, 2] would return [1...
true
9a3ecfad05a80abe490885249fb761a0ca77afb6
milenamonteiro/learning-python
/exercises/radiuscircle.py
225
4.28125
4
"""Write a Python program which accepts the radius of a circle from the user and compute the area.""" import math RADIUS = float(input("What's the radius? ")) print("The area is {0}".format(math.pi * math.pow(RADIUS, 2)))
true
4ad91e1cd661f5b7ce3b6c0960cb022136275e0a
testergitgitowy/calendar-checker
/main.py
2,618
4.15625
4
import datetime import calendar def name(decision): print("Type period of time (in years): ", end = "") while True: try: period = abs(int(input())) except: print("Must be an integer (number). Try again: ", end = "") else: break period *= 12 print("Type the day you want to check f...
true
f1579f18820ec92be33bbf194db207d4b8678b89
nonelikeanyone/Robotics-Automation-QSTP-2021
/Week_1/exercise.py
717
4.1875
4
import math def polar2cart(R,theta): #function for coonverting polar coordinates to cartesian print('New Coordinates: ', R*math.cos(theta), R*math.sin(theta)) def cart2polar(x,y): #function for coonverting cartesian coordinates to polar print('New Coordinates: ', (x**2+y**2)**(0.5), math.atan(y/x)) print('Conver...
false
07fa76c6a9fcbc33d34229f1e62c27e22ec93365
juanperdomolol/Dominio-python
/ejercicio15.py
595
4.1875
4
#Capitalización compuesta #Crear una aplicación que trabaje con la ley de capitalización compuesta. #La capitalización compuesta es una operación financiera que proyecta un capital a un período futuro, # donde los intereses se van acumulando al capital para los períodos subsiguientes. capitalInicial= float(input("Cu...
false
a57504d5e5dd34e53a3e30b2e0987ae6314d6077
MattCoston/Python
/shoppinglist.py
298
4.15625
4
shopping_list = [] print ("What do you need to get at the store?") print ("Enter 'DONE' to end the program") while True: new_item = input("> ") shopping_list.append(new_item) if new_item == 'DONE': break print("Here's the list:") for item in shopping_list: print(item)
true
96aa4c549c9a5341a565699832cdbbf30ff406e7
liweinan/hands_on_ml
/sort_class.py
982
4.125
4
from collections import OrderedDict class Student: def __init__(self, name, order): self.name = name self.order = order tom = Student("Tom", 0) jack = Student("Jack", 0) rose = Student("Rose", 1) lucy = Student("Lucy", 2) users = OrderedDict() users[rose.name] = rose users[lucy.name] = lucy user...
false
4de4ba9a0b6507c01147f52527413bfbf0305982
ferdirn/hello-python
/ternaryoperator.py
231
4.1875
4
#!/usr/bin/env python a = 1 b = 2 print 'a = ', a print 'b = ', b print '\n' #ternary operator print 'Ternary operator #1' print 'a > b' if (a > b) else 'b > a' print '\nTernary operator #2' print (a > b) and 'a > b' or 'b > a'
false
c3bc1f9db4fd2ab9b4ba40ce7e8d69b0da87fd42
lior20-meet/meet2018y1lab2
/MEETinTurtle.py
972
4.15625
4
import turtle turtle.penup() #Pick up the pen so it doesn’t #draw turtle.goto(-200,-100) #Move the turtle to the #position (-200, -100) #on the screen turtle.pendown() #Put the pen down to start #drawing #Draw the M: turtle.goto(-200,-100+200) turtle.goto(-200+50,-100) turtle.go...
false
7235257c51e5a1af67454306e76c5e58ffd2a31c
VeronikaA/user-signup
/crypto/helpers.py
1,345
4.28125
4
import string # helper function 1, returns numerical key of letter input by user def alphabet_position(letter): """ Creates key by receiving a letter and returning the 0-based numerical position of that letter in the alphabet, regardless of case.""" alphabet = string.ascii_lowercase + string.ascii_uppercase ...
true
f7c61b747436cfcd105a925edd695ac3c8d97279
ksheetal/python-codes
/hanoi.py
654
4.1875
4
def hanoi(n,source,spare,target): ''' objective : To build tower of hanoi using n number of disks and 3 poles input parameters : n -> no of disks source : starting position of disk spare : auxillary position of the disk target : end posit...
true
de64db2e733e592558b5459e7fb4fcfd695abd1b
moogzy/MIT-6.00.1x-Files
/w2-pset1-alphabetic-strings.py
1,220
4.125
4
#!/usr/bin/python """ Find longest alphabetical order substring in a given string. Author: Adrian Arumugam (apa@moogzy.net) Date: 2018-01-27 MIT 6.00.1x """ s = 'azcbobobegghakl' currloc = 0 substr = '' sublist = [] strend = len(s) # Process the string while the current slice location is less then the length of t...
true
27ebcf2e51a5a9184d718ad14097aba5fb714d94
tanawitpat/python-playground
/zhiwehu_programming_exercise/exercise/Q006.py
1,421
4.28125
4
import unittest ''' Question 6 Level 2 Question: Write a program that calculates and prints the value according to the given formula: Q = Square root of [(2 * C * D)/H] Following are the fixed values of C and H: C is 50. H is 30. D is the variable whose values should be input to your program in a comma-separated sequ...
true
cb3fb384955f9767077db0d80a5b1374c82c1674
BurnFaithful/KW
/Programming_Practice/Python/Base/Bigdata_day1001/Input05.py
304
4.1875
4
# 문자열은 인덱스 번호가 부여됨 strTemp = input("아무 문자열이나 입력하세요: ") print("strTemp : ", strTemp) print("strTemp : {}".format(strTemp)) print("strTemp[0] : {}".format(strTemp[0])) print("strTemp[1] : {}".format(strTemp[1])) print("strTemp[2] : {}".format(strTemp[2]))
false
a5d8b66c92ada51e44ca70d2596a30f0da6f7482
jmlippincott/practice_python
/src/16_password_generator.py
639
4.1875
4
# Write a password generator in Python. Be creative with how you generate passwords - strong passwords have a mix of lowercase letters, uppercase letters, numbers, and symbols. The passwords should be random, generating a new password every time the user asks for a new password. Include your run-time code in a main met...
true
9d057f9b4c79e82df90153757e7797f593adb009
TasosVellis/Zero
/8.Object Oriented Programming/4_OOPHomework.py
1,425
4.21875
4
import math # Problem 1 # # Fill in the Line class methods to accept coordinates as a # pair of tuples and return the slope and distance of the line. class Line: """ coordinate1 = (3,2) coordinate2 = (8,10) li = Line(coordinate1,coordinate2) li.distance() = 9.433981132056603 li.slope() = 1.6 ...
false
71fb6615811b40c8877b34456a98cdc34650dc92
arvimal/DataStructures-and-Algorithms-in-Python
/04-selection_sort-1.py
2,901
4.5
4
#!/usr/bin/env python3 # Selection Sort # Example 1 # Selection Sort is a sorting algorithm used to sort a data set either in # incremental or decremental order. # How does Selection sort work? # 1. Iterate through the data set one element at a time. # 2. Find the biggest element in the data set (Append it to anoth...
true
a287c15b12ed3e3194c5aedac6b2fbb8adeb629b
gomgomigom/Exercise_2
/w_1-2/201210_4.py
2,013
4.125
4
# numbers라는 빈 리스트를 만들고 리스트를 출력한다. # append를 이용해서 numbers에 1, 7, 3, 6, 5, 2, 13, 14를 순서대로 추가한다. 그 후 리스트를 출력한다. # numbers 리스트의 원소들 중 홀수는 모두 제거한다. 그 후 다시 리스트를 출력한다. # numbers 리스트의 인덱스 0 자리에 20이라는 수를 삽입한 후 출력한다. # numbers 리스트를 정렬한 후 출력한다. # 빈 리스트 만들기 numbers = [] print(numbers) numbers.append(1) numbers.append(7) numbers...
false
7d2fe2f51f6759be77661c2037c7eb4de4326375
rbrook22/otherOperators.py
/otherOperators.py
717
4.375
4
#File using other built in functions/operators print('I will be printing the numbers from range 1-11') for num in range(11): print(num) #Printing using range and start position print("I will be printing the numbers from range 1-11 starting at 4") for num in range(4,11): print(num) #Printing using range, start...
true
b86322bff277a38ee7165c5637c72d781e9f6ee2
Bbenard/python_assesment
/ceaser/ceaser.py
678
4.34375
4
# Using the Python, # have the function CaesarCipher(str, num) take the str parameter and perform a Caesar Cipher num on it using the num parameter as the numing number. # A Caesar Cipher works by numing all letters in the string N places down in the alphabetical order (in this case N will be num). # Punctuation, space...
true
5165e39c4ff20f645ed4d1d725a3a6becd002778
ashishbansal27/DSA-Treehouse
/BinarySearch.py
740
4.125
4
#primary assumption for this binary search is that the #list should be sorted already. def binary_search (list, target): first = 0 last = len(list)-1 while first <= last: midpoint = (first + last)//2 if list[midpoint]== target: return midpoint elif list[midpoint] < ta...
true
33c960afb411983482d2b30ed9037ee6017fbd34
aggy07/Leetcode
/600-700q/673.py
1,189
4.125
4
''' Given an unsorted array of integers, find the number of longest increasing subsequence. Example 1: Input: [1,3,5,4,7] Output: 2 Explanation: The two longest increasing subsequence are [1, 3, 4, 7] and [1, 3, 5, 7]. Example 2: Input: [2,2,2,2,2] Output: 5 Explanation: The length of longest continuous increasing su...
true
9ee533969bbce8aec40f6230d3bc01f1f83b5e96
aggy07/Leetcode
/1000-1100q/1007.py
1,391
4.125
4
''' In a row of dominoes, A[i] and B[i] represent the top and bottom halves of the i-th domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.) We may rotate the i-th domino, so that A[i] and B[i] swap values. Return the minimum number of rotations so that all the values in A are th...
true
8bdf3154382cf8cc63599d18b20372d16adbe403
aggy07/Leetcode
/200-300q/210.py
1,737
4.125
4
''' There are a total of n courses you have to take, labeled from 0 to n-1. Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1] Given the total number of courses and a list of prerequisite pairs, return the ordering of courses you s...
true
e9d57ebf9fe9beec2deb9654248f77541719e780
aggy07/Leetcode
/100-200q/150.py
1,602
4.21875
4
''' Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression. Note: Division between two integers should truncate toward zero. The given RPN expression is always valid. That means the expression...
true
8f83262573f48ba2f847993cc9ba7ffeb5fc1b17
aggy07/Leetcode
/1000-1100q/1035.py
1,872
4.15625
4
''' We write the integers of A and B (in the order they are given) on two separate horizontal lines. Now, we may draw a straight line connecting two numbers A[i] and B[j] as long as A[i] == B[j], and the line we draw does not intersect any other connecting (non-horizontal) line. Return the maximum number of connectin...
true
fe6681006dca45b41fd2ce1a4715decda8b4ce76
IrsalievaN/Homework
/homework5.py
578
4.125
4
from abc import ABC, abstractmethod from math import pi class Figure(ABC): @abstractmethod def draw (self): print("Квадрат нарисован") class Round(Figure): def draw(self): print("Круг нарисован") def __square(a): return S = a ** 2 * pi class Square(Figure): def draw(self): super().dr...
false
64f7eb0fbb07236f5420f9005aedcbfefa25a457
JATIN-RATHI/7am-nit-python-6thDec2018
/variables.py
730
4.15625
4
#!/usr/bin/python ''' Comments : 1. Single Comments : '', "", ''' ''', """ """ and # 2. Multiline Comments : ''' ''', and """ """ ''' # Creating Variables in Python 'Rule of Creating Variables in python' """ 1. A-Z 2. a-z 3. A-Za-z 4. _ 5. 0-9 6. Note : We can not create a variable name with numeric Value as a...
true
356b0255a23c0a845df9c05b512ca7ccc681aa12
JATIN-RATHI/7am-nit-python-6thDec2018
/datatypes/list/List_pop.py
781
4.21875
4
#!/usr/bin/python aCoolList = ["superman", "spiderman", 1947,1987,"Spiderman"] oneMoreList = [22, 34, 56,34, 34, 78, 98] print(aCoolList,list(enumerate(aCoolList))) # deleting values aCoolList.pop(2) print("") print(aCoolList,list(enumerate(aCoolList))) # Without index using pop method: aCoolList.pop() print("") ...
true
29d770237ec753148074d79ef96ef25287fde94a
JATIN-RATHI/7am-nit-python-6thDec2018
/loops/for_decisionMaking.py
853
4.375
4
""" for variable_expression operator variable_name suit statements for i in technologies: print(i) if i == "AI": print("Welcome to AI World") for i in range(1,10): #start element and end element-1 : 10-1 = 9 print(i) # Loop Controls : break and continue for i in technologies: print(i...
false
e23ca223aef575db942920729a53e52b1df2ed4d
JATIN-RATHI/7am-nit-python-6thDec2018
/DecisionMaking/ConditionalStatements.py
516
4.21875
4
""" Decision Making 1. if 2. if else 3. elif 4. neasted elif # Simple if statement if "expression" : statements """ course_name = "Python" if course_name: print("1 - Got a True Expression Value") print("Course Name : Python") print(course_name,type(course_name),id(course_name)) print("I am ou...
true
71fb2e89c852750f33e2512e2f83ab1f9a021b68
JATIN-RATHI/7am-nit-python-6thDec2018
/datatypes/basics/built-in-functions.py
2,190
4.375
4
# Creating Variables in Python : #firstname = 'Guido' middlename = 'Van' lastname = "Rossum" # Accesing Variables in Python : #print(firstname) #print("Calling a Variable i.e. FirstName : ", firstname) #print(firstname,"We have called a Variable call Firstname") #print("Calling Variable",firstname,"Using Print Funct...
false
47d9ba9ec790f0b9fde1a350cf8b240e5b8c886a
JATIN-RATHI/7am-nit-python-6thDec2018
/OOPS/Encapsulation.py
1,035
4.65625
5
# Encapsulation : """ Using OOP in Python, we can restrict access to methods and variables. This prevent data from direct modification which is called encapsulation. In Python, we denote private attribute using underscore as prefix i.e single “ _ “ or double “ __“. """ # Example-4: Data Encapsulation in Python ...
true
9f6536e8d1970c519e84be0e7256f5b415e0cf3e
JATIN-RATHI/7am-nit-python-6thDec2018
/loops/Password.py
406
4.1875
4
passWord = "" while passWord != "redhat": passWord = input("Please enter the password: ") if passWord == "redhat": print("Correct password!") elif passWord == "admin@123": print("It was previously used password") elif passWord == "Redhat@123": print(f"{passWord} is your recent ...
true
436120f034d541d70e2373de9c3a0c968b47f7ad
idubey-code/Data-Structures-and-Algorithms
/InsertionSort.py
489
4.125
4
def insertionSort(array): for i in range(0,len(array)): if array[i] < array[0]: temp=array[i] array.remove(array[i]) array.insert(0,temp) else: if array[i] < array[i-1]: for j in range(1,i): if array[i]>=array[j-1] a...
true
9441cb892e44c9edd6371914b227a48f00f5d169
hospogh/exam
/source_code.py
1,956
4.21875
4
#An alternade is a word in which its letters, taken alternatively in a strict sequence, and used in the same order as the original word, make up at least two other words. All letters must be used, but the smaller words are not necessarily of the same length. For example, a word with seven letters where every second let...
true
fb745ae55b2759660a882d00b345ae0db70e60d2
irfan-ansari-au28/Python-Pre
/Interview/DI _ALGO_CONCEPT/stack.py
542
4.28125
4
""" It's a list when it's follow stacks convention it becomes a stack. """ stack = list() #stack = bottom[8,5,6,3,9]top def isEmpty(): return len(stack) == 0 def peek(): if isEmpty(): return None return stack[-1] def push(x): return stack.append(x) def pop(): if isEmpty(): ret...
true
511b43f80a63e424aa9403ac3a9d21529eca3082
Vanderson10/Codigos-Python-UFCG
/4simulado/tabelaquadrados/Chavesegura/chavesegura.py
1,009
4.125
4
#analisar se a chave é segura #se não tiver mais que cinco vogais na chave #não tem tre caracteres consecultivos iguais #quando detectar que a chave não é segura é para o programa parar e avisar ao usuario #criar um while e analisar se tem tres letras igual em sequencia #analisar se tem mais que cinco vogais, analis...
false
6a34496d114bc6e67187e4bc12c8ff874d575de0
BrightAdeGodson/submissions
/CS1101/bool.py
1,767
4.28125
4
#!/usr/bin/python3 ''' Simple compare script ''' def validate(number: str) -> bool: '''Validate entered number string is valid number''' if number == '': print('Error: number is empty') return False try: int(number) except ValueError as exp: print('Error: ', exp) ...
true
49b854f0322357dd2ff9f588fc8fb9c6f62fd360
BowieSmith/project_euler
/python/p_004.py
352
4.125
4
# Find the largest palindrome made from the product of two 3-digit numbers. def is_palindrome(n): s = str(n) for i in range(len(s) // 2): if s[i] != s[-i - 1]: return False return True if __name__ == "__main__": ans = max(a*b for a in range(100,1000) for b in range(100,1000) if is_...
true
eed8d54cb38af8b0bb62927b9dadfdf0aa69d378
debargham14/bcse-lab
/Sem 4/Adv OOP/python_assignments_set1/sol10.py
444
4.125
4
import math def check_square (x) : "Function to check if the number is a odd square" y = int (math.sqrt(x)) return y * y == x # input the list of numbers print ("Enter list of numbers: ", end = " ") nums = list (map (int, input().split())) # filter out the odd numbers odd_nums = filter (lambda x: x%2 == 1, nums) ...
true
6b2736e3ef5bd2b374367750d21d8af3e9ca2e0a
debargham14/bcse-lab
/Sem 4/Adv OOP/python_assignments_set1/sol11.py
434
4.28125
4
print ("Pythagorean Triplets with smaller side upto 10 -->") # form : (m^2 - n^2, 2*m*n, m^2 + n^2) # generate all (m, n) pairs such that m^2 - n^2 <= 10 # if we take (m > n), for m >= 6, m^2 - n^2 will always be greater than 10 # so m ranges from 1 to 5 and n ranges from 1 to m-1 pythTriplets = [(m*m - n*n, 2*m*n, m*m...
false
669f4bbca09f2d6062be01a30fdfd0f7a0367394
mckinleyfox/cmpt120fox
/pi.py
487
4.15625
4
#this program is used to approximate the value of pi import math def main(): print("n is the number of terms in the pi approximation.") n = int(input("Enter a value of n: ")) approx = 0.0 signchange = 1.0 for i in range(1, n+1, 2): approx = approx + signchange * 4.0/i # JA signchange...
true
4c538d0eccedfa427845be1ca803cdb6cc2ef867
jorgeromeromg2/Python
/mundo2/ex008_D41.py
787
4.25
4
#--------CATEGORIA NATAÇÃO--------# print(10 * '--=--') print('CADASTRO PARA CONFEDERAÇÃO NACIONAL DE NATAÇÃO') print(10 * '--=--') nome = str(input('Qual é o seu nome: ')).capitalize() idade = int(input('Qual é a sua idade: ')) if idade <= 9: print('{}, você tem {} anos e está cadastrado na categoria MIRIM.'.forma...
false
fd614fdd36b34645dd4afc125153dc09493841c2
jorgeromeromg2/Python
/mundo1/ex005.py
648
4.15625
4
#--------SOMA ENTRE NÚMEROS------ #n1 = int(input('Digite o primeiro número: ')) #n2 = int(input('Digite o segundo número: ')) #soma = n1 + n2 #print('A soma entre {} e {} é igual a {}!'.format(n1, n2, soma)) #--------SUCESSOR E ANTECESSOR----- n = int(input('Digite um número e verifique o sucessor e antecessor:')) a ...
false
0b1c100231c6dbe5d970655a92f4baed0cbe1221
firoj1705/git_Python
/V2-4.py
1,745
4.3125
4
''' 1. PRINT FUNCTION IN PYTHON: print('hello', 'welcome') print('to', 'python', 'class') #here by default it will take space between two values and new line between two print function print('hello', 'welcome', end=' ') print('to', 'python', 'class') # here we can change end as per our requirement, by addind end=' ...
true
c5db4886b9e216f7da109bcfdd190a2267d7258b
BMHArchives/ProjectEuler
/Problem_1/Problem_1.py
1,128
4.21875
4
# Multiples of 3 and 5 #--------------------- #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. numberCount = 1000 # Use this number to find all multiples under the numberCount total...
true
c0d728b393c1b9184357b51442f0f3ee96e0db3d
edvalvitor/projetos
/python/media2.py
1,215
4.15625
4
#Programa para calcular a média e quanto falta para passar #Centro Universitário Tiradentes #Edval Vitor #Versão 1.0.1 while True: print("Programa para calcular média da UNIT") print("Se você quer calcular a sua média digite 1") print("Se quer calcular quanto precisa para passar digite 2") opcao = int...
false
c219b35384dcc23574658cfcbae883f4223f8709
LRG84/python_assignments
/average7.5.py
538
4.28125
4
# calculate average set of numbers # Write a small python program that does the following: # Calculates the average of a set of numbers. # Ask the user how many numbers they would like to input. # Display each number and the average of all the numbers as the output. def calc_average (): counter = int (input('How ...
true
833bd691452513944dabb2af51272c90c70c8eaf
lucasrwv/python-p-zumbis
/lista III/questao04.py
273
4.125
4
#programa fibonacci num = int(input("digite um numero ")) anterior = 0 atual = 1 proximo = 1 cont = 0 while cont != num : seun = proximo proximo = atual + anterior anterior = atual atual = proximo cont += 1 print("o seu numero fibonacci é %d" %seun)
false
a085d9ff5c97264c048a0f265806c906647d90df
shyam-de/py-developer
/d2exer1.py
1,091
4.1875
4
# program to check wether input number is odd/even , prime ,palindrome ,armstrong. def odd_even(num): if num%2==0: print("number is even") else: print( 'number is odd') def is_prime(num): if num>1: for i in range(2,num//2): if (num%i)==0: print('...
false
f179a86035e710a59300a467e2f3cd4e9f8f0b15
tweatherford/COP1000-Homework
/Weatherford_Timothy_A3_Gross_Pay.py
1,299
4.34375
4
##----------------------------------------------------------- ##Programmed by: Tim Weatherford ##Assignment 3 - Calculates a payroll report ##Created 11/10/16 - v1.0 ##----------------------------------------------------------- ##Declare Variables## grossPay = 0.00 overtimeHours = 0 overtimePay = 0 regularPay = 0 #Fo...
true
046ecafc48914b85956a7badd6b8500232a57db4
lathika12/PythonExampleProgrammes
/areaofcircle.py
208
4.28125
4
#Control Statements #Program to calculate area of a circle. import math r=float(input('Enter radius: ')) area=math.pi*r**2 print('Area of circle = ', area) print('Area of circle = {:0.2f}'.format(area))
true
362eb0297bbb144719be1c76dc4696c141b72017
lathika12/PythonExampleProgrammes
/sumeven.py
225
4.125
4
#To find sum of even numbers import sys #Read CL args except the pgm name args = sys.argv[1:] print(args) sum=0 #find sum of even args for a in args: x=int(a) if x%2==0: sum+=x print("Sum of evens: " , sum)
true
a1fe59470da2ee519283240483f8fa24917891b3
lathika12/PythonExampleProgrammes
/ifelsestmt.py
316
4.375
4
#Program for if else statement #to test if a number is even or odd x=10 if x%2==0: print("Even Number" ,x ) else: print("Odd Number" , x ) #Program to test if a number is between 1 to 10 x=19 if x>=1 and x<=10: print(x , " is in between 1 to 10. " ) else: print(x , " is not in between 1 to 10. " )
false
99ef2163869fda04dbe4f1c23b46e56c14af7a17
TredonA/PalindromeChecker
/PalindromeChecker.py
1,822
4.25
4
from math import floor # One definition program to check if an user-inputted word # or phrase is a palindrome. Most of the program is fairly self-explanatory. # First, check if the word/phrase in question only contains alphabetic # characters. Then, based on if the word has an even or odd number of letters, # begin co...
true
a113879ec0112ff4c269fb2173ed845c29a3b5e5
ravenclaw-10/Python_basics
/lists_prog/max_occur_elem.py
708
4.25
4
# Element with maximum occurence in a list=[2, 3, 8, 4, 7, 9, 8, 2, 6, 5, 1, 6, 1, 2, 3, 4, 6, 9, 1, 2] . #Python program to check if the elements of a given list are unique or not. n=int(input("Enter the no. of element in the list(size):")) list1=[] count=0 max=0 print("Enter the elements of the lists:") for ...
true
6094c69f6d4fa7a0bb59fc8da0eb7fb379832514
Boukos/AlgorithmPractice
/recursion/rec_len.py
328
4.1875
4
def rec_len(L): """(nested list) -> int Return the total number of non-list elements within nested list L. For example, rec_len([1,'two',[[],[[3]]]]) == 3 """ if not L: return 0 elif isinstance(L[0],list): return rec_len(L[0]) + rec_len(L[1:]) else: return 1 + rec_len(L[1:]) print rec_len([1,'two',[[],...
true
15f68fe0b019bb466d2d7bcfbd83c6baabf2efc4
eyeCube/Softly-Into-the-Night-OLD
/searchFiles.py
925
4.125
4
#search a directory's files looking for a particular string import os #get str and directory print('''Welcome. This script allows you to search a directory's readable files for a particular string.''') while(True): print("Current directory:\n\n", os.path.dirname(__file__), sep="") searchdir=input("...
true
8097283ba70a2e1ee33c31217e4b9170a45f2dd1
NagarajuSaripally/PythonCourse
/StatementsAndLoops/loops.py
2,014
4.75
5
''' Loops: iterate through the dataypes that are iterable, iterable datatypes in python or in any language string, lists, tuples, dictionaries keywords to iterate through these iterables: #for syntax for list_item in list_items: print(list_item) ''' # lists: my_list_items = [1,2,3,4,5,6] for my_list_item in my...
true
30cf7566ca858b10b86bf6ffc72826de02134db2
NagarajuSaripally/PythonCourse
/Methods/lambdaExpressionFiltersandMaps.py
1,141
4.5
4
''' Lambda expressions are quick way of creating the anonymous functions: ''' #function without lamda expression: def square(num): return num ** 2 print(square(5)) #converting it into lambda expression: lambda num : num ** 2 #if we want we can assign this to variable like square2 = lambda num : num ** 2. # we are...
true
3f947479dbb78664c2f12fc93b926e26d16d2c34
ankurkhetan2015/CS50-IntroToCS
/Week6/Python/mario.py
832
4.15625
4
from cs50 import get_int def main(): while True: print("Enter a positive number between 1 and 8 only.") height = get_int("Height: ") # checks for correct input condition if height >= 1 and height <= 8: break # call the function to implement the pyramid structure ...
true
49d3fbe78c86ab600767198110c6022be77fefe9
SagarikaNagpal/Python-Practice
/QuesOnOops/F-9.py
507
4.1875
4
# : Write a function that has one character argument and displays that it’s a small letter, capital letter, a digit or a special symbol. # 97-122 65-90 48-57 33-47 def ch(a): if(a.isupper()): print("u...
true
43462ac259650bcea0c4433ff1d27d90bbc7a09e
SagarikaNagpal/Python-Practice
/QuesOnOops/C-4.py
321
4.40625
4
# input a multi word string and produce a string in which first letter of each word is capitalized. # s = input() # for x in s[:].split(): # s = s.replace(x, x.capitalize()) # print(s) a1 = input("word1: ") a2 = input("word2: ") a3 = input("word3: ") print(a1.capitalize(),""+a2.capitalize(),""+a3.capitalize()...
true
c56fecfa02ec9637180348dd990cf646ad00f77f
SagarikaNagpal/Python-Practice
/QuesOnOops/B-78.py
730
4.375
4
# Write a menu driven program which has following options: # 1. Factorial of a number. # 2. Prime or Not # 3. Odd or even # 4. Exit. n = int(input("n: ")) menu = int(input("menu is: ")) factorial = 1 if(menu==1): for i in range(1,n+1): factorial= factorial*i print("factorial of ",n,"is",factorial) el...
true
7b8acefe0e74bdd25c9e90f869009c2e3a24a4fc
SagarikaNagpal/Python-Practice
/QuesOnOops/C-13.py
213
4.40625
4
# to input two strings and print which one is lengthier. s1 = input("String1: ") s2 = input("String2: ") if(len(s1)>len(s2)): print("String -",s1,"-is greater than-", s2,"-") else: print(s2,"is greater")
true
e09aad9458b0eceb8a8acfc23db8a78637e3ebfe
SagarikaNagpal/Python-Practice
/tiny_progress/list/Python program to swap two elements in a list.py
809
4.25
4
# Python program to swap two elements in a list def appendList(): user_lst = [] no_of_items = int(input("How many numbers in a list: ")) for i in range(no_of_items): user_lst.append(int(input("enter item: "))) return user_lst def swapPos(swap_list): swap_index_1 = int(input("Enter First In...
false
a33e791b4fc099c4e607294004888f145071e6ff
SagarikaNagpal/Python-Practice
/QuesOnOops/A22.py
254
4.34375
4
#Question A22: WAP to input a number. If the number is even, print its square otherwise print its cube. import math a=int(input("num: ")) sq = int(math.pow(a,2)) cube =int (math.pow(a,3)) if a%2==0: print("sq of a num is ",sq) else: print(cube)
true
169945565fd5ffb9c590d7a38715b3a08a8280ff
SagarikaNagpal/Python-Practice
/QuesOnOops/A-10.py
248
4.34375
4
# to input the number the days from the user and convert it into years, weeks and days. days = int(input("days: ")) year = days/365 days = days%365 week = days/7 days = days%7 day = days print("year",year) print("week",week) print("day",day)
true
832c6af00dcabd3682df2be233f20bc677e8718a
SagarikaNagpal/Python-Practice
/QuesOnOops/B25.py
385
4.125
4
# Question B25: WAP to input two numbers and an operator and calculate the result according to the following conditions: # Operator Result # ‘+’ Add # ‘-‘ Subtract # ‘*’ Multiply n1= int(input("n1")) n2 = int(input("n2")) opr = input("choice") if(opr== '+'): print(n1+n2) elif(opr== '-'): ...
false
e5944d3d25b846e0ba00b84150eff7620517e608
juthy1/Python-
/e16-1.py
1,673
4.28125
4
# -*- coding: utf-8 -*- #将变量传递给脚本 #from sys import argv from sys import argv #脚本、文件名为参数变量 #script, filename = argv script, filename = argv #打印“我们将建立filename的文件”%格式化字符,%r。字符串是你想要展示给别人或者从 #从程序里“导出”的一小段字符。 #print ("We're going to erase %r." % filename) print ("We're going to erase %r." % filename) #打印提示,如何退出,确定回车 #print ...
false