blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
c820a8e1c9d53f94054205ccd56514df45e95322
Eric-Xie98/CrashCoursePython
/CrashCoursePython/Chapter 8/PassingRandom.py
2,246
4.84375
5
## Sometimes we don't know how many arguments we're going to pass into the function, so Python let's use the * ## and create a tuple that takes in arguments: def make_pizza(*toppings): for topping in toppings: print(topping) ## No matter how many arguments are given, Python treats them the same and pack...
true
fe6c2bc5f7c1e6bfed845a6ca016675fc6c0246a
Eric-Xie98/CrashCoursePython
/CrashCoursePython/Chapter 10/writingFile.py
2,196
4.5625
5
## One of the simplest ways to save data is to write to a file. Even after the program is closed, you can ## still look at the output file in its stored location as well as share it to others. You can also ## write programs that read it back into memory and work with it again later. # To write in a file, we use the op...
true
456d3ff0b114ec6d98f6e3a3628d786a2b36a17e
Eric-Xie98/CrashCoursePython
/CrashCoursePython/Chapter 4/Looping.py
1,525
4.59375
5
## Rather than individually index each element in a list, we can utilize a for loop: numbers = ["1", '2', '3', '4'] for number in numbers: print("I'm on number " + number) print("\n") names = ['Eric', 'Max', 'Bryan', 'Allinn', 'Nate', 'Edwin'] for i in range(0, 3): print("Wow, " + names[i] + " that was a g...
true
e480d9ce1b35de66f0393131ef8befc18dc99dc9
Eric-Xie98/CrashCoursePython
/CrashCoursePython/Chapter 7/whileLists.py
2,851
4.46875
4
## While loops can be used with lists and dictionaries and allows for modification while traversing them ## We can move items in one list to another using a while loop: unconfirmed_users = ['eric', 'max', 'allinn'] confirmed_users = [] while unconfirmed_users: current = unconfirmed_users.pop() print("Verifyi...
true
cacecdc7e6b9ccb7efe90f953200e0cb59ec2d8e
csumithra/pythonUtils
/03_generate_dict.py
457
4.21875
4
#With a given integral number n, write a program to generate a dictionary that contains (i, i x i) such that is an integral number # between 1 and n (both included). and then the program should print the dictionary. # Suppose the following input is supplied to the program: 8 #Then, the output should be: #{1: 1, 2: 4,...
true
ee945e5b0086fee77ce3b3d30443758ddd06c3e3
csumithra/pythonUtils
/23_24_sqaure_number.py
246
4.15625
4
#Write a method which can calculate square value of number def square_num(num): ''' Returns the square value of the input number. ''' return num ** 2 print(square_num.__doc__) print(square_num(int(input('Enter a number: '))))
true
65640293c12bcfc29e9286d84e48502afaf8a9d8
csumithra/pythonUtils
/18_CheckPassword_validity.py
1,091
4.1875
4
# Following are the criteria for checking the password: # At least 1 letter between [a-z] # At least 1 number between [0-9] # At least 1 letter between [A-Z] # At least 1 character from [$#@] # Minimum length of transaction password: 6 # Maximum length of transaction password: 12 # Your program should accept a sequenc...
true
cfe9703339f8e79ca07db80d9cb713aff1def06d
enzosison/lab0.1
/lab-0-enzosison-master/planets.py
439
4.1875
4
# float string -> float # Given earth weight and planet, returns weight on provided planet def weight_on_planets(pounds, planet): # write your code here return 0.0 if __name__ == '__main__': pounds = float(input("What do you weigh on earth? ")) print("\nOn Mars you would weigh", weight_on_planets(p...
true
c1b8c156121f86fdf828f400df08ae45d3e8dd56
nelliher/IS51Test2
/test_2.py
1,466
4.15625
4
""" This program will display the class exam averages based on the total number of grades. The first calculation will display the number of grades. The second calculation will display the average of the total grades. The third calculation will display the total percentage of the grades abover average. There will be t...
true
96ec75d796df27044f683ff8b16a0d53b86c74b5
hkmangla/ML_mini_projects
/quiz.py
908
4.25
4
"""Count words.""" def count_words(s, n): """Return the n most frequently occuring words in s.""" # TODO: Count the number of occurences of each word in s l = s.split(); occurrenceList = {} for i in l: if i in occurrenceList.keys(): occurrenceList[i] += 1 else: ...
true
01e06eb1c3001bddefaa09ced8952b3bb17c6b8d
SCollinA/python104
/square2.py
901
4.34375
4
# Ask user for length of square. Print square using one * character per unit length of square. BAD_INPUT = True # set flag for asking for user input ERROR_MESSAGE = "Bad user input." # message if bad input received while BAD_INPUT: # continue to ask for input until is is int try: # prompt user for size of square ...
true
53266a0ba7e13ea1c9ffe3cb4af43cec27cb8be5
SCollinA/python104
/square.py
416
4.15625
4
# Print a 5x5 square of * characters row_counter = 5 # number of rows while row_counter > 0: # loop through all rows col_counter = 5 # number of columns while col_counter > 0: # loop through all cols print('*', end='') # print one * per col without starting new line col_counter -= 1 # decremen...
true
5850c4b0d8dfc977e0b94d88313474deafaa4241
chigginss/HackerRank
/cracking_the_coding_interview/python_solutions.py
490
4.3125
4
# Cracking the Coding Interview Problems from HackerRank """ 1) Array Left Rotation A left rotation operation on an array shifts each of the array's elements 1 unit to the left. For example, if 2 left rotations are performed on array [1,2,3,4,5] then the array would become [3,4,5,1,2]. Given an array a of n intege...
true
0af7622fa9152a670732e2e36931070ec8640447
Bichwaa/xtractor
/xtractor/xtractor/extractor.py
1,032
4.125
4
''' This module contains functions which get the text content of an xml file, strips it of its xml tags and returns what is left. the get_text function can also parse text from ordinary text files (format txt) and html files. ''' import re, fire def get_text(enc='utf-8', filepath=None): """returns...
true
90c3f5756220e27d6ed387d351a987a7de3d006a
vvveracruz/ossu
/mit-intro-to-cs/ps0/ps0.py
434
4.21875
4
# Write a program that does the following in order: # 1. Asks the user to enter a number “x” # 2. Asks the user to enter a number “y” # 3. Prints out number “x”, raised to the power “y”. # 4. Prints out the log (base 2) of “x”. import numpy as np x = float( input( ' Enter a number x: ' ) ) y = float( input( ' Enter...
true
c9f3079ae8a217c5a860e446bae77d285b09f343
sohailshaikh1432/BasicPrograms
/FactorialFind.py
342
4.21875
4
def main(): # declaring vairiables input = userInput fact = 1 #!For loop to find factorial of given input for i in range(1, input+1): fact= fact*i print("Factorial of ", input ," is :", fact) if __name__ == "__main__": # Taking input from the user userInput = int(input("Enter n...
true
3826627ba652855ef9b4266e245487d6bbfae012
97joseph/Digital-Intelligence-2
/hw2problem2.py
2,813
4.1875
4
# PUT YOUR NAME HERE # PUT YOUR SBU ID NUMBER HERE # PUT YOUR NETID (BLACKBOARD USERNAME) HERE # # IAE 101 (Fall 2021) # HW 2, Problem 2 def frequency(c, s): # ADD YOUR CODE HERE return -1 # CHANGE OR REMOVE THIS LINE # 1. First, count the number of times that c appears in s. c_occ = 0 for ch in ...
true
78368a525bcf610efa7f1d09ddf571bc89074fa1
Shwetapatil05/new-python
/control_flow_statements/for_loop.py
1,198
4.21875
4
#------------------------------------------------------- #Description : for loop #syntax : # for item in items: # statements; #About : Iterates over single character of a string #------------------------------------------------------- player = 'sudeep'; print("------------Iterating over a String-...
true
b45b49e7fa5d900b3bd741393e6cd48cc6f05813
countvajhula/composer
/composer/timeperiod/utils.py
710
4.21875
4
from datetime import timedelta def get_next_day(date): """Given a date, return the next day by consulting the python date module :param :class:`datetime.date` date: The date to increment :returns :class:`datetime.date`: The next date """ next_day = date + timedelta(days=1) return next_day...
true
8e47468aeab29400f67729f5d8908eb4c23e22f7
Itz-Cook1e/College-Mailbox-File
/main.py
1,036
4.25
4
# Assignment: # Write a program to prompt the user to provide a file name # (use the file that is provided, mbox-short.txt) read through the file, and print the first 50 characters of each line that begins with 'Subject' # (line by line). Lastly, provide a count of the number of these lines. # Your program should incl...
true
55982d0837bb9a8288fb9261c5ea7f00690f1327
PROxZIMA/Python-Projects
/User_Packages/amult.py
236
4.125
4
def mult(): L=[] b=1 num=int(input("Enter how many numbers you are multiplying : ")) for i in range(num): n=float(input("Enter the numbers : ")) L.append(n) b=b*n print('Multiplication of the numbers is =',b)
true
ce3d1049e7150520a9695f3343e19ff00918d3ec
vinhlee95/oop-python
/instance_class_static_methods/main.py
1,663
4.375
4
from typing import List class MyClass: foo = "bar" def method(self): """ Instance method could be invoked only from a class instance It could modify the instance's propery, but not the class itself """ return f"instance method called. foo is {self.foo}" @classmethod def classmethod(cls): """ Class...
true
df816e3e75ebdaf4d9a723b4f95586363fae2151
StoopDJ/Second_Year_College
/Python/Overloading.py
2,021
4.46875
4
# Function: # 1. Write a class to represent an Item - each item has name, price and quantity. # Include a method to calculate total price. Test your class by creating few Item objects. # 2. Write a class to represent a complex number. # Complex numbers can be written in the form of a+bi where a and b are real numbe...
true
171955d3878d5b80117e1ad0e116814933795550
ssarber/PythonClass
/algorithms/reverse_array.py
856
4.3125
4
# Task # Given an array, A , of N integers, print A's elements in reverse order as a single line of space-separated numbers. # Input Format # The first line contains an integer, N (the size of our array). # The second line contains space-separated integers describing array A's elements. # Output Format # Print t...
true
36a8a44107be97f1470f0d15dfc0dd886b1b3379
gladystyn/MCQ_biology_revision_program
/app.py
2,740
4.25
4
print("Title of program: MCQ biology revision program") print() counter = 0 score = 0 total_num_of_qn = 3 counter +=1 tracker = 0 while tracker !=1: print("Q"+str(counter)+") "+ "What does the liver produce?") print(" a) Salivary amylase") print(" b) Pancreatic amylase") print(" c) Bile") print("...
true
05de78717af1e3c22bf978c5593410db9850883c
pujalb/100-days-of-python
/Day-08-Function-Parameters-&-Caesar-Cipher/Interactive Coding Exercise - Day 8.2 Prime Number Checker/main.py
726
4.21875
4
#Write your code below this line 👇 from math import sqrt, ceil def prime_checker(number): # Ceck if number is greater than 1 if number < 2: print("It's not a prime number.") return # Instead of checking all numbers from 0 to number, just check from 0 to square root of the number last_...
true
5d9f5f14d35c6ea272b6df47ccbab10b72a9a3c5
sharder996/hacker-hell
/leetcode/python3/[208]_implement-trie-prefix-tree.py
1,640
4.1875
4
# # @lc app=leetcode id=208 lang=python3 # # [208] Implement Trie (Prefix Tree) # # @lc code=start class TrieNode: def __init__(self, val: set, next): self.val = val self.next = next self.terminal = False class Trie: ''' Accepted 15/15 cases passed (176 ms) Your runtime beats 65.22 % of python3 ...
true
7d9917a5b0e25d38d509e0f8fda62700203cefad
gmolinsm/PythonP2
/Exceptions/main.py
438
4.21875
4
# A simple example in how to catch exceptions try: num = input("Give me a number: ") num = int(num) num2 = input("Give me another number: ") num2 = int(num2) result = num / num2 except ValueError: print("Please give me a proper number") except ZeroDivisionError: print("The second number can...
true
a6c3fae7387c6ebe7a2593a0f5a55f6b445df0ca
rybakovas/Python
/Python/basic/if_statement_comparison.py
390
4.125
4
def max_num(num1, num2, num3): if num1 >= num2 and num1 >= num3: print("Number " + str(num1) + " is the bigger") elif num2 >= num1 and num2 >= num3: print("Number " + str(num2) + " is the bigger") else: print("Number " + str(num3) + " is the bigger") max_num(300, 400, 5) # == equa...
true
0834c5ba0b3caa6836d6ad1e26eb9da989fac8bc
santokalayil/my_python_programs
/name_age_turning_100.py
1,356
4.15625
4
# Creator : Santo K. Thomas '''Program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old.''' import datetime now = datetime.datetime.now() this_year = now.year name = str(input('Enter Your Name?')) while True: ...
true
0e16eeb99d2583a8bc229813196f9d976b674ac9
michaelwise12/cmpt120wise
/bankaccount.py
1,310
4.15625
4
# bankaccount.py class BankAccount: """Bank Account protected by a pin number.""" def __init__(self, pin): """Initial account balance is 0 and pin is 'pin'.""" self.balance = 0 print("Welcome to your bank account!") self.pin = pin def deposit(self, pin, amount):...
true
7249e01fd01776deca989d0ac449bc9021f147b7
Amarmuddana/python-training
/Day9/day9.py
1,236
4.25
4
#How to create a dictionary # empty dictionary my_dict = {} # dictionary with integer keys my_dict = {1: 'text1', 2: 'text2'} # dictionary with mixed keys my_dict = {'name': 'ram', 1: [2, 4, 3]} # using dict() my_dict = dict({1:'apple', 2:'ball'}) # from sequence having each item as a pair my_dict = d...
true
242954fda3a7a3e112413a3dac56c9e42534867f
Ronak912/Programming_Fun
/Array/LargetSumContiguousSubArray.py
634
4.15625
4
# https://www.geeksforgeeks.org/largest-sum-contiguous-subarray/ # Write an efficient program to find the sum of contiguous subarray within a one-dimensional array of numbers # which has the largest sum. # ex: lst = [-2, -3, 4, -1, -2, 1, 5, -3] # Answer: Maximum sum is for subarray [4, -1, -2, 1, 5] = 7 def getMax...
true
45291fb16c1e03a09bdba50879e6df0cc4ee93a4
Ronak912/Programming_Fun
/String/GroupWordsWithSameSetChar.py
1,454
4.40625
4
# http://www.geeksforgeeks.org/print-words-together-set-characters/ """Group words with same set of characters Given a list of words with lower cases. Implement a function to find all Words that have the same unique character set . Example: Input: words[] = { "may", "student", "students", "dog", "st...
true
f0c815fa098139a73e9f53b7f7e1c57d407d0e05
Ronak912/Programming_Fun
/String/LongestSubsequenceWithAtleastKTimes.py
1,022
4.15625
4
# https://www.geeksforgeeks.org/longest-subsequence-where-every-character-appears-at-least-k-times/ ''' Method 1 (Brute force) We generate all subsequences (check file GetAllSubString.py). For every subsequence count distinct characters in it and find the longest subsequence where every character appears at-least k tim...
true
454d52168a772d064bde8aea9ea92381c30cb877
Ronak912/Programming_Fun
/hashmap/FindItinerary.py
1,135
4.46875
4
# http://www.geeksforgeeks.org/find-itinerary-from-a-given-list-of-tickets/ # # Find Itinerary from a given list of tickets # Given a list of tickets, find itinerary in order using the given list. # # Example: # # Input: # "Chennai" -> "Banglore" # "Bombay" -> "Delhi" # "Goa" -> "Chennai" # "Delhi" -> "Goa" # # Out...
true
cd903b6bda471945b827c95f743e0221a18770f7
Ronak912/Programming_Fun
/LinkedList/printReverseLinkedListUsingRecursive.py
492
4.40625
4
# http://www.geeksforgeeks.org/write-a-recursive-function-to-print-reverse-of-a-linked-list/ # Write a recursive function to print reverse of a Linked List import LinkedList def printReverseRecur(node): if node is None: return printReverseRecur(node.next) print node.data, if __name__ == "__ma...
true
bbc4aaf7932b8895de06fdf899830298f7e5448c
shashank2123/Regular_Expression-_python
/phone_number_matching_using_re.py
418
4.46875
4
#import regular expression mofule import re pattern='\d\d\d-\d\d\d-\d\d\d\d' #if you want to give the different pattern uncomment below statement #pattern=input('Enter the pattern :') #give the text in which you have to extract the phone number message=input("drop ur message :") phone_re=re.findall(p...
true
dee1afdec993b3af139fa6d4704a615a66297ab7
mohd-tanveer/PythonAdvance
/lecture22Assertion.py
987
4.375
4
#lecture22 #Assertions: '''-------------------------- assertion is use for DeBugging Purpose as an alternative of Print statements, if we are using print statement that should be remove after fixing the problem how ver aseert is not need to be executed based on choice we can enabled or disable the assertion state...
true
127ea617de37032cdd252d0759d5c45ebe480f0f
jessica-younker/Python-Exercises
/exercises/tuples/zoo.py
1,008
4.6875
5
# Create a tuple named zoo that contains your favorite animals. # Find one of your animals using the .index(value) method on the tuple. # Determine if an animal is in your tuple by using for value in tuple. # Create a variable for each of the animals in your tuple with this cool feature of Python. # # example # (li...
true
5893204d4d87c6cea3769ad555a678e2fb988213
eduhmc/CS61A
/Teoria/Class Code/Lecture 2.py
1,252
4.4375
4
# python DEMO1: "Names, Assignment, and User-Defined Functions" pi from math import pi pi * 71 / 223 from math import sin sin sin(pi/2) # Assignment radius = 10 radius 2 * radius area, circ = pi * radius * radius, 2 * pi * radius area circ radius = 20 # Function values max max(3, 4) f = max f max f(3, 4) max = 7 f(3,...
true
677c7c2fdfeec2f5a49312b26561c267b63e009e
boconlonton/python-deep-dive
/part-2/2-iterators/2-iterator.py
1,656
4.40625
4
""" An object is called Iterator if it implement the following methods: - __iter__(): return the object itself - __next__(): return the next item or raise StopIteration Issues: - Exhaustion problems! """ class Squares: def __init__(self, length): self.length = length self.i = 0 d...
true
16dcb28955930caff5c78e1ac0b847619574e83a
boconlonton/python-deep-dive
/part-2/3-generators/3-making_an_iterable_from_generator.py
476
4.15625
4
"""Making an Iterable from a Generator""" class Squares: """An iterable that return square result""" def __init__(self, n): self._n = n def __iter__(self): """Iterable Protocol""" return Squares.squares_gen(self._n) @staticmethod def squares_gen(n): """A generato...
true
b21a9b070f78dd7d934e65cd3bfe17b87e863078
khalid-joomun/GuessTheNumber-game
/NumberGuessing/NumberGuessing.py
980
4.34375
4
# Number guessing game a.k.a HiLo # The player enters a number. The program says whether the number to be guessed # is higher or lower than the user's guess. # This continues until the player guesses the right number import random number = random.randint(-100, 100) attempt = 1 guess = 101 while (guess != number): ...
true
49cb24a5d6d8e5ea0741bc387e22f28a5e7917b3
dmccuk/python
/lists.py
2,170
4.15625
4
my_list1 = [1,2,3,4] print(my_list1) print(type(my_list1)) list1 = ["Dennis",3.4,5.6,"Lists are Flexible",14] print(list1) list2 = [1,2,3,4,5,6,7,8,9,0,0,0,5] print(len(list2)) my_list3 = list("Hello World!") print(my_list3) my_list = [1,2,3,4,5,"a","b",3.14] print(my_list) print(my_list[0]) print(my_list[2]) pri...
true
1716b42edbcbd4eabb3111947f27abd9a9d632a3
ruzguz/python-stuff
/4-functions/test.py
537
4.21875
4
# -*- coding:utf8 -*- import turtle # Is called when the program start def main(): window = turtle.Screen() dave = turtle.Turtle() # draw square draw_square(dave) turtle.mainloop() # Fundtion to draw a square def draw_square(t): lenght = int(input('square size: ')) for i in r...
true
09a889f867f388761c051331a443e5dbd97460e2
brisa123/python_practice_programs
/fizzbuzz.py
341
4.1875
4
import os #if number divisible by 3, print fizz, if divisible by 5, print buzz, if divisible by both, print fizzbuzz,else print num for num in range(1,100): if (num%3==0 and num%5==0): print("fizzbuzz") elif(num%3==0): print("fizz") elif(num%5==0): print("buzz") else...
true
57a086a2350cddbf305407d94b21a0e1f6ddb91b
kranthikiranm67/Second_Assignment
/02_flip_123.py
1,164
4.3125
4
""" You are given an integer n consisting of digits 1, 2 and 3 and you can flip one digit to a 3. Return the maximum number you can make. Example 1 Input n = 123 Output 323 Explanation We flip 1 to 3 Example 2 Input n = 333 Output 333 Explanation Flipping doesn't help. """ import unittest # Implement the belo...
true
b49a990f2050f7e369c9adece857d7da2682e66c
raysomnath/Python-Basics
/Class__str__repr__init__private_protected_public/public_protected_private_attributes.py
2,516
4.3125
4
# There are two ways to restrict the access to class attributes: # First, we can prefix an attribute name with a leading underscore "_". # This marks the attribute as protected. It tells users of the class not to use this attribute unless, somebody writes a subclass # Second, we can prefix an attribute name with two le...
true
44c75ce287e91308b7d15f743aef0b9fc7c7d919
raysomnath/Python-Basics
/Class__str__repr__init__private_protected_public/the__init__method.py
850
4.5
4
# __init__ is a method which is immediately and automatically called after an instance has been created. # This name is fixed and it is not possible to chose another name. The __init__ method is used to initialize an instance. # The __init__ method can be anywhere in a class definition, but it is usually the first me...
true
e30f732155cf705bfe538ee1df522859661b66b7
raysomnath/Python-Basics
/Arithmetic_Operators.py
1,197
4.3125
4
import sys numbers = 1+2*3 / 4.0 print (numbers) remainder = 11 % 3 print(remainder) # using two multiplication symbol makes a power relationship squared = 7 ** 2 cubed = 2 ** 3 print(squared) print(cubed) #python supports string concatenation helloworld = "hello" + " " + "world" print(helloworld) #Python also s...
true
174b65aa091f61e733f5c5fae74f111184a3146a
raysomnath/Python-Basics
/args_kwargs/args_kwargs.py
1,004
4.46875
4
import sys # *args and **kwargs are mostly used in function definitions. # *args and **kwargs allow you to pass a variable number of arguments to a function. # What variable means here is that you do not know beforehand how many arguments # can be passed to your function by the user so in this case you use these tw...
true
4ba77af2125a0d44ee0ce4ac29b67afa8e89bc63
raysomnath/Python-Basics
/Decorator/ReturningFunctoinsFromFunctions.py
777
4.375
4
import sys # Python also allows you to use functions as return values.\ # The following example returns one of the inner functions from the outer parent() function: def parent(num): def first_child(): return "Hi I am Emma" def second_child(): return "Call me Liam" if num == 1: ...
true
916f03b0f1df29e5381bd2f2929d3bacf88bcb84
brandon-todd/alien_invasion_game
/Downloads/project2/project2/main.py
1,904
4.25
4
""" This takes temperature of cities in 5 different days and cost of five hotels to find the highest average temperature of a trip to each city in the dictionary and plans hotels to stay at along the way to maximize your budget in this example of $850. """ from itertools import permutations, combinations_with_replacem...
true
f3272bc5d1cad2c5efd9184c2db469821e5fb671
mohak007/adrian-github-list_and_strings
/program 11.py
279
4.25
4
#Write a function that merges two sorted lists into a new sorted list. [1,4,6],[2,3,5] → [1,2,3,4,5,6]. You can do this quicker than concatenating them followed by a sort. lista=[1,4,6] listb=[2,3,5] lista.sort() listb.sort() listc=lista +listb listc.sort() print(listc)
true
4bf3b3e5b97721fb459c6a799d1ff52be24e89e6
sanchezpe/pythonproject3
/pa3.py
1,276
4.15625
4
#ask user 1 for information name1=input("Enter name of customer #1: ") gallons1=eval(input("Enter gallons for customer #1: ")) question1=input("Is customer #1 residential or commercial? ") print("------------------------------------------------------") #aks user 2 for information name2=input("Enter name of c...
true
361253b2f7a7378f3287399f1d3e6d20d06aa725
dchasepdx/rpg-dice-roller
/rollerFinal.py
1,256
4.1875
4
from random import randint count = 1 #initialize a count. start at 1 for more intuitive print results #get input for number of dice and sides userRoll = input("Enter number and sides of dice like so: xdy. x is number of dice and y is number of sides: ") dice_total = 0 #initilaze dice_total #turn input into a l...
true
9b66b129cefbe2f3dc32f33cf523504fc362e678
daygregory/PFAB_3_2014
/list.py
410
4.125
4
list1 = ['English' , 'Spanish' , 'Math' , 'Biology' , 'Computer Science' , 'Gym' , 'Music' , 'Theater'] gpas = [ 3.12 , 4.0, 2.57, 3.33, 3.01, 2.22, 1.98] #print first member of the list list1 print list1[0] print list1[3] print gpas[2] print (gpas[0] + gpas[1])/2 #Number inside the [x] is known as the index print ...
true
770b0cf4eb77bf4f7985e94a0fe100cec45dd7db
Ash0492/Python
/practice8.py
1,771
4.375
4
import random #The Game of Rock, Paper and Scissors #Rules of the game print('Winning rules of the game are as follows:\n'+ 'Rock VS Paper => Paper wins\n' +'Rock VS Scissor => Rock Wins\n' +'Paper VS Scissor => Scissor wins') while True: print("Please enter one the below choices:\n"+ "1. Rock\n"+...
true
241690cbb760e66d91eee3d5aeb6ebcd0d0d82f8
mcorley1/Intro_Biocom_ND_319_Tutorial5
/Exercise_5_Challenge_Complete.py
1,667
4.1875
4
#Completing Part 1 import pandas #loading the pandas package to use data frames data = pandas.read_csv("wages.csv", header=0,sep=",") #loads the file gender_yrsexp = data.iloc[:,0:2] #subsets data by selecting the first two columns uniquegender = gender_yrsexp.drop_duplicates() #drops duplicates, like the ...
true
413a12a90d2a8675efdc6d0e5a45f8d076a4cc36
shanthanaroja/guessing_number
/number_guessing.py
451
4.25
4
import random number=random.randint(1,9) chance=0 while chance<=5: guess=int(input("Enter a number:")) if guess<number: print("Your guess is too low guess a number greater than",guess) elif guess>number: print("Your guess is too high guess a number less than",guess) else: print("...
true
51e5618900a8414c4cfb43eb8147c21e03db090f
markodevcic/codingbats-python
/string-1/extra_end.py
338
4.3125
4
# Given a string, return a new string # made of 3 copies of the last 2 chars # of the original string. The string # length will be at least 2. # # # extra_end('Hello') → 'lololo' # extra_end('ab') → 'ababab' # extra_end('Hi') → 'HiHiHi' def extra_end(str): if len(str) >= 2: return str[-2:] * 3 print(extr...
true
4ee55da716a17407829b8e26482a779216789164
mdtitong/ITS320
/ITS320_CTA1_Option2.py
449
4.375
4
# Read two integers and print two lines. The first line should contain integer division, //, the second line # should contain float division, /, and the third line should contain modulo division, %. You do not need to # perform any rounding or formatting operations. num1 = int(input("First number: ")) num2 = int(input(...
true
8653611091f2f42ab7d3e5de445f04cd89532e57
abir-hasan/PythonGround
/scratch_files/scratch_section_2.py
1,351
4.15625
4
############### Section 2 Language Overview ################ # Example of import import platform version = platform.python_version() print('this is python version: {}'.format(version)) # Example with pre-formatted and format function name = "Abir" # pre-formatted f print(f"Hello worlds {name}") # with format functio...
true
f09c256c36edcf414cc47fcddf8bed8e1d903f62
Smisosenkosi/mypackage
/mypackage-master/test/sorting.py
1,068
4.3125
4
def bubble_sort(items): '''Return array of items, sorted in ascending order''' for num in range(len(items)-1,0,-1): for i in range(num): if items[i]>items[i+1]: temp = items[i] items[i] = items[i+1] items[i+1] = temp ...
true
8c7dde5fa2a03661a3bcaae698f85ca9459dc325
felgun/BioinformaticsAlgorithms
/CountingDnaNucleotides.py
2,097
4.625
5
""" CountingDnaNucleotides.py """ import argparse import os.path def count_dna_nucleotides(sequence): """ Counts each nucleotide in the DNA sequence and prints them in the following order: A,C,G,T. Returns a dictionary with nucleotide as key and its count as value. Param: sequence {str} : The DNA sequence of ...
true
6fe338ba5908d977c7c2e263eeabc3ac9e2accd7
Qliangw/python_notes
/basic/ba_04_traverse_list.py
1,380
4.34375
4
from src import print_split_line # for循环的使用 magicians = ['alice', 'david', 'carolina'] print("使用for打印出数组元素:") for magician in magicians: print(magician) print_split_line.print_split_line('*', 20) for magician in magicians: print(magician.title() + ", that was a great trick!") print("I can`t wait to see you...
true
3165145b0c893d632c0c22163e0c36f05f52862d
PaulBStephens/python-challenge
/PyBank/.ipynb_checkpoints/main-checkpoint.py
2,325
4.21875
4
# Create dependencies import csv # file to load file_to_load = "budget_data.csv" # Read the csv and convert info into lists; the first and second columns are data given, the third to store data calculated from the second column with open(file_to_load) as revenue_data: reader = csv.reader(revenue_data) ...
true
04aa146e5dc7454a0176eb855472d19f97065021
RashikWasik/PythonDataStructures
/Python Data Structures/Week 3/Assignment 7.2.py
1,000
4.25
4
# 7.2 Write a program that prompts for a file name, then opens that file and reads through the file, looking for lines of the form: # X-DSPAM-Confidence: 0.8475 # Count these lines and extract the floating point values from each of the lines and compute the average of those values and produce an output # as shown b...
true
e1e450bf4bff900d9e12a290706f5308c8fb97cf
sargey18/rock-paper-sicssors
/main.py
921
4.3125
4
import random # 1) we need the random # 2) we will also need a function called play def play(): # 3) we will also need a variable to stor one of three inputs from the user user = input("What is your choice 'r' for rock, 'p' for paper, 's' for scissor\n") # 4) the computer also needs to choose , vatiable...
true
9d14085766c3a5a7a8099377970e8b843be8f665
tabo2659-cmis/Tabo2659-cmis-cs2
/cs2quiz3.py
1,698
4.46875
4
#Section 1: Terminology # 1) What is a recursive function? #A recursive function is a function that calls itself until it meets the requirments of the base case where it stops. #point # # 2) What happens if there is no base case defined in a recursive function? #It will recurse infinitly or about a 1000 times dependin...
true
cd0bfde949db56dc45822cfe6e06c57d3ce75bf5
mbutkevicius/100_Days_Of_Code
/day_2.py
2,196
4.1875
4
# Data Types # String print("Hello"[4]) print("123" + "345") # Integer print(123 + 345) # 123_456_789 # _ works as , # Float # 3.14159 # Boolean # True # False # num_char = str(len(input("What is your name?\n"))) # print("Your name has " + num_char + " characters.") a = str(123) print(type(a)) # 🚨 Don...
true
0c4b07f056aa9b12db0af708de3d397e4f0bcf73
mbutkevicius/100_Days_Of_Code
/day_10.py
2,194
4.1875
4
# def my_function(): # return 3 * 2 # # # output = my_function() # print(output) def format_name(f_name, l_name): """Take first and lsat name and format it to return the title case version of the name.""" if f_name == "" or l_name == "": return "You didn't provide valid inputs." formatted...
true
45b9a99f04ea8582a564a791458c66e8a67ff224
alexDavis28/udemy_python
/Python/5_36_usefull_operators_and_functions.py
1,750
4.625
5
#these didn't really fit into any other lecture, so are here #range function mylist = [1,2,3] for num in range(10): print(num) #prints every number from 0 to 10 for num in range(3,10): print(num) #prints every number from 0 to 9, not including 10 for num in range(0,10,2): print(num) #prints every number from 0...
true
c0da33ed657b52e4c56a4a20767f547efc1ae4b5
SaeedTaghavi/numerical-analysis
/python/02-interpolation/01-newton-forward/forward.py
1,185
4.25
4
# Python3 Program to interpolate using # newton forward interpolation # calculating u mentioned in the formula def u_cal(u, n): temp = u; for i in range(1, n): temp = temp * (u - i); return temp; # calculating factorial of given number n def fact(n): f = 1; for i in range(2, n + 1): f *= i; re...
true
a5ea38f82eb0747c37cc0738c17817b4e6498e50
chawlaj100/pythoniffie
/prime_number_checker.py
398
4.15625
4
prime = int(input("What number do you wanna check?")) if prime > 1 : for i in range(2,prime): if (prime % i) == 0: print("Your number is not a prime number") print("Because "+str(prime)+" divided by "+str(i)+" is 0.") break else: print(prime,"is a pr...
true
a3a1b1797558c68a7d46eee8f1132f53d1d04b98
Ameya-k1709/Object-Oriented-Programming-in-Python
/class.py
1,410
4.4375
4
# creating a class named programmers class Employee: company = 'Microsoft' # the company attribute is a class attirbute because every programmers is from microsoft number_of_employees = 0 def __init__(self, name, age, salary, job_role): # This is a constructor self.name = name ...
true
3834284ded0d2d975396b73b06440baf6d0d84b2
Roopa-palani-samy/DG-Python-Assignment
/Squarethevalue.py
397
4.25
4
# 8. Write a program which can map() to make a list whose elements are square of numbers # between 1 and 20 (both included). # using map def squared(n): return n * n numbers = (1, 2, 3, 4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20) result = map(squared, numbers) print(list(result)) # using lambd...
true
e09901378bbb935d2c4e12fd165334748f17f4ff
tungsys/FPU
/test_bench/num_gen/IEEE_number_gen.py
1,762
4.25
4
from sys import argv import struct import random def main(): """ This program takes two inputs, an op code and a number. OP Codes 1 - Convert number to IEEE 2 - Generate n random IEEE numbers and display them next to their decimal counterpart 3 - Generates and converts n random numbers and sav...
true
16bbee2868d8d28bb4757ad8676ae08677d671e3
shailymishra/EulerProject
/euler4.py
1,469
4.375
4
# A palindromic number reads the same both ways. # The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. # Find the largest palindrome made from the product of two 3-digit numbers. ## Also in recurrsive function return the function, otherwise it will show none ## Have a palindrome f...
true
01e3add9db5b09606cf11318a41aa8c39b46bb72
KzZe-Sama/Python_Assignment-III-1
/QnA/Bubblesort.py
658
4.28125
4
# bubble sort algorithm # the function sorts list of numbers in ascending order def sortList(data): for i in range(len(data)): for j in range(len(data)): if(j!=len(data)-1): if data[j]>data[j+1]: # creating temp var and storing before swapping ...
true
2d9308a0b0d941fbae26fba050313b8133f5ae83
l4nicero/learning_python
/at_seq.py
1,075
4.25
4
#!/usr/bin/env python3 import random #random.seed(1) # comment-out this line to change sequence each time # Write a program that stores random DNA sequence in a string # The sequence should be 30 nt long # On average, the sequence should be 60% AT # Calculate the actual AT fraction while generating the sequence # Rep...
true
31f6d146a867eec1ca797913e54e1e012726505c
TheHalfling/Py3ArcadeGameClass
/Calculator.py
2,239
4.15625
4
# -*- coding: utf-8 -*- """ Spyder Editor Calculator from Chapter 1 of Program Arcade Games with Pygame """ def mpg(): # miles per gallon print("This program calculates mpg.") # Get Miles driven from user miles_driven = float(input("Enter miles driven: ")) #get gallons used f...
true
e0996ed85bbb7753d9ade2645ea13b0ef81292e6
IlonaPelerin/CTI110
/M5HW2_RunningTotal_Pelerin.py
713
4.125
4
# CTI-110 # M5HW2 - Running Total # Ilona Pelerin # October 19, 2017 # def main(): # declaring and initializing the variables. number = 1.0 runningTotal = 0.0 # setting up the while loop to add numbers until a negative one is entered. while number >= 0: number = float(input('En...
true
957ddea417c9ab85ca19acc451b73dacf714cf19
RocketHTML/holbertonschool-higher_level_programming
/0x06-python-classes/4-square.py
926
4.1875
4
#!/usr/bin/python3 class Square: def __init__(self, size=0): self.size = size @staticmethod def __check_size(size): if not type(size) == int: raise TypeError("size must be an integer") elif size < 0: raise ValueError("size must be >= 0") @property de...
true
f21e4386013fb02c8346175bc0987e272457f2c8
RocketHTML/holbertonschool-higher_level_programming
/0x06-python-classes/6-square.py
1,685
4.15625
4
#!/usr/bin/python3 class Square: def __init__(self, size=0, position=(0, 0)): self.size = size self.position = position @staticmethod def __check_size(size): if not type(size) == int: raise TypeError("size must be an integer") elif size < 0: raise Val...
true
d17c6d12f42b9125f5bf76fcb639b97b621f518d
idaln/INF200-2019-Exercises
/src/ida_lunde_naalsund_ex/ex_02/bubble_sort.py
813
4.28125
4
# -*- coding: utf-8 -*- __author__ = "Ida Lunde Naalsund" __email__ = "idna@nmbu.no" def bubble_sort(data): """Takes a list or tuple of numbers as input. Returns a copy of the list where the numbers are sorted in increasing order. :param data: List or tuple containing numbers. :return: Sorted li...
true
5b24fb3a6a665e4d0cc20c678d4a0a7fc2cb6dd5
idaln/INF200-2019-Exercises
/src/ida_lunde_naalsund_ex/ex01/letter_counts.py
669
4.25
4
# -*- coding: utf-8 -*- __author__ = 'Ida Lunde Naalsund' __email__ = 'idna@nmbu.no' def letter_freq(txt): """Function returns a dictionary with letters, symbols and digits from input "txt" as keys and counts as values. :param txt: Text written by user :return: freq """ freq = {} for e...
true
fbe73ec569ec7bc54dcd3dd0b8dabce4e17d1688
Gilbert-Adu/my_currency_converter
/proapp.py
598
4.40625
4
""" User interface for module currency When run as a script, this module prompts the user for two currencies and amount. It prints out the result of converting the first currency to the second. Author: Gilbert Adu Date: 7th February 2019 """ import pro currency_from=input('3-letter code for original currency: ') ...
true
2287cc941b4798589932e8fda8ea02b9e4f0803f
rajat3105/Algorithms
/babylonian.py
268
4.1875
4
def root(n): x=n y=1 e=0.001 # e difines the accuracy level while(x-y>e): x=(x+y)/2 y=n/x return x n= int(input("Enter the number whose square root you need to found : ")) print("Root is: ", round(root(n),3))
true
52c4a5cd2f042de57f62d6f675eab8ee2fff14b8
superleggera-21/BI-Class
/in-class hw.py
2,651
4.59375
5
# Define a function called hotel_cost with one argument days as user input. # The hotel costs $140 per day. So, the function hotel_cost should return 140 * days. def hotel_cost(x): return 140*x # Define a function called plane_ride_cost that takes a string, city, as user input. # The function sh...
true
9a687191d6e4fba72658656287b9e86877a7ffe1
dchirag/Python
/a84.py
1,296
4.21875
4
''' This code is written to fulfil coursera assignment for the coursera Python Data Structures University Of Michigan, Prof. Charles Severance Aug 2016 It is written with my own efforts and settings. You are free to use it for non-coursera works. However, it is copywrighted mat...
true
1340b8cab54e2bf2a0ac75d27d164ce52258ea68
hyro64/Python_growth
/Chapter 10/Book Examples/pi_string.py
1,540
4.4375
4
"""# Ver 3.0 # this version check to see if the input appears in the data specified # After searching through the data it prints accordingly fileName = "pi_million_digits.txt" with open(fileName) as file_object: lines = file_object.readlines() pi_string = '' for line in lines: pi_string += line. strip() birthd...
true
2f8f258bbd76f62e4b06aec72dc0bb5e35be6e70
psmohammedali/pythontutorial
/loops/while2.py
664
4.28125
4
print("Hacker Rank Question") # Objective # In this challenge, we're going to use loops to help us do some simple math. Check out the Tutorial tab to learn more. # Task # Given an integer, # , print its first multiples. Each multiple (where # # ) should be printed on a new line in the form: n x i = result. # ...
true
7e7524c2453c777f808f8db1a2cce2492d244edf
lenaurman/py
/2.py
2,243
4.125
4
# next step # import import turtle import random # color mode & screen color turtle.colormode(255) turtle.bgcolor(0,0,0) # background color - black def spirala(t): """ Draws a spiral with a given tartle object (t) Starting point is random Color is random blue Width is random """ t.penup() ...
true
2a65af6428836391762f57871a7fdc5ef5aee6cb
cliffjsgit/chapter-12
/exercise122.py
1,878
4.375
4
#!/usr/bin/env python3 __author__ = "Your Name" ############################################################################### # # Exercise 12.2 # # # Grading Guidelines: # - No answer variable is needed. Grading script will call function. # - Function "anagram_finder" should return a list of of all the sets of # w...
true
c117517faab9e23db4803f6ba0eba32fa8370031
shiva-adith/python_projects
/rock_paper_scissors/game.py
1,341
4.21875
4
import random while True: choice = input("Enter your choice or enter end to quit: ").lower() if choice == 'end': break choices = ['rock', 'paper', 'scissors'] # the args for randint set the range required for the output. # the end value is inclusive and hence one is subtracted to prevent...
true
0402d59e632e05bbf53d074d50a4feac6fd2863c
Utkarshrathore98/mysirgPythonAssignment_Solution
/Assignment_2/greatest among three.py
458
4.21875
4
num_1=int(input("enter the first number ")) num_2=int(input("enter the second number")) num_3=int(input("enter the third number ")) if num_1>num_2: if num_1>num_3: print("the greater number is",num_1) else: print("the greater number is ",num_3) elif num_1==num_2==num_3: print("all numbers a...
true
1a1713ecef84b1963a752e7ebe68491b5d71fd3c
cjc41042/Pig_Latin
/PygLatin.py
410
4.28125
4
import myfunctions input("Hello! Welcome to the English to PigLatin Translator! Hit Enter to begin!") word = input('Enter a word or phrase:') while len(word) > 0: print ("Your new word or phrase is:") print (myfunctions.pig(word)) print ("") print ("Hit Enter to end,") word = input('Or enter ano...
true
891a2b1a83f8e8b672ce299b6d5c8e56fc865139
anushanav/python_logical_solutions
/mirrormatrix.py
505
4.25
4
# Printing mirror image of the given matrix matrix = [[1,2,3], [4,5,6], [7,8,9]] mirror= [[0]*3 for i in range(3)] rows = 3 columns = 3 for i in range(rows): for j in range(columns): mirror[i][j]=matrix[i][columns-1-j] # printing a matrix that shows addition of the given matrix and i...
true