blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
3b007e9ed267ca8ad1c22e0e34284734daf84d90
Ernjivi/bedu_python01
/Curso-de-Python/Clase-02/listas-de-enteros-funciones.py
1,734
4.21875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ El script deberá de crear e imprimir la lista de números enteros con N elementos, el valor de N será proporcionado por el usuario, por lo que se sugiere hacer uso de dos funciones. """ # No inicies a escribir el script desde aquí, ve al final del script e # inicia ...
false
e15850165397b66795497cfa10d2495139998de0
Davenport70/python-basics-
/practice strings.py
1,351
4.5625
5
# practice string # welcome to Sparta - excercise # Version 1 specs # define a variable name, and assign a string with a name welcome = 'Hello and welcome!' print(welcome) # prompt the user for input and ask the user for his/her name user_input = input('What is your name?') print(user_input) # use concatenation to...
true
47f5e052808e5a77df1a15980e1ea37fad4756e4
raghavgr/Leetcode
/reverse_string344.py
862
4.3125
4
""" Write a function that takes a string as input and returns the string reversed. Example: Given s = "hello", return "olleh". """ class Solution: """ 2 solutions """ def reverseString(self, s): """ in-place reverse string algorithm i.e. another string is not used to store the result ...
true
c834fd40f3a86542a2d81ea0297c71d1cf1853fd
JoshMez/Python_Intro
/Dictionary/Empty_Dict.py
245
4.21875
4
#Aim: To learn about empty dictionaries # #Creating an empty dictionary. dict = {} #Put two curly braces. #No space between them. # #Adding values to the empty dictionay. # dict['Jason'] = 'Blue' dict['Belle'] = 'Red' dict['John'] = 'Black' # #
true
c7136ec6647afc0f3044059082e63a55d80506d5
JoshMez/Python_Intro
/Programming_Flow/List_Comprehension.py
298
4.25
4
#Basic demonstration of list comprehension. #Variable was declared. #List was create with the square brackets. #value ** 2 was created. #The a for loop was created ; NOTICE : THere was not the semi:colon as the end. squares = [ value ** 2 for value in range(1,11) ] print(squares)
true
bfd57f6ad775a8c6cd91ba2db417421d9716a415
JoshMez/Python_Intro
/Functions/Exercies_8.py
1,645
4.75
5
#8-1. Message: Write a function called display_message() that prints one sentence #telling everyone what you are learning about in this chapter. Call the #function, and make sure the message displays correctly. #Creating a function. def display_message(): """Displaying the chapter focuses on""" print("In this ...
true
f77853c57409d16a7d23731165daa4fb70a2bf20
JoshMez/Python_Intro
/While_Input/Dict_User_Input.py
714
4.25
4
#Creating an empty dictionary. # #Creating an empty dictionary. responses = {} # #Creating a flag. polling_active = True #### # while polling_active: #Prompting the user for input. naming = input("Whats your name: ") response = input("Which mountain do you want to visit: ") #Store the responses in the ...
true
a0f6073ebcf2f8159b91f630968acb177b9b561b
JoshMez/Python_Intro
/Dictionary/Loop_Dict.py
1,293
4.90625
5
#Aim: Explain Loop and Dictionaries. # # #There are several ways to loop through a dictionary. #Loop through all of Key-pair values. #Loop through keys only. #Loop though values only. # # ############Example of looping through all dictionary key-pair values#################### # #Creating a dictionary of a ...
true
f95e10517f70584b947de934b5fa33dee7d149bc
JoshMez/Python_Intro
/Dictionary/Nesting_2.py
601
4.1875
4
aliens = [] #Basically creating the variable 30 times over. # #The range just tells Python how many times we want to loop and repeat. #Each time loop occurs, we create a new alien and append it to the new alien list. for alien in range(30): new_alien = {'color': 'green', 'points': 5, ...
true
1068634872d3d4acb23453519b7f6e3b9069bcae
JoshMez/Python_Intro
/Programming_Flow/Number_Lists.py
1,243
4.53125
5
#Creating lists that contain number in Python is very important. #Making a list with even numbers in it. even_numbers = list(range(0,11,2)) #The list function has been used to say that a lists is being created. #Passing the range arguments in that , stating arugments in that. print(even_numbers) #Creating ...
true
170b81c95440d3e3b418d2ae47a5fd74a654dd88
AnmolKhullar/training-2019
/Day10A.py
984
4.1875
4
"""This module is for calculate Employee salary""" class Employee: """This is class Employee Hello world""" empCount = 0 def __init__(self, name, salary): self.name = name self.salary = salary Employee.empCount += 1 def displayCount(self): print("Total E...
false
38936a50b1ef5570cef7a9cd19e1774ddc7e21ce
shekhar270779/Learn_Python
/prg_OOP-05.py
2,388
4.5625
5
''' Class Inheritance: Inheritance allows a class to inherit attributes and methods from parent class. This is useful as we can create subclass which inherits all functionality of parent class, also if required we can override, or add new functionality to sub class without affecting parent class ''' class Employ...
true
8bdc82cc4590b320da4b8f2e8462b3db0960ea59
andu1989anand/vtu-1sem-cpl-lab-in-python
/palindrome1.py
450
4.34375
4
print "\n Python program to reverse a given integer number and check whether it is a" print "PALINDROME or not. Output the given number with suitable message\n\n" num=input("Enter a valid integer number:") temp = num rev=0 while(num != 0): digit=num % 10 rev=rev * 10 + digit num=num / 10 print "\n\n The rev...
true
eaa8e5da435544cd8e07457a6e90e79c5a59591c
pilifengmo/Electrical-Consumption-Prediction-System
/PROJECT/website/model.py
1,776
4.125
4
import sqlite3 as sql class Database(object): """ Create database if not exist """ def __init__(self): con = sql.connect("database.db") cur = con.cursor() cur.execute("create table if not exists users (id integer primary key autoincrement, username text not null UNIQUE, email text not...
true
e9d5619d853a46cfe7f3e26f693d56ae14768567
hashncrash/IS211_Assignment1
/assignment1_part2.py
559
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- "IS 211 Assignment 1, part 2. Dave Soto" class Book(object): author = " " title = " " "Book Class information" def __init__(self, author, title): self.author = author self.title = title "Function to dsiplay the book author and title" def...
true
aeea6c0d9e8763f11c32f28d6456a8782483af28
sysulj/leetcode
/easy/string/563. 二叉树的坡度.py
2,342
4.15625
4
""" 给定一个二叉树,计算整个树的坡度。 一个树的节点的坡度定义即为,该节点左子树的结点之和和右子树结点之和的差的绝对值。空结点的的坡度是0。 整个树的坡度就是其所有节点的坡度之和。 示例: 输入: 1 / \ 2 3 输出: 1 解释: 结点的坡度 2 : 0 结点的坡度 3 : 0 结点的坡度 1 : |2-3| = 1 树的坡度 : 0 + 0 + 1 = 1 注意: 任何子树的结点的和不会超过32位整数的范围。 坡度的值不会超过32位整数的范围。 """ # Definition for a binary tree node. # class Tree...
false
3db6fbcb14c16503f5c6dbddcba388cf25db73d1
Alilujian/Election_Analysis
/Python_Practice.py
2,825
4.3125
4
counties = ["Arapahoe", "Denver","Jefferson"] if counties[1] == 'Denver': print(counties[1]) counties_tuple = ("Arapahoe", "Denver", "Jefferson") counties_dict ={} counties_dict["Arapahoe"] = 422829 counties_dict["Denver"] = 463353 counties_dict["Jefferson"] = 432438 counties_dict.items() counties_dict.keys() cou...
false
d5ed2a5b8c599a693c41178f7096995589fa4dc0
s290717997/Python-100-Days
/day1-15/day7/day7_5.py
657
4.25
4
#练习5:计算指定的年月日是这一年的第几天 days_of_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] def if_leap_year(year): if year % 400 == 0 or year % 4 == 0 and year % 100 != 0: return True else: return False def which_day(year, month, day): sum = 0 for i in range(1, month): sum += da...
true
e2defc1b4568b4f52e7c4ac3249d6a67e17275b6
Krashex/pl
/Chapter5/DaddyChooseGame.py
2,264
4.53125
5
pairs = {'Oleg': 'Petr', 'Artur': 'Denis', 'Ivan': 'Petr'} choice = None print(""" Type 1 - if you want to know smb's father's name Type 2 - if you want to add new pairs Type 3 - if you want to remove sm pair Type 4 - if you want to chang...
true
632144ea0c2dc95a6a87d20d642528339be71a52
wilcerowii/mtec2002_assignments
/class10/labs/exceptions.py
1,367
4.21875
4
""" exceptions.py ===== To handle errors, use a try/catch block: ----- try: # do your stuff except SomeError: # deal with some error ----- optionally... you can continue catching more than one exception: ----- . . except AnotherError: # deal with another error ----- Substitute SomeError with the kind of error yo...
true
90952d5c964ca74bb1c221b4cf93395799f1f564
jbrownxf/mycode
/wk1proj/gotime2
1,544
4.1875
4
#!/usr/bin/env python3 #imports import random #This is a board game. Every player rolls a dice from 1-12 first to 100 wins #By Josh Brown from random import randint #ask for number of players, creates a dic for every player num_player = input("How many will be playing Dicequest?(2-6 players) ") num_players =int(num...
true
f745f56706575fc6f3e565b026029103c51cca4a
adnanhanif793/Python-Codes
/Basic/com/Anagram.py
448
4.1875
4
''' Created on 18-Mar-2019 @author: adnan.hanif ''' def check(s1, s2): # the sorted strings are checked if(sorted(s1)== sorted(s2)): print("The strings are anagrams.") else: print("The strings aren't anagrams.") # driver code n=int(input...
true
3043d49c09e87ff59adc9386745996dbfeccf057
jonalynnA-cs29/Intro-Python-I
/src/05_lists.py
2,269
4.53125
5
# For the exercise, look up the methods and functions that are available for use # with Python lists. ''' Python List append() Add a single element to the end of the list Python List extend() Add Elements of a List to Another List Python List insert() Inserts Element to The List Python List remove() Removes item fro...
true
698c957da6315ef6124c57ca3b22aa7a6776df0b
nshattuck20/Data_Structures_Algorithms1
/ch9/9-1.py
630
4.59375
5
''' Section 9-1: Recursive Functions ''' #Example of recursive function #I used the code from the animation example in the course material def count_down(count): if count == 0: print('Go!') else: print(count) count_down(count -1) count_down(2) # recursively call count_down 3 tim...
true
efcb7864f7ec7260c361402910aea5a5b9cbb091
nshattuck20/Data_Structures_Algorithms1
/ch8/8-6.py
347
4.46875
4
''' 8-6 List Comprehensions: Form: new_list = [expression for name in iterable] 3 components: 1. The expression to evaluate each iterable component 2. A loop variable to bind to the components 3. An iterable object ''' #Example my_list = [5, 10, 15] my_list_plus5 = [(i + 5) for i in my_list] print('New list...
true
17786b5a311cfbb8e4c2e56f7bf0e9ce35e9269a
nshattuck20/Data_Structures_Algorithms1
/ch9/9-5-1.py
874
4.40625
4
''' 9-5-1 Write a program that outputs the nth Fibonacci number, where n is a user-entered number. So if the user enters 4, the program should output 3 (without outputting the intermediate steps). Use a recursive function compute_nth_fib that takes n as a parameter and returns the Fibonacci number. The function ha...
true
148c9c7ffecb1938db146f2c7e263e82bdfb741e
nshattuck20/Data_Structures_Algorithms1
/Chapter4/4.9/dictionary_basics.py
451
4.34375
4
''' Simple program demonstrating the basics of Dictionaries. ''' players = {'Lionel Messi' : 10, 'Cristiano Ronaldo' : 7 } print(players) #Accessing an entry uses brackets [] with the specified key print('The value of this player is :' + str(players['Cristiano Ronaldo'])) #Editing the value of an entry ...
true
1fa915224e3880af57d0012bd843a6d76dc184ad
nshattuck20/Data_Structures_Algorithms1
/ch7/7-7.py
1,097
4.71875
5
'''Class customization * Referes to how classes can be altered by rhe programmer to suit her needs. * _str_() changes how to print the output of an object ''' class Toy: def __init__(self, name, price, min_age): self.name = name self.price = price self.min_age = min_age truck = Toy('Monster Truck ...
true
cdddcec194bbb01b91d42d936b6cf97bd6edc182
nshattuck20/Data_Structures_Algorithms1
/ch8/8-10.py
1,792
4.78125
5
''' 8-10: Nested dictionaries (Dictionaries within dictionaries) ''' # To declare a nested dictionary, do the following: students = {} # empty dictionary ''' #Create indexing operation with key 'John and value of another dictionary' print('John:') ###EXAMPLE#### ''' # students['John'] = {'Grade' : 'A+' , 'StudentID'...
false
749979c042cf6df3dd7c34f16dd0a506fd4147f8
bsfraga/prog-web
/pessoa.py
963
4.25
4
class Pessoa: ''' Objeto pessoa e seus atributos. Objeto pessoa projetado para guardar em apenas um instância uma lista de ocorrencias do objeto Exemplo: list_pessoa: [ { 'nome':'ABCDE', 'idade':33, }, ... ] ''' def __init__(self): ''...
false
906a5fdf384a4825b3cfa126777f35b9d1cb0b4c
mattprodani/letter-box
/Dictionary.py
1,049
4.15625
4
class Dictionary(): def __init__(self, dictionary, gameboard): """ Builds a dictionary object containing a list of words as well as groups them into a Dictionary separated by starting letter, where starting letters are in gameboard. """ wordList = [] self.wordGroups = {} ...
true
e0638d35fea87b4176d06cc0e33f136a805b7554
CB987/dchomework
/Python/Python104/blastoff3.py
237
4.1875
4
# countdown that asks user where to start n = int(input("From what number should start our countdown?")) #getting user input while n >= 0: #setting end condition print(n) #instructing to print number n -=1 #incrementing downwards
true
59c6d6de128a455c43a756ff527d25ce053e15ca
CB987/dchomework
/Python/Python104/blastoff2.py
365
4.4375
4
# create a countdown from 10 to 0, then prints a message n = 10 #start point of countdown while n >= 0: # set duration of countdown print(n) #printing the number n -=1 #Incrementing down, sends back up to print. loops until condition is false if n < 0: #instructing when to print the message print("M...
true
f675d32ecf2cf6d0afef4b975674d4adfdfd0bb2
alisheryuldashev/playground
/Python/classes.py
780
4.4375
4
#this snippet shows how to create a class in Python. #this program will prompt for information, append same into a class, and output a message. #create a class called Student class Student: def __init__(self,name,dorm): self.name = name self.dorm = dorm #import custom functions from CS50...
true
d56bdfbf76c0cbbce6c42a98844db12474e9c51b
Sandhie177/CS5690-Python-deep-learning
/ICP3/symmetric_difference.py
610
4.28125
4
# -*- coding: utf-8 -*- #A={1,2,3,4} #B={1,2} def list1(): n=eval(input("How many numbers do you have in the list?")) #takes number of elements in the list i=0 list1={0} #creating an empty set list1.remove(0) for i in range(n): x=int(input("enter a number\n")) list1.add(x) #adding ne...
true
015efad385e902e83ba1d21e2e4e7bf86d29a5a2
Sandhie177/CS5690-Python-deep-learning
/Assignment_1/Assignment_1c_list_of_students.py
1,271
4.4375
4
#Consider the following scenario. You have a list of students who are attending class "Python" #and another list of students who are attending class "Web Application". #Find the list of students who are attending “python” classes but not “Web Application” #function to create list def list1(): n=eval(input("Studen...
true
5c267a5620aa7a658ccdb79e677f3998207756a3
sciencefixion/HelloPython
/Hello - Basics of Python/sliceback.py
857
4.28125
4
letters = "abcdefghijklmnopqrstuvwxyz" backwards = letters[25:0:-1] print(backwards) backwards2 = letters[25::-1] print(backwards2) # with a negative step the start and stop defaults are reversed backwards3 = letters[::-1] print(backwards3) # Challenge: Using the letters string add some code to create the following ...
true
3d3108c007d9a67e5c257a28329b4effe701d322
ngssss/xuewei
/utils/getAngel.py
1,145
4.28125
4
import math class Point: """ 2D坐标点 """ def __init__(self, x, y): self.X = x self.Y = y class Line: def __init__(self, point1, point2): """ 初始化包含两个端点 :param point1: :param point2: """ self.Point1 = point1 se...
false
4b1b47754908d1408d23be833869d656231ec113
casanova98/Project-201501
/Practical one/q1_fahrenheit_to_celsius.py
232
4.21875
4
#q1_fahrenheit_to_celsius.py answer = input("Enter the temperature you want in Celsius!") x = float(answer) celsius = round((5/9) * (x - 32), 1) print("The temperature from Fahrenheit to Celsius to 1 decimal place is", celsius)
true
9d2ef8e3764b1709b9dfcbf68bb4af5bd4b64eae
casanova98/Project-201501
/Practical two/q08_top2_scores.py
552
4.125
4
students = int(input("Enter number of students: ")) names = [] score = [] while students != 0: names.append(str(input("Enter your name: "))) score.append(int(input("Enter your score: "))) students -= 1 highest = max(score) print("Student with highest score is:", names[score.index(highest)], "with ...
true
783d04424384829bec20a0b6d4dddca93f46e3ae
Smily-Pirate/100DaysOfCode
/Day1.py
971
4.125
4
# Day1 of 100 days of coding. # Starting from list. # Accessing Values in Lists. list1 = ['hi', 'there', 18, 1] list2 = [1, 2, 3, 4, 5, 6, 7, 8] print(list1[0]) print(list2[2]) # Updating list list1[0] = 'ghanshyam' list1[1] = 'joshi' list2[7] = 'hi' print(list1) print(list2) list1.append('10') print(list1) # Delet...
true
49ba616fc87d3f9287ef22e444a7b872839f1aa7
Akshay-Chandelkar/PythonTraining2019
/Ex21_Arthimetic.py
1,458
4.125
4
print("Free fall code to begin") def add(num1,num2): sum = num1 + num2 print("The sum of two numbers is : ", sum) def sub(num1,num2): sub = num2 - num1 print("The difference between the two numbers is : ", sub) def mul(num1,num2): mul = num1 * num2 print("The multiplication of t...
true
c57f2c473a90a15353b101a8bd2e6b8f4031ceb3
Akshay-Chandelkar/PythonTraining2019
/Ex64_Stack_List.py
2,492
4.125
4
def IsStackFull(L1): if IsStackEmpty(L1): print("\nThe stack is empty.\n") elif len(L1) >= 6: return True else: print("\nThe stack is not full.\n") def IsStackEmpty(L1): if L1 == []: return True else: return False def Push(L1): if not IsSt...
true
d8dc56075b59c4790ef758177723e44a2b09bf8f
vonnenaut/coursera_python
/7 of 7 --Capstone Exam/probability.py
854
4.21875
4
# Fundamentals of Computing Capstone Exam # Question 12 def probability(outcomes): """ takes a list of numbers as input (where each number must be between 1 and 6 inclusive) and computes the probability of getting the given sequence of outcomes from rolling the unfair die. Assume the die is rolled exactly the number o...
true
56555a338b03786e7de3d8cd5546f8d3b5f65158
vonnenaut/coursera_python
/7 of 7 --Capstone Exam/pick_a_number.py
1,280
4.15625
4
# Fundamentals of Computing Capstone Exam # Question 17 scores = [0,0] player = 0 def pick_a_number(board): """ recursively takes a list representing the game board and returns a tuple that is the score of the game if both players play optimally by choosing the highest number of the two at the far left and right edg...
true
dcceddfae83a164aeae8bfa0fdb6177fad4b90de
vonnenaut/coursera_python
/2 of 7 -- Intro to Interactive Programming with Python 2/wk 6/quiz_6b_num8.py
2,021
4.34375
4
""" We can use loops to simulate natural processes over time. Write a program that calculates the populations of two kinds of “wumpuses” over time. At the beginning of year 1, there are 1000 slow wumpuses and 1 fast wumpus. This one fast wumpus is a new mutation. Not surprisingly, being fast gives it an advantage, as...
true
c9d3d1735eadee86c6601193da7690ed39d6e472
777shipra/dailypython
/assignment_acadview/question_9.py
255
4.125
4
sentence=raw_input("enter your sentence :") uppercase_letters=0 lowercase_letters=0 for x in sentence: if x.isupper(): uppercase_letters +=1 elif x.islower(): lowercase_letters +=1 print uppercase_letters print lowercase_letters
true
b67904bd5415cde5c5ddc1a4e1cb121c47778274
777shipra/dailypython
/enumerate.py
261
4.25
4
choices=['pizza','ice','nachos','trigger'] for i,item in enumerate(choices): print i,choices #prints the whole list print i,item #prints the content of the list for i,items in enumerate (choices,1): print i,items #begins the itteration from index 1
true
83757a54e0ca9d5c0acac7dbf949a800eac053ff
KudzanaiGomera/cs50_Projects
/cs50_web/Python/lopps.py
402
4.21875
4
# iterate through a list of numbers for i in [0,1,2,3,4,5,6]: print (f"iterate through a list of numbers: {i}") # iterate through a list of strings names = ["Kudzai", "Steve", "John", "Adam"] for name in names: print(f"iterate through a list of strings: {name}") # iterate through a string a print ech char ...
false
c222489968812c65d58847cbe1b7780f9f620b4c
elormcent/centlorm
/conditional.py
542
4.21875
4
i = 6 if(i % 2 == 0): print ("Even Number") else: print ("Odd Number") def even(): number = int(input("Enter a whole number :- ")) if (number > 0 % 2 == 0): print("It\'s an even number, nice work") elif (number > 0 % 2 == 1): print("it\'s an odd number, good job") elif (number ...
true
a97025850246a1a6e2a630565d20da91579e84fe
olivianauman/programming_for_informatics
/value_return.py
392
4.15625
4
def multiply3to9(input_number): sum = 0 for to_multiply_with in range(3, 10, 2): product = input_number * to_multiply_with print(' {} * {} = {:.2f}'.format(input_number, to_multiply_with, product)) sum += product return sum sum1 = multiply3to9(-2.5) sum2 = multiply3to9(21) ...
false
e40b81ba5afa39fdfe0b6384a5802695f53b1662
olivianauman/programming_for_informatics
/untitled-2.py
995
4.40625
4
# turtle trys import turtle # set window size turtle.setup(800,600) # get reference to turtle window window = turtle.Screen() # set window title bar window.title("making a shape") # set background color window.bgcolor('purple') the_turtle = turtle.getturtle() # default turtle # 3 attributes: positioning...
true
a4c327eb87a6b535eeb6a6750f86279eedf0b16b
peterlulu666/CourseraStartingWithPython
/Assignment 4.6.py
1,064
4.4375
4
# 4.6 Write a program to prompt the user for # hours and rate per hour using input to # compute gross pay. Pay should be the # normal rate for hours up to 40 and time-and-a-half # for the hourly rate for all hours worked above 40 hours. # Put the logic to do the computation of pay in a function # called computepay() an...
true
43141dce566e017494468bec1d4ff2d904f45477
RekidiangData-S/SQLite-Project
/sqlite_App/app.py
751
4.15625
4
import database #database.create_db() def main(): print(""" WELCOME TO STUDENTS DATABASE ############################ Select Operation : (1) for create Table (2) for Add Record (3) for Show Records (4) for Delete Records (5) for Records Selection """) operation = input("Enter your ...
true
d13dcf6e579b458d12f013700eb760936d9f2e4c
cubicova17/Python_scripts
/fib.py
936
4.21875
4
#------------------------------------------------------------------------------- # Name: module1 # Purpose: FibNumbers # # Author: Dvoiak # # Created: 07.10.2014 # Copyright: (c) Dvoiak 2014 # Licence: <your licence> #-------------------------------------------------------------------------------...
true
b882a6c8f38065b75d2fdeff2c640cc84ac731f4
kimchison/HardWay
/ex30.py
424
4.125
4
people = 20 cars = 40 buses = 50 if cars > people: print "We should take the cars..." elif cars < people: print "We should not take the cars..." else: print "We can't decide." if buses > cars: print "Thats too many buses" elif buses < cars: print "Maybe we could take the buses" else: print "We still can't deci...
true
576672d0fdacac1002b6d96deed88c7ada514fd4
mschruf/python
/division_without_divide_operation.py
1,493
4.3125
4
def divide(numerator, denominator, num_decimal_places): """Divides one integer by another without directly using division. Args: numerator: integer value of numerator denominator: integer value of denominator num_decimal_places: number of decimal places desired in result Returns: ...
true
e366ffbd98c7cf6e860489e91b1f07457695b5ab
KishenSharma6/SF-Airbnb-Listings-Analysis
/Project_Codes/03_Processing/Missing_Stats.py
1,102
4.15625
4
import pandas as pd import numpy as np def missing_calculator(df,data_type = None): """ The following function takes a data frame and returns a dataframe with the following statistics: data_type takes a string or list of strings referenceing data type missing_count: Number of missing values per...
true
320c5067f7607baedb6009db27bca5f99e60b74e
muralimandula/cspp1-assignments
/m7/p3/Functions - Assignment-3/assignment3.py
1,521
4.125
4
""" A program that calculates the minimum fixed monthly payment needed in order pay off a credit card balance within 12 months using bi-section method """ def payingdebt_offinayear(balance, annual_interestrate): """ A function to calculate the lowest payment""" def bal_d(balance, pay, annual_interestrate): ...
true
db9cb334ca1e7502b06fac5edfdc3fb24c47fc64
jleko75/Python_SQLite
/sqlite_demo.py
2,147
4.15625
4
import sqlite3 from employee import Employee # conn = sqlite3.connect(':memory:') conn = sqlite3.connect('employee.db') c = conn.cursor() # budući baza podataka već postoji ovo nam ne treba # c.execute("""CREATE TABLE employees ( # first text, # last text, # pay integer # ...
false
7d25fca29ef23d397b784da8567293279cf4d0ca
alvinuy1110/python-tutorial
/oop/basic.py
867
4.40625
4
##### # This is the OOP tutorial ##### title = "OOP Tutorial" print(title) # Basic class print("\nBasic Class\n") # class definition class A(): # constructor def __init__(self): print("classA initialized") # constructor def __init__(self, name=None): print("classA initialized") ...
true
2aaad3f3fe4b0a57e481f2b752266a7dc636a6e3
alvinuy1110/python-tutorial
/loop/loop.py
809
4.4375
4
##### # This is the Looping tutorial ##### title = "Looping Tutorial" print(title) # Looping print("\n\nLooping\n\n") myMap = {"key1": "value1", "key2": 1234} print(myMap) # print the entries print("\nKey-Value\n") for k, v in myMap.items(): print(k, v) # loop with the index print("\nIndex-Value\n") for (i, v) i...
true
c115a55e98a112cbd4f2170590cfbbb219c9720a
cal1log/python
/tuples.py
243
4.125
4
#!/usr/bin/env python3 '''creating a tuple''' tup = (10, 20, 30, 40) '''getting a tuple index value''' print(tup[2]) '''impossible to change values in a tuple''' try: tup[2] = 60 except: print("a tuple can not changes your values")
true
69b832863c278164de52ef419b82d3c4d5bee86d
sudhanvalalit/Koonin-Problems
/Koonin/Chapter1/Exercises/Ex5.py
1,427
4.1875
4
""" Exercise 1.5: Write programs to solve for the positive root of x^2-5 using the Newton-Raphson and secant methods. Investigate the behavior of the latter with changes in the initial guesses for the root. """ import numpy as np from scipy.misc import derivative tolx = 1e-6 def f(x): return x**2 - 5.0 def Ne...
true
02774b2a40e58bf843a661fde07fc87b91bcdabd
Scientific-Computing-at-Temple-Physics/prime-number-finder-Scadow121
/primes.py
1,479
4.25
4
# This is a comment. Python will ignore these lines (starting with #) when running import math as ma import time # To use a math function, write "ma." in front of it. Example: ma.sin(3.146) # These functions will ask you for your number ranges, and assign them to 'x1' and 'x2' x1 = raw_input('smallest number to ch...
true
f862fbb0d2ebc93e57d6e571899c699563c5d86b
anthonyhertadi/Python-Course
/Day 2/conditional.py
541
4.125
4
# == comparison # = assignment operator cuaca ="ga hujan" if cuaca == "hujan" or cuaca == "Hujan": print("BAWA PAYUNG CUK!!!") elif cuaca == "tidak tahu": print("Jaga-jaga aja bor") else: print("Gausa Bawa Payung, Bego!") nilai = 80 #!= =tidak sama dengan if nilai >= 75 and nilai <= 90: print("L...
false
f1ac4e45bc78b065f5cb55fde220b57f011d71e9
plotnik102rus/Stady_repo
/Task 2-5.py
735
4.28125
4
#Реализовать структуру «Рейтинг», представляющую собой не возрастающий набор натуральных чисел. # У пользователя необходимо запрашивать новый элемент рейтинга. # Если в рейтинге существуют элементы с одинаковыми значениями, # то новый элемент с тем же значением должен разместиться после них. my_list = [9, 6, 5, 3...
false
a1b046530bf211a353f6d3fd7dbbc9b7a134020d
test-learn/github-learn
/helloWorld.py
1,533
4.3125
4
print("Hello World!!!") print("This is my first python program") intVal = 5 floatVal = 4.54 boolVal = True print(boolVal) boolVal = False print(intVal) print(floatVal) print(boolVal) # single line comment """ Saare jahaan se achha """ print("Adding above 2 numbers = ", intVal+floatVal) operator1 = 2 operator2 =...
false
3b7ec7522103f8d09d04e3955ffc1167c1aca47d
abdulwasayrida/Python-Exercises
/Exercise 6.18.py
569
4.21875
4
#Exercise 6.18 #Display a matrix of 0s and 1s #Rida Abdulwasay #1/12/2018 def printMatrix(n): #Create a function from random import randint for side1 in range (n): for side2 in range (n): print(randint(0, 1), end=" ") #randint generates the random number sequence print(" ") ...
true
e65af2007a3a9096a6dc4569338d5b84aa4e93fa
abdulwasayrida/Python-Exercises
/RegularPolygon.py
1,418
4.3125
4
#Exercise 7.5 #Geometry: n-sided regular polygon #Rida Abdulwasay #1/14/2018 import math #Create a Class named RegularPolygon class RegularPolygon: def __init__(self, n = 3, side = 1, x = 0, y = 0): self.__n = n self.__side = side self.__x = x self.__y = y #Create a function to t...
true
23ebf6103e927ea58302f57258cb19ef96079f0e
abdulwasayrida/Python-Exercises
/Exercise 4.23.py
985
4.21875
4
#Exercise 4.23 #Geometry: point in a rectangle? #Rida Abdulwasay #1/8/2018 import turtle #Prompt the user to enter a point x , y = eval(input("Please enter a point with two coordinates:")) #Draw the rectangle turtle. color ("blue") turtle. penup () turtle. forward (2.5) turtle. left (90) turtle. pendown() turtle. fo...
false
a947b5056d77c1dcb67ece941a86ce3afd26cdf2
Faranaz08/assignment2
/decimaltobin.py
226
4.21875
4
# decimal to binary usingfunction def convertToBinary(n): if n > 1: convertToBinary(n//2) print(n % 2 ,end=' ' ) # decimal number dec = int(input("enter a decimal number")) convertToBinary(dec) print()
false
e6a084c2bf6c0c34e3ffcd81ec94d893412a74db
chengming-1/python-turtle
/W7/lab-7/names.py
612
4.1875
4
# Create an empty dictionary names = {} names['Wash'] = 'Rick' names['Geier'] = 'Caitlin' names['DiLisio'] = 'Armand' names['wang']='chengming' a = input("Enter the last name of a student: ") b = input("Enter the First name of a student: ") names[a]=b while True: last_name = input("Enter a stude...
true
09b19aa33e576b71a463bd1aced49b14e2e0d74b
lebuingockhang123/L-p-tr-nh-python
/LeBuiNgocKhang_53157_CH03/Exercise/page_85_exercise_04.py
657
4.125
4
""" Author: Le Bui Ngoc Khang Date: 12/07/1997 Problem: Assume that the variables x and y refer to strings. Write a code segment that prints these strings in alphabetical order. You should assume that they are not equal. Solution: The sorted words are: bui khang le ngoc """ # Program to sort alphabetically the wor...
true
53878427622bba5b8e795204524588c123540e36
lebuingockhang123/L-p-tr-nh-python
/LeBuiNgocKhang_53157_CH06/Projects/page_203_exercise_02.py
719
4.25
4
""" Author: Le Bui Ngoc Khang Date: 12/07/1997 Program: Convert Newton’s method for approximating square roots in Project 1 to a recursive function named newton. (Hint: The estimate of the square root should be passed as a second argument to the function.) Solution: 2.0000000929222947 """ approximating = 0.000001 ...
true
34df6e92f6125e3408e46221b645c44b2855e728
lebuingockhang123/L-p-tr-nh-python
/LeBuiNgocKhang_53157_CH06/Exercise/page_182_exercise_02.py
569
4.21875
4
""" Author: Le Bui Ngoc Khang Date: 12/07/1997 Program: The factorial of a positive integer n, fact(n), is defined recursively as follows: fact(n) = 1 , when n = 1 fact(n) n * fact (n-1) , otherwise Define a recursive function fact that returns the factorial of a given positive integer Solution: Ent...
true
81125a2c8610d4531755bb4a53cb19aa3d946c96
lebuingockhang123/L-p-tr-nh-python
/LeBuiNgocKhang_53157_CH04/Projects/page_132_exercise_02.py
640
4.40625
4
""" Author: Le Bui Ngoc Khang Date: 12/07/1997 Program: Write a script that inputs a line of encrypted text and a distance value and outputs plaintext using a Caesar cipher. The script should work for any printable characters Solution: Enter the coded text: khoor#zruog Enter the distance value: 3 hello world """ # R...
true
7a5c1a0d7c416a8f88934c5b6daecb4c36fefa45
lebuingockhang123/L-p-tr-nh-python
/LeBuiNgocKhang_53157_CH06/Projects/page_204_exercise_09.py
623
4.125
4
""" Author: Le Bui Ngoc Khang Date: 12/07/1997 Program: Write a program that computes and prints the average of the numbers in a text file. You should make use of two higher-order functions to simplify the design. Solution: Enter the file name: textnumber.txt The average is 3.0 """ def main(): fileName = input(...
true
47c65a3c577e406863dba437b479719540e39061
lebuingockhang123/L-p-tr-nh-python
/LeBuiNgocKhang_53157_CH03/Projects/page_99_exercise_02.py
1,005
4.3125
4
""" Author: Le Bui Ngoc Khang Date: 12/07/1997 Problem: Write a program that accepts the lengths of three sides of a triangle as inputs. The program output should indicate whether or not the triangle is a right triangle. Recall from the Pythagorean theorem that in a right triangle, the square of one side equals the sum...
true
6873aa32b9630205bbc7475864686dd85187beaa
lebuingockhang123/L-p-tr-nh-python
/LeBuiNgocKhang_53157_CH04/Projects/page_132_exercise_06.py
1,004
4.375
4
""" Author: Le Bui Ngoc Khang Date: 12/07/1997 Program: Use the strategy of the decimal to binary conversion and the bit shift left operation defined in Project 5 to code a new encryption algorithm. The algorithm should add 1 to each character’s numeric ASCII value, convert it to a bit string, and shift the bits of thi...
true
81627d0a80c0c03f3027ff7296a3638a447c37e7
lebuingockhang123/L-p-tr-nh-python
/LeBuiNgocKhang_53157_CH04/Projects/page_133_exercise_09.py
941
4.21875
4
""" Author: Le Bui Ngoc Khang Date: 12/07/1997 Program: Write a script named copyfile.py. This script should prompt the user for the names of two text files. The contents of the first file should be input and written to the second file. Solution: Enter the input file name: test9.txt Enter the output file name: test9_...
true
fc90debc52d5f84e0d03ab770ba10746405d657f
lebuingockhang123/L-p-tr-nh-python
/LeBuiNgocKhang_53157_CH07/Exercise/page_218_exercise_03.py
480
4.46875
4
""" Author: Le Bui Ngoc Khang Date: 12/07/1997 Program: Add a function named circle to the polygons module. This function expects the same arguments as the square and hexagon functions. The function should draw a circle. (Hint: the loop iterates 360 times.) Solution: """ import turtle def polygon(t, length, n): ...
true
26ce3efa3df58e629c706ad5da9b8457ba0e9d52
lebuingockhang123/L-p-tr-nh-python
/LeBuiNgocKhang_53157_CH06/Exercise/page_199_exercise_02.py
317
4.21875
4
""" Author: Le Bui Ngoc Khang Date: 12/07/1997 Program: Write the code for a filtering that generates a list of the positive numbers in a list named numbers. You should use a lambda to create the auxiliary function. Solution: [1, 79] """ numbers = [1, -2, -66, 79] result = list(filter(lambda x: x > 0, numbers)) print...
true
5c5fc3250152575883481aca9ee77e0a632f7c95
Dukiemar/RSA-Encryption
/RSA_Encryption.py
2,632
4.34375
4
import random def PGP_encryption(): p=input("enter the 1st prime number:")#prompts the user to enter the value for p q=input("enter the 2nd prime number:")#prompts the user to ented the value for q message=input("enter message:") def isPrime(n): #this function ristricts the user to only enter p...
true
f7df966b90cd84cadf6805203d190df700a58f9f
prastabdkl/pythonAdvancedProgramming
/chap7lists/plotting/sec5piechart.py
511
4.25
4
# plotting a Piechart # Author: Prastab Dhakal # Chapter: plotting import matplotlib.pyplot as plt def main(): #create a list of values values=[20,60,80,40] #title plt.title("PIE CHART") #create a list of labels for the slices. slice_labels=['1st Qtr','2nd Qtr','3rd Qtr','4th Qtr'] ...
true
941f9950cf21e526a0cb8c50feb2a553d6e5d4c3
prastabdkl/pythonAdvancedProgramming
/chap6FilesAndException/others/save_file_records.py
2,541
4.125
4
# This program gets employee data from the user and # saves it as records in the employee.txt file. # read the records and show until the end is reached handles the value errors, # read file error and searches the file until the end is reached # # Author: Prastab Dhakal # Chapter: Files and Exception(Complex problem)...
true
d5fc347cad1f2a3a1cd26cab15653aea5f9bb986
rodri0315/pythonCSC121
/chapter3/area_of_rectangles.py
966
4.59375
5
# Chapter 1 Assignment # Author: Jorge Rodriguez # Date: February 5, 2017 print('You will enter the length and width for two rectangles') print('The program will tell you which rectangle has the greater area') # get length and width of 2 rectangles rect_length1 = float(input('Enter the length of the first rectangle: '...
true
fab42d2bbb28bff895054c136584314f4091fb20
xis24/CC150
/Python/FreqOfMostFrequentElement.py
965
4.25
4
from typing import List class FreqOfMostFrequentElement: ''' The frequency of an element is the number of times it occurs in an array. You are given an integer array nums and an integer k. In one operation, you can choose an index of nums and increment the element at that index by 1. Return the maxim...
true
29108375b2c46d239764d70dd6b7fc4416c5e89d
xis24/CC150
/Python/SortColors.py
931
4.15625
4
from typing import List class SortColors: # 1. discuss the approach # 2. run the test case # 3. ask if I can start to code # 4. start to code # 5. run test case with code # 6. time complexity and space complexity def sortColors(self, nums: List[int]) -> None: zeros = 0 # positio...
true
2d8c9ba19b177f95ecf6e65da4c5a5c353390d42
travisthurston/OOP_example
/Card.py
549
4.125
4
#Card class is a blueprint of the card object #This is the parent or base class for Minion class Card: #initializer to create the attributes of every class object def __init__(self, cost, name): self.cost = cost self.name = name #attributes - argument - parameter - describes the object ...
true
4a2186d1443b1dcba7bd4a02c93afe9cb55e4855
Ustabil/Python-part-one
/mini_projects/guess_the_number/guess_the_number.py
2,497
4.28125
4
# template for "Guess the number" mini-project # input will come from buttons and an input field # all output for the game will be printed in the console #Codeskulptor URL: http://www.codeskulptor.org/#user40_06oB2cbaGvb17j2.py import simplegui import random current_game = 0 # helper function to start and restart t...
true
4523e4efe62db4005d9e09b9fa8e5f20b548ef81
grebwerd/python
/practice/practice_problems/shortestPath.py
1,021
4.15625
4
def bfs_paths(graph, start, goal): queue = [(start, [start])] #queue is a list made up of a tuple first tuple is a start and the second tuple is a list while queue: (vertex, path) = queue.pop(0) for next in graph[vertex] - set(path): #for each next adjacency node not in the set already ...
true
befb06130ebf46def192f3a33c799e7139303290
abaker2010/python_design_patterns
/decorator/decorator.py
861
4.125
4
""" Decorator - Facilitates the addition of behaviors to individual objects without inheriting from them Motivation - Want to augment an object with additional functionality - Do no want to rewrite or alter existing code (OCP) - Want to keep new functionality separate (SRP) - Need to be able to interact with existin...
true
69ceec17993f350329a7f6214657fc9aae84ef1a
Zolton/Sprint-Challenge--Algorithms
/recursive_count_th/count_th.py
806
4.21875
4
''' Your function should take in a single parameter (a string `word`) Your function should return a count of how many occurences of ***"th"*** occur within `word`. Case matters. Your function must utilize recursion. It cannot contain any loops. ''' test = "THtHThth" test2 = "abcthefthghith" test3 = "abcthxyz" count = ...
true
7c2549bcb4f95d76184c334a4968773a0ab7e500
Zchhh73/Python_Basic
/chap6_struct/struct_break_continue.py
208
4.15625
4
for item in range(10): if item == 3: break print('Count is : {0}'.format(item)) print('\n') for item in range(10): if item == 3: continue print('Count is : {0}'.format(item))
true
9ad465abc7b49c53b21b65897650da85f39303f0
Lousm/Python
/01_py基础/第1周/day05/test06.py
2,383
4.40625
4
# 学生管理 a = {'001': {"name": '小张', 'age': 21, "address": "北京"}, '002': {"name": '小明', 'age': 22, "address": "山东"}, '003': {"name": '小王', 'age': 23, "address": "河北"}, '004': {"name": '小李', 'age': 24, "address": "北京"}} def add(): snum = input("请输入你要添加的学号:") while True: if snum in a: ...
false
4b1bb8a4e501b50680d29d4688405b1a5c0f8bf4
mgtz505/algorithms
/implementations/sorting_algorithms/quicksort.py
518
4.15625
4
print("Implementation of Quicksort") test_data = [3,11,4,0,7,2,12,7,9,6,5,10,3,14,8,5] def quickSort(N): length = len(N) if length <= 1: return N else: larger, smaller = [], [] pivot = N.pop() for num in N: if num < pivot: smaller.append(num) ...
true
3e36b2f72dbe1c248365e51566f81a21e6e18b3e
alex-mucci/ce599-s17
/18-Design and Classes/Car.py
2,655
4.4375
4
#constansts START_NORTH = 0 START_SOUTH = 0 START_EAST = 0 START_WEST = 0 # Define the class class Car(object): """ Base class for a car """ def __init__(self, color,location = [0,0],direction = 'N'): if len(location) < 2 or len(location) > 2: print('location is the x,y coordina...
true
8969c70857b05f92b3cec8f3339bb543498b39e3
kolevatov/python_lessons
/simple_object.py
550
4.15625
4
# Simple object class Simple(object): """Simple object with one propertie and method""" def __init__(self, name): print("new object created") self.__name = name def __str__(self): return "Simple object with name - " + self.__name @property def name(self): return sel...
true
fd4890d93ad997451e2fb0a222e793c5beb4a3bb
kolevatov/python_lessons
/calculation table.py
711
4.34375
4
# Составить программу вывода таблицы умножения на число M # Таблица составляется от M * a, до M * b, где M, a, b запрашиваются у пользователя. print("Программа ввывода таблицы умножения на число M") m = int(input("Введите число M: ")) a = int(input("Введите число a: ")) b = int(input("Введите число b: ")) while a > b:...
false