blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
e5cd322b04d126d2283dd2be8caed59f1985ef17
Xuehong-pdx/python-code-challenge
/caesar.py
667
4.1875
4
from string import ascii_lowercase as lower from string import ascii_uppercase as upper size = len(lower) message = 'Myxqbkdevkdsyxc, iye mbkmuon dro myno' def caesar(message, shift): """ This function returns a caesar (substitution) cipher for a given string where numbers, punctuation, and other non-alphabe...
true
cde0d233f7e9d53bd8e501fae8365584dadb402b
VitBomm/Algorithm_Book
/1.12/1_1_is_multiple.py
355
4.3125
4
# Write a short Python function, is_multiple(n, m), that takes two integer values and returns True if n # is a multiple of m, n = mi for some integer i, and False otherwise # def is_multiple(n, m): if n/m % 1 == 0: return True return False n = eval(input("Input your n: ")) m = eval(input("Input your ...
true
ce4a2f26dff9b7aae290e08ea4e02a6054f4e650
SBCV/Blender-Addon-Photogrammetry-Importer
/photogrammetry_importer/utility/type_utility.py
385
4.15625
4
def is_int(some_str): """ Return True, if the given string represents an integer value. """ try: int(some_str) return True except ValueError: return False def is_float(some_str): """ Return True, if the given string represents a float value. """ try: float(some_str)...
true
52ae20a0eadb2ac4e684ef4920f6c105d6187a6d
jeffsnguyen/Python
/Level 1/Homework/Section_1_3_Functions/Exercise 5/variance_dof.py
1,003
4.40625
4
''' Type: Homework Level: 1 Section: 1.3: Functions Exercise: 4 Description: Create a function that calculates the variance of a passed-in list. This function should delegate to the mean function (this means that it calls the mean function instead of containing logic to calculate ...
true
55568741e62e8f4da5189d2582f58916995cd8a3
jeffsnguyen/Python
/Level_3/Homework/Section_3_2_Generators_101/Exercise_1/num_iterable.py
883
4.46875
4
# Type: Homework # Level: 3 # Section: 3.2: Generators 101 # Exercise: 1 # Description: Contains the tests to iterate through a list of numbers # Create a list of 1000 numbers. Convert the list to an iterable and iterate through it. ####################### # Importing necessary packages from random import random, se...
true
a6948de57520137916bd17f153148e83f51d3f35
jeffsnguyen/Python
/Level 1/Homework/Section_1_5_Dicts_and_Sets/Exercise 2/name_usuk.py
2,581
4.21875
4
''' Type: Homework Level: 1 Section: 1.5 Dicts and Sets Exercise: 2 Description: Create two sets: Set 1 should contain the twenty most common male first names in the United States and Set 2 should contain the twenty most common male first names in Britain (Google it). Perform the...
true
92209793e197de9c33c0d3f6c219455620de4282
jeffsnguyen/Python
/Level 1/Homework/Section_1_6_Packages/Exercise 2/anything_program/hello_world_take_input/take_input_triangle/take_input/take_input.py
332
4.25
4
''' Type: Homework Level: 1 Section: 1.1 Variables/ Conditionals Exercise: 4 Description: Create a program that takes input from the user (using the input function), and stores it in a variable. ''' def take_input(): var = input('Input anything: ') # Take user's input and store in variable var ...
true
c0f0fbf101b3a648ef5dfd24d760fdcca394c260
jeffsnguyen/Python
/Level_3/Homework/Section_3_3_Exception_Handling/Exercise_2/divbyzero.py
1,719
4.4375
4
# Type: Homework # Level: 3 # Section: 3.3: Exception Handling # Exercise: 2 # Description: Contains the tests for handling div/0 exception # Extend exercise 1) to handle the situation when the user inputs something other than a number, # using exception handling. If the user does not enter a number, the code s...
true
a1f40e6da78edd81dadd58f19b78490f33aeb4ea
jeffsnguyen/Python
/Level_4/Lecture/string_manipulation_lecture.py
1,778
4.46875
4
# string manipulation lecture def main(): s = 'This is my sample string' # indexing print(s[0]) print(s[-1]) print() # slicing print(s[0:2:3]) print(s[:3]) print() # upper: create a new string, all uppercase print(s.upper()) print() # lower: create a new string, ...
true
5afb09b8eb3c629211076857bfc6b1f859d28f46
jeffsnguyen/Python
/Level_4/Lecture/string_formatting_lecture.py
1,421
4.21875
4
# string formatting lecture def main(): age = 5 print('Ying is %i years old'%age) # format flag i = integer print('Ying is %f years old'%age) # format flag f = float print('Ying is %.1f years old' % age) # format flag f = floag, truncate it 1 decimal place print('Ying is %e years old' % age) # ...
true
8251f87063be621d270c55e3c3849c758ae2f28b
jeffsnguyen/Python
/Level 1/Homework/Section_1_3_Functions/Exercise 1/day_of_week.py
1,320
4.3125
4
''' Type: Homework Level: 1 Section: 1.3: Functions Exercise: 1 Description: Write a function that can print out the day of the week for a given number. I.e. Sunday is 1, Monday is 2, etc. It should return a tuple of the original number and the corresponding name of the day. ''' import sys #...
true
0e7639bd5f7fc3b37bfa0cdbcd091fd94121e827
jeffsnguyen/Python
/Level_3/Homework/Section_3_2_Generators_101/Exercise_4/fibonacci.py
2,283
4.46875
4
# Type: Homework # Level: 3 # Section: 3.2: Generators 101 # Exercise: 4 # Description: Contains the tests to modified fn() method to generate Fibonacci sequence # Modify the Fibonacci function from Exercise 1.3.2 to be a generator function. Note that the function # should no longer have any input parameter sin...
true
5792af4a3d9edc774bba3c6cf4bb7cba31ef6b0d
jeffsnguyen/Python
/Level_3/Homework/Section_3_1_Advanced_Functions/Exercise_1/test_hypotenuse.py
1,140
4.375
4
# Type: Homework # Level: 3 # Section: 3.1: Advanced Functions # Exercise: 1 # Description: This contains the method to test the hypotenus of a right triangle # Create a stored lambda function that calculates the hypotenuse of a right triangle; it should take # base and height as its parameter. Invoke (test) this lam...
true
4f999f411dc875269cba559dcdfdcc478f3bdd7b
BrandonOdiwuor/Problem-Solving-With-Algorithms-and-Data-Structures
/queue/queue.py
691
4.125
4
class Queue: def __init__(self): self.queue_list = [] def is_empty(self): ''' Returns a boolean indicating if the Queue is empty Wost Case Complexity O(1) ''' return self.queue_list == [] def size(self): ''' Returns the size of the Queue Worst Case Complexity ...
true
5def4ffc1d4aa1f09363d0a3d3e86661085c23b0
damingus/CMPUT174
/weather1.py
407
4.4375
4
#This program sees whether 2 inputted temperatures are equal or not #assign 'a' to the first temperature we ask for and 'b' for the next a = input("What is the first temperature? ") b = input("What is the second temperature? ") #we convert 'a' into a string from an integer a = str(a) b = str(b) if a == b: print...
true
3bb05110f4e61837f3033087526ee6f96e418f8d
andrew1236/python
/organism population calculator.py
864
4.1875
4
#ask user for number of intital organisms, the average increases of organisms, and how many days to calcualte def calculate_organism_population(): organisms=int(input('Enter number of organisms:')) average_increase =int(input('Enter average daily increase:')) days=int(input('Enter number of days to multiply...
true
e03234ead130d80f81f623ad279e8a1987578390
Muhammadtawil/Python-Lessons
/set-part1.py
822
4.3125
4
# ----------------------------- # -- Set -- # --------- # [1] Set Items Are Enclosed in Curly Braces # [2] Set Items Are Not Ordered And Not Indexed # [3] Set Indexing and Slicing Cant Be Done # [4] Set Has Only Immutable Data Types (Numbers, Strings, Tuples) List and Dict Are Not # [5] Set Items Is Unique # --...
true
2f9b3ee9e458ca2e53599ca5a3a1befd90d04268
dshipman/devtest
/part_2_6.py
621
4.25
4
""" Write a short docstring for the function below, so that other people reading this code can quickly understand what this function does. You may also rename the functions if you can think of clearer names. """ def create_step_function(start_time, end_time, value): """ Create a step function that takes a si...
true
d91fc95f364e491f76c5c341aa5d777caa2c1911
AmirMoshfeghi/university_python_programming
/Functions/wine_house.py
1,549
4.46875
4
# Working with Functions # Making a house wine project # Wine Temperature must be closely controlled at least most of the time. # The program reads the temperature measurements of the wine container # during the fermentation process and tells whether the wine is ruined or not. def main(): # Get number of measure...
true
ae430661d281a65275da7d7230c35096d68c593e
Jayu8/Python3
/assert.py
636
4.125
4
""" It tests the invariants in a code The goal of using assertions is to let developers find the likely root cause of a bug more quickly. An assertion error should never be raised unless there’s a bug in your program. assert is equivalent to: if __debug__: if not <expression>: raise AssertionError """ # Asserts a...
true
b2d675b96a26428a9bd8695a2425a1d0f09dfe59
netteNz/Python-Programming-A-Concise-Introduction
/problem2_5.py
1,296
4.21875
4
'''Problem 2_5: Let's do a small simulation. Suppose that you rolled a die repeatedly. Each time that you roll the die you get a integer from 1 to 6, the number of pips on the die. Use random.randint(a,b) to simulate rolling a die 10 times and printout the 10 outcomes. The function random.randint(a,b) will generate an ...
true
f3db3ba1af9a34c6b223dd1d4d0e55c99e1319fe
prudhvireddym/CS5590-Python
/Source/Python/ICP 2/Stack Queue.py
852
4.15625
4
print("Enter Elements of stack: ") stack = [int(x) for x in input().split()] con ="yes" while con[0]=="y": ans = input("Enter 0 for push\n1 for pop\n2 to print stack\n3 for Top most element : ") while ans == "0": a = int(input("Enter the element to append")) stack.append(a) print(stack) ...
true
2853c45cb2b7883d73a62a288916aa026c6db2be
aligol1/beetroot111
/lesson37.py
1,421
4.59375
5
"""Task 1 Create a table Create a table of your choice inside the sample SQLite database, rename it, and add a new column. Insert a couple rows inside your table. Also, perform UPDATE and DELETE statements on inserted rows. As a solution to this task, create a file named: task1.sql, with all the SQL statements you h...
true
69eaa079f4ad20db8c19efa7af08adcdcf174e1a
aligol1/beetroot111
/lesson14.py
2,240
4.65625
5
"""Lesson 14 Task 1 Write a decorator that prints a function with arguments passed to it. NOTE! It should print the function, not the result of its execution! For example: "add called with 4, 5" def logger(func): pass @logger def add(x, y): return x + y @logger def square_all(*args): return [arg ** 2 fo...
true
7a85e32340f82247a32ce4f234a38b3b30c9ffc9
Gwinew/To-Lern-Python-Beginner
/Tutorial_from_Flynerd/Lesson_4_typesandvariables/Task2.py
817
4.21875
4
# Make a list with serial movie # # Every serial movie should have assigned rate in scale 1-10. # Asking users what they serial movie want to see. # In answer give they rate value. # Asking user if they want to add another serial movie and rate. # Add new serial movie to the list. # -*- coding: utf-8 -*- dictserial={...
true
b1077695d8b814286c878c7d809eed423b224f72
Gwinew/To-Lern-Python-Beginner
/Tutorial_from_Flynerd/Lesson_3_formattingsubtitles/Task2.py
886
4.125
4
# -*- coding: utf-8 -*- # # Create a investment script which will have information about: # -Inital account status # -Annual interest rate # -The number of years in the deposit # # Result show using any formatting text. # enter=input("Hi! This is Investment script.\nI want to help you to count your money impact at the ...
true
931c283cfe56acb0b02c9e26205980a3fda9f4ff
Gwinew/To-Lern-Python-Beginner
/Pluralsight/Intermediate/Unit_Testing_with_Python/1_Unit_Testing_Fundamentals/2_First_Test/test_phonebook.py
1,405
4.1875
4
"""Given a list of names and phone numbers. Make a Phonebook Determine if it is consistent: - no number is a prefix of another - e.g. Bob 91125426, Anna 97625992 - Emergency 911 - Bob and Emergency are inconsistent """ import unittest #class PhoneBook: # Right-cli...
true
ee0eb65582ce9db9cc635038101221a257bbc5f6
Aa-yush/Learning-Python
/BMICalc.py
331
4.28125
4
weight = float(input("Enter your weight in kg : ")) height = float(input("Enter your height in meters : ")) BMI = weight / (height**2) if(BMI <= 18.5): print("Underweight") elif(BMI >18.5 and BMI <= 24.9): print("Normal weight") elif(BMI>24.9 and BMI<=29.9): print("Overweight") else: print("...
true
8a2edf5d14180fefe7c387a81465edb89c12eca0
rohit98077/python_wrldc_training
/24_read_write_text_files.py
816
4.375
4
''' Lesson 2 - Day 4 - read or write text files in python ''' # %% # read a text file # open the file for reading with open("dumps/test.txt", mode='r') as f: # read all the file content fStr = f.read() # please note that once again calling f.read() will return empty string print(fStr) # this will...
true
b096fbd435e5058f59aa46d546a0a4ade727fa69
rohit98077/python_wrldc_training
/13_pandas_dataframe_loc.py
574
4.125
4
''' Lesson 2 - Day 3 - Pandas DataFrame loc function loc function is used to access dataframe data by specifying the row index values or column values ''' #%% import pandas as pd # create a dataframe df = pd.DataFrame([[2, 3], [5, 6], [8, 9]], index=['cobra', 'viper', 'sidewinder'], columns=['max_speed', 's...
true
0e66cef7b14800d47a750139d943d8c439338232
fengkaiwhu/A_Byte_of_Python3
/example/addr_book.py
1,812
4.1875
4
#!/usr/bin/env python # coding=utf-8 # Filename: addr_book.py class addr_book: '''Represent an addr_book''' book = {} def __init__(self, book): addr_book.book = book def get_book(self): return addr_book.book def add_person(self): name = input('Please input name-->') ...
true
85ca3ab76550a0092f926eb777a834246c85c557
RyanWaltersDev/NSPython_chapter3
/travel_dest.py
729
4.71875
5
#Ryan Walters Nov 21 2020 -- Practicing the different sorting methods with travel destinations #Initial list travel_dest = ['tokyo', 'venice', 'amsterdam', 'osaka', 'wales', 'dublin'] #Printing as a raw Python list and then in order print(travel_dest) print(sorted(travel_dest)) #Printing in reverse alphabetical orde...
true
d0d118fe3a88f33f1c18d12c565e9e83620fe9f8
spettigrew/cs2-codesignal-practice-tests
/truck_tour.py
2,736
4.5
4
""" Suppose there is a circle. There are N petrol pumps on that circle. Petrol pumps are numbered 0 to (N - 1) (both inclusive). You have two pieces of information corresponding to each of the petrol pump: (1) the amount of petrol that particular petrol pump will give, and (2) the distance from that petrol pump to the ...
true
53ba03e8e1cbb013f566be89f6b0df2722a7319d
spettigrew/cs2-codesignal-practice-tests
/roman-to-integer.py
2,820
4.25
4
""" Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just two one's added together. 12 is writt...
true
d9bc3016a040ecb9b68e404cf4a9244ed6ee81a6
spettigrew/cs2-codesignal-practice-tests
/anagrams.py
2,712
4.46875
4
""" A student is taking a cryptography class and has found anagrams to be very useful. Two strings are anagrams of each other if the first string's letters can be rearranged to form the second string. In other words, both strings must contain the same exact letters in the same exact frequency. For example, bacdc and dc...
true
307c0d178659494d3639d78df5f4b1bd1dfc9607
thomasmcclellan/pythonfundamentals
/02.01_strings.py
525
4.21875
4
# Strings hold text info and hold "" or '' # Can have [] 'hello' "hello" "I'm a dog" my_string = 'abcdefg' print(my_string) print(my_string[0]) print(my_string[3:]) print(my_string[:3]) #Goes up to, BUT NOT INCLUDING the number print(my_string[2:5]) print(my_string[::]) print(my_string[::2]) #The number is the step s...
true
d7c16c08b73fa5b2a45356431d35416a2e30155e
alaasal95/problem-solving
/Convert_second _to_hour_min_second.py
323
4.15625
4
''' ----->Ex:// read an integer value(T) representing time in seconds and converts it to equivalent hours(hr),minutes(mn)and second(sec) ''' p1=int p2=int p3=int second=4000 p1=second%60 p2=second/60 print('p2_',p2) p3=p2%60 print('p2',p2) p2=p2/60 print(p2 ,":",p3,":",p1...
true
06e6aa8918528136b1b4a56e463dcfb369580261
emmanuelthegeek/Python-Exercises
/Widgets&gizmos.py
1,130
4.25
4
#An online retailer sells two products. widgets and gizmos. Each widget weighs 75 grams, while each gizmo weighs 112 grams. #Write a program that displays the total weight of an order, in kilograms, given two variables containing the number of widgets #and gizmos. #Solution # 1 widget = 75g # 1 gizmos = 112g # 1000g ...
true
6cc0e043bd8778e825fa2fd6748518a6e641a5f9
MihaiDinca1000/Game
/Exercitii/Test_inheritance.py
2,254
4.59375
5
''' In this Python Object-Oriented Tutorial, we will be learning about inheritance and how to create subclasses. Inheritance allows us to inherit attributes and methods from a parent class. This is useful because we can create subclasses and get all of the functionality of our parents class, and have the ability to...
true
43bdd743c29efec4b9756ce9d6ecd8f5bcf61b99
porregu/unit3
/unitproject.py
1,336
4.21875
4
def arearectangle(a,b): """ solve the area of the rectangle :param a: heigth :param b: with :return: return the fucntion to do it more times """ return a*b def withh():# dpuble (h) because dosent let me put one # with called by the user """ make the user tell the with :return: t...
true
b6d777bda60b89b9880543ecdd6f132a111b039e
tanay2098/homework4
/task2.py
1,023
4.15625
4
import random # importing package random nums = [] # initializing an empty list called nums for i in range(0,2): # Loop for 2 elements nums.append(random.randint(0,10)) # generating 2 numbers between 0 to 10 and appending them in the list t1 = tuple(nums) # converting list into a tuple named t1 correct_answ...
true
f76f683497bbf7caff26732105b355888d3160e1
damiannolan/python-fundamentals
/current-time.py
224
4.1875
4
# Problem 2 - Current Time import time; import datetime; # Print the the date and time using 'time' print("Current time is : ", time.asctime(time.localtime(time.time()))) print("Today's date is: ", datetime.date.today())
true
82bd6970962a9f11921c2dc8892969dacad895c8
srholde2/Project-4
/queue.py
1,103
4.28125
4
class Queue: # queue class constructor def __init__(self): self.queue = ["car", "car", "car", "car", "car"] def enqueue(self): item = input("Please enter the item you wish to add to the queue: ") self.queue.append(item) def dequeue(self): item = self.queu...
true
1050e66e270df03c2c88cb35e5d4bf364de138b7
hiranmayee1123/Hacktoberfest-2021
/windowslidingproblem.py
1,013
4.21875
4
#This technique shows how a nested for loop in some problems can be converted to a single for loop to reduce the time complexity. #Let’s start with a problem for illustration where we can apply this technique – #Given an array of integers of size ‘n’. #Our aim is to calculate the maximum sum of ‘k’ #consecutive elem...
true
3a7e5870dc242615ee553d0f00295ace995c470a
green-fox-academy/klentix
/Topic 5 Data Structure/List Introduction 1.py
810
4.5625
5
namelist = ['William'] namelist.extend(['Jony', 'Amanda']) # add on multiple items in the list print("No. of name", len(namelist)) # print total number of items print("Name list: ", namelist) # print out each element print("the 3rd name is:", namelist[2]) #iterate through a list and print out individual name for ...
true
ce86046945bc3f35b226e37d29f8be3d4f36b893
PramitaPandit/Rock-Paper-Scissor
/main.py
2,492
4.4375
4
#Rock-Paper-Scissor game # import random #step1: Stating game instructions print('Rules of Rock-Paper-Scissor are as follows:\n Rock v/s Paper -> Paper wins \n Rock v/s Scissor -> Rock wins \n Scissor v/s Paper -> Scissor wins ') # Step2: Taking user input user = input('Enter your name: ') while True: player_cho...
true
3dfecdcc2e10e2a8726896802dbed82b8ceef96c
FX-Wood/python-intro
/name_length.py
291
4.375
4
# Exercise 3: # Write a script that asks for a name and prints out, "Your name is X characters in length." # Replace X with the length of the name without the spaces!!! name = input('Please enter your name: \n > ') print(f"Your name is {len(name.replace(' ', ''))} characters in length")
true
04a659e77718a85fad089298850585a77cdb9d00
FX-Wood/python-intro
/collections/print_names.py
246
4.40625
4
# Exercise 1 # Create a list named students containing some student names (strings). # Print out the second student's name. # Print out the last student's name. students = ["Fred", "Alice", "Bob", "Susie"] print(students[1]) print(students[-1])
true
c7dbc874de58b7713d58d422a399f09efebbe726
deepakkadarivel/python-programming
/7_file_processing/7_2_search_in_file.py
946
4.28125
4
""" “Write a program to prompt for a file name, and then read through the file and look for lines of the form: X-DSPAM-Confidence:0.8475” Pseudo code 1. Read file name from user 2. open file 3. Handle No file exception 4. Iterate through files for text and increment count 5. print total...
true
f2d750dadce5e8cf3359b18e806ba763842042e9
deepakkadarivel/python-programming
/6_1_reverse_string.py
567
4.40625
4
""" Write a while loop that starts at the last character in the string and works it’s way through first character in the string, printing each letter in a separate line except backwards. TODO 1: Accept a string from io TODO 2: Find the length of the string TODO 3: decrement len and print charac...
true
8915bb5963f3b0accb33e02d68fba4a8c3bf7628
deepakkadarivel/python-programming
/6_2_letter_count.py
757
4.375
4
""" Find the count of a letter in a word. Encapsulate the code in a function named count, and generalize it so that it accepts the string and letter as an argument. TODO 1: Accept input for a word and letter to search for. TODO 2: Define a count function that accepts word and letter as parameter to cou...
true
6a154af4ddbf024665295fdfab72fe4d6f828de8
Jrbrown09/Brown-Assignment5
/.vscode/exercise6.py
2,138
4.4375
4
from helpers import * ''' Exercise 6 Calories from Fat and Carbohydrates This program calculates the calories from fat and carbohydrates that the user consumed. The calorie amounts are calculated using the input from the user in carbohydrates and fat. ''' ''' Define the 'main' function ''' def main(): fat_gram...
true
32b144e97cd8f10500b1848ebd8af4599ae66d12
markvassell/Python
/test/multiplication_table.py
1,248
4.21875
4
import math print("This is test multiplication table: Still in progress") file_name = "Multiples.txt" try: #opens a file to write to mult_file = open(file_name, "w") while (True): try: inp_range = int(input("Please enter how many multiplication tables you would like to generate: ")) ...
true
c52dac3f89683c8ade4f3bc4f81b4a9ff350cc1d
surendhar-code/python_practice
/program1.py
306
4.3125
4
#python program to interchange first and last elements in a list. def firstlast(list1,n): beg=list1[0] end=list1[n] print("The first and last element of the list {0} is {1} and {2}\n".format(list1,beg,end)) list1=list(range(0,5)) print(list1) n=(len(list1))-1 firstlast(list1,n)
true
60b5cb899cef0911bd7d7a775cfbb7ea557aa01f
Robdowski/code-challenges
/running_sum_1d.py
739
4.125
4
""" This problem asks to keep a running total of the sum of a 1 dimensional array, and add that sum to each item in the array as we traverse. To do this, we can simply declare a variable, running sum, and add it to each item in the array as we traverse. We need to add the sum to the item in the array, while storing th...
true
2d516c584352f0d835fc8f9f7dc076fd032e8af3
N0l1Na/Algorithms_Python
/PIL006/PIL006.py
1,306
4.25
4
""" PIL - The exercise is taken from the Pilshchikov's Pascal problem book Task 8.7 page 40 Regular types: vectors Using the Gender and Height arrays, determine: a) The name of the tallest man b) The average height of women Creator Mikhail Mun """ import random array = [] total_height_women = 0 amount_women = 0 ...
true
ec6e1871e6a55516a520a49b11dcd267d7dbb28a
nguyenthanhthao1908/classpython_basic_online
/rewrite_code_resource_w/dictionary/bai9.py
235
4.3125
4
"""Write a Python program to iterate over dictionaries using for loops.""" D = {"Name": "Thao", "Age": 20, 19: 8} # for i in D.items(): # print(i) # solution 2: for key, value in D.items(): print(key, "is:", D[key])
true
aa2b00e3bcd8cc17d08ef67e68ab65aaa64c0435
nguyenthanhthao1908/classpython_basic_online
/rewrite_code_resource_w/dictionary/bai15.py
226
4.15625
4
"""Write a Python program to get the maximum and minimum value in a dictionary. """ D = {3: 30, 2: 20, 19: 8} print("Maximum:", max(D.keys(), key=(lambda k: D[k]))) print("Minimum:", min(D.keys(), key=(lambda k: D[k])))
true
6c952a8e00c4a823828985e353e4ff04c5c747c8
Bigg-Iron/152_001
/C_activities/C10.py
2,963
4.1875
4
""" 10.1.2: Modify a list. Modify short_names by deleting the first element and changing the last element to Joe. Sample output with input: 'Gertrude Sam Ann Joseph' ['Sam', 'Ann', 'Joe'] """ # user_input = input() # short_names = user_input.split() # ''' Your solution goes here ''' # del short_names[0] # del shor...
true
f683cbbba69ce43dbcf7aa072a7b5890b123aadb
kennylugo/Tweet_Generator_Data_Structures_-_Probability
/1.3_anagram_generator.py
1,343
4.15625
4
import sys, random # THIS ANAGRAM GENERATOR IS NOT WORKING YET # method signature def generate_anagram(): # the list method will break a word apart and add each letter to a list data structure list_of_letters_from_word_input = list(sys.argv[1]) # we store the count of the elements in the list above ...
true
0af53ed79a3d2df089f628732cd0f0989ef4e26c
abdullahclarusway/Python_Assignments
/Assignment_9.py
214
4.28125
4
name = input("Please enter your name:").title() my_name = "Abdullah" if name == my_name: print("Hello, {}! The password is: W@12".format(my_name)) else: print("Hello, {}! See you later.".format(name))
true
5f1df607c99984af8b32cabeb6d38bb9b85d91e3
srinisha2628/new_practice
/cuberoot.py
358
4.125
4
x= int(input("enter a number\n")) ans=0 while ans**3 < abs(x): ans+=1 if(ans**3!= abs(x)): print("it is not a perfect cube") else: if(x<0): ans = -ans print("cube root of "+ str(x)+" is "+ str(ans)) cube=int(input("enter a number")) for guess in range(cube+1): if(guess**2==cube): p...
true
076f59fedeb631a4284093eab8358526ea1390a5
mewilczynski/python-classwork
/program41.py
865
4.375
4
#Marta Wilczynski #February 2nd, 2016 © #Chapter 4 assignment program41.py #Start program #Import math since we will be using PI #Set up a range of numbers, using the for loop. #Calculate area of a circle with "radius", where the equation # will be area = (PI * (radius ** 2)) #Calculate circumfrence with "rad...
true
b496deacdbb5b1098a24631825f11221a2cbfcb6
mewilczynski/python-classwork
/order32.py
1,681
4.21875
4
#Marta Wilczynski #February 2nd, 2016 © #order32.py #Start program. #Get the number of t-shirts being purchased from the user, #assign to variable "amountOfShirts". #Calculate amountOfShirts * 12.99, assign to variable "priceOfShirts". #Assign number 8.99 to variable "shipping". #Determine discounts by lookin...
true
61a787ee69c3e67a8fbaab6c6d057aeab66245e6
Manish-bitpirate/Hacktoberfest
/python files/story_maker_by_cyoa.py
2,019
4.125
4
name=input("What's your name?") print("Treasure Hunter, a custom story by " + name ) print("You are a brave explorer that was recognized by the world and found an ancient Mayan temple!") opt1=input("Do you walk in? y/n?") opt2="" opt3="" opt4="" if opt1=="y": print("You walk in, your footsteps echoing in the dark. ...
true
8fde712d6f525b47c1989497f3dbd086c61c7041
SAMLEVENSON/ACET
/Factorialwi.py
233
4.125
4
def main(): print("To find the Factorial of a Number") a= int(input("Enter the Number:")) if(a>=20) fact =1 for i in range(1,a + 1): fact = fact*i print(fac) if __name__ == '__main__': main()
true
9eb5f962bc60fa4c74d117fab1c7234562f1266d
anantkaushik/Data-Structures-and-Algorithms
/Data-Structures/Graphs/bfs.py
1,458
4.125
4
""" Graph traversal means visiting every vertex and edge exactly once in a well-defined order. While using certain graph algorithms, you must ensure that each vertex of the graph is visited exactly once. The order in which the vertices are visited are important and may depend upon the algorithm or question that you ...
true
2964932bc4395158beb2ee0eba705ee180eaac84
dbzahariev/Python-and-Django
/Python-Basic/exam_preparation_1/part_1/task_4.py
539
4.1875
4
best_player_name = '' best_player_goal = -1 while True: text = input() if text == 'END': break player_name = text player_goals = int(input()) if player_goals > best_player_goal: best_player_name = player_name best_player_goal = player_goals if player_goals >= 10: ...
true
0adc5800f99519b907a6939fee2c38ebc950da38
chaosWsF/Python-Practice
/leetcode/0326_power_of_three.py
710
4.34375
4
""" Given an integer, write a function to determine if it is a power of three. Example 1: Input: 27 Output: true Example 2: Input: 0 Output: false Example 3: Input: 9 Output: true Example 4: Input: 45 Output: false Follow up: Could you do it without using any loop / recursio...
true
ba66e9707f75734abd0a2bfb61c9c74655f4ed62
chaosWsF/Python-Practice
/leetcode/0035_search_insert_position.py
1,291
4.15625
4
""" Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array. Example 1: Input: [1,3,5,6], 5 Output: 2 Example 2: Input: [1,3,5,6], 2 Output: 1 Example 3: ...
true
6c9a0b00945ee3ea85cc7430ec2b40e660d05d4e
chaosWsF/Python-Practice
/leetcode/0532_k-diff_pairs_in_an_array.py
1,281
4.1875
4
""" Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i and j are both numbers in the array and their absolute difference is k. Example 1: Input: [3, 1, 4, 1, 5], k = 2 Output: 2 Ex...
true
99b3a845267202d53a1f0e9e346b8bcb0a21a577
chaosWsF/Python-Practice
/leetcode/0020_valid_parentheses.py
1,707
4.1875
4
""" Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Note that an empty string is also consider...
true
ee5da787fc7206823a2f764e883ca3d3ecbf5caf
chaosWsF/Python-Practice
/leetcode/0344_reverse_string.py
1,092
4.25
4
""" Write a function that reverses a string. The input string is given as an array of characters char[]. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. You may assume all the characters consist of printable ascii characters. Example 1: ...
true
c70a497fa0a9db39e3f4546fd96775912458e71d
chaosWsF/Python-Practice
/leetcode/0027_remove_element.py
1,988
4.25
4
""" Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. The order of elements can be changed. It doesn't matter what you leave beyond...
true
bcd5d58a4b1789a205e03f69fe2458b9b4a5b5a2
chaosWsF/Python-Practice
/leetcode/0088_merge_sorted_array.py
2,069
4.21875
4
""" Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional elements from...
true
dd0ca36d22e09a8278608bbd0c02f554bc9cab26
chaosWsF/Python-Practice
/leetcode/1002_find_common_characters.py
1,281
4.15625
4
""" Given an array A of strings made only from lowercase letters, return a list of all characters that show up in all strings within the list (including duplicates). For example, if a character occurs 3 times in all strings but not 4 times, you need to include that character three times in the final answer. You may r...
true
674ef5c016216bb2e64195ccb36ccb056773a720
chaosWsF/Python-Practice
/leetcode/0434_number_of_segments_in_a_string.py
546
4.15625
4
""" Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters. Please note that the string does not contain any non-printable characters. Example: Input: "Hello, my name is John" Output: 5 """ class Solution: def countSegments1(self, s): ...
true
400142c7d92f56ad7af22a82663441976791369d
JQuinSmith/learning-python
/ex15.py
813
4.34375
4
# imports the module from sys import argv # the script, and the text file are used as modules script, filename = argv # Assuming "open" opens the file being passed into it for use in the rest of the script. txt = open(filename) # # Serves up the filename based on what is entered into the terminal. # print ("Here's y...
true
71678e32831ef0554e88ee5e916b749ba0a8ced9
Program-Explorers/Random_Password_Generator
/random_password.py
1,963
4.21875
4
# import statements #Random Password Generator import random import string def greeting(): print("This programs makes your password more secure based on a word you provide!" + "\nIt increases the strenth of your password by adding random letters and digits before or after the word\n") class password_g...
true
1cb20485ce03458d71b766dc450d2b9f624f8e21
Benjamin-Menashe/Project_Euler
/problem1.py
470
4.25
4
# -*- coding: utf-8 -*- """ Created on Sun Jan 3 10:09:34 2021 @author: Benjamin """ # If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. import numpy as np fives = np.array(rang...
true
8d208cee28c4dc5fa45b42d4a7e57e2508840a3d
Yasaman1997/My_Python_Training
/Test/lists/__init__.py
1,599
4.375
4
zoo_animals = ["pangolin", "cassowary", "sloth", "dog"]; # One animal is missing! if len(zoo_animals) > 3: print "The first animal at the zoo is the " + zoo_animals[0] print "The second animal at the zoo is the " + zoo_animals[1] print "The third animal at the zoo is the " + zoo_animals[2] print "The fourth...
true
810e9b7a1d47e4c5e19b452bb3ecda92a5cd79d1
zerojpyle/learningPy
/ex19_practice.py
590
4.15625
4
# define a function to do some math # I'm trying to find 10 ways to run a function def my_calc(number1, number2): print(f"First, {number1} + {number2} = {number1 + number2}!") print(f"Second, {number1} x {number2} = {number1 * number2}!") print(f"And that's it! Come back later and maybe you'll get more.\n")...
true
ea825b27fe780710ee9520c77bc7bdd9b69b6515
zerojpyle/learningPy
/ex6.py
887
4.4375
4
# define variable with a number types_of_people = 10 # define a variable as a literal string x = f"There are {types_of_people} types of people." # define a couple strings as variables binary = "binary" do_not = "don't" # define a variable as a literal string y = f"Those who know {binary} and those who {do_not}." # pr...
true
a0f73784a1ad1a2971e71c9844e3d48c9eeed9a1
cyber-holmes/Centimeter_to_meter-and-inches_python
/height_cm.py
418
4.4375
4
#Goal:Convert given Height from Centimeter to Meter and Inches. #Step1:Take the input. height = input("Enter the Height in Centimeter: ") #Step2:Calculate the value of Meter from Centimeter. meter = height/100.0 #Step3:Calculate the value of Inch from Centimeter. inch = height/2.54 #Step4:Print the Height in Meter...
true
7377dab7bacfc1c807b49f473775fea650c305b3
starmap0312/python
/libraries/enumerate_zip.py
849
4.78125
5
print("1) enumerate():") # 1) enumerate(iterable): # return enumerate object that can be used to iterate both the indices and values of passed-in iterable for index, value in enumerate(["one", "two", "three"]): print(index, value) # 2) zip(iterable1, iterable2): # return an iterator of tuples, where the i-t...
true
9dc6900c0eb28775c0e4e8f9fbb353f0a57f6af9
xploreraj/HelloPython
/algos/programs/ZeckendorfsTheorem.py
479
4.28125
4
''' Print non-consecutive fibonacci numbers summing up to a given number ''' # return nearest fibonacci num lesser or equal to argument def nearest_fibo_num(num): a, b = 0, 1 while True: if a + b > num: break temp = b b = a + b a = temp return b if __name__ == ...
true
2dcff43bb6f73d3b5141178c3374911344e3c4aa
ronaldaguerrero/practice
/python2/python/fundamentals/lambdas.py
1,291
4.6875
5
# # Example 1 # # create a new list, with a lambda as an element # my_list = ['test_string', 99, lambda x : x ** 2] # # access the value in the list # # print(my_list[2]) # will print a lambda object stored in memory # # invoke the lambda function, passing in 5 as the argument # print(my_list[2](5)) # # Example 2 # # ...
true
d2331f4d0ae550d79cc36677b8d55a4c92153840
zahraaliaghazadeh/python
/functions_intro/banner.py
2,242
4.15625
4
# def banner_text(text=" ", screen_width=80): def banner_text(text: str = " ", screen_width: int = 80) -> None: """ Print a string centred, with ** either side. :param text: The string to print. An asterisk (*) will result in a row of asterisks. The default will print a blank line, with a ** borde...
true
5fdfa562e309a1adf91d366bfe03937faa133888
zahraaliaghazadeh/python
/NU-CS5001/lab02/adder.py
463
4.1875
4
# num1 = float(input("Enter a first value: ")) # num2 = float(input("Enter a second value: ")) # sum = num1 + num2 # print("The sum of {} + {} is {}".format(num1, num2, sum)) # ================================== # same code with function dedinition def main(): num1 = float(input("Enter a first value: ")) ...
true
ac9d5c265190401c2e11d2b144cbf16961da09a2
snalahi/Python-Basics
/week3_assignment.py
2,114
4.4375
4
# rainfall_mi is a string that contains the average number of inches of rainfall in Michigan for every month (in inches) # with every month separated by a comma. Write code to compute the number of months that have more than 3 inches of # rainfall. Store the result in the variable num_rainy_months. In other words, coun...
true
06dbe5531992d6c6df8feb30c6b97b17b113b824
Daksh-ai/swapcase-of-string
/string swapcase.py
216
4.21875
4
def swapcase(string): return s.swapcase() s=input("Enter The String") sub=swapcase(s) print(sub) #example-->input=Daksh output-->dAKSH #in genrally we say that its used to change the case of string and vice-versa
true
4a5c254c5d241a0c09862ca7995b1652932cd858
arvagas/Sorting
/src/recursive_sorting/recursive_sorting.py
1,557
4.125
4
# TO-DO: complete the helpe function below to merge 2 sorted arrays def merge( arrA, arrB ): elements = len( arrA ) + len( arrB ) merged_arr = [0] * elements # TO-DO count = 0 while count < elements: if len(arrA) == 0: merged_arr[count] = arrB[0] arrB.pop(0) e...
true
654e27532d4de8711c90cdb88e30006c8702751a
srimanikantaarjun/Object_Oriented_Programming_Fundamentals
/08 Constructor in Inheritance.py
868
4.34375
4
class A: def __init__(self): print("in A init") def feature1(self): print("Feature 1 is working") def feature2(self): print("Feature 2 is working") class B: def __init__(self): super().__init__() print("in B init") def feature3(self): ...
true
9853a2266d1acbf23b8bba45db882b0b444fa030
hari2pega/Python-Day-wise-Practice-Sheets
/Hari_July 27th_Practice Sheet - Numbers and Introduction to List.py
1,862
4.53125
5
#!/usr/bin/env python # coding: utf-8 # In[1]: #Commenting the Line #What ever has been written after the Hash symbol, It will be considered as Comment #Numbers #Integers 2+3 # In[2]: #Numbers 3-2 # In[3]: #Float - It will be give the decimal value - Declaring in Decimal is called Float 0.1+0.2 # In[8]: ...
true
74402dc7fb9d97f14ecaebf30b201a5b96a7e7e3
dogeplusplus/DailyProgrammer
/222balancingwords.py
1,304
4.3125
4
def balance_word(word): '''the position and letter itself to calculate the weight around the balance point. A word can be balanced if the weight on either side of the balance point is equal. Not all words can be balanced, but those that can are interesting for this challenge. The formula to calculate the weight of th...
true
e90b652e9b9d921a5d3ca94e1b299ce07e07812f
sfmajors373/PythonPractice
/OddTest.py
364
4.1875
4
#Input largestoddnumbersofar = 0 counter = 0 #Test/Counter while counter < 10: x = int(input("Enter a number: ")) if x%2 == 1: if x > largestoddnumbersofar: largestoddnumbersofar = x counter = counter + 1 print(counter) #Output if counter == 10: print ("The largest od...
true
02673b7a8aaac520aec772ab345391aae54ab1d8
Vlad-Mihet/MergeSortPython
/MergeSortAlgorithm.py
2,189
4.3125
4
import random # Generating a random Array to be sorted # If needed, the random elements assignment could be removed, so a chosen array could be sorted ArrayToBeSorted = [random.randint(-100, 100) for item in range(15)] def MergeSort (array, left_index, right_index): if left_index >= right_index: r...
true
5f4783efff3f567033bff8c2752602a13a3b7b2e
jackfish823/Hangman_Python
/Guess.py
597
4.125
4
import re #lib to search in a string def is_valid_input(letter_guessed): # checks if the function the input letter_guessed is good spread_guess = re.findall('[A-Za-z]', letter_guessed) #list of the guess_input of only english if len(letter_guessed) == len(spread_guess): if len(letter_guessed) =...
true
ecfc083467a06ff836565a89858b8218e64bd56b
npradha/multTables
/multTables.py
386
4.28125
4
while True: print("\n") print("What number do you want the multiplication table of?") num = input() print("\n") for mul in range(13): answer = num * mul print(str(num) + " x " + str(mul) + " = " + str(answer)) print("\n") print("Do you want to input another number? (y/n)") ans = raw_input() if ans == 'y':...
true
53b5e0a564b279e63ceb6458310fcbaeec68d933
DustinRPeterson/lc101
/crypto/vigenere.py
2,230
4.125
4
#Encrypts text using the vignere algorithm (https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher) from helpers import alphabet_position, rotate_character #import alphabet_position and rotate_character from helpers.py lower_case_dict = dict() #create dictionary for lowercase letters upper_case_dict = dict() #creat...
true