blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
7b2d2d37f5acf56da96b52e0665532969285978c
gnoubir/Network-Security-Tutorials
/Basic Cryptanalysis/basic-analyze-file.py
1,983
4.15625
4
#!/usr/bin/python # # computer the frequency of lowercase letters __author__ = "Guevara Noubir" import collections import argparse import string import numpy as np import matplotlib.pyplot as plt parser = argparse.ArgumentParser(description='Analyze a file.') # ./basic-analyze-file.py file # program has one pa...
true
ae9f2189f73437e8ab24932c8f44108d7cbb467d
UMBC-CMSC-Hamilton/cmsc201-spring2021
/classes_start.py
1,501
4.21875
4
""" A class is a new type ints, floats, strings, bool, lists, dictionaries class <-- not really a type a type maker. What kind of things can types have? data inside of them (member variables, instance variables) functions inside of them. """ class Lion: """ ...
true
0fac1e302275fd8c77181ceca7f85afdf0056bc4
mackrellr/PAsmart
/rock_paper_scissors.py
2,208
4.1875
4
import random player_choice = 0 npc_choice = 0 game_on = True # Indicate choices for win def choices(p1, p2): print() if p1 == 1: print('Player choose Rock.') if p1 == 2: print('Player choose Paper.') if p1 == 3: print('Player choose Scissors.') if p2 == 1: pr...
true
bde72147f0609811ecca5e12bd8a2b56f1c8d06f
kaliadevansh/data-structures-and-algorithms
/data_structures_and_algorithms/challenges/array_reverse/array_reverse.py
2,916
4.53125
5
""" Reverses input array/list in the order of insertion. """ def reverseArray(input_list): """ Reverses the input array/list in the order of insertion. This method reverses the list by iterating half of the list and without using additional space. :param input_list: The list to be reversed. Returns No...
true
a41a499a78fc0dc44174812b5b3b7db1e12239b3
FranVeiga/games
/Sudoku_dep/createSudokuBoard.py
1,654
4.125
4
''' This creates an array of numbers for the main script to interpret as a sudoku board. It takes input of an 81 character long string with each character being a number and converts those numbers into a two dimensional array. It has a board_list parameter which is a .txt file containing the sudoku boar...
true
828066159ed3f735e0ea6b16ce8c81b23e62ff1d
DipeshDhandha07/Data-Structure
/infix to postfix2.py
1,310
4.1875
4
# The main function that converts given infix expression # to postfix expression def infixToPostfix(self, exp): # Iterate over the expression for conversion for i in exp: # If the character is an operand, # add it to output if self.isOperand(i): self.output.append(i...
true
ca1ad7d1ad24c77156a97b54683f63dc205c2730
kaushikamaravadi/Python_Practice
/Transcend/facade.py
888
4.125
4
"""Facade Design Pattern""" class Vehicle(object): def __init__(self, type, make, model, color, year, miles): self.type = type self.make = make self.model = model self.color = color self.year = year self.miles = miles def print(self): print("vehicle ty...
true
ff5ca971a1feac7ea7c26d34f8e3b63e4a4c2ea5
kaushikamaravadi/Python_Practice
/DataStructures/linked_list.py
2,244
4.1875
4
"""Linked List""" class Node(object): def __init__(self, data=None, next=None): self.data = data self.next = next def get_data(self): return self.data def get_next(self): return self.next def set_next(self, new_next): self.next = new_next class LinkedList(...
true
a80c87614a06de6b2c9b0293520196b93418e5ea
Rokesshwar/Coursera_IIPP
/miniproject/week 2_miniproject_3.py
2,291
4.1875
4
# template for "Guess the number" mini-project # input will come from buttons and an input field # all output for the game will be printed in the console import simplegui import random # initialize global variables used in your code range = 100 secret_num = 0 guesses_left = 0 # helper function to start...
true
fd00acdfa7e5f6187dcef82ca53e2a34595bb3e9
erinmiller926/adventurelab
/adventure_lab.py
2,337
4.375
4
# Adventure Game Erin_Miller import random print("Last night, you went to sleep in your own home.") print("Now, you wake up in a locked room.") print("Could there be a key hidden somewhere?") print("In the room, you can see:") # The menu Function: def menu(list, question): for item in list: print(1...
true
bc4cf020e12cef8167f0ce3cad98399b5d7d9f8f
michealwave/trainstation
/lesson.py
1,763
4.4375
4
# Calculation, printing, variables # Printing to the screen # The built in function print(), prints to the screen # it will print both Strings and numbers print("Printing to the screen") print("Bruh") # in quotes are called strings print('bruhg') print(6) #a number print("6") print(6 + 6) #prints 12 print("...
true
840ac0b807f67faca806e65f63fb4512c8ec1f40
niskrev/OOP
/old/NotQuiteABase.py
636
4.28125
4
# from Ch 23 of Data science from scratch class Table: """ mimics table in SQL columns: a list """ def __init__(self, columns): self.columns = columns self.rows = [] def __repr__(self): """ pretty representation of the table, columns then rows :return: ...
true
36872204f3439dbafd3370cc89e3a26fb245930a
pranavnatarajan/CSE-163-Final-Project
/MatchTree.py
2,753
4.15625
4
""" Alex Eidt- CSE 163 AC Pranav Natarajan - CSE 163 AB CSE 163 A Final Project This class represents a Data Structure used to build up the bracket of the UEFA Champions League to create the bracket graphics. """ import random class MatchTree: """ Data Structure used to represent a full brack...
true
0e180c7692a5807f278056be53142739700d5fce
anitakumarijena/Python_advantages
/deepak.py
1,275
4.1875
4
graph ={ 'a':['c'], 'b':['d'], 'c':['e'], 'd':['a', 'd'], 'e':['b', 'c'] } # function to find the shortest path def find_shortest_path(graph, start, end, path =[]): path = path + [start] if start == end: return path shortest = None for node in graph[start]: if n...
true
4c786e38d93357f3a768506f39993248e8414b64
Isoxazole/Python_Class
/HW2/hm2_william_morris_ex_1.py
447
4.1875
4
"""Homework2, Exercise 1 William Morris 1/29/2019 This program prints the collatz sequence of the number inputted by the user.""" def collatz(number): if number == 1: print(number) return 1 elif number % 2 == 0: print(number) return collatz(int(number/2)) else: prin...
true
5e4d121ef247320d9f3a90162561d10694c2ab49
Isoxazole/Python_Class
/HW4/hm4_william_morris_ex_1.py
1,461
4.21875
4
""" Homework 4, Exercise 1 William Morris 2/22/19 This program has 3 classes: Rectangle, Circle, and Square. Each class has the functions to get the Area, Diagonal, and perimeter of their respective shape. At the end of this program, the perimeter of a circle with radius the half of the diagonal of a rectangle with len...
true
d57991f5faa7b5b8d3ed8ade332d57c55242bb98
Ottermad/PythonBasics
/times_tables.py
564
4.125
4
# times_tables.py # Function for times tables def times_tables(how_far, num): n = 1 while n <= how_far: print(n, " x ", num, " = ", n*num) n = n + 1 # Get user's name name = input("Welcome to Times Tables. What is your name?\n") print("Hello " + name) # Get timestable and how far do you want ...
true
7b6739be5389da8351294fa3b430002989b83b84
avin82/Programming_Data_Structures_and_Algorithms_using_Python
/basics_functions.py
2,225
4.59375
5
def power(x, n): # Function name, arguments/parameters ans = 1 for i in range(0, n): ans = ans * x return ans # Return statement exits and returns a value. # Passing values to functions - When we call a function we have to pass values for the arguments and this is done exactly the same way as as...
true
ea834767462615e5a124b4e723e4507dcf393cec
MillaKelhu/tiralabra
/Main/Start/board.py
2,127
4.28125
4
from parameters import delay, error_message import time # User interface for asking for the board size from the user def get_board(): while True: print("Choose the size of the board that you want to play with.") print("A: 3x3 (takes three in a row to win)") print("B: 5x5 (takes four in a ...
true
e16aa01c242c5fc654d01f889c1a3cde6551d618
elvargas/calculateAverage
/calculateAverage.py
2,865
4.4375
4
# File: calculateAverage.py # Assignment 5.1 # Eric Vargas # DESC: This program allows the user to choose from four operations. When an operation is chosen, they're allowed to choose # two numbers which will be used to calculate the result for the chosen operation. Option 5. will ask the user how # many numbers th...
true
c0e32988331e72474e7b50ea59ac3891627ebd6b
georgeescobra/algorithmPractice
/quickSort.py
1,408
4.25
4
# this version of quicksort will use the last element of the array as a pivot import random import copy def quickSort(array, low, high): if(low < high): partitionIndex = partition(array, low, high) quickSort(array, low, partitionIndex - 1) quickSort(array, partitionIndex + 1, high) # don't necessarily have to ...
true
e18f0f34927a7aa2398152077a7f88a811466f11
klandon94/python3_fundamentals
/lambda.py
820
4.1875
4
def square(num): return num*num square(3) #Lambda is used to specify an anonymous (nameless) function, useful where function only needs to be used once and convenient as arguments to functions that require functions as parameters #Lambda can be an element in a list: y = ['test_string', 99, lambda x: x ** 2] print...
true
1769e7ee9a9dad0296ef5fd1e189ac4f8ac1e6c6
ayush94/Python-Guide-for-Beginners
/FactorialAlgorithms/factorial.py
1,290
4.1875
4
from functools import reduce ''' Recursively multiply Integer with its previous integer (one less than current number) until the number reaches 0, in which case 1 is returned ''' def recursive_factorial(n): # Base Case: return 1 when n reaches 0 if n == 0 : return 1 # recursive call to function with the integer ...
true
e224a34ec37f50014e7dde73993710b560d54606
FilipM13/design_patterns101
/pattern_bridge.py
2,431
4.28125
4
""" Bridge. Structure simplifying code by deviding one object type into 2 hierarchies. It helps solving cartesian product problem. Example: In this case if I want to create one class for every combination of plane and ownership i'd need 16 classes (4 planes x 4 ownerships) Thanks to bridge pattern I only have 8 cl...
true
78b5b3a4e8076f804716015f9ea3d8bcb419ea2f
samuelluo/practice
/bst_second_largest/bst_second_largest.py
2,041
4.125
4
""" Given the root to a binary search tree, find the second largest node in the tree. """ # ---------------------------------------- class Node: def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right def bst_insert(root, val): if root is None...
true
620369233f7cb25553ec58246c922b11cca6bbd4
msznajder/allen_downey_think_python
/ch3_ex.py
2,743
4.6875
5
""" Exercise 1 Write a function named right_justify that takes a string named s as a parameter and prints the string with enough leading spaces so that the last letter of the string is in column 70 of the display. """ def right_justify(s): print((70 - len(s)) * " " + s) right_justify("abba") """ Exercise 2 A fu...
true
3cf8c28b06e50bf446701066958e4e04079e777d
evural/hackerrank
/cracking/chapter1/is_unique_bitwise.py
535
4.15625
4
# 1. Initialize a checker variable to 0 # 2. For each character in the text, shift left bits of 1 # 3. If bitwise AND of this value returns a number other than 0, return False # 4. Bitwise OR this value with the checker variable def is_unique(text): checker = 0 for c in text: val = ord(c) - ord("a") ...
true
70e9075afd47443a993e4be807274629de87329d
Kevin8523/scripts
/python/python_tricks/class_v_instance_variables.py
1,110
4.15625
4
# Class vs Instance Variable Pitfalls # Two kind of data attributes in Python Objects: Class variables & instance variables # Class Variables - Affects all object instance at the same time # Instance Variables - Affects only one object instance at a time # Because class variables can be “shadowed” by instance variables...
true
701c22b62921af1315710489d3f1935a28079b07
burgonyapure/cc1st_siw
/calc.py
494
4.28125
4
def f(x): return { '+': int(num1) + int(num2), '-': int(num1) - int(num2), '*': int(num1) * int(num2), '/': int(num1) / int(num2) }.get(x, "Enter a valid operator (+,-,*,/)") while True: num1 = input("\nEnter a number,or press a letter to exit\n") if num1.isdigit() != True: break y = input("Enter ...
true
0e76971f4c57f194f05cbccf3803771fa24c9e02
hack-e-d/codekata
/sign.py
216
4.25
4
#to find if positive ,negative or zero n=int(input()) try: if(n>0): print("Positive") elif(n<0): print("Negative") else: print("Zero") except: print("Invalid Input")
true
a8c28d2602f9400fae0baad00135c1612187f4f9
tasnimz/labwork
/LAB 3.py
1,934
4.1875
4
##LAB 3 ##TASK 1 ##TASK 2 ##TASK 3 st = []; # Function to push digits into stack def push_digits(number): while (number != 0): st.append(number % 10); number = int(number / 10); # Function to reverse the number def reverse_number(number): # Function call to push number's...
true
56a99d737a1ae86f6b31a180c5bc9a319bf06461
Alenshuailiu/Python-Study
/first.py
202
4.1875
4
num=input('Enter a number ') print('The number you entered is ',num) num=int(num) if num > 10: print('you enter a number > 10') elif num > 5: print('you enter a number >5 <10') else: print('Others')
true
0501089bafc9bc2a488e9c4cf2e0689e26db6ff7
jenyton/Sample-Project
/operators.py
551
4.34375
4
##Checking the enumerate function print "##Checking the enumerate function##" word="abcde" for item in enumerate(word): print item for item in enumerate(word,10): print item mylist=["apple","mango","pineapple"] print list(enumerate(mylist)) ##Checking the Zip function print "##Checking the Zip function##" name = [...
true
c2fbe51a4c53f968c64cf470c86ac1cf6b4b448d
TardC/books
/Python编程:从入门到实践/code/chapter-10/cats&dogs.py
361
4.15625
4
def print_file(filename): """Read and print a file.""" try: with open(filename) as f_obj: contents = f_obj.read() except FileNotFoundError: # msg = "The file " + filename + " does not exist!" # print(msg) pass else: print(contents) print_f...
true
b295d0857648ad8e09a8a484e58d4745ebe74b69
ChastityAM/Python
/Python-sys/runner_up.py
561
4.15625
4
#Given participants score sheet for University, find the runner up score #You're given n scores, store them in a list and find the score of the #runner up. list_of_numbers = [2, 3, 6, 6, 5] print(sorted(list(set(list_of_numbers)))[-2]) #or list2 = [2, 3, 6, 6, 5] def second_place(list2): list2.sort(reverse=True) ...
true
9673488c7cfc5abd1e0339bd5815615780fa8b07
ChastityAM/Python
/Python-sys/lists.py
721
4.21875
4
list_of_numbers = [1, 2, 3, 4, 5, 6, 7, 8] a = list_of_numbers[5] #selecting an index b = list_of_numbers[2:5] #slicing the list #doesn't include last index given in printout print(a) print(b) list_of_numbers[5] = 77 list_of_numbers.append(10) list_of_numbers.pop(4) #removes at this index, if not indi...
true
c4c1bc5ac2c4e5d28656af5dc987968d34c2feaa
ChastityAM/Python
/Python-sys/sqrt.py
231
4.25
4
import math #Create a function that takes a number n from the user. #Return a list containing the square of all numbers between 1 and n num1 = int(input("Please enter a number: ")) def sq_root(num1): return math.sqrt(num1)
true
0005a28c25142263623a6c52686bd0d1ef6def3f
afcarl/PythonDataStructures
/chapter4/exercise_7.py
410
4.25
4
def is_divisible_by_n(x,n): if type(x) == type(int()) and type(n)==type(int()): if x % n == 0: print "yes,"+str(x)+" is divisible by "+ str(n) else: print "no,"+str(x)+" is not divisible by "+str(n) else: print "invalid input" num1 = input("Please input a number ...
true
4a118fbc0b36030195ebc7067b6feb98de8c4945
afcarl/PythonDataStructures
/chapter6/exercise_3.py
606
4.3125
4
def print_multiples(n, high): #initialize and iterator i = 1 #while the iterator is less than high, print n*i and a tab while i <= high: print n*i, '\t', i += 1 print #print a new line def print_mult_table(high): #initialize an interator i = 1 #while the iterator is less...
true
4bad22567b2966e77af73848c19bb95542360a1a
gadi42/499workspace
/Lab4/counter.py
916
4.46875
4
def get_element_counts(input_list): """ For each unique element in the list, counts the number of occurrences of the element. :param input_list: An iterable of some sort with immutable data types :return: A dictionary where the keys are the elements and the values are the corresponding numb...
true
8874c382f717ef3828bda2da5763cb2d833f655b
mentekid/myalgorithms
/Permutations/permutations.py
1,092
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Computes all possible permutations of [0...N-1] for a given N If you need the permutations of another array, just use N = len(alist) and then print alist[perm] for perm in p Author: Yannis Mentekidis Date: April 28, 2015 """ from time import clock import sys def all_...
true
567c3c71afd8baa107f1d3a3a9a130edbb2401f9
Coder2100/mytut
/13_1_input_output.py
2,484
4.4375
4
print("7.1. Fancier Output Formatting") year = 2016 event = 'referendum' print(f"Result of the {year} {event} was BREXIT.") print("The str.format()") yes_votes =42_572_654 no_votes =43_132_495 percentage_yes = yes_votes/(no_votes + yes_votes) results = '{:-9} YES votes {:2.2%}'.format(yes_votes, percentage_yes) p...
true
46a0a26d0c0ae7ae5eefcf51f5ef47e26d0d175f
gstroudharris/PythonAutomateTheBoringStuff
/Lessons/lists.py
866
4.28125
4
#purpose: place items in a list, put them in a function, then call them myLists = [['Grant', 'Dana', 'ListItem3'], [10, 20, 35]] #index evaluates to a single item at a time print((myLists[0][0]) + str((myLists[1][-2]))) #slice will evaluate to a a whole list print(myLists[1:2]) #replace an item in the list myList...
true
802a63767ddf4ac4449b11045c4e5ee1b2f69e04
Hoverbear/SPARCS
/week4/board.py
1,386
4.125
4
def draw_board(board): """ Accepts a list of lists which makes up the board. Assumes the board is a list of rows. (See my_board) """ # Draw the column indexes. print(" ", end="") for index, col in enumerate(board): # Print the index of each column. # Note: sep="", end="" p...
true
2157ab6936bd0e03959d122e9cc4a0c6908081fd
Hoverbear/SPARCS
/week2/2 - Loops.py
2,579
4.90625
5
# Loops! Loops! Loops! # The above is an example of a loop. Loops are for when you want to do something repeatedly, or to work with a list. # First, some useful things for us to know. my_range = range(10) # This creates an "iterator" which is sort of like a list, in fact, we can use a cast to make a list out of it. pr...
true
3428bb3e2794381738752bb1a368b196fcebee13
14E47/Hackerrank
/30DaysOfCode/day9_recursion3.py
302
4.125
4
#!/bin/python3 import math import os import random import re import sys # Complete the factorial function below. def factorial(n): if n<=1: return 1 else: fac = n*factorial(n-1) return fac n = int(input("Enter factorial no. :")) result = factorial(n) print(result)
true
0d19a01a43ef753af9eb1f9f09817c86e99f0dec
jacobbathan/python-examples
/ex8.10.py
344
4.25
4
# a string slice can take a third index that specifies the 'step size' # the number of spaced between successive characters # 2 means every other character # 3 means every third # fruit = 'banana' # print(fruit[0:5:2]) def is_palindrome(string): print(string == string[::-1]) is_palindrome('racecar') ...
true
e857a43a220a5e158610933d8f478046e6559ae8
sheikh210/LearnPython
/functions/challenge_palindrome_sentence.py
345
4.1875
4
def is_palindrome(string: str) -> bool: return string[::-1].casefold() == string.casefold() def is_sentence_palindrome(sentence: str) -> bool: string = "" for char in sentence: if char.isalnum(): string += char return is_palindrome(string) print(is_sentence_palindrome("Was it a...
true
e4e6df7f0136d45eaa671d592b74fe4767774cfe
sheikh210/LearnPython
/functions/challenge_fizz_buzz.py
1,549
4.3125
4
# Write a function that returns the next answer in a game of Fizz Buzz # You start counting, in turn. If the number is divisible by 3, you say "fizz" instead of the number # If the number if divisible by 5, you say "buzz" instead of the number # If the number is divisible by 3 & 5, you say "fizz buzz" instead of the nu...
true
7f5ade077d195863562b3d90d89cf9bebd1d715b
sheikh210/LearnPython
/data_structures/sets/sets_intro.py
1,506
4.25
4
# Sets are unordered and DO NOT contain any duplicate values - Think of sets like a collection of dictionary keys # Elements in a set MUST be immutable (hashable) # DEFINING A SET # ********************************************************************************************************************** # Method 1 - Decla...
true
0a24d97defcca7fe24bcaec53337ba790151a76f
crystalballz/LearnPythonTheHardWay
/ex3.py
700
4.46875
4
print "I will now count my chickens:" # Hens and Roosters are counted separately print "Hens", 25 + 30 / 6 print "Roosters", 100 - 25 * 3 % 4 # Not too many eggs since there are more Roosters than Hens print "Now I will count the eggs:" print 3 + 2 + 1 - 5+ 4 % 2 - 1 / 4 + 6 # Verifies if the statement that follows is...
true
64c14de2c423cebafdbd7cc8b4869bd3724c0a4e
ninsamue/sdet
/python/act_4.py
1,487
4.25
4
print("ROCK PAPER SCISSORS") print("-------------------") Name1 = input("Enter Player 1 Name : ") Name2 = input("Enter Player 2 Name : ") player1Score=0 player2Score=0 play="Y" while play=="Y": player1Choice = input(Name1+"'s choice - Enter rock/paper/scissors : ").lower() player2Choice = inp...
true
4cc104ae49f21d9ca55166c2aa5149e646dfda4d
mrparkonline/ics4u_solutions
/10-06-2020/letterHistogram.py
1,080
4.3125
4
# Write a program that reads a string and returns a table of the letters of the alphabet in alphabetical order which occur in the string together with the number of times each letter occurs. Case should be ignored. def letterHistogram(word): ''' letterHistogram tracks the occurance of each alpha characters ...
true
5e018f447d9d13832317ee5720012440a9c73c7c
mrparkonline/ics4u_solutions
/09-14-2020/factoring.py
731
4.3125
4
# 09/14/2020 # Factoring Program num = int(input('Enter a number you want the factors for: ')) # While Loop Solution divisor = 1 while divisor <= num: # we are checking all numbers from 1 to inputted num if num % divisor == 0: # when num is divided by divisor the remainder is 0 ...
true
78fcf013af9f568d0314b181d721acb49cb0f59a
mrparkonline/ics4u_solutions
/10-06-2020/numDict.py
1,333
4.34375
4
''' Q4a) Write a Python program to sum all the items in a dictionary Q4b) Write a Python program to multiply all the items in a dictionary Q5a) Create a function that sorts a dictionary by key → Create a sorted list of keys. Q5b) Create a function that sorts a dictionary by value → Create a sorted list of values....
true
3c91e7f0397bac3d0f7684e95642afbf6183a74d
mrparkonline/ics4u_solutions
/10-19-2020/binarySearch.py
1,119
4.15625
4
# Binary Search Non recursive def binSearch(data, target): left = 0 right = len(data) - 1 while left <= right: middle = (left + right) // 2 if data[middle] == target: return middle elif data[middle] < target: left = middle + 1 else: ...
true
71c8bdc6bf5b8561a8306cf147b782a3266d8bf5
ask-ramsankar/DataStructures-and-Algorithms
/stack/stack using LL.py
1,217
4.15625
4
# creates a node for stack class Node: def __init__(self, data, prev=None): self.data = data self.prev = prev self.next = None class Stack: # initialize the stack object with the top node def __init__(self, data): self.top = Node(data) # push the data to the...
true
6857698560aa61ddccd54c02d71f57b57be8644c
ask-ramsankar/DataStructures-and-Algorithms
/queue/queue using LL.py
1,050
4.125
4
# Node of the queue class Node: def __init__(self, data): self.data = data self.next = None class Queue: # Initialize the queue with the first node def __init__(self, data): self.first = Node(data) # add a node to the queue at last def enqueue(self, data): curre...
true
1d86a1f0c018922cff28368903e4a99a1eea139f
jodr5786/Python-Crash-Course
/Chapter 4/4-10.py
329
4.1875
4
# Slices my_foods = ['pizza', 'falafel', 'carrot cake', 'cannoli', 'fish', 'lobster'] friend_foods = my_foods[:] print("\nThe first 3 items in my list are:") print(my_foods[:3]) print("\nThe items in the middle of my list are:") print(my_foods[1:5]) print("\nThe last 3 items in the list are:") print(my_fo...
true
9073f99a3d78244b516d34730f0321e01e80f341
ravindra-lakal/Python_new
/mak.py
912
4.3125
4
################################### #1 Find the last element of a list. list = ['a','b','c','d'] #validation list =[] print list[-1:] #print "list[4]",list[4] #2 Find the last but one element of a list. list =['z','w','e','i','t','l','e','t','z','t','e','s'] #validation list=[1] print list[-2:-1] #3 1.03 (*) ...
true
000e177fda7bf009742ef757bdd466249e42bd9a
nyeddi/Adv-Python
/class_method_.py
1,745
4.46875
4
class Shape(object): # this is an abstract class that is primarily used for inheritance defaults # here is where you would define classmethods that can be overridden by inherited classes @classmethod def from_square(cls, square): # return a default instance of cls return cls() c...
true
c21643f5c58676f77da8ffbc14d3dc488c5b0d8e
saadkang/PyCharmLearning
/basicsyntax/indexvstring.py
2,088
4.40625
4
""" We will see how the index works in python """ nameOfAString = "This is for educational purposes only" # The : in the [] is has no starting and ending index so it will print the whole String print("There is nothing before or after the : so it will print complete String: "+nameOfAString[:]) # In the example below ...
true
445befab60ef2ad7e87ec1b5ce54925ace4977b8
saadkang/PyCharmLearning
/basicsyntax/tuplesdemo.py
1,493
4.5
4
""" Tuple Like list but they are immutable that means you can't change them """ # What the above line in green is trying to say is that list (also called Array in Java) can be changed # Like in the example below: # The list or Array is defined by the [] my_list = [1, 2, 3] print(my_list) my_list[0] = 0 print(my_list) ...
true
bf1a776903b0befb342dd7b8a8ea0b26d2b307dd
cnrmurphy/python-lessons
/exercises/session_1/calc.py
2,685
4.21875
4
''' Exercise: Implement a basic calculator that supports add,subtract,multiply,divide Basic requirements: four functions that perform the aforementioned operations will suffice. Extending: Implement a function, calculator, that takes 3 inputs: operation (string), num_a, and num_b. the function, calculator, should...
true
a5c1932418534132648d77c240e64e839244fd70
aditparekh/git
/python/lPTHW/ex3.py
460
4.375
4
print 'I will not count my chickens:' print "Hens", 25+30/6 print "Roosters", 100-25*3%4 print 'Now I will coung the eggs:' print 3+2+1-5+4%2-1/4+6 print 4//3 print "is it true that 3+2<5-7" print 3+2<5-7 print "Waht is 3+2?",3+2 print "Waht is 5-7?",5-7 print "Ph, that's why it's False" print "How abot some mo...
true
2badc0380cce0cef6f0b76a76d6164e6f6b51d39
aditparekh/git
/python/lPTHW/ex25.py
837
4.28125
4
def break_words(stuff): """This function will break up words for us""" words = stuff.split(" ") return words def sort_words(words): """Sorts the words""" return sorted(words) def print_first_word(words): """Prints the firs word after popping it off""" word=words.pop(0) print word def print_last_words(words):...
true
d96410728328d7382eefaae6929001873fefa702
ajaymatters/scripts-lab
/script-lab/python-scripts/PartA7/pa7.py
519
4.15625
4
def AtomicDictionary(): atomic = {"H":"Hydrogen", "He":"Helium", "N":"Nitrogen"}; x = input("Enter symbol ") y = input("Enter element name ") if x in atomic.keys(): print("Key already exists. Value will be updated") else: print("New Key with Value added") atomic[x] = y print(atomic) print("Number of el...
true
45c036e33d642d8ada09272dec7152a87dea512b
Sridhar-S-G/Python_programs
/Extract_numbers_from_String.py
370
4.125
4
''' Problem Statement A string will be given as input, the program must extract the numbers from the string and display as output Example 1: Input: Tony Stark's daughter says 143 3000 Output: 143 3000 Example 2: Input: There4 I think you will be satis5ed with this tutorial Output: 4 5 ''' #Solution Code import re s=...
true
3c4f4279850d8e2f0bb240fa3c2703b54f2796bc
simiss98/PythonCourse
/UNIT_1/Module1.2/MOD01_1-2.2_Intro_Python.py
1,583
4.21875
4
#creating name variable name = "Petras" # string addition print("Hello " + name + "!") # comma separation formatting print("Hello to",name,"who is from Vilnius.") print("Hello to","Petras","who is from Vilnius.") # [ ] use a print() function with comma separation to combine 2 numbers and 2 strings print("I was born at...
true
6c19170153ee9669fbafe02192606989d031e7a5
simiss98/PythonCourse
/UNIT_1/Module1.1/MOD01_1-1.4.py
2,115
4.375
4
Task1 #creating x,y and z integer variables and then adding then calculating sum of 3 integers. x=1 y=2 z=3 x+y+z # displaying sum of float and integer. 65.7+4 #creating string name variable and then using print just for fun to display both strings. name="Evaldas" print("This notebook belongs to "+name) #creating sm_nu...
true
5d22d099a117896b83c84babf34a3916a06504fc
Futi7/AnagramChecker
/main.py
1,949
4.1875
4
class AnagramChecker: list_of_strings = [] first_string_keys = {} second_string_keys = {} list_of_keys = [first_string_keys, second_string_keys] def __init__(self, first_string, second_string): self.list_of_strings.append(first_string) self.list_of_strings.append(second_string) ...
true
9498fe8866498ef6be30b8d8967dad971f09d801
charanchakravarthula/python_practice
/Baics.py
499
4.3125
4
# variable assignment var = 1 print(var) # multiple values assignment to a variable var1,var2 =(1,2) print(var1,var2) #ignoring unwanted values var1,__,__=[1,2,3] print(var1) var1=var2=var3=1 print(var1,var2,var3) # knowing the type of the varible i.e data type of variable var1=[1,2,3] var2=('a',"b","c") var3=1...
true
e3e76c37ff817bae9836c142f0a7113ede554505
bang103/MY-PYTHON-PROGRAMS
/PYTHONINFORMATICS/DictDayOfWeek.py
871
4.25
4
#Exercise 9.2 in Python for INformatics #Exercise 9.2 Write a program that categorizes each mail message by which day of #the week the commit was done. To do this look for lines which start with *From*, #then look for the third word and then keep a running count of each of the days #of the week. At the end of the p...
true
adc3327fe24e67694446fd98f023306cafd012d2
bang103/MY-PYTHON-PROGRAMS
/WWW.CSE.MSU.EDU/STRINGS/Cipher.py
2,729
4.25
4
#http://www.cse.msu.edu/~cse231/PracticeOfComputingUsingPython/ #implements encoding as well as decoding using a rotation cipher #prompts user for e: encoding d: decoding or q: Qui import sys alphabet="abcdefghijklmnopqrstuvwxyz" print "Encoding and Decoding strings using Rotation Cipher" while True: o...
true
27e4ef0d8bb177a902727eabc24249c933fbb6e2
AO-AO/pyexercise
/ex8.py
653
4.4375
4
""" Define a function called anti_vowel that takes one string, text, as input and returns the text with all of the vowels removed. For example: anti_vowel("Hey You!") should return "Hy Y!". """ def anti_vowel(text): result = "" lenth = len(text) for i in xrange(0, lenth): if i == 0: r...
true
6dad0e0b1ac99cd489e20a297b8b9929a6d8b77e
Trollernator/Lesson
/app.py
929
4.25
4
#variable #data types int, float, str #input(), print(), type() # len() shows the lenght of str # upper() makes the letters BIG # lower() makes the letters smol # capitalize() captitalize the first letter # replace() replace certain letters # FirstName="Tom" # print(FirstName.find("enter search")) # a=58 # b=108 # if ...
true
df6dc1e87f1a2861224107bbba1c901a0b89e094
rajeshvermadav/XI_2020
/character_demo.py
376
4.3125
4
#program to display indivual character name = input("Enter any name") print("Lenght of the string is :", len(name)) print("Location or memmory address of the Character :",len(name)-1) print("Character is :", name[len(name)-6]) print("Substring is :",name[1]) print("Substring is :",name[-1]) print("Substring ...
true
cdc710c7c64c2029fa2b53f210689162fcaf1931
acs/python-red
/leetcode/two-sum/two-sum.py
746
4.15625
4
from typing import List, Tuple def twoSum(nums, target): twoSumTargetTuples = [] for (i, number) in enumerate(nums): for otherNumber in nums[i+1:]: print(number, otherNumber) # Move this logic to a function if (number + otherNumber) == target: if [nu...
true
7f8b3ceeff28f59b0b186d3b3dbd8a7bafd24fdc
Environmental-Informatics/building-more-complex-programs-with-python-roccabye
/Program_7.1.py
2,669
4.375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jan 28 09:55:50 2020 Lab Assignment02 ThinkPython 2e, Chapter 7: Exercise 7.1 This program finds the Square Root of a number by using the famous newton's Method approach and using the function from 'math' library. And compares the absolute values estimat...
true
d6aa20a31894a3f6e94e0d964de05c0e2c232f50
RuthieRNewman/hash-practice
/hash_practice/exercises.py
2,735
4.125
4
#This is a solution that I worked out with a study group hosted by a TA and Al. It was working #until I made some changes and now I cant seem to figure out what I did or how it was #really working in the first place. I will continue to work on it but I didnt feel it was worthy #turning in fully. def anagram_he...
true
9958cd212de0d2c36d608a088f100429c95dd6ff
jadeaxon/hello
/Python/generator.py
772
4.46875
4
#!/usr/bin/env python # Python has special functions called generators. # All a generator is is an object with a next() method that resumes where it left off each time it is called. # Defining a function using yield creates a factory method that lets you create a generator. # Instead of using 'return' to return a valu...
true
711b0da87e3c90aa3fd25c9d902d2c8433d796ea
jadeaxon/hello
/Python 3/interview/singly_linked_list.py
2,260
4.21875
4
#!/usr/bin/env python3 """ A singly-linked list class that can be reversed in place. Avoids cycles and duplicate nodes in list. """ class Node(object): """A node in a singly-linked list.""" def __init__(self, value): self.next = None self.value = value class SinglyLinkedList(object): """A...
true
ea91e41e939909b6d58f425c36b4f4203ce7de72
jadeaxon/hello
/Python/LPTHW/example33.py
315
4.15625
4
#!/usr/bin/env python i = 0 numbers = [] while i < 6: print "At the top, i is %d." % i numbers.append(i) # i++ -- Are you joking? No ++ operator!!! i += 1 print "Numbers now: ", numbers print "At the bottom, i is %d" % i print "The numbers: " for number in numbers: print number
true
af1558e78172d696613b99a8a110d69ba8751db2
SheezaShabbir/Python-code
/Date_module.py
546
4.4375
4
#Python Dates #A date in Python is not a data type of its own, but we can import a module named datetime to work with dates as date objects. #Example #Import the datetime module and display the current date: import datetime x = datetime.datetime.now() print(x.year) print(x.strftime("%A")) print(x) x = da...
true
f07443f0174818f2a9abadcd724ce6b60d9ebdd1
SheezaShabbir/Python-code
/finaltestithink.py
889
4.1875
4
def str_analysis(pass_argument): if(pass_argument.isdigit()): int_conversion=int(pass_argument) if(int_conversion>90): printvalue=str(int_conversion)+" "+"is pretty big number." return printvalue elif(int_conversion<90): printvalue=str(int_conversion)+" "+"is p...
true
6a20b87f76f5e01dab9552208c1a42b197199e9a
jmavis/CodingChallenges
/Python/DecimalToBinary.py
1,796
4.3125
4
#--------------------------------------------------------- # Author: Jared Mavis # Username: jmavis # Problem name: Decimal To Binary # Problem url: https://www.codeeval.com/open_challenges/27/ #--------------------------------------------------------- import sys import math #-------------------------------...
true
b2d2dd3baed364c81e22d193586c21f0abbd56d0
jmavis/CodingChallenges
/Python/Star.py
898
4.4375
4
#------------------------------------------------------------------------------ # Jared Mavis # jmavis@ucsc.edu # Programming Assignment 2 # Star.py - Creates an n-pointed star based on user input #------------------------------------------------------------------------------ import turtle numPoints = int(inpu...
true
daaf1572ef7bf3971cd3a1e27c3397622aa0a172
schoentr/data-structures-and-algorithms
/code-challanges/401_code_challenges/linked_list/linked_list.py
2,852
4.25
4
from copy import copy, deepcopy class LinkedList(): head = None def __init__(self, iterable=None): """This initalizes the list """ self.head = None if iterable: for value in iterable: self.insert(value) def __iter__(self): """This makes...
true
78a6e7972a8960932922e1aad5982183086a8670
schoentr/data-structures-and-algorithms
/code-challanges/401/trees/fizzbuzz.py
809
4.15625
4
from tree import BinaryTree def fizzbuzz (self, node = None): """ This Method traverses across the tree in Order. Replacing the value if divisable by 3 to Fizz, if divisibale by 5 to buzz and if divisiable by both 3 and 5 to fizzbuzz """ rtn = [] if node is None: ...
true
8e3a079278d9a5c59df34cbbe77c2b10a47449f6
schoentr/data-structures-and-algorithms
/code-challanges/401_code_challenges/sorts/radix_sort/fooradix_sort.py
2,103
4.125
4
def radix_sort(inpt_list, base=10): """This sort takes in a list of positive numbers and returns the list sorted in place. Arguments: inpt_list {[list]} -- [Unsorted List] Keyword Arguments: base {int} -- [description] (default: {10}) Returns: [list] -- [Sorted List] """...
true
c0a814a1761bd9b11510500386eee4044f4f3d75
abhinab1927/Data-structures-through-Python
/ll.py
1,631
4.21875
4
class Node: def __init__(self,val): self.next=None self.value=val def insert(self,val): if self.value: if self.next is None: self.next=Node(val) else: self.next.insert(val) else: self.v...
true
e556737d693fb598ee89751696aa05ff4b791e9a
moemaair/Problems
/stacks/python/sort_stack.py
2,680
4.1875
4
from Stack import Stack from Stack import build_stack_from_list """ Sort Stack Write a method to sort a stack in ascending order Approaches: 1) 3 stacks - Small, Large, Current 2) Recursive - Sort and Insertion Sort """ def sort_stack_recursive(stack): if len(stack) == 0: return ele...
true
176d58d5bd2b5c3148c3882d9010a9be36568071
moemaair/Problems
/strings/python/is_rotation.py
2,181
4.375
4
#Cases """ 1) Empty string 2) Normal is rotation 1-step 3) Normal is rotation multistep 4) Normal no rotation same chars 5) 1,2,3+ length 6) Strings not same length == False """ #Approaches """ 1) Submethod called "rotate" which rotates string one-place, main method rotates str2 len(str1) times, checks if strings are ...
true
e37c22e6e03c1a576b264ae00769edbf084fcc4b
moemaair/Problems
/graphs/python/pretty_print.py
1,411
4.125
4
from Graph import Graph from Graph import build_test_graph from Vertex import Vertex """ Pretty Print Starting with a single Vertex, implement a method that prints out a string representation of a Graph that resembles a visual web Approach: 1) Using BFS, extract all unique vertices from the graph into set 2) Loop ...
true
469a59d991f878a9a668df228b310a9d633a60f4
moemaair/Problems
/stacks/python/stacks_w_array.py
1,569
4.125
4
from Stack import Stack from Node import Node """ Stacks with Array Implement 3 stacks using a single array Approaches 1) Index 0, 3, 6.. first stack. 1, 4, 7.. second stack. 2, 5, 8.. third stack. """ class StacksWithArray(object): def __init__(self): self.array = [None for x in range(99)] # Represent next av...
true
1043391288e9b6b26e2feeff248cee4ebefcc085
moemaair/Problems
/stacks/python/evaluate_expression.py
2,374
4.3125
4
from Stack import Stack """ Evaluate Expression Evaluate a space delimited mathematical that includes parentheses expression. e.g. "( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )" == 101 Approaches: 1) Use two stacks, one for operators, one for operands. If you get to close paren?, then pop last two operands off and combine u...
true
8ba5229b9bf24c36eec6fc113b1b020064b8ed87
artopping/nyu-python
/course2/session2/classses_session2.py
710
4.4375
4
#!/usr/bin/env python3 #Classes: storage of data and set of functions that define the class # class has a function and data (local to itself) # when you want to use it< instance= MyClass()> class MyClass: pass #obect my_circle as instance of Class circle # think of class as bucket...lot of room, for data storage a...
true
89db7f6519f2542bec43ceecaa3be231b1e429af
vivekgupta8983/python3
/range.py
269
4.21875
4
#!/usr/bin/python3 #range functions returns a sequence for number start from o and ends ta specific number #range(start, stop, step) # for i in range(100): # print(i) # for i in range(2, 10, 2): # print(i) my_range = range(1, 10) print(my_range.index(3))
true
064cb46b734706c23c60ce872fb16fccecee22a4
nikileeyx/learning_python
/2. Dictionary and List/2002_codeReusing.py
842
4.34375
4
#The Code Reusing 1.0 by @codingLYNX ''' Note: In this question, 0 is considered to be neither a positive number nor negative number. You are to implement the following three functions with the following specifications: is_odd(x) returns True if the input parameter x is odd, False otherwise. is_negative(x) returns Tru...
true
690f4504114a972a0c3aa1b2021b820880eff724
kmurphy13/algorithms-hw
/dac_search.py
736
4.1875
4
# Kira Murphy # CS362 HW2 def dac_search(lst: list, key) -> bool: """ Function that searches for an item in an unsorted array by splitting the array into halves and recursively searching for the item in each half :param lst: The unsorted array :param key: The item being searched for :return: Tr...
true