blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
bd3d80133d7780eaacc843d4f7f9a144a6a56802
testmywork77/WorkspaceAbhi
/Year 8/Concatenation_Practice.py
1,042
4.34375
4
name = "Abhinav" age = "11" fav_sport = "Cricket" fav_colour = "red" fav_animal = "lion" # Create the following sentences by using concatenation # Example: A sentence that says who he is and how old he is print("My name is " + name + " and I am " + age + " ,I like to play " + fav_sport) # NOTE: Don't forget about sp...
true
d1c7cadba59a9c79cf30df4167483821263c15e5
krishnaja625/CSPP-1-assignments
/m6/p3/digit_product.py
416
4.125
4
''' Given a number int_input, find the product of all the digits example: input: 123 output: 6 ''' def main(): ''' Read any number from the input, store it in variable int_input. ''' N3 = int(input()) N2 = N3 N = abs(N3) S = 0 K = 0 if N > 0: S = 1 while N > 0: N2 = N%10 S = S*N2 N = N//10...
true
065d5fda40b2c6f28f7736e946076f3b3d709f27
Santoshi321/PythonPractice
/ListExcercise.txt
1,866
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jul 8 15:06:30 2019 @author: sgandham """ abcd = ['nintendo','Spain', 1, 2, 3] print(abcd) # Ex1 - Select the third element of the list and print it abcd[2] # Ex2 - Type a nested list with the follwing list elements inside list abcd mentioned above...
true
3630cc5aeda264cc010df9809a3ef48d809b9cb3
myNameArnav/dsa-visualizer
/public/codes/que/que.py
1,771
4.25
4
# Python3 program for array implementation of queue INT_MIN = -32768 # Class Queue to represent a queue class Queue: # __init__ function def __init__(self, capacity): self.front = self.size = 0 self.rear = capacity - 1 self.array = [None]*capacity self.capacity = capacity ...
true
ed57a1ae2c3abd176cf440c00857b411899dd32e
myNameArnav/dsa-visualizer
/public/codes/dfs/dfs.py
1,868
4.28125
4
# Python3 program to implement DFS # This function adds an edge to the graph. # It is an undirected graph. So edges # are added for both the nodes. def addEdge(g, u, v): g[u].append(v) g[v].append(u) # This function does the Depth First Search def DFS_Visit(g, s): # Colour is gray as it is visited par...
true
d78d4b827bc6013444e4db630cd1261773a0bea8
Bcdirito/django_udemy_notes
/back_end_notes/python/level_two/object_oriented_notes/oop_part_two.py
791
4.53125
5
# Example class Dog(): # Class Object Attributes # Always go up top species = "Mammal" # initializing with attributes def __init__(self, breed, name): self.breed = breed self.name = name # can be done without mass assignment my_dog = Dog("German Shepherd", "Louis") # can be...
true
f4ddf222cd4c3d87ffee555eb23937de49298016
AshurMotlagh/CECS-174
/Lab 3.13.py
223
4.375
4
## # Print the first 3 letters of a string, followed by ..., followed by the last 3 letters of a string. ## word = input("Enter a word with longer than 8 letters: ") print("The new word is", word[0:3], "...", word[-3:])
true
5b52810c905e0213d4e30a36931640fe503e8f09
ivelinakaraivanova/SoftUniPythonFundamentals
/src/Lists_Advanced_Exercise/01_Which_Are_In.py
265
4.15625
4
first_list = input().split(", ") second_list = input().split(", ") result_list =[] for item in first_list: for item2 in second_list: if item in item2: if item not in result_list: result_list.append(item) print(result_list)
true
0b246053cbffe4fa6a52f10f5a0982052cdebf4f
azdrachak/CS212
/212/Unit2/HW2-2.py
1,564
4.125
4
#------------------ # User Instructions # # Hopper, Kay, Liskov, Perlis, and Ritchie live on # different floors of a five-floor apartment building. # # Hopper does not live on the top floor. # Kay does not live on the bottom floor. # Liskov does not live on either the top or the bottom floor. # Perlis lives on a h...
true
75fa0274e9cfd4193bb5d1730caf90b2b0c5b194
edagotti689/PYTHON-7-REGULAR-EXPRESSIONS
/1_match.py
508
4.15625
4
''' 1. Match is used to find a pattern from starting position ''' import re name = 'sriram' mo = re.match('sri', name) print(mo.group()) # matching through \w pattern name = 'sriram' mo = re.match('\w\w\w', name) print(mo.group()) # matching numbers through \d pattern name = 'sriram123' mo = re.match...
true
a59503d23f606bad8fc8ff6c68001e6ea1783431
Rd-Feng/holbertonschool-higher_level_programming
/0x0A-python-inheritance/1-my_list.py
257
4.125
4
#!/usr/bin/python3 """Define MyList that extends list""" class MyList(list): """add print_sorted instance method that prints the list in sorted order""" def print_sorted(self): """print list in sorted order""" print(sorted(self))
true
705cc760876474bc595a7244895ea27ecb875d76
shrirangmhalgi/Python-Bootcamp
/25. Iterators Generators/iterators.py
495
4.34375
4
# iterator is object which can be iterated upon An object which returns data, one at a time when next() is called on it name = "Shrirang" iterator = iter(name) print(next(iterator)) print(next(iterator)) print(next(iterator)) print(next(iterator)) print(next(iterator)) print(next(iterator)) print(next(iterator)) print...
true
2302ed436657bca98feffd12477b4294ba12313b
shrirangmhalgi/Python-Bootcamp
/8. Boolean Statements/conditional_statements.py
789
4.125
4
name = input("Enter a name:\n") if name == "shrirang": print("Hello Shrirang") elif name == "suvarna": print("Hello Suvarna") elif name == "rajendra": print("Hello Rajendra") else: print("Hello User") # truthiness and falsiness # (is) is used to evaluate truthiness and falsiness # falsiness includes #...
true
d81cadb1c01234f822fab833bc67f06b8c0cfa10
shrirangmhalgi/Python-Bootcamp
/20. Lambdas and Builtin Functions/builtin_functions.py
1,851
4.125
4
import sys # 1. all() returns true if ALL elements of iteratable are truthy print(all(list(range(10)))) print(all(list(range(1, 10)))) # 2. any() returns true if ANY of the element is truthy print(any(list(range(10)))) print(any(list(range(1, 10)))) # 3. sys.getsizeof print(sys.getsizeof([x % 2 == 0 for x in range(1...
true
713b3b42119f727b8e3bc59a09a6f0f27e748339
shrirangmhalgi/Python-Bootcamp
/12. Lists/lists.py
1,903
4.53125
5
# len() function can be used to find length of anything.. # lists start with [ and end with ] and are csv task = ["task 1", "task 2", "task 3"] print(len(task)) # prints the length of the list... list1 = list(range(1, 10)) # another way to define a list # accessing data in the lists # lists are accessed like arra...
true
4a9158546b978eb121262bb114def980bfbc2ca9
shrirangmhalgi/Python-Bootcamp
/30. File Handling/reading_file.py
528
4.1875
4
file = open("story.txt") print(file.read()) # After a file is read, the cursor is at the end... print(file.read()) # seek is used to manipulate the position of the cursor file.seek(0) # Move the cursor at the specific position print(file.readline()) # reads the first line of the file file.seek(0) print(file.readlines...
true
d7df6511316ed65740cca6f8570f152fad2637fe
chivitc1/python-turtle-learning
/turtle15.py
552
4.15625
4
""" animate1.py Animates the turtle using the ontimer function. """ from turtle import * def act(): """Move forward and turn a bit, forever.""" left(2) forward(2) ontimer(act, 1) def main(): """Start the timer with the move function. The user’s click exits the program.""" reset() sha...
true
1731be54e0a9905f6f751a97808931ce54e0bec0
chivitc1/python-turtle-learning
/menuitem_test.py
1,121
4.28125
4
""" menuitem_test.py A simple tester program for menu items. """ from turtle import * from menuitem import MenuItem from flag import Flag INDENT = 30 START_Y = 100 ITEM_SPACE = 30 menuClick = Flag() def changePenColor(c): """Changes the system turtle’s color to c.""" menuClick.value(True) color(c) def ...
true
4dfa7c1f1f9f51b838fcfb7e7d6c9f5f4fad2d42
chivitc1/python-turtle-learning
/turtle17.py
1,508
4.46875
4
""" testpoly.py Illustrates the use of begin_poly, end_poly, and get_poly to create custom turtle shapes. """ from turtle import * def regularPolygon(length, numSides): """Draws a regular polygon. Arguments: the length and number of sides.""" iterationAngle = 360 / numSides for count in range(numSides...
true
dab151fa8d3e2045bd5fab97d96c7ed1e1e9fe7f
MichaelTennyson/OOP
/lab3(practice).py
516
4.5
4
# The following program scrambles a string, leaving the first and last letter be # the user first inputs their string # the string is then turned into a list and is split apart # the list of characters are scrambled and concatenated import random print("this program wil take a word and will scramble it \n") ...
true
4e44b69e698e6f9435bc9e147b473398e8c794e1
DanielShin2/CP1404_practicals
/prac05/emails.py
624
4.1875
4
def name_from_email(email): username = email.split("@")[0] parts = username.split(".") name = " ".join(parts).title() return name def main(): email_name = {} email = input("Enter your email: ") while email != "": name = name_from_email(email) correct = input("Is your name {}...
true
7b7ae24c2bf54988394165e6c63c165a84472f0e
mrudulamucherla/Python-Class
/2nd assign/dec to binary,.py
510
4.25
4
# -*- coding: utf-8 -*- """ Created on Mon Mar 9 16:19:30 2020 @author: mrudula """ #write prgm to convert decimal to binary number sysytem using bitwise operator binary_num=list() decimal_num=int(input("enter number")) for i in range(0,8): shift=decimal_num>>i #code to check value of last bit and ...
true
d99c43ed6e3f8ff9cbd3ee31063216578a3702f5
mrudulamucherla/Python-Class
/While Loop,134.py
236
4.21875
4
# -*- coding: utf-8 -*- """ Created on Sat Mar 7 14:13:32 2020 @author: mrudula """ #Print all 3 multiples from 1 to 100 using for while loop. while True: for i in range (1,101): print(i*3,end=" ") break
true
4cf6cf7d66050a5a9a4f2ef8f7ad48b5f20d9dc3
lilbond/bitis
/day1/exploring.py
2,508
4.53125
5
""" Samples below are intended to get us started with Python. Did you notice this is a multi-line comment :-) and yes being the first one and before code, it qualifies to be documentation as well. How Cool!!! In order to be a docstring it had to be multi-line """ # print hello world :-), Hey this is a single line com...
true
ab4ad6fb7096a9276d614b2d0b4a97276f1c2512
cpucortexm/python_IT
/python_interacting _with_os/logfile/parse_log.py
1,985
4.3125
4
#!/usr/bin/env python3 import sys import os import re ''' The script parses the input log file and generates an output containing only relevant logs which the user can enter on command prompt ''' def error_search(log_file): error = input("What is the error? ") # input the error string which you want to see in th...
true
3802612e9ba51aaa8d3307e8ab39d413dc8b6d20
nguyntony/class
/large_exercises/large_fundamentals/guess2.py
1,553
4.21875
4
import random on = True attempts = 5 guess = None print("Let's play a guessing game!\nGuess a number 1 and 10.") while on: # correct = random.randint(1, 10) while True: try: guess = int(input()) break except ValueError: print("Please give a number!") ...
true
9148ba1063ba78923a760707e24d3f3e78a2fab1
nguyntony/class
/python101/strings.py
303
4.1875
4
# interpolation syntax first_name = "tony" last_name = "nguyen" print("hello %s %s, this is interpolation syntax" % (first_name, last_name)) # f string print(f"Hi my name is {first_name} {last_name}") # escape string, you use the back slash \ # \n, \t # concatenating is joining two things together
true
518a262e0db8dc3b9a9645f41f331ee79794dc54
nguyntony/class
/python102/dict/ex1_dict.py
458
4.21875
4
siblings = {} # for a list you can not create a new index but in a dictionary you can create a new key with the value at any time. siblings["name"] = "Misty" siblings["age"] = 15 siblings["fav_colors"] = ["pink", "yellow"] siblings["fav_colors"].append("blue") print(siblings) # loop # key for key in siblings: ...
true
aa4105b0f27729de85e91b4a106d25509b6a991d
nguyntony/class
/python102/list/ex3_list.py
1,185
4.375
4
# Using the code from exercise 2, prompt the user for which item the user thinks is the most interesting. Tell the user to use numbers to pick. (IE 0-3). # When the user has entered the value print out the selection that the user chose with some sort of pithy message associated with the choice. things = ["water bott...
true
280dde835bdd22c44a461955634526aa9bd57faa
cute3954/Solving-Foundations-of-Programming
/problem-solving-with-python/makeBricks.py
1,302
4.3125
4
# https://codingbat.com/prob/p183562 # # We want to make a row of bricks that is goal inches long. # We have a number of small bricks (1 inch each) and big bricks (5 inches each). # Return true if it is possible to make the goal by choosing from the given bricks. # This is a little harder than it looks and can be done ...
true
1226a6de159e071159a9aca6f00a4dd2483265ab
daveboat/interview_prep
/coding_practice/binary_tree/populating_next_right_pointers_in_each_node.py
2,486
4.125
4
""" LC116 - Populating Next Right Pointers in Each Node You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition: struct Node { int val; Node *left; Node *right; Node *next; } Populate each next pointer to point...
true
49dfa92d60ff280719607b50f9e5a6aa40f76e1e
daveboat/interview_prep
/coding_practice/general/robot_bounded_in_circle.py
2,663
4.15625
4
""" LC1041 - Robot bounded in circle On an infinite plane, a robot initially stands at (0, 0) and faces north. The robot can receive one of three instructions: "G": go straight 1 unit; "L": turn 90 degrees to the left; "R": turn 90 degress to the right. The robot performs the instructions given in order...
true
c38cc560308edabac42c87bec8252bc9f446e39c
momentum-cohort-2019-05/w2d2-palindrome-bhagh
/palindrome.py
577
4.25
4
import re #grab user input submission = input("Enter a word or sentence(s): ") #function to clean up text by user def cleantext (submission): submission = (re.sub("[^a-zA-Z0-9]+", '', submission).replace(" ","")) return submission print(cleantext(submission)) #create a string that's the reverse of the text ...
true
e74a0ce8b1b2301019f58e51ad1befacaf983a4c
sidmusale97/SE-Project
/Pricing Algorithm/linearRegression.py
1,113
4.28125
4
''' ------------------------------------------------------------------------------------ This function is used to compute the mean squared error of a given data set and also to find the gradient descent of the theta values and minimize the costfunction. ------------------------------------------------------------...
true
93226ba29c06e18e86531e1c7326ab89082d473c
SAbarber/python-exercises
/ex12.py
611
4.34375
4
#Write a Python class named Circle. Use the radius as a constructor. Create two methods which will compute the AREA and the PERIMETER of a circle. A = π r^2 (pi * r squared) Perimeter = 2πr class Circle: def area(self): return self.pi * self.radius ** 2 def __init__(self, pi, radius): self.pi = pi ...
true
1cca34bd53ba9d73f844dccf011526deb399cd18
darkbodhi/Some-python-homeworks
/divN.py
713
4.25
4
minimum = int(input("Please insert the minimal number: ")) maximum = int(input("Please insert the maximal number: ")) divisor = int(input("Please insert the number on which the first one will be divided: ")) x = minimum % divisor if divisor <= 0: raise Exception("An error has occurred. The divisor is not a natural ...
true
aa0c6a66944e2cef568c401bd7f55e55bca1cec6
anilkumar-satta-au7/attainu-anilkumar-satta-au7
/create_a_dictionary_from_a_string.py
430
4.21875
4
#3) Write a Python program to create a dictionary from a string. # Note: Track the count of the letters from the string. # Sample string : 'w3resource' # Expected output: {'3': 1, 's': 1, 'r': 2, 'u': 1, 'w': 1, 'c': 1, 'e': 2, 'o': 1} test_str = "w3resource" all_freq = {} for i in test_str: ...
true
01b0cf471c7e1a3d5ea42bd4e8ce2b44eaaba293
pyaephyokyaw15/credit-card-validation
/credit-card.py
1,811
4.28125
4
''' Credit-card Validation - This script is used to determine whether a certain credit-card is valid or not. - It is based on Luhn’s algorithm. - It also determines the type of Card(eg.MASTER, VISA, AMEX) ''' def main(): # getting number from user until it is numeric value while True: card = i...
true
a36d51210c4062391cca3a8218f990388fc20cca
jenihuang/hb_challenges
/EASY/lazy-lemmings/lemmings.py
942
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 >>> furthest(7, [0, 6]) 3 >>> furthest(3, [0, 1, 2])...
true
de62ef9fb09f2d10b0813bf727442cb6c282b546
jenihuang/hb_challenges
/EASY/replace-vowels/replacevowels.py
946
4.34375
4
"""Given list of chars, return a new copy, but with vowels replaced by '*'. For example:: >>> replace_vowels(['h', 'i']) ['h', '*'] >>> replace_vowels([]) [] >>> replace_vowels(['o', 'o', 'o']) ['*', '*', '*'] >>> replace_vowels(['z', 'z', 'z']) ['z', 'z', 'z'] Make sure to handle ...
true
6ce8b6c28e28ea4207d7bfbc95fb9ccc0d558602
jenihuang/hb_challenges
/MEDIUM/balanced-brackets/balancedbrackets.py
1,935
4.15625
4
"""Does a given string have balanced pairs of brackets? Given a string, return True or False depending on whether the string contains balanced (), {}, [], and/or <>. Many of the same test cases from Balance Parens apply to the expanded problem, with the caveat that they must check all types of brackets. These are fi...
true
29c4f36d8bfa47db7391311153a590deeb43216b
jenihuang/hb_challenges
/MEDIUM/maxpath/maxpath.py
2,844
4.125
4
"""Given a triangle of values, find highest-scoring path. For example:: 2 5 4 3 4 7 1 6 9 6 = [2,4,7,9] = 22 This works: >>> triangle = make_triangle([[2], [5, 4], [3, 4, 7], [1, 6, 9, 6]]) >>> triangle [2, 5, 4, 3, 4, 7, 1, 6, 9, 6] >>> maxpath(triangle) 22 """ class Node(...
true
9015d36d969ed1e22d46113064e94a3c26dc0043
jenihuang/hb_challenges
/EASY/rev-string/revstring.py
519
4.15625
4
"""Reverse a string. For example:: >>> rev_string("") '' >>> rev_string("a") 'a' >>> rev_string("porcupine") 'enipucrop' """ def rev_string(astring): """Return reverse of string. You may NOT use the reversed() function! """ rev_str = '' for i in range(len(astring)-1, ...
true
6fdb741e9ccd497a7f6a7ae00604072bbf178262
jenihuang/hb_challenges
/EASY/missing-number/missing.py
831
4.15625
4
"""Given a list of numbers 1...max_num, find which one is missing in a list.""" def missing_number(nums, max_num): """Given a list of numbers 1...max_num, find which one is missing. *nums*: list of numbers 1..[max_num]; exactly one digit will be missing. *max_num*: Largest potential number in list >...
true
de346421fd9bf36a0113d702ccf6de03620b8198
Johan-p/learnpythonShizzle
/exercise_36_birthdayplots.py
1,639
4.28125
4
""" In this exercise, use the bokeh Python library to plot a histogram of which months the scientists have birthdays in! """ print(__doc__) from bokeh.plotting import figure, show, output_file from collections import Counter import json def read_jsonfile(): #global birthday_dictionary global x global ...
true
713ed8035bf707c380e127bab4f0c6b36f6641ce
Johan-p/learnpythonShizzle
/Madlibs.py
1,517
4.46875
4
""" In this project, we'll use Python to write a Mad Libs word game! Mad Libs have short stories with blank spaces that a player can fill in. The result is usually funny (or strange). Mad Libs require: A short story with blank spaces (asking for different types of words). Words from the player to fill in those ...
true
8a8d89f72edd35ccb2928af5b147ad882899c6fe
Johan-p/learnpythonShizzle
/exercise_33_birthdaydictionaries.py
884
4.59375
5
""" or this exercise, we will keep track of when our friends birthdays are, and be able to find that information based on their name. Create a dictionary (in your file) of names and birthdays. When you run your program it should ask the user to enter a name, and return the birthday of that person back to them. ...
true
c816a4224eeff0e5610176feb5df8eacfe3efcfb
HarrisonWelch/MyHackerRankSolutions
/python/Nested Lists.py
496
4.25
4
# Nested Lists.py # Given the names and grades for each student in a Physics class of N students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade. marksheet = [] for _ in range(0,int(input())): marksheet.append([raw_input(), float(raw_input())]) second_highest =...
true
fc9d7761b45597c8d3efb6fd81f76f0c96d547b7
Lenux56/FromZeroToHero
/text_vowelfound.py
519
4.4375
4
''' Enter a string and the program counts the number of vowels in the text. For added complexity have it report a sum of each vowel found. ''' import re def multi_re_find(): ''' search and count vowels ''' phrase = input('Please, enter a phrase to find vowels and count it: ') while not phrase: ...
true
20e59d6494ba4c87140ccf88af9e846164ce0596
vikas-ukani/Hacktoberfest_2021
/Rock_Paper_Scissors.py
1,368
4.28125
4
import random print("Welcome to rock paper scissors game .....") print("You have three chances greater the wins in individual game will increase your chance to win") print("Press 0-->paper , 1-->rock , 2-->scissors") comp = 0 player = 0 for i in range(3): player_choice = input("Your turn") comp_choice=random.r...
true
3f7c545c8765583c918074b6c73f4114522a1d2b
emmanuelnaveen/decision-science
/date_format.py
292
4.3125
4
from datetime import date # Read the current date current_date = date.today() # Print the formatted date print("Today is :%d-%d-%d" % (current_date.day,current_date.month,current_date.year)) # Set the custom date custom_date = date(2021, 05, 20) print("The date is:",custom_date)
true
49c046a92870d3f128849c8ad0452ca7c71c75f1
SruthiM-10/5th-grade
/Programs/reverseName.py
275
4.21875
4
s=input("What is your first name?") f=input("What is your middle name if you have one? If you don't have a middle name, just type no") r=input("What is your last name?") if f=="no": print("Your name in reverse is",r,s) else: print("Your name in reverse is",r,f,s,)
true
513a9d0167adda155e9f267aab31db2b75f4e441
dulalsaurab/Graph-algorithm
/plot.py
418
4.1875
4
''' This file will plot 2-d and 3-d points''' import numpy as np import matplotlib.pyplot as plt # drawing lines between given points iteratively def draw_line(array): data = array # array should be of format [(),(),(),()] # 2D ploting using matplotlib def plot_2D(array, size): # array should be of format...
true
950fb0e048a560043577605d9642d69808f974da
Rohitha92/Python
/Sorting/BubbleSort.py
774
4.1875
4
#Bubble sort implementation #multiple passes throught the list. ##Ascending order def bubble_sort(arr): swapped = True while(swapped): swapped = False for i in range(len(arr)-1): if arr[i] > arr[i+1]: temp = arr[i] arr[i] = arr[i+1] arr[i+1]= temp swapped = Tr...
true
7216c73c1532bb08e436447f01903f98e7be6660
Rohitha92/Python
/StacksQueuesDeques/Queue.py
578
4.21875
4
#Implement Queue #First in First out #insert items at the First (zero index) #delete from first (zero index) class Queue(object): def __init__(self): self.items=[] def enqueue(self,val): #add to the rear self.items.insert(0,val) def size(self): return len(self.items) def isempty(self):...
true
7aeba56b0611f7db71a27daf3cb8f007273cdbc2
Shubhamditya36/python-pattern-programs
/a13.py
391
4.1875
4
# PROGRAM TO PRINT PATTERN GIVEN BELOW. # 1 # 2 1 2 # 3 2 1 2 3 # 4 3 2 1 2 3 4 # 5 4 3 2 1 2 3 4 5 num=int(input ("enter a number of rows:")) for row in range(1,num+1): for col in range(0,num-row+1): print(end=" ") for col in range(row,0,-1): print(col,end=" ") ...
true
6539173b858b23d1e0ce6daa4431edc7c0c8761b
svigstol/100-days-of-python
/days-in-a-month.py
1,522
4.21875
4
# 100 Days of Python # Day 10.2 - Days In A Month # Enter year and month as inputs. Then, display number of days in that month # for that year. # Sarah Vigstol # 5/31/21 def isLeap(year): """Determine whether or not a given year is a leap year.""" if year % 4 == 0: if year % 100 == 0: if ye...
true
02350014103279d5c3d072b18cae6a3e0798de75
teddyk251/alx-higher_level_programming-1
/0x07-python-test_driven_development/2-matrix_divided.py
1,289
4.28125
4
#!/usr/bin/python3 """ divides all elements of a matrix """ def matrix_divided(matrix, div): """ divides all elements of a matrix Args: matrix: matrix to be divided div: number used to divide Return: matrix with divided elements """ if not all(is...
true
758b8709a3d0133fa00beb506b662cb00bd51129
rkgitvinay/python-basic-tutorials
/3-control_flow.py
714
4.21875
4
""" Control Flow Statements """ """ uses an expression to evaluate whether a statement is True or False. If it is True, it executes what is inside the “if” statement. """ """ If Statement """ if True: print("Hello This is if statement!") """ Output: Hello This is if statement! """ if 5 > 2: print("5 is greate...
true
06e0b06b985e0ac48cfe3ecd6c1ca1de69334424
ybettan/ElectricalLabs
/electrical_lab_3/aws_experiment/part2/preliminary/q4.py
279
4.3125
4
grades = {"python": 99, "java": 90, "c": 90} grades_list = [x for _, x in grades.items()] max_grade = max(grades_list) min_grade = min(grades_list) print "My lowest grade this semester was {}".format(min_grade) print "My highest grade this semester was {}".format(max_grade)
true
2d11b7b1d939f6be364dc2394728fe2a21b99e95
Nduwal3/python-Basics
/function-Assignments/soln16.py
377
4.125
4
""" Write a Python program to square and cube every number in a given list of integers using Lambda. """ def calc_square_and_cube(input_list): square_list = map(lambda num: num * num, input_list) cube_list = map(lambda num: num ** 3, input_list) print(list(square_list)) print(list(cube_list)) sample...
true
f4fd513b8f8706e0339d7da3284b5f22364b5d04
Nduwal3/python-Basics
/soln43.py
374
4.25
4
""" Write a Python program to remove an item from a tuple. """ # since python tuples are immutable we cannot append or remove item from a tuple. # but we can achive it by converting the tuple into a list and again converting the list back to a tuple my_tuple = ('ram', 37, "ram@r.com") my_list = list(my_tuple) my_l...
true
10047fa0561ecf373381ce8abed48587402952b3
Nduwal3/python-Basics
/function-Assignments/soln7.py
825
4.21875
4
""" Write a Python function that accepts a string and calculate the number of upper case letters and lower case letters. Sample String : 'The quick Brow Fox' Expected Output : No. of Upper case characters : 3 No. of Lower case Characters : 12 """ def count_string_lower_and_upper_case(input_string): count_up...
true
4af30bc0c5fa913415ad507c23232f86a20fad8a
Nduwal3/python-Basics
/function-Assignments/soln9.py
591
4.15625
4
""" Write a Python function that takes a number as a parameter and check the number is prime or not. Note : A prime number (or a prime) is a natural number greater than 1 and that has no positive divisors other than 1 and itself. """ def check_prime(num): is_prime = False if num > 1: for i in range...
true
515a4847f1592a5d8329f075cf40506c63350f82
Nduwal3/python-Basics
/soln25.py
548
4.1875
4
""" Write a Python program to check whether all dictionaries in a list are empty or not. Sample list : [{},{},{}] Return value : True Sample list : [{1,2},{},{}] Return value : False """ def check_empty_dictionaries(sample_list): is_empty = False for item in sample_list: if item: is_...
true
fc5d4c5006f3c9217d58848447a4fd76382a4a72
GravityJack/keyed-merge
/keyed_merge/merge.py
880
4.1875
4
import functools import heapq def merge(*iterables, key=None): """ Merge multiple sorted iterables into a single sorted iterable. Requires each sequence in iterables be already sorted with key, or by value if key not present. :param iterables: Iterable objects to merge :param key: optional, callab...
true
7c918ccd80ec7fd3c45d8233a12a62bd423c7937
msflyee/Learn_python
/code/Chapter4_operations on a list.py
1,062
4.28125
4
# Chapter4-operations on a list magicians = ['Alice','David','Liuqian']; for magician in magicians: #define 'magician' print(magician + '\t'); for value in range(1,5): #define value print(value); numbers = list(range(1,6)); print(numbers); even_numbers = list(range(2,11,2)); #打印偶数,函数range()的第三个参数为 步数 print(...
true
30808f5fb665d31421e878ace60502afebf33836
ShaneRandell/Midterm_001
/midterm Part 4.py
867
4.1875
4
## Midterm Exam Part 4 import csv # imports the csv library file = open("book.csv", "a") # Opening a file called book.csv for appending title = input("enter a title: ") # asking the user to enter a title author = input("Enter author: ") # asking the user to enter a author year = input("Enter the year it wa...
true
065aff05e0876ed0cedeea555109f6147a9d3219
Venkatesh147/60-Python-projects
/60 Python projects/BMI Calculator.py
572
4.28125
4
Height=float(input("Enter your height in centimeters: ")) Weight=float(input("Enter your weight in kg: ")) Height=Height/100 BMI=Weight/(Height*Height) print("your Body Mass Index is: ", BMI) if(BMI>0): if (BMI<=16): print("you are severly underweight") elif (BMI<=18.5): ...
true
2b654bfaf67cefdbdff9a1b4b61d4d80af3da5ff
CodecoolBP20172/pbwp-3rd-si-code-comprehension-frnczdvd
/comprehension.py
1,948
4.34375
4
# This program picks a random number between 1-20 and the user has to guess it under 6 times import random # Import Python's built-in random function guessesTaken = 0 # Assign a variable to 0 print('Hello! What is your name?') # Display a given output message myName = input() # Ask for user input number = random.ran...
true
f97c7326e6be4786e1fda3a5c4a55c61aa6c6f3c
KLKln/Module11
/employee1.py
2,382
4.53125
5
""" Program: employee.py Author: Kelly Klein Last date modified: 7/4/2020 This program will create a class called employee allowing the user to access information about an employee """ import datetime class Employee: def __init__(self, lname, fname, address, phone, start_date, salary): """ use r...
true
6ba6176c13121443a781646914751b1430766e51
RaHuL342319/Integration-of-sqlite-with-python3
/query.py
813
4.375
4
import sqlite3 # to connect to an existing database. # If the database does not exist, # then it will be created and finally a database object will be returned. conn = sqlite3.connect('test.db') print("Opened database successfully") # SELECTING WHOLE TABLE cursor = conn.execute( "SELECT * from Movies") ...
true
ae3dfe81639e3c295061a8b173dde8303632fd41
holbertra/Python-fundamentals
/dictionary.py
1,201
4.3125
4
# Dictionaries # dict my_dictionary = { "key" : "value", "key2" : 78 } product = { "id" : 2345872425, "description": "A yellow submarone", "price" : 9.99, "weight" : 9001, "depart" : "grocery", "aisle" : 3, "shelf" : "B" } #print(product["price"...
true
27c43829d72a2e43b5ca4f1d6d54031bfdd10138
axayjha/algorithms
/diagonal_traverse.py
886
4.21875
4
""" https://leetcode.com/problems/diagonal-traverse/ Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image. Example: Input: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] Output: [1,2,4,7,5,3,6,8,9] Explanation: Note: The total...
true
edff4979701065d3a63aa5b1c7312a8389989d0b
shaduk/MOOCs
/UdacityCS101/app/days.py
1,144
4.34375
4
def nextDay(year, month, day): """Simple version: assume every month has 30 days""" if day < 30: return year, month, day + 1 else: if month == 12: return year + 1, 1, 1 else: return year, month + 1, 1 def daysBetweenDates(year1, month1, day1...
true
2aa27e73539e9ef7766fcf5ee480679d7b4fe2e2
shaduk/MOOCs
/edx-CS101/myLog.py
1,063
4.375
4
'''Write a simple procedure, myLog(x, b), that computes the logarithm of a number x relative to a base b. For example, if x = 16 and b = 2, then the result is 4 - because 24=16. If x = 15 and b = 3, then the result is 2 - because 32 is the largest power of 3 less than 15. In other words, myLog should return the larges...
true
41411ad71ab27f75e0771dbadac75de58b9bb3dc
sol83/python-simple_programs_7
/Lists/get_first.py
467
4.34375
4
""" Get first element Fill out the function get_first_element(lst) which takes in a list lst as a parameter and prints the first element in the list. The list is guaranteed to be non-empty. You can change the items in the SAMPLE_LIST list to test your code! """ SAMPLE_LIST = [1, 2, 3, 'a', 'b', 'c'] def get_first_e...
true
5298e43d2497174ebf8477e9adede2f9c008fc67
TSG405/SOLO_LEARN
/PYTHON-3 (CORE)/Fibonacci.py
659
4.21875
4
''' @Coded by TSG, 2021 Problem: The Fibonacci sequence is one of the most famous formulas in mathematics. Each number in the sequence is the sum of the two numbers that precede it. For example, here is the Fibonacci sequence for 10 numbers, starting from 0: 0,1,1,2,3,5,8,13,21,34. Write a program to take N (variab...
true
6dd541d14a70d5d0654da10db9074c0999507725
kumarritik87/Python-Codes
/factorial.py
217
4.21875
4
#program to find factorial of given number using while loop:- n = int(input("Enter the no to find factorial\n")) temp = n f = 1 while(temp>0): f = f*temp temp = temp-1 print('factorial of ',n,'is', f)
true
de6c458f37b0512d53d4f87baa84115af4cc235c
infinitumodu/CPU-temps
/tableMaker.py
1,787
4.21875
4
#! /usr/bin/env python3 def makeXtable(data): """ Notes: This function takes the data set and returns a list of times Args: data: a list with each element containing a time and a list of the core tempatures at that time Yields: a list of times """ xTable = [] ...
true
d8275b0bbc9be8dbf86bd2657ab2a7c4e3768c02
jack-alexander-ie/data-structures-algos
/Topics/3. Basic Algorithms/1. Basic Algorithms/binary_search_first_last_indexes.py
2,635
4.125
4
def recursive_binary_search(target, source, left=0): if len(source) == 0: return None center = (len(source)-1) // 2 if source[center] == target: return center + left elif source[center] < target: return recursive_binary_search(target, source[center+1:], left+center+1) el...
true
d2fdddb9967037869d65f92edf0a93c4a1717c6f
jack-alexander-ie/data-structures-algos
/Topics/2. Data Structures/Recursion/recursion.py
2,728
4.6875
5
def sum_integers(n): """ Each function waits on the function it called to complete. e.g. sum_integers(5) The function sum_integers(1) will return 1, then feedback: sum_integers(2) returns 2 + 1 sum_integers(3) returns 3 + 3 sum_integers(4) returns 4 ...
true
92d1e98c5ee646d5d8e9811c609af686208cb983
abhijitmk/Rock-paper-scissors-spock-lizard-game
/rock paper scissors spock lizard game.py
2,191
4.1875
4
# Rock-paper-scissors-lizard-Spock template # The key idea of this program is to equate the strings # "rock", "paper", "scissors", "lizard", "Spock" to numbers # as follows: # # 0 - rock # 1 - Spock # 2 - paper # 3 - lizard # 4 - scissors import random # helper functions def name_to_number(name): if(name==...
true
0a3caa0649b0442ab39a9d4baebce376191a4767
jeevan-221710/AIML2020
/1-06-2020assignment.py
994
4.15625
4
#password picker import string from random import * print("Welcome password Picker!!!!") adj = ["Excellet","Very Good","Good","Bad","Poor"] noun = ["jeevan","sai","narra","anaconda","jupyter"] digits = string.digits spl_char = string.punctuation Welcome password Picker!!!! while True: password = choice(adj) + choic...
true
f820b900bce0f1a3de25fca50a91cf8a8a23eab9
MLameg/computeCones
/computeCones.py
811
4.375
4
import math print("This program calculates the surface area and volume of a cone.") r = float(input("Enter the radius of the cone (in feet): ")) h = float(input("Enter the height of the cone (in feet): ")) print("The numbers you entered have been rounded to 2 decimal digits.\nRadius = " +str(round(r,2))+ "...
true
4b69f0783a133a08f34e2dc0a1190df3340dc0f1
Tha-Ohis/demo_virtual
/Functions/Using Funcs to guess highest number.py
400
4.15625
4
def highest_number(first, second, third): if first > second and first > third: print(f"{first}is the highest number") elif second > first and second > third: print(f"{second} is the highest number") elif third > first and third > second: print(f"{third} is the highest number") e...
true
81634c60ec9ab4a5d9c75c7de1eada0e8ec45865
Tha-Ohis/demo_virtual
/Program that checks the hrs worked in a day and displays the wage.py
631
4.25
4
# #Write a program that accepts the name, hours worked a day, and displays the wage of the person name=input("Enter your Name: ") hrs=float(input("Enter the No of Hours Worked in a day: ")) rate=20*hrs wage=(f"You've earned {rate}$") print(wage) # #Write a program that takes in the sides of a rectangle and displays it...
true
a0b3d022d89f844f0c0c0e577a64b17b64518869
xvrlad/Python-Stuff
/Lab01A - Q10.py
294
4.125
4
prompt = "Enter a word: " string = input(prompt) letter_list = list(string) letter_list.sort() new_dict = {} for letters in letter_list: if letters not in new_dict: new_dict[letters] = ord(letters) for letters, asciis in new_dict.items(): print("{}:{}".format(letters,asciis))
true
72f6ecdabe68de3f216b47c50f029dbb20d634cb
KrisNguyen135/PythonSecurityEC
/PythonRefresher/01-control-flow/loops.py
829
4.5625
5
#%% While loops check for the conditions at each step. x = 1 while x < 10: print(x) x += 1 print('Loop finished.') #%% For loops are used to iterate through a sequence of elements. a = [1, 2, 3] for item in a: print(item) print() #%% range(n) returns an iterator from 0 to (n - 1). for index in range(len(a...
true
d36fe85647e5b761c392d510b0227c48a40b6d38
faryar48/practice_bradfield
/python-practice/learn_python_the_hard_way/ex08.py
2,230
4.5
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 first word after popping it off.""" word = words.pop(0) print ...
true
c119cf284f9e9afe49e906b8f4b1ff771eee66c9
ddh/codewars
/python/range_extraction.py
1,817
4.625
5
""" A format for expressing an ordered list of integers is to use a comma separated list of either individual integers or a range of integers denoted by the starting integer separated from the end integer in the range by a dash, '-'. The range includes all integers in the interval including both endpoints. It is not c...
true
14390a2ae3b6ad53a988c321de9df62ad7110e00
ddh/codewars
/python/basic_mathematical_operations.py
1,478
4.34375
4
""" Your task is to create a function that does four basic mathematical operations. The function should take three arguments - operation(string/char), value1(number), value2(number). The function should return result of numbers after applying the chosen operation. Examples basic_op('+', 4, 7) # Output: 11 bas...
true
160c7cb9ab9719c4d0573ce90bb4c9e70ba1ca9b
junyechen/PAT-Advanced-Level-Practice
/1108 Finding Average.py
2,573
4.34375
4
""" The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be legal. A legal input is a real number in [−1000,1000] and is accurate up to no more than 2 decimal places. When you calculate the average, those i...
true
7ac060f0eaedadd5c18d3dce33afa776639f45f2
TranD2020/Backup
/lists.py
1,315
4.34375
4
# Make a list myClasses = ["Algebra", "English", "World History"] print(myClasses) # add an item to the list # append or insert # append will add to the back of the list myClasses.append("Coding") print(myClasses) favClass = input("What is your favorite class? ") myClasses.append(favClass) print(myClasses)...
true
aa5d7c78bc0e77b5ad660b713b65b918ae20707d
TranD2020/Backup
/practice3.py
393
4.375
4
print("Hello, this is the Custom Calendar.") day = input("What is today(monday/tuesday/wednesday/thursday/friday/saturday/sunday): ") if day == "monday": print("It's Monday, the weekend is over") elif day == "friday": print("It's Friday, the weekend is close") elif day == "saturday" or "sunday": print("It...
true
a795152079fe503c87516ab5b753c0c33c504c73
gouri21/c97
/c97.py
491
4.25
4
import random print("number guessing game") number = random.randint(1,9) chances = 0 print("guess a number between 1 and 9") while chances<5: guess = int(input("enter your guess")) if guess == number: print("congratulations you won!") break elif guess<number: print("guess a number hi...
true
e0883ed37e79623f17ea2eaae85cc49b05e012ea
BigPPython/Name
/name.py
1,110
4.125
4
# Code: 1 # Create a program that takes a string name input, # and prints the name right after. # Make sure to include a salutation. import sys a = '''********************************** *WHAT IS YOUR SEXUAL ORIENTATION?* *TYPE * *M FOR MALE * *F FOR FEMALE ...
true
5cf92bdd9fbd1820297c63dcb370a5d7b3bb1129
SKosztolanyi/Python-exercises
/11_For loop simple universal form.py
345
4.25
4
greeting = 'Hello!' count = 0 # This is universal python for loop function form # The "letter" is <identifier> and "greeting" is <sequence> # the "in" is crucial. "letter" can be changed for any word and the function still works for letter in greeting: count += 1 if count % 2 == 0: print letter p...
true
11cea43282d93c8ff11abe1bd833275be18744c6
SKosztolanyi/Python-exercises
/88_Tuples_basics.py
1,136
4.6875
5
# Tuples are non-changable lists, we can iterate through them # Tuples are immutable, but lists are mutable. # String is also immutable - once created, it's content cannot be changed # We cannot sort, append or reverse a tuple # We can only count or index a tuple # The main advantage of a tuple is, they are more effic...
true
d0fc126abdd1251d5c7555870ec36b49798c8936
SKosztolanyi/Python-exercises
/33_Defining factorials functions iterativela and recursively.py
374
4.15625
4
# Recursive and iterative versions of factorial function def factI(n): ''' Iterative way assume that n is an int>0, returns n! ''' res = 1 while n >1: res = res*n n-=1 return res def factR(n): ''' Recursive way assume that n is an int>0, returns n! ''' ...
true