blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
bdd706b18ce4a36e14e6e69253fae329f14696c9
m0hanram/ACADEMICS
/clg/sem4/PYTHONLAB/psbasics_1/assignment 1/ps1basic_7.py
324
4.15625
4
def panagram_func(sentence): alphabet = "abcdefghijklmnopqrstuvwxyz" for i in alphabet: if i not in sentence.lower(): return "false" return "true" sen = input("enter the sentence : ") if (panagram_func(sen) == "true"): print("it is a panagram") else: print("it is not a panagram...
true
3bf9847235620c0ad7663bb9e1b8f205e62801d0
SelvaLakshmiSV/Registration-form-using-Tinker
/form.py
2,701
4.53125
5
#how to create simple GUI registration form. #importing tkinter module for GUI application from tkinter import * #Creating object 'root' of Tk() root = Tk() #Providing Geometry to the form root.geometry("500x500") #Providing title to the form root.title('Registration form') #this creates 'Label' widget for Registra...
true
b727ed52184529f3bb0735f536986e244a21d4dd
kangliewbei128/sturdy-siamese
/caesar cipher.py
2,471
4.75
5
import pyperclip import string #This asks the user for what message they want to be encrypted inputedmessage=input('enter a message to be translated:') #converts the message that the user inputed into lowercase letters. optional. If you want it converted, add .lower() at the end of inputedmessage message=inputedmessage...
true
b432afe745e13a897a4ad44ea51f6105440d39c8
petrenkonikita112263/Python_Professional_Portfolio_Projects
/Tic Tac Toe/tic_tac.py
2,171
4.28125
4
class TicTacToeGame: def __init__(self, board) -> None: """Class constructor""" self.board = board def display_board(self) -> None: """Function that sets up the board as the list""" print(f""" ------------------------- |\t{self.board[1]}\t|\t{self.board[2]}\t|\t...
true
39a4aee8be08db5c2e90b874a862ecbff87c1389
k1ll3rzamb0n1/Code_backup
/Undergrad/2012/Fall 2012/comp sim/plants-and-animals/plants and animals/plotter.py
2,124
4.125
4
# COMP/EGMT 155 # # Program to create a graphical plot of functions # stored as points read from a text file. # # This program will plot the output from the # plants_and_animals.py program. from graphics import * from string import * #--------------------------------------------------- # Function to transform a poin...
true
11a8b6b733cb8b55e32149da5b17ba576c7faea5
Hunter-Chambers/WTAMU-Assignments
/CS3305/Demos/demo1/Python/timer.py
1,262
4.34375
4
#!/usr/bin/env python3 '''This file contains the Timer class''' from time import time, sleep class Timer: '''A class to model a simple timer''' def __init__(self): '''default constructor ''' self.start_time = 0 self.stop_time = 0 # end __init__ def start(self): '''st...
true
f6dbb5cef74dea564a35491e61e991f5bb2a2259
fsahin/algorithms-qa
/Recursive/PhoneNumberPermutation.py
729
4.21875
4
""" For any phone number, the program should print out all the possible strings it represents. For example 2 can be replaced by 'a' or 'b' or 'c', 3 by 'd' 'e' 'f' etc. """ d = { '0':"0", '1':"1", '2': "ABC", '3': "DEF", '4': "GHI", '5': "JKL", '6': "MNO", '7': "PQRS", '8': "TUV...
true
fed28e9c2affe058cfb233be1cfa1f918c0cff51
ukms/pyprogs
/factorial.py
293
4.40625
4
def findFactorial(num): if num == 1 or num == 0: return 1 else: factorial = num * findFactorial(num -1) return factorial num = input(" Enter the number to find the Factorial: ") if num < 0: print -1 else: print "The Factorial is: ",findFactorial(num)
true
a49360504955debdc1f902b8970de4fd8cf4d2a7
tdcforonda/codewars-practice
/Python/valid_parentheses.py
544
4.1875
4
def valid_parentheses(string): # your code here checker = 0 if string == "": return True for char in string: if char == "(": checker += 1 if char == ")": checker -= 1 if checker < 0: return False if checker == 0: ...
true
841fda7005cd87d5f3ac6e9008d926058e0db87b
SDSS-Computing-Studies/003-input-darrinGone101
/task1.py
325
4.5
4
#! python3 """ Ask the user for their name and their email address. You will need to use the .strip() method for this assignment. Be aware of your (2 points) Inputs: name email Sample output: Your name is Joe Lunchbox, and your email is joe@koolsandwiches.org. """ name = str( input("input name:")).stip() email = ...
true
66c58c5a4739510a1209147258355d2af2d0eb30
eightarcher/hackerrank
/SimpleArraySum.py
768
4.25
4
""" Given an array of integers, can you find the sum of its elements? Input Format The first line contains an integer, , denoting the size of the array. The second line contains space-separated integers representing the array's elements. Output Format Print the sum of the array's elements as a single integer. S...
true
4a0a227a309e7b976951b23d36d148af14384198
LucaCappelletti94/dict_hash
/dict_hash/hashable.py
1,322
4.1875
4
class Hashable: """The class Hashable has to be implemented by objects you want to hash. This abstract class requires the implementation of the method consistent_hash, that returns a consistent hash of the function. We do NOT want to use the native method __hash__ since that is willfully not consi...
true
13466cd075e3ed41d71b05df3bb0a9ac86e80a1f
dAIsySHEng1/CCC-Junior-Python-Solutions
/2004/J1.py
208
4.1875
4
def squares(): num_tiles = int(input()) i = 1 a = i**2 while a <= num_tiles: i+= 1 a = i**2 b = str(i-1) print('The largest square has side length',b+'.') squares()
true
b8840a75e87046562283642f0e11be187d7a1cf9
jmhernan/code4fun
/quartiles.py
1,413
4.25
4
# Given an array, 'arr', of 'n' integers, calculate the respective first quartile (Q1), second quartile (Q2), # and third quartile (Q3). It is guaranteed that Q1, Q2, and Q3 are integers. # Steps # 1. Sort the array # 2. Find the lower, middle, and upper medians. # If the array is odd then the middle element in the mi...
true
591375be5bf0f32ee9b52b076560e52ec8d2d2c0
MouseCatchCat/pythonStudyNote
/venv/Include/classes.py
1,122
4.21875
4
students = [] class Student: school_name = 'School' # constructor to init an obj def __init__(self, name, student_id=1, student_grade=0): self.name = name self.student_id = student_id self.student_grade = student_grade # override the print function basically, if I print t...
true
37a29bb134960c34710dd94d56c8f4410cf4d5e3
Yahya-Elrahim/Python
/Matplotlib/Scatter Plot/scatter.py
1,001
4.1875
4
# ------------------------------------------------------------- # ----------------------- Scatter ----------------------------- # Scatter plots are used to observe relationship between variables and uses dots to represent the relationship # between them. The scatter() method in the matplotlib library is used to draw ...
true
58862e58468698bbe77a5405b78df4f948e48e33
CindyTham/Favorite-Meal-
/main.py
693
4.125
4
print('Hello, What is your name?') name = input('') print('Hello ' + name +', Let me get to know you a little better, Tell me about your Favourite meal?') respond = input ('') print ('Great, what is your favourite starter?') starter = input('') print('And your favourite main course?') main_course = input('') print('Gre...
true
0a8a2e3035a8329e9da15b572fb51398ea291289
erikkvale/algorithms-py
/sort/selection_sort.py
740
4.34375
4
def find_smallest(_list): """ Finds the smallest integer in an array >>> demo_list = [4, 5 , 2, 6] >>> find_smallest(demo_list) 2 """ smallest = _list[0] smallest_idx = 0 for idx, num in enumerate(_list): if num < smallest: smallest = num smallest_idx...
true
29e6efc7ed814dd9228ea9da15dc42cff8ca14a0
coderrps/Python-beginners
/newcode_11.py
206
4.40625
4
#exponents (2**3) used as 2^3 def raise_to_power(base_num, pow_num): result = 1 for index in range(pow_num): result = result * base_num return result print(raise_to_power(4,2))
true
187e9470b42a049edd81f56ff46e443570e69a3e
danjgreene/python
/Coursera - Python 1 & 2/coursera_intro_py_pt2/wk5/wk5A_lsn1_practice1.py
823
4.3125
4
# Echo mouse click in console ################################################### # Student should enter code below # Examples of mouse input import simplegui import math # intialize globals WIDTH = 450 HEIGHT = 300 # define event handler for mouse click, draw def click(pos): print "Mouse click at " + str(pos)...
true
edbde5c1980e9947ed07222c875f7f42f864efcb
sushantchandanwar/Assignment_01
/42_CheckSubstringInString&LengthOfString.py
969
4.15625
4
# Method1: Using user defined function. # function to check if small string is # there in big string def check(string, sub_str): if (string.find(sub_str) == -1): print("NO") else: print("YES") # driver code string = "geeks for geeks" sub_str = "geek" check(string, sub_str) # method-2 def c...
true
204c3817555e95c26eb82523001a7d92c6cd5677
sushantchandanwar/Assignment_01
/30_PositveNoList.py
328
4.375
4
# Python program to print positive Numbers in a List # method-1 list1 = [11, -21, 0, 45, 66, -93] for num in list1: if num >= 0: print(num, end=" ") # method-2 # list1 = [-10, -21, -4, 45, -66, 93] # # # using list comprehension # n = [x for x in list1 if x >= 0] # # print("Positive numbers in the list:...
true
951bf4357da6caeea01211d980fd694036518bb7
joeryan/100days
/cybrary.py
1,114
4.25
4
# cybrary1.py # exercise 1: practical applications in python # adapted and expanded from cybrary.it video course # Python for Security Professionals at www.cybrary.it/course/python # used to improve pytest understanding and overall python knowledge import platform import numbers # 1. determine if the input is odd or...
true
488899ba082277204541e5227250ba3ee0571684
khurath-8/SDP-python
/assignment1_areaoftriangle_58_khurath.py
234
4.21875
4
#PROGRAM TO FIND AREA OF TRIANGLE height=float(input("enter the height of triangle:")) base=float(input("enter the base of the triangle:")) aot=(height*base)/2 print("area of triangle is :",aot)
true
c54432a3b333ab2ba233568328f7971f60e63f61
joneskys7/pi
/NESTED IF.py
714
4.1875
4
while True: a=(raw_input("please enter value of A")) b=(raw_input("please enter value of B")) if a>b: print "A is greater" c=(raw_input("please enter value of c")) d=(raw_input("please enter value of d")) if c>d: print "c is greater" if c<d: ...
true
68f5968fd6b077983bee5ffee8ea059d65a08b3f
joneskys7/pi
/IF GREATER.py
246
4.1875
4
while True: a=(int(input("please enter value of A"))) b=(int(input("please enter value of B"))) if a>b: print "A is greater" if b>a: print "B is greater" if a==b: print"Both are equal"
true
75b49068bfa72485b42356d3d2b533635ad8d515
leerobertsprojects/Python-Mastery
/Advanced Python Concepts/Functional Programming/Common_Functions.py
830
4.21875
4
from functools import reduce # map, filter, zip & reduce #map def multiply_by2(item): return item*2 print(list(map(multiply_by2, [1,2,3]))) mylist = [2,3,4] def multiply_by3(item): return item*3 def check_odd(item): return item % 2 != 0 print(list(map(multiply_by3, mylist))) print(mylist) # filter ...
true
6a486c3807ab428f11ceae22c4996ce363855670
heyese/hackerrank
/2d array.py
1,189
4.125
4
#https://www.hackerrank.com/challenges/2d-array/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=arrays def hour_glass_sum(x,y, arr): """ arr is a list of lists. 0,0 is top left element in arr (x,y) -> x is the column, y is the row. (3,2) is 4th element in ...
true
c3881a0b59adb0fd8d3ab4b8717c5fd9a9f725db
puglisac/hackerrank-practice
/arrays_ds.py
370
4.46875
4
""" Function Description Complete the function reverseArray in the editor below. reverseArray has the following parameter(s): int A[n]: the array to reverse Returns int[n]: the reversed array >>> reverse_array([1, 2, 3]) [3, 2, 1] """ def reverse_array(arr): reversed=[] for i in range(0,len(arr)): ...
true
0f887fd140fe691a2a8d69dc70feb7c035f04ddf
Sourav692/100-Days-of-Python-Code
/Day 1/1. array_longest_non_repeat_solution.py
1,117
4.3125
4
# --------------------------------------------------------------- # python best courses https://courses.tanpham.org/ # --------------------------------------------------------------- # Challenge # # Given a string, find the length of the longest substring # without repeating characters. # Examples: # Given "abcabcbb"...
true
da7b84bdc7883e02407b47f49c2c8fbeb0dbe24d
tanu312000/pyChapter
/linksnode.py
2,609
4.125
4
class Node: def __init__(self, val, next_ref): self.val = val; self.next = next_ref; # Global variable for header and tail pointer in singly linked list. head = tail = None; # appends new node at the end in singly linked list. def append_node(val): global head, tail; node = Node(val...
true
84277dde39dc9b9ba32d48ee811154c9ca1bf363
kelraf/ifelif
/learn python 3/ifelif.py
872
4.3125
4
#The program asks the user to input an intager value #The program evaluates the value provided by the user and grades it accordingly #The values provided must be between 0 and 100 #caution!!! if you provide other values other than ints the program will provide errors marks=int(input("Please enter Students marks to Gra...
true
907c2116937946b84cdd771730ca9d41576730d1
TroGenNiks/python_for_beginers
/basics/string.py
473
4.21875
4
str = "Welcome in my world ." print(str) print(str[:5]) # print upto 5 print(str[2:]) # print from 2 print(str[0::2]) # print by skipping 1 letter print(str[::-1]) # reverse the string # functions of string print(str.isalnum()) # checking string for alphanumeric or not print(str.lower()) # converting into lower prin...
true
c001dc7306530a377450ac57337cab0d7880e998
kgrozis/netconf
/bin/2.4 Matching and Searching for Text Patterns.py
2,343
4.375
4
''' Title - 2.4. Matching & Searching for Text Patterns Problem - Want to match or search text for a specific patterns Solution - If match is a simple literal can use basic string methods ''' text = 'yeah, but no, but yeah, but no, but yeah' # Exact match print('Exact Match:', text == 'yeah') # Match at start...
true
2aa611cce77b26f6ec0eca14d32e703d7cc4cf36
emlam/CodingBat
/List-1/first_last6.py
469
4.125
4
def first_last6(nums): """ Given an array of ints, return True if 6 appears as either the first or last element in the array. The array will be length 1 or more. first_last6([1, 2, 6]) → True first_last6([6, 1, 2, 3]) → True first_last6([13, 6, 1, 2, 3]) → False """ if nums[0] ...
true
f5f21b70304bc006ef8e67593ef13a257d318767
AChen24562/Python-QCC
/Week-1/VariableExamples_I/Ex7a_numbers_integers.py
754
4.25
4
# S. Trowbridge 2020 # Expression: 5+2 # + is the operator # 5 and 2 are operands # Expression: num = 5+2 # = is called assingment, this is an assignment operation # integers and basic maths print(5+2) # addition print(5-2) # subtraction print(5*2) # multiplication print("") print(5/2) # floating-point division...
true
48453ed9edda73bb3a756d220d98fe763774562c
AChen24562/Python-QCC
/Week-1/VariableExamples_I/Ex6_type_casting.py
424
4.28125
4
# Chap2 - Variables #type casting from float to integer x = int(2.8) print(x,type(x)) #type casting from string to integer x = int("3") print(x,type(x)) #type casting from integer to float y = float(1) print(y,type(y)) #type casting from string to float y = float("3.8") print(y,type(y)) #type casting from integer ...
true
89516e62abc9a2e12dd14c65cb2750a4088b2ae7
AChen24562/Python-QCC
/Week-2-format-string/Week-2-Strings.py
292
4.1875
4
address = '5th Avenue' print('5th Avenue') print(address) print("This string has a 'quotation' in it") item1 = "apples" item2 = "pears" number = 574 message = f"I want to buy {number} {item1} and {item2}." print(message) message = f"Hi, do you want to buy {number} {item1}?" print(message)
true
a2e9857ca65fe8486937e6a632996f5347b7f724
AChen24562/Python-QCC
/Exam2/Q10.py
911
4.5625
5
'''a) Create a dictionary, people, and initialize it with the following data: 'Max': 15 'Ann': 53 'Kim': 65 'Bob': 20 'Joe': 5 'Tom': 37 b) Use a loop to print all items of the dictionary people as follows: name is a child (if the value is younger than 12). name is a teenager (if the value is younger than 20). name is...
true
e7dac55232da561490983510b4d0ec74d289a2c4
AChen24562/Python-QCC
/Exam2-Review/Review2-input-if.py
212
4.3125
4
num = int(input("Enter an integer number: ")) # Determine if input is negtive, positive or zero if num < 0: print("Negative") else: if num == 0: print("Zero") else: print("Positive")
true
d63e95c3988f731fc95b7fb25d0b2219fe7fee23
ledbagholberton/holbertonschool-machine_learning
/pipeline/0x03-data_augmentation/2-rotate.py
348
4.15625
4
#!/usr/bin/env python3 """ Write a function that rotates an image by 90 degrees counter-clockwise: image is a 3D tf.Tensor containing the image to rotate Returns the rotated image """ import tensorflow as tf import numpy as np def rotate_image(image): """Rotate image""" flip_2 = tf.image.rot90(image, k=1, n...
true
76ae676219453fdcbc8218dbc8a0ee6f98e8eee0
ledbagholberton/holbertonschool-machine_learning
/math/0x06-multivariate_prob/multinormal.py
2,625
4.25
4
#!/usr/bin/env python3 """ data is a numpy.ndarray of shape (d, n) containing the data set: n is the number of data points d is the number of dimensions in each data point If data is not a 2D numpy.ndarray, raise a TypeError with the message data must be a 2D numpy.ndarray If n is less than 2, raise a ValueError with t...
true
18cb1709c41d781f819fd31dfa3e28da5b181be9
Fiskk/Project_Euler
/#1.py
1,505
4.3125
4
#Steffan Sampson #11-8-2017 #Project Euler Problem 1 def sum_of_multiples(): print("This function finds the sums of multiples of integers below an upper bound") print("This function takes in an upper bound") print("As well as the numbers to be used to find the multiples") #low_end = int(input("Please...
true
18ec76f38dd7a8e9405d351a4e2e3f6b794296b8
sainathprabhu/python-class
/Assertion.py
359
4.1875
4
#assert is a keyword to check values before performing the operations def multiplication(a,b): assert(a!=0), "cannot perform the operation" #makes sure that a is not zero assert(b!=0), "cannot perform the operation" #makes sure that b is not zero return(a*b) print(multiplication(3,0)) #print(multiplica...
true
b6bd7b83c8d50a8dc499c6efccbf237f480df0f9
Debu381/Coding-battel
/2.py
1,609
4.15625
4
def pattern(number): li = list() # to store of lists num=1 # to initiate for i in range(1, number+1): x = list() # to create a temporary list for j in range(1 , ...
true
1a9c8c09b72a831f202c42f27f3647c9baeb26f5
Kertich/Algorithm-qns
/smallest_difference.py
786
4.15625
4
array_a = [-1, 5, 10, 20, 28, 3] array_b = [26, 134, 135, 15, 17] get = [] def smalldifference(array_a, array_b): ''' Prints a list of two values each from different array(array_a, array_b). The difference of the two values returns the smallest difference. Parameters: ---------- array_a(it...
true
9c7baffba283344307ada04b57412dff6c52a2db
wildsrincon/holbertonschool-higher_level_programming
/0x06-python-classes/6-square.py
2,198
4.375
4
#!/usr/bin/python3 """6-square.py: Script to print tuples of square position""" class Square: """Creates Square type""" def __init__(self, size=0, position=(0, 0)): """Initializes the square with position and size""" self.size = size try: self.position = position ...
true
e737e7b18d4dec68ffea54b048e3c207320733c2
AlexSkrivseth/python_scripts
/python_scripts/ah.py
877
4.125
4
# In the formula below, temperature (T) is expressed in degrees Celsius, # relative humidity (rh) is expressed in %, # and e is the base of natural logarithms 2.71828 [raised to the power of the contents of the square brackets]: # # Absolute Humidity (grams/m3) = 6.112 × e^[(17.67 × T)/(T+243.5)] × rh × 18.02 / (273.1...
true
12f98b8a6150acf567acc1e62de69e1ebdb012ad
ADARSHGUPTA111/pythonBasics
/python_basics(git)/dictionaries.py
1,331
4.21875
4
#dictionaries act as a key value pair ninja_belts={"crystal":"red","ryu":"black"} print(ninja_belts) print(ninja_belts['crystal']) #this returns the value associated with this key #how to check whether there exists a key in the given dictionary or not #use key in dict print('yoshi' in ninja_belts)#returns ...
true
80970b63c28851bcb5ab76b8b3d418e5f5289489
Chadmv95/cis457-Project-1
/ftp-client.py
2,774
4.125
4
# CIS457 Project 1 # Description: ftp-client will connect to an ftp server. Valid commands are exit, retrieve, store, and list #!/usr/bin/python3 import ftplib # Function to get FTP connection information from user # return IP of server and port number def welcome(): print("Welcome to FTP client app\n") ser...
true
b94da510b1b838748c6f1fac774f8dc8ab74fd0a
iliankostadinov/thinkpython
/Chapter9/Ex9.6.py
573
4.15625
4
#!/usr/bin/env python3 """ Write a function called is_abecedarian that returns True if the letters in a word appear in alphabetical order (double letters are ok). How many abecederian words are there? """ def is_abecedarian(word): tmp_char = 'a' for letters in word: if tmp_char > letters: ...
true
059220dcf416327b83c9fe2eeb06b3fb25b39202
iliankostadinov/thinkpython
/Chapter9/Ex9.4.py
336
4.25
4
#!/usr/bin/env python3 """ Write a function named uses_only that takes a word and a string of letters, and that returns True if the word contains only letters in the list """ def uses_only(word, string): for chars in word: if chars in string: continue else: return False ...
true
389c7c1344976822a774803fa44dfcca8e0f4414
behrouzmadahian/python
/pandas/13-hierarchical-Indexing.py
2,756
4.34375
4
import pandas as pd ''' Up to this point we've been focused primarily on one-dimensional and two-dimensional data, stored in Pandas Series and DataFrame objects, respectively. Often it is useful to go beyond these and store higher-dimensional data–that is, data indexed by more than one or two keys. ''' print('R...
true
8c01d08334ea73dfef9c593241aaf2281585dd79
behrouzmadahian/python
/python-Interview/4-sort/3-insertion-sort.py
1,122
4.125
4
''' for index i: looks into the array A[:i] and shifts all elements in A[:i] that are greater than A[i] one position forward, and insert a[i] into the new position. takes maximum time if elements are sorted in reverse order. ''' def insertion_sort(a): for i in range(1, len(a)): key = a[i] ...
true
ba3f073b642f828f39bc28fb3ea7b185fbf01f1c
behrouzmadahian/python
/python-Interview/4-sort/2-bubbleSort.py
689
4.125
4
''' Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order. on the first pass, the last element is sorted, On the second pass the last two elements will be sorted,.. O(n2) ''' def bubble_sort(a): for i in range(len(a)): for j...
true
d4a2ec8e6957ad4b2550589260d608267a3c90c9
behrouzmadahian/python
/python-Interview/5-linkedList/2-Insertion.py
1,568
4.53125
5
''' A node can be added in three ways 1) At the front of the linked list 2) After a given node. 3) At the end of the linked list. ''' class Node: def __init__(self, data): self.data = data self.next = None # LinkedListClass class LinkedList: # function to initialize the linke...
true
64fa4a7d5c0651baf5a24367aeac8663b1e94e34
KkrystalZhang/ToyRobot
/robot.py
2,228
4.125
4
from grid import Grid from utils import DIRECTIONS, MOVES class Robot(object): """ The Robot class contains state of the robot and methods to update the state. """ def __init__(self): self.x = None self.y = None self.direction = None def place(self, x: int, y: int, directi...
true
016a78e9e87e2eaa9bebe126a658dcef73ce281a
Sarbodaya/PythonGeeks
/Variables/Variables.py
831
4.28125
4
# Global Variable # Global variables are those who are declared # outside the function we need to use inside the function def f(): s = 'Me Too' print(s) s = "I want to Become Data Scientist" f() print(s) # If a variable with the same name is defined inside the scope of # function as well then it...
true
24ffdc95caf475b3cd21d1dd134adfb64ad97f42
Sarbodaya/PythonGeeks
/Data Types/AccessingTuples.py
1,048
4.78125
5
# Accessing the tuple with indexing Tuple1 = tuple("Geeks") print("First element of Tuple : ") print(Tuple1[1]) # Tuple Unpacking Tuple1 = ("Sarbodaya Jena", "Indian Army", "Indian Navy", "Indian Air Force") # This line unpack the values of tuple a, b, c, d = Tuple1 print("Values after Unpacking : ") print...
true
d9d06ff6ea7e72fa2a977246d418e3d06f765637
Sarbodaya/PythonGeeks
/ControlFlows/tut5.py
1,046
4.53125
5
king = {'Akbar': 'The Great', 'Chandragupta': 'The Maurya', 'Modi': 'The Changer'} for key, value in king.items(): print(key, value) # Using sorted(): sorted() is used to print the container is sorted order. It doesn’t # sort the container but just prints the container in sorted order for 1 instance. # The ...
true
5db93f86f3128a7ff07ecead0bacc8cd82b362a3
Sarbodaya/PythonGeeks
/ControlFlows/tut3.py
431
4.1875
4
fruits = ["apple", "orange", "kiwi"] for fruit in fruits: print(fruit) # Creating an iterator object # from that iterable i.e fruits fruits = ["mango", "banana", "grapes"] iter_obj = iter(fruits) while True: try: # getting the next item fruit = next(iter_obj) print(fruit...
true
21795b39ac96ea65e171431811c5c75f2594e797
Sarbodaya/PythonGeeks
/ControlFlows/tut4.py
1,594
4.9375
5
# Different Looping Techniques # Using enumerate(): enumerate() is used to loop through the containers printing # the index number along with the value present in that particular index. for key, value in enumerate(['The', 'Big', 'Bang', 'Theory']): print(key, value) for key, value in enumerate(['Geeks',...
true
6955a27ab909bd7a55235829d2eb3390cbdb75f8
rekikhaile/Python-Programs
/4 file processing and list/list_examples.py
828
4.28125
4
# Initialize my_list = [] print(my_list) my_list = list() print(my_list) ## Add element to the end my_list.append(5) print(my_list) my_list.append(3) print(my_list) # notice, list can contain various types my_list.append('Im a string') print(my_list) ## more operations on lists my_list.remove('Im a string') print(my...
true
c52f66676fcf6ab8ed68d82dfb96cf773ab265f2
KarlYapBuller/03-Higher-Lower-game-Ncea-Level-1-Programming-2021
/02_HL_Get_and_Check_User_Choice_v1.py
1,092
4.1875
4
#Get and Check User input #Number Checking Function goes here def integer_check(question, low=None, high=None): situation = "" if low is not None and high is not None: situation = "both" elif low is not None and high is None: situation = "low only" while True: try: ...
true
a4af8a265f728ad04325783b9a2279421beb44ed
zhanglae/pycookbook
/ch1/cookbook1_13.py
1,192
4.3125
4
'1.13 Sorting a List of Dict by common key' ''' Problem You have a list of dictionaries and you would like to sort the entries according to one or more of the dictionary values. ''' 'Think about its a small db, sort by one column' rows = [ {'fname': 'Brian', 'lname': 'Jones', 'uid': 1003}, {'fna...
true
adfc200cf4be55de65e19c6dfc81c41f6cea7892
texttest/storytext-selftest
/tkinter/widgets/menubutton/target_ui.py
1,807
4.375
4
#$Id: menubartk.py,v 1.1 2004/03/18 05:44:21 mandava Exp $ #this is program that creates a menubar using Tkinter widgets. # a menubar is just a frame that holds menus. #We will then pass menubar to all of the subsequent menus we'll define #(File, Edit, Help, etc.) as the parent function. #A menu in Tk is a combination ...
true
9a42f4f082403c60ff224c7447e096ce03b3f3ce
JadeHayes/coding-challenges
/is_pal.py
985
4.34375
4
# Write an efficient method that checks whether any permutation ↴ of an input string is a palindrome. ↴ # You can assume the input string only contains lowercase letters. # Examples: # "civic" should return true # "ivicc" should return true # "civil" should return false # "livci" should return false def is_palindr...
true
7bbaccc3164f4988c2e749630b552875e8211466
JadeHayes/coding-challenges
/lazy-lemmings/lemmings.py
832
4.21875
4
"""Lazy lemmings. Find the farthest any single lemming needs to travel for food. >>> furthest(3, [0, 1, 2]) 0 >>> furthest(3, [2]) 2 >>> furthest(3, [0]) 2 >>> furthest(6, [2, 4]) 2 >>> furthest(7, [0, 6]) 3 """ def furthest(num_holes, cafes): """Find longest distance...
true
6a8d4210f42d8e66b0cc62770bbf33ce16a5de1e
JadeHayes/coding-challenges
/problem_solving_datastructures_algorithms/time_it.py
1,804
4.1875
4
# timeit.py # check to see that list index is constant time O(1) '''To use timeit you create a Timer object whose parameters are two Python statements. The first parameter is a Python statement that you want to time; the second parameter is a statement that will run once to set up the test''' import timeit def test1(...
true
741f97f3646be248079fccbf8f0a3bd4a53f1b8b
vipsh18/cs61a
/recursion/max_product_non_consecutive.py
487
4.28125
4
def max_product(s): """ Return the maximum product that can be formed using non-consecutive elements of s. >>> max_product([10,3,1,9,2]) # 10 * 9 90 >>> max_product([5,10,5,10,5]) # 5 * 5 * 5 125 >>> max_product([]) 1 """ if len(s) <= 2: return max(s) if len(s) >= 1 else ...
true
6e61a9a7fe86684d6f8fb97ea19b19b39151868e
vipsh18/cs61a
/iterators_generators/accumulate.py
467
4.21875
4
from operator import add, mul def accumulate(iterable, f): """Takes in an iterable and a function f and yields each accumulated value from applying f to the running total and the next element. >>> list(accumulate([1, 2, 3, 4, 5], add)) [1, 3, 6, 10, 15] >>> list(accumulate([1, 2, 3, 4, 5], mul)) [...
true
13f8c02e9d192c60f1eedfbe7a7489ad3f6d17c5
kevinfrancis/practice
/dp/robot_path.py
1,723
4.1875
4
#!/usr/bin/env python import sys # From Cracking the Coding interview # Given # maze r rows & c cols. maze[i][j] = { 0, if cell is traversable, # 1, if it is an obstacle } # robot standing at 0th row, 0th col. # robot can only move right or down # (i.e. next step from (i...
true
6a792aee0b04ec52b8b18864ec84dea61a93e340
kulkarnidk/datastructurePrograms
/Binary_Search_Tree.py
651
4.25
4
def factorial(num): """ @:param calculates the factorial of num :param num:input for factorial method for calculation of factorial :return:returns factorial number of num """ res = 1 for i in range(1, num + 1): res = res * i return res tree_values=[] tree_count=[] num=int(input("...
true
b72d5c8a330df8c72151a16fef910973d2715954
indraputra147/pythonworkbook
/chapter1/ex23.py
434
4.15625
4
#Exercise 23: Area of a Regular Polygon """ Write a program that reads length of a side(s) and n number of sides from the user then displays the area of a regular polygon constructed from these values. """ n = int(input("Enter the number of sides of polygon: ")) s = float(input("Enter the length of the side of polyg...
true
54ee4d44ee7e5851ad55dc04c85eaeb46bcb1c46
indraputra147/pythonworkbook
/chapter2/ex52.py
923
4.125
4
#Exercise 51: Letter Grade to Grade Points """ The program begins by reading a letter from the user then compute and display the equivalent number of grade points """ GRADE = input("Enter the letter of your grade (from A to F): ") if GRADE == "A" or GRADE == "A+": print("Your grade points is 4.0") elif GRADE ==...
true
e7bbcbcd43636310ba8cc439390c7f378d8ece51
indraputra147/pythonworkbook
/chapter1/ex15.py
356
4.1875
4
#Exercise 15: Distance Units """ Input of measurements in feet output in inches yards, and miles """ #input in feet from the user ft = float(input("Measurement in feet: ")) #compute the output inch = ft * 12 yrd = ft / 3 mile = ft / 5280 print("output:") print("%.2f" % inch + " inches") print("%.2f" % yrd + " yards"...
true
bcd8616ee86c889b7db353718696c0f911aca56a
jeetmehta/Cracking-The-Coding-Interview
/Arrays and Strings/check_permutation.py
1,168
4.125
4
# CTCI - Chapter 1: Arrays and Strings # # Question 1.2 # PROBLEM STATEMENT: Given two strings, write a method to decide if one is a permutation of the other. # HINTS: #1, #84, #122, #131 # Checks if two strings are permutations of each other using hash maps # O(n) time, O(n) space def checkPermutations(firstString, s...
true
42b468d4eb709699c95eb5e9ce96418616f412d5
poojasaini22/edx-Introduction-to-Python-Absolute-Beginner
/str_analysis.py
723
4.21875
4
#Create the str_analysis() function that takes a string argument. In the body of the function: #Program: str_analysis() Function def str_analysis(arg): while True: if arg=="": str_analysis(input("enter")) break elif arg.isdigit()==True: if int(arg)<=99: ...
true
6b94a8fe1cab6d15504c19b40d8f8fcd79fb2094
aa-glitch/aoc2019
/day03/wire.py
2,262
4.21875
4
from typing import List, Tuple, Dict def find_crossings(wire1: List[Tuple], wire2: List[Tuple]) -> List[Dict]: """Return all crossing points with distance and steps. Find all coordinates where the given wires cross. For each point, determine the manhattan distance to the origin ('dist') and the combined ...
true
f8933fd2bd5739e868eb4f9b563538f849a18308
adityakumar1990/iNueron
/list/sort_nested_list_one_level_nesting.py
587
4.21875
4
def sort_nested_list(input_list): sorted_list=[] for e in input_list: if type(e) not in (str,int,float): ##print(e) #sorted_list.append(e.sort(reverse=True)) ##This will not work because e.sort(reverse=True) return none and none will be appended ...
true
3516fa49f214a7eb57d4592843ae3b498ca10853
EmmanuelSHS/LeetCode
/lint_implement_trie.py
1,397
4.25
4
""" Your Trie object will be instantiated and called as such: trie = Trie() trie.insert("lintcode") trie.search("lint") will return false trie.startsWith("lint") will return true """ class Trie: def __init__(self): self.root = {} self.END = '/' # @param {string} word # @return {void} # Inserts a word ...
true
d1a3694b40a21fe1d3f8b45555ff24e91ca9bc04
meralegre/cs50
/pset6/cash/cash.py
968
4.1875
4
from cs50 import get_float def main(): change = get_positive_float("Change : ") print('input change : ', change) # Convert this input from float to int cents = round(change*100) print('input round : ', cents) # Coins possible quarter = round(0.25*100) dime = round(0.10*100) nickel = round...
true
b21f6d981ce96ee41c58779e81f33067d313b2de
hendalf332/tratata
/projShift.py
2,932
4.125
4
#!/usr/bin/env python import os import string def clr(): if os.name == "nt": os.system("cls") else: os.system("clear") alphabet=list(string.ascii_lowercase) alphabet.append(' ') alphabet_upper=list(string.ascii_uppercase) punct=list(string.punctuation) for x in range(0,9): punct.app...
true
8b980f1f09d963af977052476b8c42e785fbc6c4
ashwinraghav08/calculator
/calculator_v2.py
799
4.21875
4
def add(num1, num2): print (num1+num2) def minus(num1, num2): print (num1-num2) def multiply(num1,num2): print(num1*num2) def divide(num1,num2): print(num1/num2) def get_input(): num1 = input("Enter num1: ") #print(num1) num2 = input("Enter num2: ") #print(num2) operation=input...
true
136a6666e7a3a6b73a440e1ac57f493076c4c0a7
LukeJermaks/Programming
/Nested If Statement.py
900
4.21875
4
#Loop thing I guess. #By Luke Jermaks def NestedLoop(): score = int(input("Input Score\n >>>")) if score > 89: #Needs to be > 89 due to the grade being only over 90 for a grade 9 print("Grade 9") #You could also use => or =< and then the lower bound...
true
1c71af4bafdb4d4d3d18d82a89b64542efebf219
mottola/dataquest_curriculum
/python_basics/python-methods.py
1,566
4.46875
4
# OBJECT METHODS IN PYTHON (METHODS CALL FUNCTIONS ON OBJECTS) # OBJECT str # _______________________ # capitalize(), replace() # OBJECT float # _________________________ # bit_length(), conjugate() # OBJECT list # ________________ # index(), count() # LIST METHODS # ______________ fam = ['liz', 1.73, 'emma', 1.6...
true
b98021728ffe1479acfa222d7f8489c85030ca22
FOSS-UCSC/FOSSALGO
/algorithms/ar-expsq/python3/exponentiation_by_squaring.py
378
4.375
4
def exponentiation_by_squaring(base, power): res = 1 while(power > 0): if(power % 2 != 0): res *= base #if power is ODD, multiply res with base base *= base # square the base power = power // 2 # halving power (integer) return res def main(): print(exponentiation...
true
3c0138867df695fb0cb1a5892f8fcdca124d73cd
cheungh/python
/bubble_sort.py
835
4.125
4
""" Very inefficient sort method do not use for sort for list larger than 200 items use quick sort or merge sort instead """ def bubble_sort(A): # for n element in list n = len(A) bound = n - 1 # let i be iterate counter of outer loop # set swap to false to detect if swap occurred swap = False ...
true
2c0dc53acf5118aba7cf67124186a723ba97d633
Eliasin/fun-things
/mark_catastrophe.py
2,114
4.15625
4
from functools import reduce english_marks = [31, 20, 44, 49, 50, 33, 45, 21, 3, 17, 40] math_marks = [26, 25, 30, 50, 41, 29, 19, 26, 38, 35, 42] print("I have a set of english marks and a set of math marks, both are out of 50.") def convert_marks_to_percentage(marks): result = [] for mark in marks: result....
true
6733cf341bc1480fb93b411cf9101ab699825d01
stewartyoung/leetcodePy-easy-1-20
/Algorithms/LongestCommonPrefix.py
1,117
4.1875
4
stringList1 = ["flower", "flow", "flight"] stringList2 = ["dog", "racecar", "car"] def longestCommonPrefix(stringList) -> str: # If string list doesn't contain anything, return empty string if not stringList: return '' # Take the last item in the stringList lastIte...
true
82b13aae211e42ae1d23045f6da88847341863d1
cs-fullstack-2019-fall/python-coding-concepts1-weekly-5-Kenn-CodeCrew
/question9.py
355
4.21875
4
# ### Problem 9: # Ask the user for a positive number. Create an empty array and starting from zero, add each number by 1 into the array. Print EACH ELEMENT of the array. userInput = int(input("Enter a positive number")) emptyArray = [] for index in range(userInput+1): emptyArray.append(index) for eachElement in...
true
eabf756621d3a5f4598cc40eceb636f91a5a61e0
milkrong/Basic-Python-DS-Algs
/BubbleSort.py
497
4.28125
4
def bubble_sort(input_list): is_sorted = False length = len(input_list) - 1 while not sorted: is_sorted = True # assume it is sorted for i in range(length): if input_list[i] > input_list[i+1]: is_sorted = False # find a position not sorted input_...
true
99fdab510f07e294362319bd0ff41e979b287693
Clucas0311/PythonCourse
/pizza_toppings.py
532
4.40625
4
# Write a loop that prompts the user to enter a series of pizza toppings until # they enter a "quit" value. As they enter each message, print a message saying # You'll add that topping to their pizza message = """\nWelcome to Pizza Shack! What kind of toppings would you like to add to your pizza?:""" message += "\n En...
true
ed71d577919662e06562094429f460f30ea0d0d3
Clucas0311/PythonCourse
/2-10.py
823
4.28125
4
# Write a progran that produces 48 cookies with the ingredients listed # 1.5 cups of sugar # 1 cup of butter # 2.75 cups of flour regular_amt_cookies = 48 regular_amt_sugar = 1.5 regular_amt_butter = 1 regular_amt_flour = 2.75 # Prompt the user on how many cookies that they will like to make? amount_of_cookies = floa...
true
418c73d1e577cf0a3140e9f0cc85510248f6d6ce
Clucas0311/PythonCourse
/2-7.py
321
4.25
4
# A cars MPG can be calcuated: # MPG = Miles driven / Gallons of gas used miles_driven = float(input("How many miles did you drive: ")) gallons_of_gas = float(input("How many gallons of gas did you use?: ")) miles_per_gallon = miles_driven / gallons_of_gas print(f"The number of miles driven: {miles_per_gallon} MPG")...
true
890f88c45a3b66e02e75dc05d5bb7711e38e5d7a
Clucas0311/PythonCourse
/restaurant2.py
1,009
4.125
4
class Restaurant: # Make a class called restaurant def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type def describe_restaurant(self): print(f"{self.restaurant_name} is a beautiful restaurant, perfect for large parti...
true
956916707ffe3eee148dbb01650936533e3fc656
aruwentar/PythonSmallProjects
/Hangman/main.py
2,038
4.125
4
import re def get_word_to_guess(): # STUB return "barnacle" def convert_word_to_char_list(word): char_list = list() for char in word: char_list.append(char) return char_list def get_user_guess(): user_guess = str() while True: user_guess = input("Please guess your letter: ...
true
65359d84f0f12ff18a98c0f1acc21b288d6fe447
ErickMwazonga/sifu
/strings/string_compression.py
1,685
4.3125
4
''' 443. String Compression Link: https://leetcode.com/problems/string-compression/ Given an array of characters chars, compress it using the following algorithm: Begin with an empty string s. For each group of consecutive repeating characters in chars: If the group's length is 1, append the character to s. Otherwise...
true
5215f67912c760305c6c22390711d8a11e4e546e
ErickMwazonga/sifu
/graphs/currency_conversion.py
2,424
4.15625
4
''' Currency Conversion Resource: https://www.youtube.com/watch?v=L9Me2tDDgY8 Paramenters: 1. array of currency conversion rates. E.g. ['USD', 'GBP', 0.77] which means 1 USD is equal to 0.77 GBP 2. an array containing a 'from' currency and a 'to' currency Given the above parameters, find the conversion rate t...
true
0cb142038b9c99afb71841bd9f194a9fec21e695
ErickMwazonga/sifu
/strings/reversed_words.py
1,412
4.21875
4
''' Write a function reverse_words() that takes a message as a list of characters and reverses the order of the words in place. message = [ 'c', 'a', 'k', 'e', ' ', 'p', 'o', 'u', 'n', 'd', ' ', 's', 't', 'e', 'a', 'l' ] reverse_words(message) -> 'steal pound cake' ''' from typing import NoReturn def revers...
true