blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
931b0405af3e64489598ed42d0b68a77d6a589de
Tanmay53/cohort_3
/submissions/sm_108_krishna-kant/week_13/day_5/tax_calculator.py
1,668
4.125
4
print("Enter Total Income") total_income = int(input()) tax = 0 taxable_income = 0 taxable_amount = 0 rebate = 0 print("Enter your savings") savings = int(input()) # Checking if savings is not greater than total income if savings > total_income: print("Savings can't be more than total Income") else : # Calculatin...
true
366a0d851d1a0fc2509323f283e48e0e9322e498
Tanmay53/cohort_3
/submissions/sm_104_asheeh/week_19/day_4/session1/rotate_the_link_list.py
1,485
4.28125
4
class Node: # constructor to initialize the node object def __init__(self, data): self.data = data self.next = None class LinkedList: # function to make the empty linkedlist def __init__(self): self.head = None # function to insert the node at # the head of the linkedl...
true
f777b0ba6016efa84309aedfecb28772bbc7193d
Tanmay53/cohort_3
/submissions/sm_112_soumik/week_13/day_4/session_1/union_sets.py
208
4.25
4
input1 = input("Enter a word") input2 = input("Enter second word") my_set = {""} for letter in input1: my_set.add(letter) for letter in input2: my_set.add(letter) print("union is", "".join(my_set))
true
25c974572883afaa2a8c697fa7522ecd3b53491c
Tanmay53/cohort_3
/submissions/sm_001_aalind/week_14/day_3/evaluation/sets_intersection.py
957
4.21875
4
# splits string by given character and returns a set def split_string(split_by, given_string): new_set = set() temp_str = '' for char in given_string: if char != ',': temp_str += char else: new_set.add(temp_str) temp_str = '' new_set.add(temp_str...
true
3c46a34d85f9f770eec03952fbfb76a6738252bf
Tanmay53/cohort_3
/submissions/sm_102_amit/week_14/day_3/evaluation/email_domain.py
235
4.1875
4
# Find the email domain email = input("Enter email address: ") result = "" for i in range(len(email)): if email[i] == "@": result = email[i + 1:] print(result) # Sample Case: ''' Enter email address: akamit21@gmail.com gmail.com '''
true
ae820b193c160d4c3bb40229cf162b2096126c6c
jrfaber90/Prime
/generate.py
1,113
4.15625
4
# !/usr/bin/python from primepackage.primemodule import * from primepackage.primeio import * """A Python module generating a list of prime numbers and output them into a csv file """ def main(): """Generate 100 prime numbers and output it into output.csv file variable primes calls getNPrime(100) to ge...
true
98ffb29a1385dead0827c3556f01f59e245da8ec
catstacks/DFESW3
/functions.py
2,372
4.34375
4
# Create a program that works out a grade based on marks with the use of functions. # The program should take the students name, homework score (/25), assessment score (/50) and final exam score (/100) as inputs, and output their name and final ICT grade as a percentage. See below: # name = str(input("Please enter yo...
true
76c61799b95031e11f8877dad72bba772d508a5c
AshishRMenon/CV-Project-2019
/bin/gui/messagebox.py
309
4.1875
4
from tkinter import * import tkinter.messagebox root = Tk() tkinter.messagebox.showinfo('Window Title',"do you want to save it!") answer = tkinter.messagebox.askquestion("Question 1","do you like it?") if answer == 'yes': print("so you like it!") else: print("so you don't like it!") root.mainloop()
true
b36c1caa002e1541f34c2c543566a92969aa0837
CableX88/Projects
/Python projects/forSquares.py
603
4.125
4
# This program allows the user to enter start and end range #Program List nums and its squares start = int(input("Enter start number: ")) end = int(input("Enter end number: ")) print("Number\t Square") print("_______________") for num in range(start,end): square = num**2 print(num,'\t',square) ##=============...
true
932405d48032f74c5eb01e6fadcbdee98dbb0663
CableX88/Projects
/Python projects/HW 5.py
2,988
4.4375
4
#David Brown #ID: 837183 #This program calculates the costs of loans class Loan: def __init__(self, rate = 2.5, years = 1, loan = 1000, borrower = " "): self.__rate = rate #the interest rate for your loan self.__years = years # the years you have to pay for self.__loan = loan # your loan ...
true
93e27d884f148db46c066f752722a9cc1894241c
yichuanma95/leetcode-solns
/python3/maxDepthNTree.py
999
4.125
4
''' Problem 559: Maximum Depth of N-ary Tree Given a n-ary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. For example, given a 3-ary tree: 1 |-3 | |-5 | |-6 |-2 |-4 * my best recreation of an N-ary tree with ASCII in a ...
true
c71f366183f0242ebf46f067ead100786877602e
yichuanma95/leetcode-solns
/python3/employeeImportance.py
1,964
4.1875
4
''' Problem 690: Employee Importance You are given a data structure of employee information, which includes the employee's unique id, their importance value and their direct subordinates' id. For example, employee 1 is the leader of employee 2, and employee 2 is the leader of employee 3. They have importance value 15...
true
fe2202c1febc99f88a854880575b070deee996c7
yaminirathod/WEEK1_Assignment
/Assignment_Question3_Method1.py
467
4.4375
4
# 3.Write a Python program to display the current date and time. # Developed by : Yamini Rathod C0796390 # Date : 16-05-2021 import datetime print('The program to display the current date and time. Prepared by : Yamini Rathod C0796390') currenttime = datetime.datetime.now() #currentday = datetime.datetime.day() #cur...
true
e3b970c21f73c854badfc06eb624c374dc019bac
jpchato/data-structures-and-algorithms-python
/challenges/ll_merge/ll_merge.py
892
4.21875
4
def mergeLists(self, other_list): list1_curr = self.head list2_curr = other_list.head # This line of code checks to ensure that there are available positions in curr while list1_curr != None and list2_curr != None # Save next pointers # Creating new variables which save next pointers ...
true
edf23eb42d256e999a6d278aa0200dd40f240ce9
jpchato/data-structures-and-algorithms-python
/challenges/merge_sort/merge_sort.py
2,423
4.40625
4
# reference https://www.geeksforgeeks.org/merge-sort/ # reference https://www.pythoncentral.io/merge-sort-implementation-guide/ def merge_sort(arr): # If the length of the array is greater than 1, execute the code below if len(arr) > 1: # Finds the middle of the array using floor division(decimals remo...
true
b21531b2085f41323820c20f2342f92eb44a3b1d
zoearon/calculator-2
/calculator.py
1,690
4.4375
4
"""A prefix-notation calculator. Using the arithmetic.py file from Calculator Part 1, create the calculator program yourself in this file. """ from arithmetic import * def find_opp(opp): if opp == "+": return add elif opp == "-": return subtract elif opp == "*": return multiply ...
true
a12c32c5c94ce9178a1265ecbf08fda3e98e8799
rojaboina/Python
/python_basics/Trouble.py
229
4.1875
4
def city_country(city,country): i=1 while i<=3: i=i+1 city=input("please enter your city name") country=input("please enter your country name") print(f"{city},{country} are amazing") city_country('city','country')
true
10abc4dcb99706de8ba7c0f5bf2e256c7570289e
gaiagirl007/char_sheet
/my_dice.py
1,232
4.34375
4
"""This 'rolls' dice.""" import random def roll(num, max): """Generates a random number between 1 and max, num times. Adds and returns the results num: int > 0 max: int > 1""" assert type(num) == int and num > 0 assert type(max) == int and max > 1 total = 0 for i in ran...
true
30a0626f0018e445b54a08dd49136be59dfebad5
SatyamAS/venom
/SL_LAB/QA2.py
532
4.25
4
##2. Write a python program to count the frequency of words in a given file. file = open("QA2.txt") worddic = { } for line in file: myline = line.split() for word in myline: w = worddic.get(word,0) worddic[word] = w + 1 print (worddic ,"\n ") ##OR ##f...
true
3e2e1985cb59016d7d9abd1bf413d6104a9c1292
SatyamAS/venom
/SL_LAB/QB4.py
827
4.25
4
##4. Load the Titanic dataset into one of the data structures (NumPy or Pandas). ##Display header rows and description of the loaded dataset. ##Remove unnecessary features (E.g. drop unwanted columns) from the dataset. ##Manipulate data by replacing empty column values with a default value. ##Pandas for structure...
true
a2e667235a5e2f5dbe17bf49e7e5e41328e97137
han8909227/leetcode
/tree/path_sum_lc112.py
1,088
4.25
4
# Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. # For example: # Given the below binary tree and sum = 22, # 5 # / \ # 4 8 # / / \ # 11 13 4 # ...
true
958d7889c39d995c6ddf5760409a234761f5f232
han8909227/leetcode
/linked_list/intersection_two_ll_lc160.py
2,111
4.1875
4
# Write a program to find the node at which the intersection of two singly linked lists begins. # For example, the following two linked lists: # A: a1 → a2 # ↘ # c1 → c2 → c3 # ↗ # B: b1 → b2 → b3 # begin to intersect at node c1. # Notes: # I...
true
1937b55cf07d80ca4289babb1eb9ee7092a5ea40
han8909227/leetcode
/tree/sibliing_pointer_ii_lc117.py
2,563
4.28125
4
# Follow up for problem "Populating Next Right Pointers in Each Node". # What if the given tree could be any binary tree? Would your previous solution still work? # Note: # You may only use constant extra space. # For example, # Given the following binary tree, # 1 # / \ # 2 3 # / \ ...
true
1db7b331d60a6872c595d0441cb07cd606284180
han8909227/leetcode
/stack_and_q/q_with_stacks_lc232.py
1,638
4.5
4
# Implement the following operations of a queue using stacks. # push(x) -- Push element x to the back of queue. # pop() -- Removes the element from in front of queue. # peek() -- Get the front element. # empty() -- Return whether the queue is empty. # Notes: # You must use only standard operations of a stack -- which ...
true
3b2575fcfca6f487c6125159cce920fc84bc8b21
Chiki1601/Insertion-sort-visualisation
/insertion.py
1,953
4.3125
4
Program: # Insertion Sort Visualization using Matplotlib in Python # import all the modules import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation import matplotlib as mp import numpy as np import random # set the style of the graph plt.style.use('fivethirtyeight') # input the size of the arra...
true
92e730a36142ca0e7aee4ae2084e75be488832e4
mrityunjaykumar911/DSA
/Hackerrank/Data Structures/Arrays/Arrays - DS.py
1,171
4.1875
4
# coding=utf-8 """ Created by mrityunjayk on 3/10/16. Website: https://www.hackerrank.com/challenges/arrays-ds ----------------------------------------------------------------- Problem Statement: An array is a type of data structure that stores elements of the same type in a...
true
de11db01eab089669ea8524708b232bc843b0663
Rayxclockwork/python-data-structures-and-algorithms
/challenges/ll_merge/ll_merge.py
1,217
4.21875
4
class LinkedList: def __init__(self): """starts empty linked list""" self.head = None def insert(self, value): """Instantiates new node as head""" current = self.head new_node = Node(value, current) self.head = new_node def merge_lists(self, linked_list1, linked_list2): """zip-merges 2 linked lists ...
true
5d3ace37037d6aeeac63924ccc3513f8d71f8c66
bryan-truong99/SASE-Name-Checker
/main.py
1,470
4.40625
4
import csv import pandas as pd names = ["francis", "kelynn", ""] def convert_csv(file): df = pd.read_csv(file) name_column = df["Name"] return name_column def scan_names(column): names = ["josh", "raph", "elton", "francis", "kelly l", "kelly c", "kaitlyn", "baron", "michelle", "young", "brandon", "...
true
63a339a1ebdc06649e169f333cb7d72686df311e
gojo5t5/elements-of-ai-building-ai
/BuildingAI/8_fishing_in_the_nordics.py
1,360
4.1875
4
# using bayes theorem and knowledge of conditional probabilities to solve probability problems countries = ['Denmark', 'Finland', 'Iceland', 'Norway', 'Sweden'] populations = [5615000, 5439000, 324000, 5080000, 9609000] male_fishers = [1822, 2575, 3400, 11291, 1731] female_fishers = [69, 77, 400, 320, 26] total_male_f...
true
26f3150214602744c5ad7f8aec6a44ce0056ef36
southpawgeek/perlweeklychallenge-club
/challenge-027/paulo-custodio/python/ch-1.py
705
4.15625
4
#!/usr/bin/python3 # Challenge 027 # # Task #1 # Write a script to find the intersection of two straight lines. The # co-ordinates of the two lines should be provided as command line parameter. # For example: # # The two ends of Line 1 are represented as co-ordinates (a,b) and (c,d). # # The two ends of Line 2 are rep...
true
31a5bcde9add1323edd56aaaab7cbe25e41e3e34
southpawgeek/perlweeklychallenge-club
/challenge-110/paulo-custodio/python/ch-2.py
858
4.3125
4
#!/usr/bin/env python3 # Challenge 110 # # TASK #2 - Transpose File # Submitted by: Mohammad S Anwar # You are given a text file. # # Write a script to transpose the contents of the given file. # # Input File # name,age,sex # Mohammad,45,m # Joe,20,m # Julie,35,f # Cristina,10,f # Output: # name,Mohammad,Joe,Julie,Cri...
true
f951353e5df55a780b2237169b0c9f9186c29eca
southpawgeek/perlweeklychallenge-club
/challenge-161/paulo-custodio/python/ch-1.py
792
4.375
4
#!/usr/bin/env python3 # Challenge 161 # # Task 1: Abecedarian Words # Submitted by: Ryan J Thompson # An abecedarian word is a word whose letters are arranged in alphabetical # order. For example, "knotty" is an abecedarian word, but "knots" is not. # Output or return a list of all abecedarian words in the dictionary...
true
030c1519a0c1d3a8f35a5f2ef66a013c57d84c89
southpawgeek/perlweeklychallenge-club
/challenge-173/mohammad-anwar/python/ch-1.py
674
4.15625
4
#!/usr/bin/python3 ''' Week 173: https://theweeklychallenge.org/blog/perl-weekly-challenge-173 Task #1: Esthetic Number You are given a positive integer, $n. Write a script to find out if the given number is Esthetic Number. ''' import unittest def is_esthetic_number(n): s = str(n) for i in...
true
42c60c0d222f3f40092de0a72c4804b2981ba967
southpawgeek/perlweeklychallenge-club
/challenge-130/paulo-custodio/python/ch-1.py
669
4.3125
4
#!/usr/bin/env python3 # Challenge 130 # # TASK #1 > Odd Number # Submitted by: Mohammad S Anwar # You are given an array of positive integers, such that all the # numbers appear even number of times except one number. # # Write a script to find that integer. # # Example 1 # Input: @N = (2, 5, 4, 4, 5, 5, 2) # Output:...
true
e26e73fc636c01477fe6d582aa9a5982d26431f2
southpawgeek/perlweeklychallenge-club
/challenge-125/paulo-custodio/python/ch-2.py
2,199
4.5625
5
#!/usr/bin/env python3 # Challenge 125 # # TASK #2 > Binary Tree Diameter # Submitted by: Mohammad S Anwar # You are given binary tree as below: # # 1 # / \ # 2 5 # / \ / \ # 3 4 6 7 # / \ # 8 10 # / # 9 # Write a script to find the diameter of the given binary tree. # # The diamet...
true
181b98baf3ef0ec7b6326b319d0265303ee35f7f
southpawgeek/perlweeklychallenge-club
/challenge-080/paulo-custodio/python/ch-1.py
604
4.1875
4
#!/usr/bin/python3 # Challenge 080 # # TASK #1 > Smallest Positive Number # Submitted by: Mohammad S Anwar # You are given unsorted list of integers @N. # # Write a script to find out the smallest positive number missing. # # Example 1: # Input: @N = (5, 2, -2, 0) # Output: 1 # Example 2: # Input: @N = (1, 8, -1) # Ou...
true
24571be35274ccdbf012e6f495cfb55113ff06bc
southpawgeek/perlweeklychallenge-club
/challenge-111/paulo-custodio/python/ch-1.py
1,727
4.1875
4
#!/usr/bin/env python3 # Challenge 111 # # TASK #1 - Search Matrix # Submitted by: Mohammad S Anwar # You are given 5x5 matrix filled with integers such that each row is sorted # from left to right and the first integer of each row is greater than the # last integer of the previous row. # # Write a script to find a gi...
true
aa4e0c6eb4930e5e41544dfa45235084582d27a2
southpawgeek/perlweeklychallenge-club
/challenge-018/paulo-custodio/python/ch-2.py
2,813
4.59375
5
#!/usr/bin/python3 # Challenge 018 # # Task #2 # Write a script to implement Priority Queue. It is like regular queue except # each element has a priority associated with it. In a priority queue, an # element with high priority is served before an element with low priority. # Please check this wiki page for more infor...
true
3562ca58227644917359011d9ac2bdc4600eba3c
southpawgeek/perlweeklychallenge-club
/challenge-123/paulo-custodio/python/ch-1.py
1,000
4.5625
5
#!/usr/bin/env python # Challenge 123 # # TASK #1 > Ugly Numbers # Submitted by: Mohammad S Anwar # You are given an integer $n >= 1. # # Write a script to find the $nth element of Ugly Numbers. # # Ugly numbers are those number whose prime factors are 2, 3 or 5. For example, # the first 10 Ugly Numbers are 1, 2, 3, 4...
true
28058f54553dc829e4b41477761197daa2b8ea53
southpawgeek/perlweeklychallenge-club
/challenge-013/paulo-custodio/python/ch-1.py
897
4.5
4
#!/usr/bin/python3 # Challenge 013 # # Challenge #1 # Write a script to print the date of last Friday of every month of a given year. # For example, if the given year is 2019 then it should print the following: # # 2019/01/25 # 2019/02/22 # 2019/03/29 # 2019/04/26 # 2019/05/31 # 2019/06/28 # 2019/07/26 # 2019/08/30 # ...
true
ddeb79648fe323c4e2332c76c2943b8635494494
southpawgeek/perlweeklychallenge-club
/challenge-140/paulo-custodio/python/ch-1.py
802
4.21875
4
#!/usr/bin/python3 # Challenge 140 # # TASK #1 > Add Binary # Submitted by: Mohammad S Anwar # You are given two decimal-coded binary numbers, $a and $b. # # Write a script to simulate the addition of the given binary numbers. # # The script should simulate something like $a + $b. (operator overloading) # # Example 1 ...
true
cbd9121e6c8c3f678ec2ce3d918c1380bf271d58
southpawgeek/perlweeklychallenge-club
/challenge-120/paulo-custodio/python/ch-2.py
1,057
4.40625
4
#!/usr/bin/env python # Challenge 120 # # TASK #2 - Clock Angle # Submitted by: Mohammad S Anwar # You are given time $T in the format hh:mm. # # Write a script to find the smaller angle formed by the hands of an analog # clock at a given time. # # HINT: A analog clock is divided up into 12 sectors. One sector represe...
true
5e4e40bdfdd873f1a7d3167402d0464c944f74a8
southpawgeek/perlweeklychallenge-club
/challenge-115/paulo-custodio/python/ch-2.py
878
4.34375
4
#!/usr/bin/env python3 # Challenge 115 # # TASK #2 - Largest Multiple # Submitted by: Mohammad S Anwar # You are given a list of positive integers (0-9), single digit. # # Write a script to find the largest multiple of 2 that can be formed from the # list. # # Examples # Input: @N = (1, 0, 2, 6) # Output: 6210 # # Inp...
true
57a13fefb2407ad365415d7736d66812291a8998
JohnnyFang/datacamp
/machine-learning-with-the-experts-school-budgets/04-learning-from-the-expert-processing/10-implementing-the-hashing-trick-in-scikit-learn.py
799
4.1875
4
""" Implementing the hashing trick in scikit-learn In this exercise you will check out the scikit-learn implementation of HashingVectorizer before adding it to your pipeline later. As you saw in the video, HashingVectorizer acts just like CountVectorizer in that it can accept token_pattern and ngram_range parameters....
true
51b2a825d5e02f40b396f365c5226e96dd1fa440
JohnnyFang/datacamp
/10-Merging-DataFrames-with-Pandas/04-case-study-Summer-Olympics/06-computing-percentage-cjange-in-fraction-of-medals-won.py
923
4.375
4
''' Create mean_fractions by chaining the methods .expanding().mean() to fractions. Compute the percentage change in mean_fractions down each column by applying .pct_change() and multiplying by 100. Assign the result to fractions_change. Reset the index of fractions_change using the .reset_index() method. T...
true
6a3c75c8c221fdaad8a6ec854679349cd7e419b5
anushajain19/Extracting-data-with-python
/Week 5/xml_parsing.py
1,261
4.15625
4
#Extracting Data from XML #In this assignment you will write a Python program somewhat similar to http://www.py4e.com/code3/geoxml.py. The program will prompt for a URL, read the XML data from that URL using urllib and then parse and extract the comment counts from the XML data, compute the sum of the numbers in t...
true
187905f103c8abf7dbfbdd019fecee72d3d739a2
ShashankDhungana/gvhj
/Lab2/N4.py
395
4.25
4
'''4. Given three integers, print the smallest one. (Three integers should be user input)''' a = int(input('Enter first number : ')) b = int(input('Enter second number : ')) c = int(input('Enter third number : ')) smallest = 0 if a < b and a < c : smallest = a if b < a and b < c : smallest = b if c < a and c ...
true
3afcb51d1df181cfc0add8a80d85af8f1a95169d
guiltylogik/automateTheBoringStuff
/guessingGame.py
1,602
4.15625
4
# A simple guessing game. # TODO: get player name # get random number - secret number # get player guesses # give hint after 3 tries # display result after 5 tries # decompose the program import random as r lower_limit = r.randint(0, 40) upper_limit = r.randint(60, 100) com_guess = r.ran...
true
1cd2e92359d0c033ea58f34d650952f09453353d
RUPAbahadur/Python-Programs
/indexingstring.py
996
4.21875
4
""" String indexing examples. """ phrase = "Python is great!" # first character print(phrase[0]) #retrieve the first char of variable'a value # fourth character fourth = phrase[3] print(fourth) print(type(phrase)) # 'type' returns the type of object ->str print(type(fourth)) # in python even a single ch...
true
42cf76652772e5a7b7799b832793aca78f15b8ce
raopratik/Commonsense-QA
/SocialIQA/utils.py
970
4.21875
4
import sys sys.path.append(".") import pickle def save_dictionary(dictionary, save_path): """ This method is used to save dictionary to a given path in pickle file Args: dictionary (dict): dictionary which has to be saved save_path (str): path where the dictionary has to be saved """...
true
862e362b69389d17a3285f4d4a77c7ff3f920c65
turboslayer198/mitx-6.00.1x
/Lecture Programs/coordinate.py
1,450
4.25
4
class Coordinate(object): def __init__(self, x, y): self.x = x self.y = y def distance(self, other_coordinate_object): x_diff_sq = (self.x - other_coordinate_object.x)**2 y_diff_sq = (self.y - other_coordinate_object.y)**2 return (x_diff_sq + y_diff_sq)**0.5 # Pytho...
true
eaa9bca966aa7efb22c0134ffea586bfa7eb8818
GuilhermeLaraRusso/python_work
/ch_9_classes/9_14_overriding_methods_from_parent_class.py
2,440
5
5
# Overriding Methods from the Parent Class # You can override any method from the parent class that doesn’t fit what # you’re trying to model with the child class. To do this, you define a method # in the child class with the same name as the method you want to override # in the parent class. Python will disregard the ...
true
119e03f8a51cf75ef2171958a5b7b15b70fdcc76
GuilhermeLaraRusso/python_work
/ch_8_functions/8_14_returning_a_dictionary.py
535
4.40625
4
# A function can return any kind of value you need it to, including more complicated # data structures like lists and dictionaries. For example, the following # function takes in parts of a name and returns a dictionary representing # a person: def build_person(first_name, last_name, age=''): """Return a dictionar...
true
6cf16136cd35f69714f4c93c3059f3b450f6fd22
GuilhermeLaraRusso/python_work
/ch_10_files_and_exceptions/10_1_reading_an_entire_file.py
2,826
4.8125
5
# To try the following examples yourself, you can enter these lines in an # editor and save the file as pi_digits.txt, or you can download the file from the # book’s resources through https://www.nostarch.com/pythoncrashcourse/. Save # the file in the same directory where you’ll store this chapter’s programs. # Here’s ...
true
80a289744df25efcbc7b6eecb170b6d4fad12daf
GuilhermeLaraRusso/python_work
/ch_6_dictionaries/6_6_modifying_values_in_dictionary.py
1,062
4.53125
5
# To modify a value in a dictionary, give the name of the dictionary with the # key in square brackets and then the new value you want associated with # that key. # # alien_0 = {'color': 'green'} # print("The alien is " + alien_0['color'] + '.') # # alien_0['color'] = 'yellow' # print("The alien is now " + alien_0['co...
true
6a4b61be398e25ff44daa2d4dce0d72dc94b882a
GuilhermeLaraRusso/python_work
/ch_5_if_statements/5_6_simple_if_statement.py
709
4.21875
4
# The simplest kind of if statement has one test and one action: # if condicional_test: # do something # You can put any conditional test in the first line and just about any # action in the indented block following the test. If the conditional test # evaluates to True, Python executes the code following the if s...
true
7e6de2fcb534cf1c31453998bfcb9b2bbe7d5149
GuilhermeLaraRusso/python_work
/ch_3_introducing_lists/3_1_listas.py
1,167
4.65625
5
# A list is a collection of items in a particular order. You can make a list that # includes the letters of the alphabet, the digits from 0–9, or the names of # all the people in your family. You can put anything you want into a list, and # 38 Chapter 3 # the items in your list don’t have to be related in any particula...
true
c550306104afca1fd23071a399f6136b94c0ab9f
GuilhermeLaraRusso/python_work
/ch_4_working_with_lists/4_12_exercicio_4_10.py
844
4.875
5
# 4-10. Slices: Using one of the programs you wrote in this chapter, add several # lines to the end of the program that do the following: # • Print the message, The first three items in the list are:. Then use a slice to # print the first three items from that program’s list. # • Print the message, Three items from t...
true
4bd4d9ac9e3089f0e7ead3871614b33d9ea350f5
GuilhermeLaraRusso/python_work
/ch_4_working_with_lists/4_11_copying_a_list.py
1,048
4.78125
5
# To copy a list, you can make a slice that includes the entire original list # by omitting the first index and the second index ([:]). This tells Python to # make a slice that starts at the first item and ends with the last item, producing # a copy of the entire list. my_foods = ['pizza', 'falafel', 'carrot cake'] fr...
true
24b521e249dbb84ce0f4fa2abcb4344cfb7fd079
GuilhermeLaraRusso/python_work
/ch_4_working_with_lists/4_15_writing_over_a_Tuple.py
490
4.5625
5
# Although you can’t modify a tuple, you can assign a new value to a variable # that holds a tuple. dimensions = (200, 50) print("Original dimensions:") for dimension in dimensions: print(dimension) dimensions = (400, 100) print("\nModified dimensions:") for dimension in dimensions: print(dimension) # When ...
true
c005f5b24a8ba094077e0f7a07e9c1e825bcbf86
GuilhermeLaraRusso/python_work
/ch_6_dictionaries/6_8_dictionary_of_similar_objects.py
591
4.4375
4
# The previous example involved storing different kinds of information about # one object, an alien in a game. You can also use a dictionary to store one # kind of information about many objects. favorite_languages = { 'jen': 'python', 'sarah': 'c', 'edward': 'ruby', 'phil': 'python', } print("Sarah's...
true
5bc9490da14edf1bf5eab478736afaccf4f8983e
GuilhermeLaraRusso/python_work
/ch_5_if_statements/5_12_exercicio_5_7.py
914
4.40625
4
# 5-7. Favorite Fruit: Make a list of your favorite fruits, and then write a series of # independent if statements that check for certain fruits in your list. # • Make a list of your three favorite fruits and call it favorite_fruits. # • Write five if statements. Each should check whether a certain kind of fruit # is...
true
a63e882dcaa372fb86f6c6f1b295b03bdd2b0df8
GuilhermeLaraRusso/python_work
/ch_6_dictionaries/6_9_exercicio_6_2.py
594
4.125
4
# 6-2. Favorite Numbers: Use a dictionary to store people’s favorite numbers. # Think of five names, and use them as keys in your dictionary. Think of a favorite # number for each person, and store each as a value in your dictionary. Print # each person’s name and their favorite number. For even more fun, poll a few # ...
true
4404a0a7e16dd2342778b7fd2482fcfa6c1229d9
GuilhermeLaraRusso/python_work
/ch_8_functions/8_15_using_function_with_while_loop.py
819
4.40625
4
# You can use functions with all the Python structures you’ve learned about # so far. For example, let’s use the get_formatted_name() function with a while # loop to greet users more formally. Here’s a first attempt at greeting people # using their first and last names: def get_formatted_name(first_name, last_name): ...
true
30a8bf8c4649b7fe4789b4b71f5c1c2bb86dea8a
GuilhermeLaraRusso/python_work
/ch_3_introducing_lists/3_9_organizando_lista.py
835
4.65625
5
# Sorting a List Permanently with the sort() Method # Python’s sort() method makes it relatively easy to sort a list. Imagine we # have a list of cars and want to change the order of the list to store them # alphabetically. To keep the task simple, let’s assume that all the values in # the list are lowercase. cars =...
true
cea42b481f54d9de79ebe6bcde75e31c2cec59e9
techkuz/cs101
/pset3/find_element.py
556
4.125
4
# Define a procedure, find_element, # that takes as its inputs a list # and a value of any type, and # returns the index of the first # element in the input list that # matches the value. # If there is no matching element, # return -1. def find_element(list1, value): for i in list1: p = str(i).find(...
true
36d3a0021913601c5a66403e84c9bf62525ea4ea
KESA24/Hello_python
/calculator.py
568
4.375
4
# num1 = input("Enter a number: ") # num2 = input("Enter another number: ") # # Returns only whole number # # result = int(num1) + int(num2) # # # float uses both decimals and whole numbers # result = float(num1) + float(num2) # print(result) # Better Calculator! num5 = float(input("Enter first number: ")) op = input...
true
52d23edde3fa733d4045a09f97707a8f93a8bc8e
david-belbeze/PythonQueue
/queue.py
1,663
4.34375
4
# -*- coding: UTF_8 -*- class Queue: FIFO = 0 LIFO = 1 def __init__(self, l=[], t=FIFO): """ An object which implement the queue logic from a list. :param l: The base list to use with this queue. The list is empty by default. :param t: The type of the queue FI...
true
659ab18067fc79c6384da8f3d08c90fc570fe09f
vinaykumargattu/Simple_Python_Programs
/nested_for_loop_in_python.py
508
4.25
4
#Nested for loop in python """x=int(input("Enter a number")) i,j=0,0 for i in range(0,x): print("") for j in range(0,i+1): print("*", end='')""" #for loop with else """number1=int(input("Enter the number")) for i in range(0,number1): print(i) else: print("Forloop completed") """ #for loop...
true
b9120e09acf688cc6359d6e1c1fa493f3247c605
millidavids/cs115
/lab6inclass.py
1,395
4.15625
4
# Prolog # Authors: David Yurek, Stanley McClister, Evan Whitmer # Section 012 :: Team 3 # September 27, 2013 # ______________________________________________________________________________ # # Purpose: The purpose of this program is to make a multiplication iteration program # based on two integer inputs fr...
true
00cffefd4ba7dc1578b785da6fb8cb913aa1629e
GrisoFandango/Week-8
/3 - dictionary example.py
646
4.125
4
contacts={"greg": 7235591, "Mary": 3841212, "Bob": 3841212, "Susan": 2213278} # print content of dictionary print("Dictionary content are: \n", contacts) #printing the value of a dictionary key print("Phone number for Susan is:", contacts["Susan"]) #print out how many keys are in the di...
true
e47858f3529f1ac82279414fcd0436d0ece6e869
manifoldfrs/python_sandbox
/python_sandbox_starter/lists.py
877
4.1875
4
# A List is a collection which is ordered and changeable. Allows duplicate members. # Create list numbers = [ 1, 2, 3, 4, 5] # Using a constructor, it's like JS, as if you're calling a new Array constructor. numbers2 = list((1,2,3,4,5)) # print(numbers, numbers2) fruits = ['Apples', 'Oranges', 'Grapes', 'Pears'] #...
true
9063134f575bc3addf0317e22d73431ff9b1c4e0
li--paul/CareerCup-1
/CC8_1/Fibo.py
386
4.21875
4
def fibo(number): if number == 0: return 0 elif number == 1: return 1 elif number == 2: return 1 else: return(fibo(number - 1) + fibo(number - 2)) number = int(input("Please input a number for fibo calculate: ")) while number < 0: print("Number should bigger than zero, try again.") number = int(input(...
true
b4129971bb0aacd1dc26dec4dacf2913caae7e02
iampruven/learning-py-games
/tictactoe.py
1,291
4.28125
4
# Tic Tac Toe Game # player1 = input("Please choose a marker: 'X' or 'O'") # position = int(input('Please enter a number between 1-9:')) from IPython.display import clear_output def display_board(board): # create the set up of the board print(board[0]+'|'+board[1]+'|'+board[2]) print('-----') print(b...
true
29ceed44c99c72879e2198bcd15a3c19ef3e9dc8
paulinatharail/python-challenge
/PyBank/main.py
2,805
4.125
4
import os import csv #path to the csv file bank_csv = os.path.join("Resources","budget_data.csv") #open the file with open (bank_csv, newline="") as bankcsvfile: #create a reader to the file csv_reader = csv.reader(bankcsvfile, delimiter = ",") csv_header = next(csv_reader) #print (f"The csv header is {csv...
true
2b50e8a5a14bed6f10bbcd5110db1cfd91876781
santoshvijapure/DS_with_hacktoberfest
/Data_Structures/Python/pytree.py
1,604
4.40625
4
# Python program to find the maximum width of # binary tree using Level Order Traversal. # A binary tree node class Node: # Constructor to create a new node def __init__(self, data): self.data = data self.left = None self.right = None # Function to get the maximum width of a binary tree def getMaxWi...
true
2d5b50af96b89121b11fb49eb6b8250ceae053b6
udoy382/PyCode
/udoy_017.py
729
4.28125
4
# Open(), Read(), & Readline() For Reading File #26 # open file using [f], then insert txt file name then insert momde. f = open("udoy_1.txt", "rt") # redlines function use for all lines shows without newline like this [\n]. print(f.readlines()) # redline function use for print one by one line. # pri...
true
74ea4821c76670d08cf6e30986ae55ac1e4c4518
endarli/SummerImmersionProjects
/DataAnalysis/DictAttac.py
974
4.3125
4
#Opens a file. You can now look at each line in the file individually with a statement like "for line in f: f = open("dict.txt","r") print("Can your password survive a dictionary attack?") #Take input from the keyboard, storing in the variable test_password #NOTE - You will have to use .strip() to strip whi...
true
d017edaa077234107b268ec1119a0e723a66670c
aalaapn/2200
/labs/example.py
669
4.28125
4
"""Examples illustrating the use of plt.subplots(). This function creates a figure and a grid of subplots with a single call, while providing reasonable control over how the individual plots are created. For very refined tuning of subplot creation, you can still use add_subplot() directly on a new figure. """ import...
true
57ab0785a8b8652b4d03bf7a61e4abc7a0058680
KaduMelo/pyqgis
/python/4_operators.py
704
4.375
4
x = 3 y = 3 # Python Arithmetic Operators # + Addition print(x + y) # - Subtraction print(x - y) # * Multiplication print(x * y) # / Division print(x / y) # % Modulus print(x % y) print(5 % 2) # ** Exponentiation x = 2 y = 5 print(x ** y) #same as 2*2*2*2*2 # // Floor division x = 24 y = 8 print(x // y) # P...
true
bdb2d706571e73da4e03bb112579b6dbc5c2c865
jmartin103/CaesarCipher
/CaesarCipher2.py
2,955
4.5625
5
# This is a program to find the key for an encrypted text file, based on the most common letters. This is used to find the key # for the file, and then use the key to decrypt the file, and then write the decrypted text to an output file. from collections import Counter # Used to count the number of occurrences of e...
true
f30f7e53ef640cd2cb52d05c220db9521617e39c
AndrewKirklandWright/Learn_Python
/Ex810.py
654
4.3125
4
"""Exercise 8.10. A string slice can take a third index that specifies the “step size;” that is, the number of spaces between successive characters. A step size of 2 means every other character; 3 means every third, etc. >>> fruit = 'banana' >>> fruit[0:5:2] 'bnn' A step size of -1 goes through the word backwards, so t...
true
8f24903333883d4324114f57a3f26bc519699a6d
zizzberg/pands-problem-set
/solution-4.py
435
4.21875
4
#step one if current value of n is positive divide it by 2 - if it is odd - #multiply by 3 and add 1 - if 1 end program n = int(input("Input a positive integer: ")) #while loops repeat code but don't run n time - only until a condition is met while n != 1: print(n) if n % 2 == 0: #even n = n / 2 ...
true
8f54776b4bb7ca618633d25488fe61059deac651
Steven-Wright1/Python-Educational-Codes
/if-elif statements.py
467
4.4375
4
# read three numbers number1 = int(input("Enter the first number: ")) number2 = int(input("Enter the second number: ")) number3 = int(input("Enter the third number: ")) # We temporarily assume that the first number # is the largest one. # We will verify this soon. largest_number = number1 if number2 > numbe...
true
03db6bbb60d35fea7ae560f0485d2c87493fcee4
Steven-Wright1/Python-Educational-Codes
/DictionariesAdvanced.py
684
4.46875
4
#In a real dictionary, you look up a word and find a meaning #In a python dictionary (or map), you look up a key, and find a value Eg_Dictionary = {"pi":3.14 , 25:"The square of 5" , "Vitthal":"A name"} # Value Lookup print("The value for key, pi, is", Eg_Dictionary["pi"]) print(Eg_Dictionary.keys()) prin...
true
cb9825acfd2c335fd104893b1374bb3fb1e0844c
tomki1/mergesort-insertionsort
/insertsort.py
1,248
4.25
4
# insertsort.py # name: Kimberly Tom # CS325 Homework 1 # insertSort with help from https://www.geeksforgeeks.org/insertion-sort/ #open a file for reading and open a file for writing data_file = open("data.txt", "r") insert_file = open("insert.txt", "w") def insertSort(integer_array): # for each number ...
true
a01e91603d048dc49c95c320a4ddad031da219c1
Hannibal404/data-structure-and-algorithms
/Arrays/maxHourGlass.py
1,469
4.125
4
# This python3 script accepts a nxn two dimensional matrix # and calculates the maximum hourglass sum possible from it. ''' Example: In this 6x6 Matrix: 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 1 1 1 0 0 0 0 1 0 0 0 0 1 1 2 The pattern: 1 1 1 0 1 0 1 1 1 makes 1 hour glass. And the sum of this hour glass is: 1 + 1...
true
186eb5bf60d983e8dd86c1fb60c7ea3c950fea4d
MikkelBoisen/OddName_SandBox
/OddNamePt2.py
477
4.125
4
""" write a program that asks the user for their name and has error-checking to make sure it's not blank. Then print every second letter in the name. Hint: use a for loop, the range function, and the length of the name. """ def main(): name = get_name() name_1 = name[1::2] print(name_1) def get_name(): ...
true
34816e3830572070815a4f70bca69871ab8f4fb8
Fravieror/Python
/try_catch.py
810
4.15625
4
# File error # with open("a_file.txt") as file: try: file = open("a_file.txt") a_dictionary = {"key": "value"} value = a_dictionary["non_existent_key"] except FileNotFoundError: # Create file from scratch file = open("a_file.txt", "w") file.write("Something") # error_message catch the name o...
true
f700ec6aa376b0c8bb0ca3573843a822deed2008
gammernut/examples_for_gavin
/example_3_data_types.py
1,205
4.125
4
# examples for gavin # strings , ints , floats and other data types # Python has multiple Data Types: # # Integers/int are whole numbers ie. 1 , 2 , 3 so on # # Floating-Point Numbers/float basically a int with with a decimal point ie 1.3 , 1.5 , 2.8 , 3.1 so on # # String/str Strings are sequences of character data...
true
bd5538f144e4beff66c97f558275899b64119634
KlwntSingh/inwk-python
/lab2/task10.py
433
4.28125
4
def check_fermat(a, b, c, n): if n <= 2: print "give n greater than 2" return leftSide=a**n + b**n rightSide=c**n if a > 0 and b > 0 and c > 0 and leftSide != rightSide: print("No, that doesn't work") else: print("Holy smokes, Fermat was wrong!") a=int(raw_input("First number i.e a ")) b=int(raw_input...
true
9ecbd36f8882e44edd90a870151fd529eda944e0
RafaelMarinheiro/CS5220-MatMul
/lecture/lec01plot.py
1,498
4.125
4
import matplotlib.pyplot as plt import numpy as np def make_speedup_plot(n, rmax, tc, tt): """Plots speedup for student counting exercise. Plots the speedup for counting a class of students in parallel by rows (assuming each row has equal student counts) vs just counting the students. Args: ...
true
eeae3dfac1c156a1c374cb0596517bde7d2471ae
bluerain109/Python_Tutorials
/Comments and Break.py
1,227
4.4375
4
#break and continue can be put inside of a loop magicNumber = 25 #Find the magic number game (goes through 100 to see if our number is the magic number) for n in range(101): if n is magicNumber: print(n, "is the magic number!") #this makes the current number n display as the magic number if it is the magi...
true
350e4ecd35179f173aed3da8e61a2dd41ae60f0b
bluerain109/Python_Tutorials
/Sets.py
409
4.21875
4
#a set is a collection of items like a list, except it cannot have any duplicates curly brackets are used groceries = {'cereal', 'milk','starcrunch','beer','duct tape','lotion','beer'} print(groceries) #because of no allowed duplicates in a set, beer will not appear twice if 'milk' in groceries: print('you already...
true
f879d36eed6e41458c105abea43527e7dac0178c
carinasauter/D09
/presidents.py
2,453
4.375
4
#!/usr/bin/env python3 # Exercise: Presidents # Write a program to: # (1) Load the data from presidents.txt into a dictionary. # (2) Print the years the greatest and least number of presidents were alive. # (between 1732 and 2016 (inclusive)) # Ex. # 'least = 2015' # 'John Doe' # 'most = 2015'...
true
917a149f97dd6484cd345c96f1c82c8130a58bd2
haegray/Python-and-Java-Files
/cashregister.py
679
4.28125
4
#cashregister.py #This program is designed to calculate and display sales price which is #list price plus a 5.3% sales tax. def cashregister(): print("Please input the list price of the item you would like to purchase.") listPrice=eval(input("price: ")) salesPrice= (listPrice + (.053 * listPrice)) pri...
true
9ea360a4d2d43d3a32f457ce24a96fefe2d1100e
jvindas-ust/Python
/Arrays.py
434
4.34375
4
#Changing several elements in the Array-List [FromIndex:QuantityOfElements]: l5 = [2, "tres", True, ["uno", 10], 6] l5[0:2] = [4, 3] print (l5) #Modify several elements in the Array-List with just one data [FromIndex:QuantityOfElements]: l6 = [2, "tres", True, ["uno", 10], 6] l6[0:2] = [5] print (l6) #Get data from a...
true
48ab31f3b7e4af27eb724a28ddf9a8203c813092
jurikolo/la-intro-to-python
/oop/classes.py
550
4.25
4
print("Docs: https://docs.python.org/3/tutorial/classes.html#classes") class Car: """ Docstring describing the class """ def __init__(self, color, transmission): """ Docstring describing the method """ self.color = color self.transmission = transmission def ...
true
4102794e661b1fa27bcda77b6b0bce53c8d39e78
adeckert23/python-problems
/algorithms/binary_search.py
492
4.3125
4
def binary_search(sorted_list, target): ''' Function to binary search a sorted list of ints for a target int. Returns index of the target if found in list, otherwise returns False. ''' l = 0 r = len(sorted_list) while l <= r: mid = (l+r) // 2 if sorted_list[mid] == target...
true
6087f2390bfdb50cc83927a15b6d0e188fada5a4
Ishkhan2002/ENGS110-2021-Homeworks
/GradedHomework1.py
760
4.125
4
def Is_Prime(Number): Check = 0 i = 2 while(i <= Number//2): if(Number % i == 0): Check = Check + 1 break i = i + 1 if(Check == 0 and Number != 1): print("%d is a prime number" %Number) return Number else: print("%d is not a prime num...
true