blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
ed88d540806403c4065e0c86ec650b49d81f01cc
kristocode/30-Days-Of-Python
/12_Day_Modules/day12_level3.py
884
4.15625
4
## 💻 Exercises: Day 12 ### Exercises: Level 3 import random import string #1. Call your function shuffle_list, it takes a list as a parameter and it returns a shuffled list def shuffle_list(lst): return random.sample(lst, k=len(lst)) # unique items #return random.choices(lst, k=len(lst)) # repeated items o...
true
3f2aaf74de320538b1f37de59c0166a487ded404
kristocode/30-Days-Of-Python
/06_Day_Tuples/day6_level1.py
743
4.59375
5
## 💻 Exercises: Day 6 ### Exercises: Level 1 # 1. Create an empty tuple my_tuple = tuple() # 2. Create a tuple containing names of your sisters and your brothers (imaginary siblings are fine) sisters = ('Janis Joplin', 'Amy Winehouse') brothers = ('Brian Jones', 'Jimi Hendrix', 'Jim Morrison', 'Kurt Cobain') # 3. Jo...
true
469962a7100b3671df69de5b5897d0a25766b0d5
kristocode/30-Days-Of-Python
/09_Day_Conditionals/day9_level1.py
1,750
4.40625
4
## 💻 Exercises: Day 9 ### Exercises: Level 1 # 1. Get user input using input(“Enter your age: ”). If user is 18 or older, give feedback: # You are old enough to drive. If below 18 give feedback to wait for the missing amount of years. Output: '''sh Enter your age: 30 You are old enough to learn to drive. Output: E...
true
70e08680dd30b42b73e81517084f828c03f36fce
huilizhou/Leetcode-pyhton
/algorithms/201-300/225.implement-stack-using-queues.py
2,080
4.28125
4
# 用队列实现栈 # class MyStack: # def __init__(self): # """ # Initialize your data structure here. # """ # self.l = [] # def push(self, x): # """ # Push element x onto stack. # :type x: int # :rtype: void # """ # self.l.append(x) # ...
true
9f29346dce506d85d142a63494d270a88db07459
sloth143chunk/Election_Analysis
/Assisngments/F_String.py
1,559
4.15625
4
# Original concatenation # my_votes = int(input("How many votes did you get in the election? ")) # total_votes = int(input("What is the total votes in the election? ")) # percentage_votes = (my_votes / total_votes) * 100 # print("I received " + str(percentage_votes)+"% of the total votes.") # F-String Printing # my_...
true
8a6fdcb1907629d142b55fe8759f4d8b266e71f8
yashsinghal07/Music-Player
/Project_gui/guidemo.py
1,595
4.28125
4
import tkinter tw=tkinter.Tk() #tw is refference of tkinter class #title() and mainloop() are instance members of tkinter class hence refference tw can call them #title() - changes the title of root window tw.title("My Gui App") #next 2 lines changes the logo on the screen img=tkinter.PhotoImage(file="E:/project...
true
ab84718b1454e7e99875966a6ee98e0cd3ba7cf2
theTransponster/Data-Science
/Statistics/Interquartile.py
1,990
4.1875
4
#Basic code to find the interquartile range in python without using libraries #The objective of this code is to understand the concept of interquartile range from scratch #Interquartil: (Q3-Q1) #Reads from STDIN, prints on STDOUT n  =  int(input())  #number  of  elements  of  the  array numbers  =  list(map(int,  ...
true
af3f83953f214f2e57d6b624e97078ba98a55194
thirdeye18/mycode
/iftest/condition02.py
504
4.125
4
#!/usr/bin/env python3 ## Program checks the hostname against the expected value hostname = input("What value should we set for hostname?") ## Notice how the next line has changed ## here we use the str.lower() method to return a lowercase string if hostname.lower() == "mtg": print("The hostname matches the expec...
true
cc9b05fc91cad733e6ff451665f286686fbff3a4
chaconcarlos/udacity-data-structures-algorithms
/1-introduction/Task0.py
1,268
4.25
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 0: What is the first record of tex...
true
ec183b0b74cbc6563b066d89c2008bea6a550a0a
zaarabuy0950/assignment-3
/assign4.py
477
4.28125
4
#4. Create a list. Append the names of your colleagues and friends to it. #Has the id of the list changed? Sort the list. What is the first item onthe list? # What is the second item on the list? list = [] print(id(list)) list.append('zanda') list.append('yabin') list.append('kendra') print(list) print(id(list)) print...
true
0445950df9813809d215cc6f1ce154fdb274c79d
zaarabuy0950/assignment-3
/assign12.py
352
4.25
4
#12. Create a function, is_palindrome, to determine if a supplied word is the same if the letters are reversed. asd = input("enter a string:") qwe = asd[::-1] print(qwe) def is_palindrome(asd, qwe): if asd == qwe: return f"The Word are Same string" else: return f"The word are not same string" ...
true
4804982df745b4072c909b5e153812cb558f53b5
satheeshkumars/my_chapter_6_solution_gaddis_book_python
/exception_handling.py
600
4.34375
4
#use the numbers.txt file to practise this piece of code def main(): try: open_numbers = open('numbers.txt', 'r') except IOError: print('Unable to open file and read data!') accumulator = 0 counter = 0 for number in open_numbers: number = number[:-1] try: ...
true
1ff0fe784d7302ca1f5fb1ba4996309ebd84017e
Shivansh-Uppal/python-coursera
/file2.py
748
4.15625
4
#Write a program that prompts for a file name, then opens that file and reads through the file, looking for lines of the form: #X-DSPAM-Confidence: 0.8475 #Count these lines and extract the floating point values from each of the lines and compute the average of those values and produce an output as shown below. Do n...
true
f183bd60b67c7d608a547b37595ff7a0d14dbe21
DamonGeorge/NLP
/project_03/proj3.py
1,315
4.15625
4
''' WRITTEN FOR PYTHON 3 Team Member #1: Robert Brajcich Team Member #2: Damon George Zagmail address for team member 1: rbrajcich@zagmail.gonzaga.edu Project 3: Extracts tokenized inaugural addresses from pickle file ('proj3.pkl') and finds the frequency of a word in each address Due: 9/14/2018 ''' #import necessar...
true
0df613e039f1764bd2390b69096c65fb16494811
bhatiakomal/pythonpractice
/Pythontutes/tut8.py
1,892
4.21875
4
mystr="harry is good boy" print(len(mystr)) #len is used for determine lenght of string and counting is start from 0 print(mystr[0]) print(mystr[0:4]) print(mystr[0:5]) #this is called string slicing print(mystr[0:18]) print(mystr[0:80])#we don't have string of 80 but system can give us upto its length print(mystr[0:5:...
true
238a74a3e89f96a59cd779df4181c849f9e5e4eb
bhatiakomal/pythonpractice
/Practice/Practice68.py
806
4.15625
4
def show(): primarycolour1=input("Please enter first colour:") primarycolour2=input("Please enter second colour:") if primarycolour1=="red" and primarycolour2=="blue" or \ primarycolour1=="blue" and primarycolour2=="red": print(primarycolour1+" is mixed with "+primarycolour2+" is purple ...
true
bf120c4fb558764f85013c8040160517d39f2072
arxaqapi/99-solutions
/Python/1_01.py
515
4.28125
4
# Find the last element of a list def find_last_element(given_list): if given_list == []: return "given_list is empty" return given_list[-1] def find_last_element_2(given_list): if given_list == []: return "given_list is empty" return given_list[len(given_list) - 1] def find_last_el...
true
9cf885a250bc9f9a4a2144c2c83fa9691871014d
stjohn/stjohn.github.io
/teaching/cmp/cis166/s15/mines.py
1,609
4.15625
4
from turtle import * from random import * """ Sets up the screen with the origin in upper left corner """ def setUpScreen(xMax,yMax): win = Screen() win.setworldcoordinates(-0.5, yMax+0.5,xMax+0.5,-0.5) return win """ Draws a grid to the graphics window""" def drawGrid(xMax,yMax): tic = Turtle() ...
true
27991d0731342e22aa2081f0e365afa31e732b8c
stjohn/stjohn.github.io
/teaching/cmp/cmp230/s13/squareTurtle.py
380
4.1875
4
import turtle def main(): daniel = turtle.Turtle() #Set up a turtle named "daniel" myWin = turtle.Screen() #The graphics window #Draw a square for i in range(4): daniel.forward(100) #Move forward 10 steps daniel.right(90) #Turn 90 degrees to the right myWin.exito...
true
74f507795fb12a75b0a499f5f302c4252e2ab9f7
leonguevara/WriteSomething_Python
/main.py
887
4.6875
5
# main.py # WriteSomething_Python # # This program will help you get the size of a phrase given by the user, and let you # know if that size is an even or odd number. # # Python interpreter: 3.6 # # Author: León Felipe Guevara Chávez # email: leon.guevara@itesm.mx # date: May 29, 2017 # # We ask t...
true
73dbb32953bc17d70ee927370b1a0a75e0e27e2c
JRRRRRRR/Python
/Comparing(ifelse).py
324
4.4375
4
#Test if a number is even or odd number = int (input("Enter input: ")) if number % 2 == 0: # == means "is equal to" print(number, "is even") else: print(number, "is odd") if number > 5: print("Greater than 5") elif number < 0: print("Number is negative") else: print("Number is relatively small") ...
true
8aa467a97e853048c5836b2e1bcd8cd0ba93bc95
somesh202/Assignments-2021
/Week1/run.py
804
4.15625
4
## This is the most simplest assignment where in you are asked to solve ## the folowing problems, you may use the internet ''' Problem - 0 Print the odd values in the given array ''' arr = [5,99,36,54,88] import array as arr a = arr.array('i', [5, 99, 36,54,88]) for i in a: if i%2 != 0: print(i, end=" ") ...
true
ca0ea374d2777b6f48dabc48935d1e3729a203ff
SherriMaya/CIS189
/validate_input_in_functions.py
989
4.28125
4
"""Takes a test_name, test_score, and invalid_message that validates the test_score, asking the user for a valid test score until it is in the range, then prints valid input as 'Test name: #""" def score_input(test_name, test_score=0, invalid_message='Invalid test score, try again!'): """Returns ...
true
eb1da2a4d6d9afdef681607b88a2ff5fea07d88e
KeetonMartin/HomemadeProgrammingIntro
/Lesson7.py
1,890
4.3125
4
#Lesson 7 topics #Problem 1 """ Write a function taking in a string like "WOW this is REALLY amazing" and returning "Wow this is really amazing". String should be capitalized and properly spaced. Hint: Try using functions like "APPLE".lower() or ourList = "Multiple words in a string".split() ["Multiple", "words", "i...
true
b251b03e61f2ffd2c4af1727b8d399b439ad87c4
KeetonMartin/HomemadeProgrammingIntro
/Lesson17.py
2,084
4.40625
4
#Lesson 17 #Student Name: """ Today's lesson will be mostly work on anticipating the actions of a program. """ teams = ["Warriors", "76ers", "Celtics", "Lakers", "Clippers"] print("Problem 1") for i in range(0, len(teams)): print(i) print(teams[i]) #Group: """ 0 Warriors 1 76ers 2 Celtics 3 Lakers 4 Clippe...
true
ea064efef05364414aa5b1665e42bb362d7a2182
stroudgr/UofT
/CSC148/exercises/ex3/linked_list_test.py
2,302
4.15625
4
# Exercise 3 - More Linked List Practice # # CSC148 Fall 2015, University of Toronto # Instructor: David Liu # --------------------------------------------- """Exercise 3, Task 1 TESTS. Warning: This is an extremely incomplete set of tests! Add your own to practice writing tests, and to be confident your code is corre...
true
5fcd0cdd756b4b4e8ee9349a04ec7dfd52efeefd
PratikAmatya/8-bit-adder-Python-Program
/Program Files/NumberValidation.py
1,028
4.40625
4
# function which returns the correct number entered by the user def validate(numberPosition): correctNumberEntered=False while correctNumberEntered == False: # Exception Handling using try except block try: if numberPosition==1: # Converting the entered number to Int datatype number=int(input("\nEnter ...
true
568ece6291cd4be09f1fb0fbeb8eee9805ee8761
louloz/Python-Crash-Course
/Ch3-4List/for_loop_list_2.py
622
4.8125
5
# Python Crash Course, Eric Matthes, no starch press # Textbook Exercises # Louis Lozano # 3-1-2019 # for_loop_list_2.py # List comprehension used to create a list of odd numbers between 1 and 20 odd_numbers = [odd for odd in range(1, 20, 2)] for num in odd_numbers: print(num) # List comprehension ...
true
6debbb8e40919aca9555ffb135ad494cb7ffcd92
louloz/Python-Crash-Course
/Ch7_User_Input_and_while_Loops/7-2_restaurant_seating.py
477
4.34375
4
# Python Crash Course, Eric Matthes, no starch press # Ch7 User Input and while Loops # Textbook Exercises # Louis Lozano # 3-8-2019 # 7-2_restaurant_seating.py group_num = input("How many people are in your dinner group?") # Converts user input(string value) into an int data type. # Lets you use user inp...
true
b290a9c28c4a25564238191f84e3737ceccfff5a
louloz/Python-Crash-Course
/Ch11_Testing_Your_Code/Employee.py
876
4.28125
4
# Python Crash Course, Eric Matthes, no starch press # Ch11 Files and Exceptions # Textbook Exercises # Louis Lozano # 07-08-2019 # Try It Yourself: 11-3 'Employee.py' # Python Version: 3.5.3 # Description: Creates an Employee class that takes a first name, last name, # and salary. Has a function to giv...
true
84fb398b4a5f7318ae4e5684e0ab2ddf30d5ccfb
barawalojas/Hacktoberfest2020-1
/Floyd_Warshall.py
1,527
4.28125
4
""" Floyd Warshall Algorithm finds All-pair shortest path for an weighted directed graph. It uses idea that distance to any points(v) must be greater sum of connecting edge weight(u,v) and preceding distance to the point(u). """ V = 4 INT_MAX = 9999 def floydWarshall(graph): dist = [row[:] for row in graph] ...
true
40336426062da448ddb8260af6ea39f82a1218ab
Tarini-Tyagi/TryPython
/Task3.py
490
4.125
4
from datetime import datetime name=input("Enter your name: ") now = datetime.now() current_time = now.strftime("%H:%M:%S") hrs=int(now.strftime("%H")) min=int(now.strftime("%M")) if hrs>4 and hrs<12: print("Good Morning "+name) elif hrs==12: print("Good Afternoon " + name) elif hrs>12 and hrs<15: print("...
true
3c93333318257673bfcad316d2ca573a8e5750e5
runaphasia335/Traveling-Salesman-WGUPS
/Algorithm.py
2,320
4.34375
4
# Carlos Perez # Student ID: 000819792 import heapq # Algorithm to determine the shortest path. # function takes the graph and the starting node. Sets the starting node to 0 distance, and predecessor to none. Since each node # has a minimum distance of MAX. 0 distance for the starting will determine each edge weight...
true
76d5e82c7bac3d270856142c7a48490ec0e4fe41
niosus/EasyClangComplete
/plugin/utils/unique_list.py
1,351
4.28125
4
"""Encapsulates set augmented list with unique stored values.""" class UniqueList: """A list that guarantees unique insertion.""" def __init__(self, other=None): """Init with another iterable if it is present.""" self.__values = list() self.__values_set = set() if not other: ...
true
b45fc04bccee35570f32935d6f8425a3974ae0d5
caoxudong/code_practice
/projecteuler/Problem4.py
758
4.15625
4
""" A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 * 99. Find the largest palindrome made from the product of two 3-digit numbers. """ import sys def isPalindrome(number) : palindromeString = str(number) palindromeStringlength...
true
d05173c139756b13c785c17485651f2cc2904e32
udaykumarbhanu/iq-prep
/ibts364/integer-to-roman.py
855
4.125
4
'''Given an integer, convert it to a roman numeral, and return a string corresponding to its roman numeral version Input is guaranteed to be within the range from 1 to 3999. Example : Input : 5 Return : "V" Input : 14 Return : "XIV" ''' class Solution: # @param A : integer # @return a strings def intTo...
true
b4e348abaf559bbf9cccbfb47397ced7c0c9296f
evansmusomi/python3-101
/design-patterns/abstract_factory.py
1,097
4.65625
5
""" Abstract factory example""" class Dog: """ One of the objects """ def speak(self): """ Implements dog's speech """ return "Woof!" def __str__(self): return "Dog" class DogFactory: """ Concrete factory """ def get_pet(self): """returns a dog object""" ...
true
bdef61984eace5ddecb594e7ee1feacffd329f1d
hrokr/pyknowledge
/short_progs/04.py
533
4.15625
4
#write a program that will print the song "99 bottles of beer on the wall". #for extra credit, do not allow the program to print each loop on a new line. # remove the # in the line above the decriment for extra credit. def bottles_of_beer(bottles): while bottles > 0: print (bottles, "bottles of beer on t...
true
e931ded5802c2206b832bb03f45348b7bd8631a3
akashmg/Python
/google-python-exercises/MyCode/hello.py~
312
4.1875
4
#!/user/bin/python # Using sys """ A program that takes an argument from the terminal and prints it """ import sys def main(): if len(sys.argv) >= 2: name = sys.argv[1] print "Hello" + name + "\nBuenos Dias!\n" else: print "Program is empty!" if __name__ == '__main__': main()
true
865d8459ec0eaf6292e8aa0193bfc53e8950b447
Jeffmanjones/python-for-everybody
/13_Extract_Data_from_JSON.py
1,567
4.40625
4
""" Extracting Data from JSON In this assignment you will write a Python program somewhat similar to http://www.py4e.com/code3/json2.py. The program will prompt for a URL, read the JSON data from that URL using urllib and then parse and extract the comment counts from the JSON data, compute the sum of the numbers in ...
true
ff5da270e46f7f9a86b121d94837f2da97c133ad
xpxu/learnPython
/decorator/multiple_closing.py
879
4.28125
4
''' Q: what is a decorator? A: input for a decrator is a function and it will return a new function ''' def log1(func): def wrapper(*args, **kwargs): print 'start' func(*args, **kwargs) print 'end' return wrapper def log2(message): # print message def decorator(func): ...
true
30590dc07df4e04943e8239cb01854279ab0b97c
prajaktanarkhede97/Python-Assignments
/Program-3.py
344
4.125
4
#Write a program which contains one function named as Add() which accepts two numbers from user and return addition of that two numbers. def add(num1,num2): ans=(num1 + num2) return ans value1=(int(input("Enter value of num1"))) value2=(int(input("Enter value of num2"))) ret= add(value1,value2) print("Sum of n...
true
9e6649455475a2943d2b12a22fea1d73e68b4306
Sylk/mit-programming-in-python
/ch-02/finger-exercise-one.py
651
4.4375
4
# Finger exercise: Write a program that examines three variables—x, y, and z—and prints the largest # odd number among them. If none of them are odd, it should print a message to that effect. from random import randint x, y, z = randint(0, 1000), randint(0, 1000), randint(0, 1000) print("X => " + str(x), "\nY => " + ...
true
c5eced1f1879b6c91ebb1c8829c6ca87927b91f6
Tanish74/Code-and-Compile
/meeting late comers.py
945
4.15625
4
""" A certain number of people attended a meeting which was to begin at 10:00 am on a given day. The arrival time in HH:MM format of those who attended the meeting is passed as the input in a single line, with each arrival time by a space. The program must print the count of people who came late (after 10:00 am) to the...
true
308efdd9e0a784de279ef0694f3121f5bae975f6
Tanish74/Code-and-Compile
/odd length string-middle three letters.py
460
4.375
4
"""An odd length string S is passed as the input. The middle three letters of S must be printed as the output. Input Format: First line will contain the string value S Output Format: First line will contain the middle three letters of S. Boundary Conditions: Length of S is from 5 to 100 Example Input/Output 1: Inpu...
true
90214a01620e9429c69d946047cb083b3656cc61
Tanish74/Code-and-Compile
/lowest mileage car.py
800
4.25
4
""" The name and mileage of certain cars is passed as the input. The format is CARNAME@MILEAGE and the input is as a single line, with each car information separated by a space. The program must print the car with the lowest mileage. (Assume no two cars will have the lowest mileage) Input Format: The first line contain...
true
3ad41e815a9a8f97c338c1f16ccfaf1438ce3c21
akshya-j31/python_bootcamp
/assignment4.py
945
4.21875
4
import os import os.path from os import path def main(): FileName = input("Please enter the file name: ") if path.exists(FileName): print("file exists") UserInput = input("***Please enter your choice***\na. Read the file\nb. Delete the file and start over\nc. Append the file\n\n") if Us...
true
0cf145c5a1915b268513880e66c448c1cd2f7a41
OkoroKelvin/parsel_tongue_mastered
/kelvin_okoro/chapter_seven/question_43.py
388
4.28125
4
# Write a function that takes a string as an argument, converts the string to a list of # characters, sorts the list, converts the list back to a string, and returns the resulting string. def conversion(strings, ): my_list = [] my_list += strings my_list.sort() my_new_string = "" return my_new_str...
true
12682c6d5d48916663860ba24972ae1ad91d0035
erikagreen7777/HackerRankPython
/capitalize.py
1,127
4.375
4
Capitalize! You are asked to ensure that the first and last names of people begin with a capital letter in their passports. For example, alison heck should be capitalised correctly as Alison Heck. Given a full name, your task is to capitalize the name appropriately. Input Format A single line of input containing t...
true
9bf22058173040b971477e36a5eff206b01d0450
calebajayi/Python_Codes
/OOSD_revision.py
2,537
4.21875
4
# # Exercise 1: Write a Python program that reads a text file and # # prints a list of unique words in the text. # # filename = "input1.txt" # unique_words = [] # try: # fp = open(filename, "r") # lines = fp.readlines() # for line in lines: # line = line.strip() # words = line.spli...
true
ceab9c9cfc0e4327b9b22b71f5f969a9d6b17477
botantantan/pangkui
/hw5/hw5_9.py
480
4.15625
4
""" Input example 1: FONTNAME and FILENAME Output sample 1: FONTAMEIL Input example 2: fontname and filrname Output sample 2: Not Found """ str1 = input() str2 = '' str3 = '' for ch in str1: if ord('A') <= ord(ch) <= ord('Z'): str2 += ch mylist = list(set(str2)) ...
true
e317b5e673f8914253e1dab99412ee407ff10115
markyashar/Python_Scientific_Programming_Book
/looplist/odd.py
454
4.28125
4
""" Generate odd numbers This program generates odd numbers from 1 to n. It sets n in the beginning of the program and uses a while loop to compute the numbers (making sure that if n is an even number, the largest generated odd number is n-1). """ n = 9 # The upper limit odd = 1 # Sta...
true
a4f140176275a52b0febb2f1bd5b56981938674f
thatnerdjoe/violent_python
/week03/lecture/Exp-8.py
936
4.25
4
''' Hash File Functions and usage example ''' from __future__ import print_function import hashlib import sys ''' Determine which version of Python ''' if sys.version_info[0] < 3: PYTHON_2 = True else: PYTHON_2 = False def HashFile(filePath): ''' function takes one input a vali...
true
c63db43c96052601ed5ba6d6bafd4265daeb54db
Stav30/Python
/range.py
209
4.125
4
""" In 3.X range is an iterable, that generates items on demand, so we need to wrap it in a list call to display its results all at once. """ x = list(range(5)), list(range(2,5)), list(range(0,10,2)) print(x)
true
f21eab6cb4090ffdf3aa201a9e685976b7830343
araschermer/python-code
/LeetCode/is-palindrom.py
1,024
4.4375
4
def is_palindrome(x): """ Given an integer x, return true if x is palindrome integer. An integer is a palindrome when it reads the same backward as forward. For example, 121 is palindrome while 123 is not. :type x: int :rtype: bool """ val = str(x) # convert number to string retur...
true
c963229ed1fcbb5dc25dc974c3c98a883960ae7e
araschermer/python-code
/LeetCode/move-zeros.py
963
4.3125
4
def move_zeroes(nums): """Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. :type nums: List[int] :rtype: None Do not return anything, modify nums in-place instead. """ # approach 01 zero_counter = 0 whi...
true
2ebda9a3f3b3c87168eb4263a11f01afbfc9fa67
araschermer/python-code
/algorithms_and_data_structures/arrays/arrays.py
2,137
4.40625
4
#Basic Array operaitons # appending elements to the first unoccupied element in the array array1 = [] for num in range(10): array1.append(num) print(f"array1: {array1}") # Inserting elements at the beginning of the array array3 = [] for num in range(10): array3.insert(0, num) print(f"array3:{array3}") # inser...
true
273846508ef2f7cb6b4fdb979ce61dcff99a7c2c
araschermer/python-code
/LeetCode/count-primes.py
1,104
4.21875
4
def count_primes(n): """Count the number of prime numbers less than a non-negative number, n. # extra: return the prime numbers :type n: int :rtype: int """ prime_numbers = [] if n < 2: return 0 prime = [1] * n # fill a list of length n with 1 for i in range(2, n): i...
true
cbd1a5e0ed518d7ed64684fe0c7dfaad577fcf3a
araschermer/python-code
/LeetCode/reverse-integer.py
1,231
4.34375
4
def reverse_integer(x): """Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-2^31, (2^31) - 1], then return 0. :type x: int :rtype: int """ x_string = str(x) if x_string[0] == "-": # in case t...
true
52e4f4dd1af4e34768962cc25132d8ba3a8f07ec
araschermer/python-code
/100 days of code/tip-calculator.py
714
4.3125
4
def calculate_tip(bill, people, tip): """ calculates a tip based on a given percentage of the total bill amount. the functionality can be viewed on repl.it website using the following links https://repl.it/@abdelkha/Tip-calculator?embed=1&output=1#main.py""" tip_percentage = tip / 100 total_tip_amo...
true
e7edf71414e6531335ebed17b5cbbcfe2478d07e
araschermer/python-code
/algorithms_and_data_structures/arrays/largest_range.py
2,138
4.375
4
def find_largest_range(array: [float]): """Returns the largest range of numbers that exist in the array Time complexity: O(NlogN) Space complexity: O(1)""" current_range = 1 max_range = 1 upper_bound = array[0] array.sort() for index, number in enumerate(array): if number == arra...
true
10b8325ef58e419e858c6a85f89feaa354d5197c
araschermer/python-code
/algorithms_and_data_structures/linked_lists/merge_linked_lists.py
2,394
4.3125
4
from linked_lists_util import print_linked_list, insert_list, Node class LinkedList: def __init__(self): self.head = None def merge_linked_lists(self, list_to_merge): """returns a single linked list out of merging two single linked lists with sorted elements.""" pointer1 = self.head ...
true
36ad6e0255aef608a48b16381dd477bed2286a37
kateallison/Python_Learnins
/ex11.py
961
4.40625
4
#ex11.py = Asking Questions #https://learnpythonthehardway.org/book/ex11.html print "How old are you?", age = raw_input() print "How tall are you?", height = raw_input() print "How much do you weigh?", weight = raw_input() print "So, you're %r old, %r tall and %r heavy." % ( age, height, weight) #[Take note of the ...
true
27982ee0b2058e23ff0889c8f2009b94a0ba6358
kateallison/Python_Learnins
/ex14.py
1,833
4.28125
4
#ex14.py = Prompting and Passing #https://learnpythonthehardway.org/book/ex14.html #from sys import argv #script, user_name = argv #prompt = '>' #print "Hi %s, I'm the %s script." % (user_name, script) #print "I'd like to ask you a few questions." #print "Do you like me %s?" % user_name #likes = raw_input(prompt) #...
true
5dd3d86a7e38261130e3add94570ce807a28aa37
dcheung15/Python
/ecs102/Hw/Distances.py
770
4.1875
4
#Doung Lan Cheung #dcheun01@syr.edu #Assignment 2, problem 2. #February 1, 2019 #Ask the user for how many pairs of points and compute the distances. import math def main(): #Ask for how many pairs of points and for the x and y cooridinates pts = eval(input("Enter how many pairs of points: ")) for ...
true
f01dc8ccdc1f52d98a7615fd02d4d919cd7db156
dcheung15/Python
/ecs102/Hw/DayofYear.py
1,177
4.25
4
#Official Name: Doung Lan Cheung #email: dcheun01@syr.edu #Assignment: Assignment 4, problem 1. #Date:February 18, 2019 #Figuring out what day of the year and week, given the date is through input def main (): monthLengths=[31,28,31,30,31,30,31,31,30,31,30,31] d = input("What is the day of the week in mm...
true
7bf149606d80aa353116f2ec9c81b64a7d0182cc
MangeshSodnar123/python-practice-programs
/factorial_forLoop.py
235
4.3125
4
num = int(input("Enter the number : ")) factorial = 1 if num == 1 or num == 0: print("The factorial is 1. ") else: for i in range( 1, num+1): factorial = factorial * i print("The factorial of the ",num,"is ",factorial)
true
7708db5110dfcb07aa1189c3c230f663c90c25fe
vandanasen/Python-Projects
/May-week4/prob5.py
545
4.125
4
""" Define a class which has at least two methods: getString: to get a string from console input printString: to print the string in upper case. Also please include simple test function to test the class methods. """ class myclass: def __init__(self,str1): self.str1 = str1 def __str__(self): ret...
true
596eb6e59ae078bb2aa4213592002a94aacda38b
harrisont/ProjectEuler
/Common/Prime.py
1,438
4.25
4
from math import sqrt, ceil, floor def is_prime(n): """ >>> is_prime(0) True >>> is_prime(1) False >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(7) True >>> is_prime(9) False >>> is_prime(13) True """ if n == 1: return False elif n < 4: return True elif n % 2 == ...
true
8456f0dc64309a6f3778657827d11758d9286475
dsmall3303/portfolio
/Python/largerthan.py
491
4.3125
4
first_number = 0 second_number = 0 user_unput = '' largest = 0 #get the first number from the user user_input = input("Please enter the first number: ") first_number = int(user_input) #get the second number from the user user_input = input("Please enter the second number: ") second_number = int(user_input) #determi...
true
6f98814417f70b385476913d50f571137c35a898
cRYP70n-13/Algorithms
/Data_Structures/python/Linked_lists/swapNodeWithoutSwappingData.py
1,630
4.15625
4
class Node : # constructor def __init__(self, val = None, next1 = None): self.data = val self.next = next1 # print list from this # to last till None def printList(self): node = self while (node != None) : print(node.data, end = " ") node = ...
true
f827a70e2dc5ab4490a8f2c3844cc530e5bb07ee
nehamundye/random-python-projects
/03_hangman/main.py
1,430
4.21875
4
import random from words import words # Pick a random word def pick_word(): word = random.choice(words) while '-' in word or ' ' in word: word = random.choice(words) return word word = pick_word() guessed_letter = [] def hide_word(guessed_letter): hide = "" for letter in word: ...
true
49f802161da33233a083944e4c6e9e0bf6c007b8
OreBank/udacity-pds
/python/lesson 6/10-practice-question.py
1,041
4.1875
4
# Create a function that opens the flowers.txt, reads every line in it, and saves it as a dictionary. The main (separate) function should take user input (user's first name and last name) and parse the user input to identify the first letter of the first name. It should then use it to print the flower name with the sam...
true
ac0b857ee83eb6e5c2539181d789dc0d2eaa645a
EthanSargent/python-ml-implementations
/LinReg.py
2,711
4.15625
4
# Author: Ethan Sargent # # The following is an implementation of regularized, multiple linear regression # (for an arbitrary number of parameters) using gradient descent. I learned the # algorithm from Andrew Ng's free online lecture. # # In the example, we predict weight from blood pressure and age, and plot the # de...
true
27c7695fc678229dca277fba603aa6404c64aed6
EL001/GemMine
/gem_enoch2.py
1,492
4.5625
5
#!/usr/bin/env python # coding: utf-8 # """ # Write a python program that does this; # It collects a user’s # - name # - age # - sex # # Prints out a welcome message like below. # “Hi {user’s name}, you are welcome. In 10 years time, you will be {age in 10 years time} years old and very old by then.” # # The python ...
true
5a0ae81921e8d28d618834a583d04ea250a53e2e
Aman-Achotani/Python-Projects
/Library_project.py
2,374
4.21875
4
# My library project class Library: def __init__(self,Book,Library) : self.book_name = Book self.library_name = Library print("\t\t***Welcome to ",self.library_name,"***") def display(self): print() print() print("Books avaiable are : ") for items in...
true
9c40bb8ffccc0817e22e59eaa8c19f2fb8e0fb2f
AdrianMartinezCodes/PythonScripts
/E14.py
585
4.1875
4
def sort(a_list): return set(a_list) def sort_list(a_list): b = [] for i in a_list: if i in a_list and i not in b: #just needed if i not in b: b.append(i) return b #updated soln below, old soln above, not working #return [b.append(i) for i in a_list if i not in b...
true
930884982712570afbd534bce6c4734bd8a94fdf
edwardst14/python_homework
/homework5/homework5.1.py
282
4.21875
4
#Homework 5.1 #Sept. 30 2020 #Use generator functions to create your own version of range function, call it my_range. #Do not use the python's range function in the code. def my_range(start, end): x = start while x < end: yield x x=x + 1 for i in my_range(0,10): print(i)
true
50b16653fa7f527117e5f77a5f336268d155c4c1
Saplyng/Hello-World-redux
/Python/chapter 7/rainfall statistics.py
2,108
4.46875
4
initial_dialog = ("""Hello User, you must be an aspiring meteorologist! that's the only reason I can think you would want something like an rainfall statistics calculator. But what would I know, I'm just a robot Anyway, I wont burden you the hassle of converting your units, just be consistent, if you start with Inche...
true
a765639b6211d5a6deed266b376e30364defd3ee
Saplyng/Hello-World-redux
/Python/chapter 3/if else statements.py
1,348
4.21875
4
# library roman_numerals = {'1': 'I', '2': 'II', '3': 'III', '4': 'IV', '5': 'V', '6': 'VI', '7': 'VII', '8': 'VIII', '9': 'IX', '10': 'X'} startup_dialog = ...
true
755196c7dd1c6a50bf33fe8b78d41927c88423d5
davidforero2016/Fundamentals-for-Python
/Lists.py
717
4.375
4
#This file contains fundamental notions about lists. Demolist1=[1, "John", True, 1,8, [1,2,3,4]] print(Demolist1) Demolist2=list((1, "John", True, 1,8, [1,2,3,4])) print(Demolist2) Demolist3=list(range(0,10)) print(Demolist3) print(len(Demolist1)) print(Demolist1[5]) print("John" in Demolist1) Demolist1[4]=False print(...
true
91a3d28deb8541b6403e5f20bc3945fcec0b6817
RobertElias/UdacityDataStructuresAlgorithms
/Python/functions.py
2,657
4.40625
4
# Example function 1: return the sum of two numbers. def sum(a, b): return a+b # Example function 2: return the size of list, and modify the list to now be sorted. my_list = ["Robert", "Cynthia", "Robbie"] def list_sort(my_list): my_list.sort() return len(my_list), my_list print(list_sort(my_list)) ###...
true
ca692034924e7c27287a7ff5524fabdf34e87201
CDinuwan/Py-Advanced
/Dictionary.py
950
4.15625
4
# Dictionary: key-Value pairs,Unordered,Mutable myDic = {"name": "Chanuka", "age": 21, "City": "New York"} print(myDic) myDict2 = dict(name="Dinuwan", age=27, city="Boston") print(myDict2) value = myDic["age"] print(value) myDic["email"] = "hecdinuwan@gmail.com" print(myDic) myDic["email"] = "chanukadinuwan35@gmai...
true
faf30f112f35955e0fa80bedd94fca75f01860ba
GT-rc/udemy-apps
/Section-5/S5L51Ex1.py
921
4.71875
5
""" In one of the previous exercises we created the following function that gets Celsius degrees as input and returns Fahrenheit, or a message if the Celsius input value is less than -273.15. def c_to_f(c): if c< -273.15: return "That temperature doesn't make sense!" else: f=...
true
83e0e6da343274fdc62fdfe1f2c6d56e46c09e9d
GT-rc/udemy-apps
/Section-6/S6L66Ex4.py
1,279
4.40625
4
""" Please take a look at the following code: temperatures=[10,-20,-289,100] def c_to_f(c): if c< -273.15: return "That temperature doesn't make sense!" else: f=c*9/5+32 return f for t in temperatures: print(c_to_f(t)) The code prints out the outp...
true
95845bd4d9d06aedbb036444a790321db23bde55
shubhrock777/Python-basic-code-
/Assignment module 5/py_module05.py
1,912
4.25
4
#############Q1 ## A)list1=[1,5.5,(10+20j),’data science’].. Print default functions and parameters exists in list1. list1=[1, 5.5, (10+20j), 'data science'] print(list1) len(list1) #length of list #Access values in the variable using index numbers print(list1[0]) #### B)How do we create a sequ...
true
91fd7464a4d0d97a4ad4d2fea73e95dc7a2b3b41
cgarcianeal/Owens-Attendance
/src/recording.py
1,773
4.25
4
import csv import sys import datetime from datetime import date more = 'y' # Settingfactor for while loop today = str(date.today()) year = datetime.date.today().year default_option = "current" prev_month = 0 prev_day = 0 file_name = "record_" + today + ".csv" #opening records csv file for writing record = open (file_...
true
1327f24d03c82c4624ce3d59d096afd9fe63e7fe
suchana172/My_python_beginner_level_all_code
/basic1/age_checker.py
250
4.125
4
your_age = input("How old are you?") your_friends_age = input("How old is your friend?") if int(your_age) >=18 or int(your_friends_age) >=18 : print("Congrats, one of you is old enough to vote!") else: print("One of you is too young to vote")
true
092f455f31e6a3ad58ad3fcf735fe93f000a67d1
krhckd93/Data-Structures
/stacks.py
1,854
4.1875
4
def display(s, top): if top == -1: print("Stack is empty!") else: while top != -1: print(s[top]) def push_item(s, top, max_size, value): if top != max_size: top += 1 s.append(value) print("Item added :", s[top]) return top else: print...
true
99d3a263f4286a26e06135d11d930b3f1071b26a
amidoge/Python-2
/ex080.py
1,923
4.21875
4
from random import randint #going to use 1 and 2 to represent heads or tails #for one round of coin flip #variables: flip_count = 0 total_flips = 0 consecutive_count = 0 #this is zero because we don't even have a flip yet. for i in range(10): #doing this 10 times #in the beginning of the line, we should have some...
true
a46c37d955945468272275e925aac5e8a7fb7fdf
amidoge/Python-2
/ex041.py
668
4.21875
4
#find out frequency from a note that the user inputs note = str(input('What note do you want to know the frequency of? ')) C4 = 261.63 D4 = 293.66 E4 = 329.63 F4 = 349.23 G4 = 392.00 A4 = 440.00 B4 = 493.88 if note == 'C4': print(C4) elif note == 'D4': print(D4) elif note == 'E4': print(E4) elif note == 'F4...
true
69579627325bee141245c3b323b5cc7ff71a2ecc
amidoge/Python-2
/ex079.py
1,229
4.25
4
from random import randint random_int = randint(1, 100) #need to get a number to store to maximum_int, so that we can compare it with the next 99 numbers maximum_int = random_int print(maximum_int) #must also print the maximum integer first otherwise I will only have 99 numbers and not 100 update_count = 0 for i in ran...
true
24bdd04f164c63779262bf95209bdfc825343c49
amidoge/Python-2
/ex096b.py
2,642
4.28125
4
#Check a password ''' Write a function that determines whether or not a password is good. We will define a good password to be a one that is at least 8 characters long and contains at least one uppercase letter, at least one lowercase letter, and at least one number. Your function should return true if the password ...
true
ce5b720b688c6c5dd06bf93195309fdaaa8e7e03
amidoge/Python-2
/ex032.py
509
4.3125
4
#read 3 different integers and list them from smallest to largest using the min() and max() functions num_1 = int(input('What is the first integer?')) num_2 = int(input('What is the second integer?')) num_3 = int(input('What is the third integer?')) highest = max(num_1, num_2, num_3) lowest = min(num_1, num_2, num_3) ...
true
01df20571644a961209dbe9966955401a876db09
SimonCWatts/MIT-6.00.1x
/MID TERM Problem 6x.py
762
4.15625
4
def laceStringsRecur(s1, s2): """ s1 and s2 are strings. Returns a new str with elements of s1 and s2 interlaced, beginning with s1. If strings are not of same length, then the extra elements should appear at the end. """ def helpLaceStrings(s1, s2, out): if s1 == '': ...
true
eda62614b41d7f54c66440c601e7d2021ffbaa0c
dansmyers/IntroToCS-2020
/Examples/2-Variables/magic_computer.py
754
4.34375
4
""" The Magic Computer: a Mad Lib CMS 195, Spring 2020 """ # Prompt the user to enter all of the required words noun1 = input('Enter a noun: ') plural_noun1 = input('Enter a plural noun: ') verb1 = input('Enter a present tense verb: ') verb2 = input('Enter a present tense verb: ') part_of_body = input('Ener a plural ...
true
7115080820e3091995c63dac919e5acd358ca45c
dansmyers/IntroToCS-2020
/Examples/3-Conditonals/pos_neg_or_zero.py
715
4.5
4
""" Test if a number is positive, negative, or zero CMS 195, Spring 2020 """ # Read the number number = int(input('Enter a number: ')) # This test block has three outcomes # # Use if-elif-else to test three or more outcomes # If the first test is True, the if block executes and all of the other cases are skipped # ...
true
93b4669fb03a0da0cfe047ec12e09c49621df58b
FrauBoes/aviation_routing
/flightplan.py
1,755
4.125
4
from itertools import permutations class Flightplan: """ Class to store flightplan objects. A Flightplan class defines a container object for a flightplan. Implements flightplan object as a queue using a list Provides methods to access the first and last item in the flightplan Store aircraft as d...
true
a5d68b227850fec5c3c7901791b24208b75d2bec
leiurus17/tp_python
/strings/python_max.py
241
4.4375
4
#The method max() returns the max alphabetical character from the string str. str = "This is really a string example....wow!!! z" print "Max character: " + max(str) str = "This is a string example." print "Max character: " + max(str)
true
7b13905fcc57e2863fcf5b7af5745db5b77b71cb
leiurus17/tp_python
/variables/python_tuple.py
414
4.3125
4
tuplez = ('abcd', 786, 2.23, 'john', 70.2) tinytuple = (123, 'daniel') print tuplez # Prints complete tuple print tuplez[0] # Prints first element of the tuple print tuplez[1:3] # Prints elements starting from 2nd till 3rd print tuplez[2:] # Prints elements starting from 3rd element print tin...
true