blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
34047e9fb0c2f4e04c39edb80bc590794d34c027
atavener68/intro_to_python
/problem4.py
806
4.34375
4
# Write a function named reverse_me that # takes a string as a parameter, # and returns the reversed string. # # Do this without using pythons [::-1] slice shortcut, # or the built in reversed() method # # You will need to count down from the length of the string, # and build up the output one piece at a time. # # The ...
true
0a7cb008779c84830c21a282b2e9ded30dfb3aeb
GRustle00/pathofpython
/lpthw/ex19/ex19.py
1,304
4.125
4
#call defined function cheese_and_crackers where the argumens are cheese_count, boxes_of_crackers def cheese_and_crackers(cheese_count, boxes_of_crackers): print(f"You have {cheese_count} cheeses!") print(f"You have {boxes_of_crackers} boxes of crackers!") print("Man that's enough for a party!") print("...
true
ae277b3a45616ff0f07b57049489dd243cafdfb8
MAdisurya/data-structures-algorithms
/questions/reverse_words.py
2,775
4.6875
5
""" Your team is scrambling to decipher a recent message, worried it's a plot to break into a major European National Cake Vault. The message has been mostly deciphered, but all the words are backward! Your colleagues have handed off the last step to you. Write a function reverse_words() that takes a message as a list...
true
624a613e35444aa6259e6de55f6210228b86f6b1
dallasmcgroarty/python
/General_Programming/strings/strings.py
437
4.28125
4
#f-strings in python3 #places a value in a string x = 10 print(f"I've told you {x} times already") #join function #can use logic in the join argument #takes a list and joins them together in a string names = ["hey","there","tom"] names_str = ' '.join(names) print(names_str) #takes a list of numbers and converts the...
true
64f357e4af0bd381e65e4fc98ae074303a8cad4d
dallasmcgroarty/python
/DataStructures_Algorithms/trees/bst_problems.py
2,459
4.15625
4
# bst problems from bst import * # problem 1 # given a binary tree, determine if its a binary search tree or not def bst_check(tree): # binary search tree orders lower to left and greater to right # therefore if we do a inorder traversal the values should be sorted # if not then we dont have a bst valu...
true
e32d47e35b1cc18e29f8a3d9baaf20707befcb20
dallasmcgroarty/python
/General_Programming/BI_Functions/zip.py
1,618
4.46875
4
# zip function # makes an iterable that takes elements from each of the iterables # takes elements from each iterable at the same positon and creates a pair,triplet,etc nums1 = [1,2,3,4,5] nums2 = [6,7,8,9,10] z = zip(nums1,nums2) z1 = zip(nums1,nums2) p = zip(nums1,nums2) # use list or dict to convert zip object prin...
true
b575310940f81b968bd1662c9d9936579f93f701
dallasmcgroarty/python
/General_Programming/OOP/grumpy_dict.py
665
4.40625
4
# overriding dictionary object in python # using magic methods we can override how a dictionary functions # this can also be applied to other objects as well class grumpyDict(dict): def __repr__(self): print("None of Your Business") return super().__repr__() def __missing__(self, key): ...
true
437fa5e62f044e2799791dc91a80c1a0af0a1766
shuvava/python_algorithms
/permutations/heap_algorithm.py
1,794
4.1875
4
#!/usr/bin/env python # encoding: utf-8 # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # Copyright (c) 2020-2022 Vladimir Shurygin. All rights reserved. # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ """ Heap's algorithm https://en.wikipedia.org/wiki/...
true
e4d68156d2c5e8dfe2299b94ed6373fbff14f555
Rhabersh/brown-repo
/oscar_project/oscar_table_create.py
1,822
4.25
4
import sqlite3 from sqlite3 import Error #Create class, pass through def sqlite_connect(): """ This function will use the sqlite3 module to connect to a database. If the specified database is not found in the local directory, a new one with the given name will be created. ...
true
aea792baa1a8e9cee6611f2a5409c5bdb036b88b
Sam-Whitley/petrikuittinen_assignments
/lesson_python_basics/for_reversed.py
278
4.125
4
names = ["Bill", "James", "Paul", "Paula", "Jenny", "Kate"] # normal order for name in names: print(name) print("Reverse order:") for name in reversed(names): print(name) print("Don't code like this") i = len(names)-1 while i >= 0: print(names[i]) i = i-1
true
dc567267261b2cf45c92e9d7dc6926ec1ae28432
Zivilevs/Python-programming
/temp_graf.py
1,244
4.25
4
#!/usr/bin/python # Program to convert Celsius to Fahrenheit using a simple # graphical interface. from graphics import * def main() : win = GraphWin( "Celsius Converter" , 400 , 300) win.setCoords (0.0, 0.0 , 3.0, 4.0) win.setBackground("white") # Draw the interface label1 = Text(Point(1,3)...
true
b901ec9ccec8c27a6010deae9cd372c7f19261f7
ryanlkraemer/RK-engineering-class
/LearningPythonTheHardWay/ex7.py
916
4.28125
4
#prints a straight string print("Mary had a little lamb") #prints a string by leaving a { in a string, then .formatting to fill it with 'snow'. Format takes whatever is in front, either a variable #defined to be a string or a string (always with a {} and puts the thing in the parentheses after the format into the {} ...
true
0830ef6c3d547d2ade1beb51446e9b4648b27743
ryanlkraemer/RK-engineering-class
/LearningPythonTheHardWay/ex15.py
671
4.15625
4
#takes the module argv from system, allowing me to input the meat of the matter from sys import argv #defines the things in that order for me to input with argv script, filename = argv #defines txt as the file that i input txt = open(filename) #says a useless thing print(f"""Here's your file {filename}. """) #reads ...
true
7764bd7f4d1dc3ebb76b6fe154fc5055282be820
cjreynol/willsmith
/willsmith/action.py
1,394
4.28125
4
from abc import ABC, abstractmethod class Action(ABC): """ Abstract base class for game actions. Subclasses are convenient containers to remove the reliance on nested tuples and the copious amounts of packing and unpacking required by them. The parse_action method is used to convert string...
true
b6f0bb3b88752eecdccd8ccda259bd94e33f6bca
DarkCron/PythonBvP
/Oefenzitting1/Extra/P2-11p81.py
553
4.25
4
gallons_gas = float(input("The number of gallons of gas in tank: ")) miles_per_gallon = float(input("The fuel efficiency in miles per gallon: ")) price_per_gallon = float(input("The price of gas per gallon: ")) DISTANCE = 100 drivable_distance = gallons_gas * miles_per_gallon; # x miles = 1 gallon # 100 miles = 1 / ...
true
7938b5edcf60ed84bf79296e95e40a41533f8909
hugolribeiro/Python_Projects
/Dice Rolling Simulator.py
1,493
4.5625
5
# 1. Dice Rolling Simulator The Goal: Like the title suggests, this project involves writing a program that simulates # rolling dice. When the program runs, it will randomly choose a number between 1 and 6. (Or #whatever other integer # you prefer — the number of sides on the die is up to you.) The program will print w...
true
2139b3e6a019ead6728fbb21595cb7ac2ce2d70a
Cabottega/python_exercises
/python_index_based_interpolation.py
907
4.5
4
# instructor notes from python documentation website. # str.format(*args, **kwargs) # Perform a string formatting operation. The string on which this method is called can contain literal text or >replacement fields delimited by braces {}. Each replacement field contains either the numeric index of a positional >argumen...
true
baec7769933fea8a98842aab9d80a8ff7f88d545
Cabottega/python_exercises
/looping_over_characters.py
290
4.6875
5
alphabet = 'abcdef' for letter in alphabet: print(letter) # instructor notes: # alphabet = 'abcdef' # for letter in alphabet: # print(letter) # """ # you have a string here # a for in loop allows you to access them just like a string/collection # 'a', 'b', 'c', 'd' ect # """
true
0985ed07d4a2dd7331e6b4a978fe8e1a75d00b30
Cabottega/python_exercises
/tuples_delete_elements.py
994
4.3125
4
post = ('Python Basics', 'Intro guide to Python', 'Some cool python content', 'published') # Removing elements from end post = post[:-1] # Removing elements from beginning post = post[1:] # Removing specific element (messy/not recommended) post = list(post) post.remove('published') post = tuple(post) print(post) #...
true
6e44076369067e868300c1341c8e1856c0449253
bglajchen/MIT-Intro-to-Python-6.0001
/ps1/ps1c.py
1,839
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jan 7 13:35:24 2020 @author: bglajchen """ annual_salary = float(input("Enter your annual salary: ")) total_cost = 1000000 semi_annual_raise = 0.07 portion_down_payment = total_cost * 0.25 current_savings = 0 number_of_months = 0 possible = True ste...
true
f6abe0260a989a51b762704a4e995e5def0a787a
venkatsvpr/Problems_Solved
/LC_Smallest_String_With_Swaps.py
2,349
4.15625
4
""" 1202. Smallest String With Swaps You are given a string s, and an array of pairs of indices in the string pairs where pairs[i] = [a, b] indicates 2 indices(0-indexed) of the string. You can swap the characters at any pair of indices in the given pairs any number of times. Return the lexicographically smallest s...
true
c031dddd3c3e0685e82ef5f5934654765ddb7ab7
alakamale/888
/Tree/src/internal_node.py
530
4.21875
4
# 1. Find internal nodes # Let's assume we have a generic tree, such as follows (node values are simply identifiers): # Then we define this tree with a list L: [4, 2, 4, 5, -1, 4, 5] such as L(i) identifies the parent of i (the root has no parent and is denoted with -1). # An internal node is any node of a tree that ha...
true
e43de700059c31e5db0c7a7f6e837c0556186b3b
ChiselD/pyglatin
/pyglatin.py
2,946
4.21875
4
# THINGS TO FIX # 1. multiple consonants at start of word - DONE! # 2. printing on separate lines - DONE! # 3. non-alphabetical strings # 3a. if user includes numbers, return error - DONE! # 3b. if user includes punctuation, move it to correct location # 4. omitted capitalization # separate variables for the two possi...
true
513be128e24652eb1eef63f752fbabcae68c7437
junweitan1999/csci1100
/homework/hw4/hw4Part1.py
2,225
4.40625
4
# function to define the word is alternating or not def is_alternating(word): #initializing vowels = [] letter=['a','b','c','d','e','f','g','h','j','k','l','i','o','u','m','n','p','q','r','s','t','v','w','x','y','z'] judge = True same_or_not = True judgment =False word_copy=...
true
2f1757c8454ec56b1cf3360f486c54ab8230eb2f
chandni-s/NewsFlash
/src/model.py
1,538
4.3125
4
class Model(): """A database model. Objects that interact with the database (add, get, delete, etc...) should be derived from this class. This helps create a consistent interface for the database to use to implement its functions (and prevents lots of repetition in queries as a bonus).""" # (str) ...
true
32825ec6823749ec084a80d18865a23f05851a6e
Tetyana-I/first-python-syntax-exercises
/words.py
469
4.5
4
def print_upper_words(words, must_start_with): """Print each word (on a separate line uppercase) from words-list that starts with any letter in must_start_with set """ for word in words: if (word[0] in must_start_with) or (word[0].upper() in must_start_with): print(word.upper()) # this sho...
true
8f38be0f4bc6445f279cf523fbb830dbc8482e94
robpalbrah/RedditDailyProgrammer
/easy/dp_293_easy.py
1,713
4.15625
4
""" [2016-11-21] Challenge #293 [Easy] Defusing the bomb https://tinyurl.com/dp-293-easy """ # Status: Done # allowed_wires = {cut_wire_color : [allowed_wire_color, ...], ...} allowed_wires = {None : ['white', 'black', 'purple', 'red', 'green', 'orange'], 'white' : ['purple', 'red', 'green', 'orange']...
true
31adb720c1fca5d66db953e58fb4e409cded43f2
RobertHostler/Python-Data-Structures
/StacksAndQueues/QueueFromStacks.py
1,100
4.15625
4
from Stacks import Stack class QueueFromStacks(): # This is a queue implemented using a stack. This is a # common interview question or puzzle, and I thought I # would attempt it myself. def __init__(self, N): self.N = N self.stack1 = Stack(N) self.stack2 = Stack(N) def __...
true
5c7774fab73738e6e625f2eb9e90fc7433f6e2e3
pzhao5/CSSI_Python_Day_4
/for_split.py
595
4.46875
4
my_string = raw_input("Type something: ") # upper() method on string would capitalize the string. # print "{} {}".format("", "") is the way to format a string. # Unlike JS, Python does not support ++, thus you should use += 1 instead print "Print words in upper case" index = 0 for word in my_string.split(): # return ...
true
2c18b87f54a76008e1e255b08b7491922f905e0d
danielzyla/Python_intermediate
/11.py
1,223
4.125
4
##choice =''' ## ##choose on from the list: ##'load data' -\t\t 1 ##'export data' -\t\t 2 ##'analyze & predict' -\t 3 ## ##''' ## ##optlisted={'1':'load data', '2':'export data', '3':'analyze & predict'} ## ##choicenr=input(choice) ## ##while choicenr: ## if not choicenr.isdigit(): ## print('it is not number'...
true
ed553ef5a29820c3f52f2b19dfc0867eda49a5d5
Vagacoder/Python_for_everyone
/P4EO_source/ch11/sec05/permutations.py
1,002
4.34375
4
## # This program computes permutations of a string. # def main() : for string in permutations("eat") : print(string) ## Gets all permutations of a given word. # @param word the string to permute # @return a list of all permutations # def permutations(word) : result = [] # The empty string has a si...
true
50e1100ebc2bf59007e20c74181dd9720813a924
Vagacoder/Python_for_everyone
/P4EO_source/ch06/how_to_1/scores.py
1,106
4.21875
4
## # This program computes a final score for a series of quiz scores: the sum after dropping # the two lowest scores. The program uses a list. # def main() : scores = readFloats() if len(scores) > 1 : removeMinimum(scores) removeMinimum(scores) total = sum(scores) print("Final score:",...
true
5a87579b0e1cc3816dc15f3dd5726a622c0b815d
Vagacoder/Python_for_everyone
/Ch11/P11_16.py
2,652
4.125
4
## P11.16 # revise evaluator.py by adding operations of % and ^ (power) def main() : expr = input("Enter an expression: ") tokens = tokenize(expr) value = expression(tokens) print(expr + "=" + str(value)) ## Breaks a string into tokens. # @param inputLine a string consisting of digits and symbols # @r...
true
a48ba5b2bef7306a04b613e4764a5172c9f12b27
Vagacoder/Python_for_everyone
/P4EO_source/ch11/sec03/palindromes2.py
1,688
4.34375
4
## # This program uses recursion to determine if a string is a palindrome. # def main() : sentence1 = "Madam, I'm Adam!" print(sentence1) print("Palindrome:", isPalindrome(sentence1)) sentence2 = "Sir, I'm Eve!" print(sentence2) print("Palindrome:", isPalindrome(sentence2)) ## Tests whether a...
true
c8779a53a5928f26a9bde553ca810f751c1ac65f
Vagacoder/Python_for_everyone
/P4EO_source/ch06/sec04/reverse.py
1,079
4.40625
4
## # This program reads, scales and reverses a sequence of numbers. # def main() : numbers = readFloats(5) multiply(numbers, 10) printReversed(numbers) ## Reads a sequence of floating-point numbers. # @param numberOfInputs the number of inputs to read # @return a list containing the input values # def rea...
true
1feb20bdb6281f6323f50c84278816dc128e218d
Vagacoder/Python_for_everyone
/P4EO_source/ch08/sec01/spellcheck.py
1,152
4.46875
4
## # This program checks which words in a file are not present in a list of # correctly spelled words. # # Import the split function from the regular expression module. from re import split def main() : # Read the word list and the document. correctlySpelledWords = readWords("words") documentWords = readWo...
true
eea9344b03ebe54c9727d8ec1539e001fe3db9e0
Vagacoder/Python_for_everyone
/Ch12/insertionsort.py
474
4.4375
4
## # The insertionSort function sorts a list, using the insertion sort algorithm. # # Sorts a list, using insertion sort. # @param values the list to sort # def insertionSort(values): for i in range(1, len(values)): next = values[i] # Move all larger elements up. j = i while j ...
true
6a18e1cc99ec66f2dd69949cb9c472dd6dcc19de
Vagacoder/Python_for_everyone
/Ch12/P12_1.py
751
4.1875
4
# -*- coding: utf-8 -*- ## P12.1 # selection sort for descending order from random import randint def selectionSortDes(values) : for i in range(len(values)) : maxPos = maximumPosition(values, i) temp = values[maxPos] # swap the two elements values[maxPos] = values[i] values[i] = temp ## Fi...
true
40828a4f4b94cff92a03e7c273ac262e8d894744
Vagacoder/Python_for_everyone
/P4EO_source/ch12/sec06/linearsearch.py
448
4.28125
4
## # This module implements a function for executing linear searches in a list. # ## Finds a value in a list, using the linear search algorithm. # @param values the list to search # @param target the value to find # @return the index at which the target occurs, or -1 if it does not occur in the list # def linearSe...
true
fce8841d3f60fd63bcf052baafc1ebc3705a264e
Vagacoder/Python_for_everyone
/P4EO_source/ch04/sec01/doubleinv.py
505
4.15625
4
## # This program computes the time required to double an investment. # # Create constant variables. RATE = 5.0 INITIAL_BALANCE = 10000.0 TARGET = 2 * INITIAL_BALANCE # Initialize variables used with the loop. balance = INITIAL_BALANCE year = 0 # Count the years required for the investment to double. while ba...
true
b23d88c162bcb6ff327a45f577e7e39ea17a1b59
anand14327sagar/Python_Learning
/Tuples.py
230
4.125
4
mytuple = (10,10,20,30,40,50) #to count the number of elements print(mytuple.count(10)) #the output will be 2 #to find the index # mytuple.index(50) #the output will be 5. since the index number at 50 is 5.
true
9e1af1f511a41856d2c0e75384f63f8d1d1ae4e0
reddyprasade/Turtle_Graphics_In_Python3
/Circles.py
863
4.25
4
# Python program to user input pattern # using Turtle Programming import turtle #Outside_In import turtle import time import random print ("This program draws shapes based on the number you enter in a uniform pattern.") num_str = input("Enter the side number of the shape you want to draw: ") if num_st...
true
8a6f6d7cb6db08dd01f59a56144cc532804f6928
ncommella/automate-boring
/exercises/hello.py
319
4.1875
4
print('Hi, what\'s your name?') userName = input() #displays length of userName print('What\'s up, ' + userName + '? The length of your name is ' + str(len(userName))) #asks for age print('What is your age?') userAge = input() print('In one year, you will be ' + str(int(userAge)+ 1) + ' years old.')
true
a51b1ddb7223ca8b07590ba82e2b2842f7c51d18
DustyHatz/CS50projects
/python/caesar.py
1,392
4.40625
4
# This program will creat a "Caesar Cipher" # User must enter a key (positive integer) and a message to encrypt from cs50 import get_string from sys import argv, exit # Check for exacctly one command line argument and make sure it is a positive integer. If not, exit. if len(argv) == 2 and argv[1].isdigit(): # Co...
true
9225eeccba5923ace5e1b5189926fe1342fa5dbd
godwinreigh/web-dev-things
/programming projects/python projects/tkinter practice/4. Creating Input Fields.py
588
4.34375
4
from tkinter import * root=Tk() #creating entry widget for input fields #we can change the size of it using the width= and function #we can also change the color using bg and fg #we can also change the border width using borderwidth= function e = Entry(root, width=50, bg='Blue', fg='White', borderwidth = 5) e.pack() #...
true
891ec9eb9e870d6a0e6b5ce3b09f2e07a32fb035
godwinreigh/web-dev-things
/programming projects/python projects/tkinter practice/2. Positioning with tkinter's grud system.py
340
4.25
4
#grid system is like a grid think of your program as a grid from tkinter import * root = Tk() #creating a label myLabel1 = Label(root, text='Hello World') myLabel2 = Label(root, text='My name is John Elder') #shoving it onto the screen #this were using grid system myLabel1.grid(row=0, column= 0) myLabel2.grid(row=1, co...
true
e96eab67caa80b14babe7375ddf669d06bbd0465
godwinreigh/web-dev-things
/programming projects/python projects/tutorials(fundamentals)/14.Buildingbettercalculator.py
475
4.40625
4
numA = float(input("Please enter a number ")) operator = input("Please print an operator ") numB = float(input("Please enter the another number ")) if operator == "+": print(numA + numB) elif operator == "-": print(numA + numB) elif operator == "*": print(numA * numB) elif operator == "/": print(numA /...
true
b03ef6a6f955644c5f3ff28075c0b33c0be05b9e
godwinreigh/web-dev-things
/programming projects/python projects/tutorials2/15. Dictionnaries.py
1,506
4.21875
4
#they are really good for: #super organized data (mini databases) #fast as hell (constant time) #sorted dictionary from collections import OrderedDict groceries = {'bananas': 5, 'oranges': 3 } print(groceries['bananas']) #to avoid syntax error that is because the element is not in th...
true
17fb36ba7be775e159d675b035f7c8ac920785af
JBustos22/Physics-and-Mathematical-Programs
/root-finding/roots.py
1,529
4.4375
4
#! /usr/bin/env python """ This program uses Newton's method to calculate the roots of a polynomial which has been entered by the user. It asks for a polynomial function, its derivative, and the plotting range. It then plots it, and asks the user for a value. Once a value is entered, the root closest to that value is e...
true
43def0189ddebca9e6d900604d692c9a9d2e1a36
JBustos22/Physics-and-Mathematical-Programs
/computational integrals/hyperspheres.py
779
4.21875
4
#! /usr/bin/env python """ This program uses the numerical monte carlo integration function from the numint module. It calculates the volume of an unit sphere for dimensions 0, through 12, and creates a plot of hypervolume vs dimension. Jorge Bustos Mar 4, 2019 """ from __future__ import division, print_function impo...
true
ae9b70d3d0a73ca6f696a681d3e82c4969b99716
ASamiAhmed/PythonPrograms
/feet_inch_cm.py
278
4.28125
4
''' Write a Python program to convert height (in feet and inches) to centimetres. ''' number = int(input("Enter number: ")) feet = number*30.48 print("The number you entered in centimeter is",feet) inch = number*2.54 print("The number you entered in centimeter is",inch)
true
e9a31c7404309047d598f507aed85fbf0630ac40
tgandrews/Project-Euler
/Problem 6/Difference between sum of square and square of sum.py
654
4.21875
4
# Difference between sum of square and square of sum # (1^2 + 2^2) - (1 + 2)^2 import time; def Sum(maxVal): resultSquares = 0; resultSum = 0; i = 0; while i <= maxVal: resultSquares += (i * i); resultSum += i; i = i + 1; print 'Sum: ' + str(resultSum); print 'Sum of...
true
34c52fae8d33c2f0390b13e2d1adaa3089805f5c
yiming1012/MyLeetCode
/LeetCode/树(Binary Tree)/199. Binary Tree Right Side View.py
2,027
4.21875
4
''' Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. Example: Input: [1,2,3,null,5,null,4] Output: [1, 3, 4] Explanation: 1 <--- / \ 2 3 <--- \ \ 5 4 <--- 通过次数26,604提交次数41,423 ...
true
cb3e2ddcbf9b58bd603b6ce23151e7df6b41cee0
yiming1012/MyLeetCode
/LeetCode/1184. Distance Between Bus Stops.py
2,425
4.34375
4
''' A bus has n stops numbered from 0 to n - 1 that form a circle. We know the distance between all pairs of neighboring stops where distance[i] is the distance between the stops number i and (i + 1) % n. The bus goes along both directions i.e. clockwise and counterclockwise. Return the shortest distance between the ...
true
47d8e7ca10710cc2e5f3124c9ce0397ee87dd9fd
yiming1012/MyLeetCode
/LeetCode/840. Magic Squares In Grid.py
1,990
4.28125
4
''' A 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum. Given an grid of integers, how many 3 x 3 "magic square" subgrids are there?  (Each subgrid is contiguous).   Example 1: Input: [[4,3,8,4], [9,5,1,9], ...
true
313d594302ee78ed6154d46cc8fa80c25493c2c6
Kristianmartinw/8-30-reference
/number.py
695
4.25
4
# Integers, no decimal print(3) print(int()) print(int(3)) print(int(3.0)) # Type casted (conversion from one type to another) # Floating Point Number, has decimal print(4.0) print(float()) print(float(4.0)) print(float(4)) # Type casted (conversion from one type to another) # Type casting to string print(str(7.0) ...
true
27fcf9b9c7d1fc17e56c38c757362da24ffef957
shermanbell/CTI110
/M6HW2_Bell.py
2,373
4.21875
4
#Sherman_Bell #CTI_110 #M6HW2_Random Number Guessing Game #9_Nov_2017 # Write a program that does the following # Gernerate a random number in the range of 1 through 100. ( We'll call this "secret number") # Ask the user to guess what the secret number is # If the user's guess the higher thatn the secret numbe...
true
05543281d6fad233f401393a66d0c1dcd63eddb6
afl0w/pythonNotes
/Activity-E.py
319
4.40625
4
#user input for the lengths of three sides of a triangle. print("Enter the lengths of the three triangle sides: ") x = int(input("x: ")) y = int(input("y: ")) z = int(input("z: ")) #if else statement if x == y == z: print("This is a Equilateral triangle") else: print("This is not a Equilateral triangle")
true
a2262ddc8021d0e5b0669bac14cd3385627b49a6
nikhilchowdarykanneganti/python_by_example_-NICHOLA-LACEY-
/the basics/c6.py
329
4.34375
4
#Challenge6 '''Ask how many slices of pizza the user started with and ask how many slices they have eaten. Work out how many slices they have left and display the answer in a user- friendly format.''' print('you are left with',int(input('How many slices of pizza have you ordered\n'))-int(input('How many slices u ate\n'...
true
76b7e9ec61e55aa043ca62db1871d7adb6e8534b
SuyogKhanal5/PythonNotes
/reg_expressions_three.py
945
4.40625
4
import re print(re.search(r'cat|dog','The cat is here')) # Use the pipe operator to see if you have cat or dog print(re.findall(r'.at', 'The cat in the hat sat')) # . is the wild card operator, so use it if you dont know one of the letters print(re.findall(r'...at', 'The cat in the hat went splat')) print(re...
true
048daa5772e37fb3b19814ef57797a323707cdc6
Simran-kshatriya/Basic
/PythonBasics2.py
534
4.15625
4
if 5 > 3: print(" 5 is grater than 3") num = 0 if num > 0: print("This is a positive number") elif num == 0: print("Number is zero") else: print("This is a negative number") num1 = [1, 2, 3, 4, 5] sum = 0 for val in num1: sum +=val print("Total is ", sum) languages = ["Python", "Java","Ruby","PHP...
true
614c48c004a052e42dcdd0f9d35fb7a49842f37d
sarahcenteno/chatServer
/server.py
2,768
4.125
4
#!/usr/bin/env python import socket host = '' port = 5713 # Creates TCP socket serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) serverSocket.bind((host, port)) # server connects to given host and port serverSocket.listen(2) # server listens for incoming TCP requests print("Server started") print("Wa...
true
573535f4084cee4bed4787ccabf7a2d4de6d75e7
linshiu/python
/data_structures_algorithms/problem_solving_data_structures_algorithms/chap02_analysis/anagram.py
1,883
4.25
4
# -*- coding: utf-8 -*- """ Problem Solving with Data Structures and Algorithms, Brad Miller Chapter 2 - Analysis Anagram IDE: Spyder, Python 3 A good example problem for showing algorithms with different orders of magnitude is the classic anagram detection problem for strings. One string is an anagram of another if...
true
414e0568c3840e44c3b1b2fd7728c613f1a26c1d
linshiu/python
/data_structures_algorithms/problem_solving_data_structures_algorithms/chap04_recursion/reverseList.py
776
4.125
4
# -*- coding: utf-8 -*- """ Problem Solving with Algorithms and Data Structures, Brad Miller Chapter 4: Recursion IDE: Spyder, Python 3 Reverse a list """ #%% Function ################################################################# def reverseList(ls): """ Reverse a list base: Args: ...
true
39d9a59d7e31ec327248ca7d8675066ffbacb494
linshiu/python
/data_structures_algorithms/problem_solving_data_structures_algorithms/chap05_searching_sorting/bubbleSort.py
2,739
4.15625
4
# -*- coding: utf-8 -*- """ Problem Solving with Algorithms and Data Structures, Brad Miller Chapter 5: Searching and Sorting IDE: Spyder, Python 3 Bubble Sort """ import timeit import matplotlib.pyplot as plt import numpy.random as nprnd import numpy as np #%% Function ################################################...
true
fced4355855688f19276d43d5b11bbaca98ade02
linshiu/python
/think_python/10_03_cum_sum.py
456
4.25
4
def cum_sum(t): ''' Write a function that takes a list of numbers and returns the cumulative sum; that is, a new list where the ith element is the sum of the first i + 1 elements from the original list. For example, the cumulative sum of [1, 2, 3] is [1, 3, 6].''' total = 0 cum_list = []...
true
a90a75e5f3b0efcf58f5c990ed4fd55f21849599
PrasamsaNeelam/CSPP1
/cspp1-practice/cspp1-assignments/m6/p2/special_char.py
399
4.15625
4
''' Author: Prasamsa Date: 4 august 2018 ''' def main(): ''' Read string from the input, store it in variable str_input. ''' str_input = input() char_input = '' for char_input in str_input: if char_input in('!', '@', '#', '$', '%', '^', '&', '*'): str_input = str_input.replac...
true
0c7c2f31713898a2ec1381e38c662fcb3ad74b34
davidgoldcode/cs-guided-project-problem-solving
/src/demonstration_09.py
1,071
4.25
4
""" Challenge #9: Given a string, write a function that returns the "middle" character of the word. If the word has an odd length, return the single middle character. If the word has an even length, return the middle two characters. Examples: - get_middle("test") -> "es" - get_middle("testing") -> "t" - get_middle("...
true
693558f4371fc3aa9d3deff7e0aa8aaefe389b24
natkam/adventofcode
/2017/aoc_05_jumps_1.py
2,014
4.46875
4
""" The message includes a list of the offsets for each jump. Jumps are relative: -1 moves to the previous instruction, and 2 skips the next one. Start at the first instruction in the list. The goal is to follow the jumps until one leads outside the list. In addition, these instructions are a little strange; after eac...
true
b9eb9cc86ccd65bba04bfce054c8238362992270
natkam/adventofcode
/2017/aoc_02_checksum1.py
1,908
4.3125
4
""" The spreadsheet consists of rows of apparently-random numbers. To make sure the recovery process is on the right track, they need you to calculate the spreadsheet's checksum. For each row, determine the difference between the largest value and the smallest value; the checksum is the sum of all of these differences....
true
ff451d9981296e73a3c71ed09a8605cb4b6dd9ed
fox-flex/lb7_2sem_op
/example/point_1.py
1,494
4.34375
4
from math import pi, sin, cos, radians class Point: 'Represents a point in two-dimensional geometric coordinates' def __init__(self, x=0, y=0): '''Initialize the position of a new point. The x and y coordinates can be specified. If they are not, the point defaults to the origin.''' ...
true
022aa7c9028a366b991567693d5be0c0ae2ed08d
DarinZhang/lpthw
/ex31/ex31.py
1,346
4.15625
4
# -*- coding: utf-8 -*- def break_words(sentence): words = sentence.split(' ') return words #sentence = "You are beautiful!" #print break_words(sentence) #print type(break_words(sentence)) print "You enter a dark room with two doors. Do you go through door #1 or door #2?" door = raw_input("> ") if door == "1": ...
true
a458570e869d9d8d3205053ea2587d07089afaca
jddelia/think-python
/Section15/rect_in_circle.py
671
4.5
4
# This program creates a circle with OOP. from math import sqrt class Point: def __init__(self, x, y): self.x = x self.y = y class Circle: def __init__(self, center, radius): self.center = center self.radius = radius class Rectangle: def __init__(self, corner, height,...
true
fe9b543b362b50a9491d74451d7fae5b27939e92
seunjeong/pykds
/pykids/class_2.py
2,518
4.3125
4
################################################################################ # More on String ################################################################################ my_name = 'Seongeun' my_age = 46 # Two different ways of print things print ('My name is: ' + my_name) print ('My name is {}'.format (my_na...
true
cc1a90064133b00c617934fb421fa56f010b4b45
longroad41377/variables
/divmod.py
441
4.125
4
try: number1 = int(input("Enter number 1: ")) number2 = int(input("Enter number 2: ")) div = number1 // number2 mod = number1 % number2 print("The integer result of the division is {}".format(div)) print("The remainder of the division is {}".format(mod)) except ValueError: ...
true
3b4d595cb330cf983825957c1ac535cef82c7668
HakiimJ/python-bootcamp
/pre-session/basic_calculations.py
767
4.21875
4
pi = 3.14 # global constant #advanced way to set globals is given here: https://www.programiz.com/python-programming/variables-constants-literals def area_circle(radius): area = pi * radius * radius return area def volume_sphere(radius): return 0 def volume_cylinder(radius, height): area = area_circle (rad...
true
93c6d65644d19659bb0b118235ab632eeb8d1d2b
salehsami/100-Days-of-Python
/Day 3 - Control Flow and Logical Operators/Roller_Coaster_Ticket.py
717
4.15625
4
# Roller coaster Ticket print("WWelcome to the RollerCoaster") height = int(input("Enter your height in cm: ")) bill = 0 if height >= 120: print("You can ride the Roller Coaster") age = int(input("What is your age: ")) if age < 12: print("Your Ticket will be $5") bill += 5 eli...
true
cd83e291a5f957ea7f201ae33d6f269f14644135
salehsami/100-Days-of-Python
/Day 10 - Beginner - Functions with Outputs/output_functions.py
254
4.21875
4
first_name = input("Enter your first name: ") last_name = input("Enter your last name: ") def format_name(f_name, l_name): first = f_name.title() last = l_name.title() return f"{first} {last}" print(format_name(first_name, last_name))
true
47759d97ecce73c812888b02765a374685273cb8
GauravPadawe/1-Player-Rock-Paper-Scissors
/Game.py
2,642
4.28125
4
import sys # Importing required packages import random import time def game(user, choice): # Defining a function which will accept 2 inputs from user as (user, choice) choice = str(input(user + ", What's your choice?: ")) ...
true
d449b9cc2aeedf6e3c4c05402012ac58bf68ef5a
sduffy826/FinchBot
/testMath.py
1,012
4.15625
4
import math def conversionTest(): degrees = input("Enter degrees: ") print("{degrees:d} converted to radians is {radians:.2f}".format(degrees=degrees,radians=math.radians(degrees))) radians = input("Enter radians: ") print("{radians:.2f} converted to degrees is: {degrees:.2f}".format(radians=radians,degrees=m...
true
f1d629382312813dde2c6855af4f63bf21c4dcb7
YesimOguz/calculate-bill-python
/calculateBill.py
687
4.15625
4
# this is a program to calculate the total amount to be paid by customer in a restourant # get the price of the meal # ask the user to chose the type of tip to give(18%,20%,25%) # base on the tip calculate the total bill meal_cost = int(input('please enter the price of the meal: ' )) percentage_of_tip = input("""what ...
true
34cb6e42eaf5504075f29b9e93eb09bdb89e9800
deShodhan/Algos
/w2pa5.py
868
4.3125
4
# Accept a string as input. Select a substring made up of three consecutive characters in the input string such that there are an equal number of characters to # the left and right of this substring. If the input string is of even length, make the string of odd length as below: • If the last character is a period ( . ...
true
d21eca2dcc25ea7d6fb521c53d3358ebef57e9c4
carlosgomes1/python-tests
/world-1/17-cateto-and-hypotenuse.py
391
4.46875
4
# Make a program that reads the length of the opposite cateto and the adjacent catheter of a # right triangle. Calculate and show the length of the hypotenuse. from math import hypot opposite = float(input('Length of opposite cateto: ')) adjacent = float(input('Length of adjacent cateto: ')) hypotenuse = hypot(oppos...
true
13e6bf1cafdc689897f61716751c132d5625cbe0
carlosgomes1/python-tests
/world-1/05-predecessor-and-successor.py
256
4.4375
4
# Make a program that receives an integer and shows on the screen its predecessor and successor. number = int(input('Enter an integer: ')) print( f'The number entered was {number}. The predecessor is {number - 1} and the successor is {number + 1}.')
true
9e71556d9191490662374993741a4b111715c9c9
carlosgomes1/python-tests
/world-1/19-sorting-item.py
494
4.1875
4
# A teacher wants to draw one of his four students to erase the board. # Make a program that helps him by reading the students' names and writing on the screen # the name of the chosen one. from random import choice student1 = input('First student: ') student2 = input('Second student: ') student3 = input('Third stud...
true
1634bb33fbde3d6e7186019a6a09ed7c8b3afcc5
monchhichizzq/Leetcode
/Reverse_Integer.py
1,516
4.25
4
''' Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−2^31, 2^31 − 1] ([−214783...
true
781b64fb1675bdb0a9455b12881ebd0e7445a33e
sgouda0412/regex_101
/example/012_matching_one_or_more_repetitions.py
373
4.21875
4
""" Task You have a test string S. Your task is to write a regex that will match S using the following conditions: S should begin with 1 or more digits. After that, S should have 1 or more uppercase letters. S should end with 1 or more lowercase letters. """ import re Regex_Pattern = r'^[\d]+[A-Z]+[a-z]+$' print(s...
true
6770521cbf59e985dc41341e5d05bd9760a66f82
sgouda0412/regex_101
/example/011_matching_zero_or_more_repetitions.py
375
4.1875
4
""" Task You have a test string S. Your task is to write a regex that will match S using the following conditions: S should begin with 2 or more digits. After that, S should have 0 or more lowercase letters. S should end with 0 or more uppercase letters """ import re Regex_Pattern = r'^[\d]{2,}[a-z]*[A-Z]*$' print...
true
0f79fabfc085fe7aae85f66fb216ff8d8591c90a
nikhilrane1992/Python_Basic_Exercise
/angle_betn_clock_hands.py
844
4.3125
4
# Find the anfle between the two clock hands # First find the hour degree and minute degree for hour angle from 12 hour_degree = (360 / 12.0) hr_minutes_degree = (360 / 12 / 60.0) # hour degree = 30 and hr minutes degree 0.5. # Find minute angle from 12 minutes_degree = 360 / 60.0 # minute degree is 6 # Now find the...
true
5749e068940ab140b24525d99e32e927ff7476a0
nikhilrane1992/Python_Basic_Exercise
/conversion.py
585
4.59375
5
# Convert kilometers to mile # To take kilometers from the user km = input("Enter value in kilometers: ") # conversion factor for km to mile conv_fac = 0.621371 # calculate miles miles = km * conv_fac print '{:.3f} kilometers is equal to {:.3f} miles'.format(km, miles) # Python Program to convert temperature in cel...
true
51010381f36511069c0e670f5d2a2a283ed40364
KOdunga/Python_Introduction
/PycharmProjects/untitled1/maxnumber.py
389
4.25
4
# Create a function that requests for three integers then get the maximum number def getnumbers(): list = [] x = 1 while x<4: num = input("Enter a number: ") list.append(num) x+=1 getmaxnum(list) def getmaxnum(list): print(max(list)) y=1 while y != 0: getnumbers() y...
true
3fcfbb9610c0aa54f8d8290b35d587e731f111bc
kevinjdonohue/LearnPythonTheHardWay
/ex7.py
878
4.40625
4
"""Exercise 7.""" # prints out a string print("Mary had a little lamb.") # prints out a formatted string with a placeholder -- inside we call format # and pass in the value to be placed in the formatted string placeholder print("Its fleece was white as {}.".format('snow')) # prints out a string print("And everywhere...
true
dbace8d9d68e4dcc983acac20ac2dfc3e2ae1fe0
kushalkarki1/pythonclass-march1
/firstclass.py
388
4.1875
4
# if <condition>: # code # if 7 > 10: # print("This is if statement") # else: # print("This is else statement") # num = int(input("Enter any number: ")) # if num > 0: # print("This is positive number.") # else: # print("This is negative number.") num = int(input("Enter any num: ")) rem = num % 2...
true
c02e22d737b5fd6d67359f913faaa23eca061dc8
ebresie/MyGitStuff
/books/OReillyBooks/LearningPython/lists.py
711
4.1875
4
L=[123, 'spam',1.23]; print(L); print('len=',len(L)) # Indexing by position 123 print(L[0]) # Slicing a list returns a new list [123, 'spam'] print(L[:-1]) # Concat/repeat make new lists too [123, 'spam', 1.23, 4, 5, 6] print(L + [4, 5, 6]) print(L * 2) L.append('NI') print(L) # additional list operators L.insert(12...
true
acffad6b2b6e77a9c93642e094345a1bbc1e1c91
abhijeetanand163/Python-Basic
/distance.py
2,774
4.34375
4
import numpy as np class point: def __init__(self, x, y): self.x = x self.y = y class distance(): """ This class contains three different function. 1. Rooks Distance 2. Pandemic Distance 3. Levenshtein Distance """ # 1. Rooks Distance...
true
983505065449a5c2dec5f57c6801aa2ef81cf868
Patrick-Ali/210CT-Programming-Algorithms-Data-Structures
/FinalPrograms/vowelsRecursive.py
885
4.125
4
def check(letter, vowel, count, size): #apple = "This letter is not a vowel" #print(letter) if(count >= size): #print("Count is %d" % count) #print("Hit") return (True) #print("Vowel is: %s" % vowel[count].upper()) if letter == vowel[count] or letter == vowel[count].upper(): ...
true
561dd19b8f6fb46448a3287960701d2e844626d0
janina3/Python
/CS 1114/drawRectangle.py
769
4.125
4
import random def drawRectangle(numRows, numColumns): '''Draws a rectangle made up of random digits. Rectangle has length numColumns and height numRows.''' for i in range(numRows): #print string of random digits of length numColumns string = '' for j in range(numColumns): ...
true
60f11118fcff0ed3e6258bcc99e4ab4e2d8dad00
Naif18/PythonCourse
/ForthWeek/twentieththree.py
356
4.1875
4
DayList= { "saturday" : 1 , "sunday" : 2, "monday" : 3, "tuesday" : 4, "wedneday" : 5, "Thersday" : 6, "friday":7 } if "friday" in DayList: print("Yes, it's Friday") #Dictionary Lengh print(len(DayList)) #Delete value DayList.pop("monday") print(DayList) #Delete the last value we ad...
true
725fc67e664fbc220885310e18742af8003c27c9
NickBarty/Python-Interactive-Kivy-Project
/song.py
1,433
4.5
4
class Song: """ Song class initialises the attributes every song will have, how they will be printed and the ability to mark a song as required or learned """ def __init__(self, title="", artist="", year=0, required=True): """ initialises the attributes songs will have with default ...
true
3dbed07c2a122a53888c11a18c4da3cf33232614
robertross04/TreeHacks
/keyphrase.py
545
4.28125
4
#Puts the key phrases from the text into a list def generate_keyphrase_list(key_phrases): key_phrases_list = [] for value in key_phrases.values(): for tmp in value: for key in tmp.values(): for phrases in key: if len(phrases) >= 3: #only want words 3 or la...
true