blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
3b3012a175b7e66ea1d9d57b493b6df098ae68f3 | peterhchen/runBookAuto | /code/example/01_Intro/03_UnitConv.py | 449 | 4.28125 | 4 | #!/usr/bin/python3
# Problem: Receive miles and convert to kilometers
# kilometers = miles * 1.6
# Enter Miles 10.
# 10 Miles euqls to 16 kilometer.
# ask the user to input miles and assign it to the mile variable.
mile = input ('Enter Mile: ')
# Convert the string to integer.
mile = int (mile)
# Perform multiplica... | true |
c208d5ee251a4de8b5d953ad057143ab9ef49bb2 | peterhchen/runBookAuto | /code/example/01_Intro/04_Calculator.py | 655 | 4.40625 | 4 | #!/usr/bin/python3
# Enter Calculator: 3 * 6
# 3 * 6 = 18
# Store the user input of 2 number and operator.
num1, oper , num2 = input ('Enter Calculator: ').split()
# Conver the strings into integers
num1 = int (num1)
num2 = int (num2)
# if + then need to provide the output based on addition
# Print the result.
if o... | true |
4a425f72e61d4dd08b5c413a2ecec116ec5c767e | jamariod/Day-5-Exercises | /WordSummary.py | 397 | 4.1875 | 4 | # Write a word_histogram program that asks the user for a sentence as its input, and prints a dictionary containing the tally of how many times each word in the alphabet was used in the text.
any_word = input(
"Enter any word to tally how many times each letter in the alphabet was used in the word: ")
word_split =... | true |
641aae71ec1efa9634631c16e6b8faa5f4742706 | boringPpl/Crash-Course-on-Python | /Exercises on IDE/7 String/ex7_2_string.py | 614 | 4.375 | 4 | '''Question 7.2:
Using the format method, fill in the gaps in the convert_distance function
so that it returns the phrase "X miles equals Y km", with Y having only 1 decimal place.
For example, convert_distance(12) should return "12 miles equals 19.2 km".
'''
def convert_distance(km):
miles = km * 0.621 # 1km is ... | true |
59155ff91c8651d8db1bd9273b46e12b9de074c1 | boringPpl/Crash-Course-on-Python | /Exercises on IDE/6 For Loops/ex6_2_for.py | 441 | 4.65625 | 5 | '''Question 6.2:
This function prints out a multiplication table
(where each number is the result of multiplying the first number
of its row by the number at the top of its column).
Fill in the blanks so that calling mul_table(1, 3) will print out:
1 2 3
2 4 6
3 6 9
'''
def mul_table(start, stop):
for x in ___:
... | true |
2f0d5f695e42fb4e7027352362c147ba68a491be | boringPpl/Crash-Course-on-Python | /Exercises on IDE/3 Function/ex3_2_function.py | 994 | 4.65625 | 5 | ''' Question 3.2:
This function converts kilometers (km) to miles.
1. Complete the function. Your function receive the input kilometers, and return the value miles
2. Call the function to convert the trip distance from kilometers to miles
3. Fill in the blank to print the result of the conversion
4. Calculate the round... | true |
3664bf0af663c33035ab8e699dd1f2d5f8af76cc | boringPpl/Crash-Course-on-Python | /Exercises on IDE/6 For Loops/ex6_3_for.py | 636 | 4.6875 | 5 | '''Question 6.3:
The display_even function returns a space-separated string
of all positive numbers that are divisible by 2, up to and
including the maximum number that's passed into the function.
For example, display_even(4) returns “2 4”. Fill in the blank to make this work.
'''
def display_even(max_num):
retur... | true |
2cf55be5afac37d8737a9e4254ffccb2394ce111 | nigelginau/practicals_cp1404 | /prac_03/password_entry.py | 872 | 4.3125 | 4 | """" Nigel Ginau """
""""write a program that asks the user for a password, with error-checking to repeat if the password doesn't meet a minimum length set by a variable.
The program should then print asterisks as long as the password.
Example: if the user enters "Pythonista" (10 characters), the program should print... | true |
e00334f1474a2caa644d4f60498ffc3497570701 | Arslan0510/learn-basic-python | /3strings.py | 574 | 4.40625 | 4 | language = 'Python'
# print(len(language))
# Access each individual letter
# letter = language[3]
# letter = language[0:3] # first to third letter
# letter = language[1:] # skip first letter and show all the remaining part
letter = language[-1] # get reverse of string
# String Methods
languageString... | true |
7866ce25883a04152b4587c683ff0be544a85ce5 | bigbillfighter/Python-Tutorial | /Part1/chap9_p2.py | 845 | 4.21875 | 4 | #the python library practise
from collections import OrderedDict
favourite_languages = OrderedDict()
favourite_languages['Lily'] = 'C'
favourite_languages['Max'] = 'Ruby'
favourite_languages['Lucas'] = 'Java'
favourite_languages['Peter'] = 'C'
for name, language in favourite_languages.items():
print(n... | true |
a2aaf99fcc1b5ce257d8506092ed273c1fd432a3 | amitsindoliya/datastructureandalgo | /selection_sort.py | 577 | 4.3125 | 4 | ## selection Sort ##
## In selection sort we find the minimum element or maximum element
# of the list and place it at the start
# continue this operation until we have an sorted array
# complexity O(N^2)/2
# unstable
def selection_sort(iterable):
for i in range(len(iterable)-1):
for j in range(i+1,len(... | true |
f65d0d677044624e03d82e2f43cb8c48a94f7226 | razmikmelikbekyan/ACA_2019_python_lectures | /homeworks/CapstoneProject/database/books.py | 1,422 | 4.28125 | 4 | from typing import Dict, List
BOOKS = "database/books.txt"
def create_books_data():
"""
Creates an empty txt file for storing books data. If the file already exists, it should
not do anything.
"""
pass
def get_all_books() -> List[Dict]:
"""Returns all books data in a list, where each item i... | true |
cc9f9dc9810af12141c6f005a9b951c25bffd1e0 | lowks/py-etlt | /etlt/cleaner/DateCleaner.py | 1,871 | 4.3125 | 4 | import re
class DateCleaner:
"""
Utility class for converting dates in miscellaneous formats to ISO-8601 (YYYY-MM-DD) format.
"""
# ------------------------------------------------------------------------------------------------------------------
@staticmethod
def clean(date):
"""
... | true |
5f59166ef3478ece7bb0bed7ea6e3fc02ef1ca44 | sb17027/ORS-PA-18-Homework07 | /task4.py | 1,336 | 4.34375 | 4 | """
=================== TASK 4 ====================
* Name: Number of Appearances
*
* Write a function that will return which element
* of integer list has the greatest number of
* appearances in that list.
* In case that multiple elements have the same
* number of appearances return any.
*
* Note: You are not allow... | true |
115490da841034c40a2c2c3029adede809f4c499 | mali0728/cs107_Max_Li | /pair_programming/PP9/fibo.py | 1,017 | 4.25 | 4 | """
PP9
Collaborators: Max Li, Tale Lokvenec
"""
class Fibonacci: # An iterable b/c it has __iter__
def __init__(self, val):
self.val = val
def __iter__(self):
return FibonacciIterator(self.val) # Returns an instance of the iterator
class FibonacciIterator: # has __next__ and __iter__
... | true |
6a98a213ff9063964adc7731056f08df3ac755ae | gatisnolv/planet-wars | /train-ml-bot.py | 2,062 | 4.25 | 4 | """
Train a machine learning model for the classifier bot. We create a player, and watch it play games against itself.
Every observed state is converted to a feature vector and labeled with the eventual outcome
(-1.0: player 2 won, 1.0: player 1 won)
This is part of the second worksheet.
"""
from api import State, uti... | true |
41895c829a967c20cb731734748fe7f407b364a3 | bats64mgutsi/MyPython | /Programs/graph.py | 2,244 | 4.28125 | 4 | # A program that draws the curve of the function given by the user.
# Batandwa Mgutsi
# 02/05/2020
import math
def getPointIndex(x, y, pointsPerWidth, pointsPerHeight):
"""Returns the index of the given point in a poinsPerWidth*pointsPerHeight grid.
pointsPerWidth and pointsPerHeight should be odd numbers... | true |
768ffb93219b9d95d73ec3075fbb191ed00837a6 | Tobi-David/first-repository | /miniproject.py | 625 | 4.15625 | 4 |
## welcome message
print("\t\t\tWelcome to mini proj! \nThis application helps you to find the number and percentage of a letter in a message.")
## User message input
user_message = input("This is my message ")
## user letter input
user_letter = input("this is my letter ")
## count letter in message
letter_fr... | true |
637267a96a001520af71a7c748f1a05109726f5e | Colosimorichard/Choose-your-own-adventure | /Textgame.py | 2,513 | 4.15625 | 4 | print("Welcome to my first game!")
name = input("What's your name? ")
print("Hello, ", name)
age = int(input("What is your age? "))
health = 10
if age >= 18:
print("You are old enough to play.")
wants_to_play = input("Do you want to play? (yes/no) ").lower()
if wants_to_play == "yes":
... | true |
d3f40012da083979a5c97407e2e2b6a43346ece0 | december-2018-python/adam_boyle | /01-python/02-python/01-required/07-functions_intermediate_2.py | 2,453 | 4.15625 | 4 | # 1. Given
x = [[5,2,3], [10,8,9]]
students = [
{'first_name' : 'Michael', 'last_name' : 'Jordan'},
{'first_name' : 'John', 'last_name' : 'Rosales'}
]
sports_directory = {
'basketball' : ['Kobe', 'Jordan', 'James', 'Curry'],
'soccer' : ['Messi', 'Ronaldo', 'Rooney']
}
z = [ {'x': 10, 'y': 20} ]
x[1][0... | true |
34533f19a443b7063a4637c798b97233006acc02 | Seon2020/data-structures-and-algorithms | /python/code_challenges/ll_zip/ll_zip.py | 698 | 4.375 | 4 | def zipLists(list1, list2):
"""
This function takes in two linked lists and merges them together.
Input: Two linked lists
Output: Merged linked list the alternates between values of the original two linked lists.
"""
list1_current = list1.head
list2_current = list2.head
while list1_current and list2... | true |
04f7f3d62fe77d102c4bf88ef08621bb6b0b1740 | Seon2020/data-structures-and-algorithms | /python/code_challenges/reverse_linked_list.py | 351 | 4.28125 | 4 | def reverse_list(ll):
"""Reverses a linked list
Args:
ll: linked list
Returns:
linked list in reversed form
"""
prev = None
current = ll.head
while current is not None:
next = current.next
current.next = prev
prev = current
current = next
l... | true |
d70c86867376ccb77491b6d1e20c3f1a0b98bfe2 | concon121/project-euler | /problem4/answer.py | 688 | 4.3125 | 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.
ZERO = 0
MIN = 100
MAX = 999
def isPalindrome(number):
reverse = str(number)[::-1]
if (str(numbe... | true |
7af9a74b13af5cc1c52a70970744b0a837bc52ca | cepGH1/dfesw3cep | /convTemps.py | 413 | 4.21875 | 4 | #°F = (°C × 9/5) + 32.
#C =(F -32)*(5/9)
myInput = input("please enter the temperature using either 'F' or 'C' at the end to show the scale: ")
theNumber = int(myInput[:-1])
theScale = myInput[-1]
print(theNumber)
print(theScale)
if theScale == "C":
fahrenheit = (theNumber*(9/5)) + 32
print(fahrenheit, "F")
if ... | true |
1cb7a726b1074a78252ba83a4b358821fd6f6385 | LeoBaz20/Netflix-Style-Recommender | /netflix-style-recommender-master/PythonNumpyWarmUp.py | 1,770 | 4.28125 | 4 |
# coding: utf-8
# In[25]:
# Handy for matrix manipulations, likE dot product and tranpose
from numpy import *
# In[26]:
# Declare and initialize a 2d numpy array (just call it a matrix, for simplicity)
# This how we will be organizing our data. very simple, and easy to manipulate.
data = array([[1, 2, 3], [1, 2... | true |
52b9c167b058db6092d8f6b5dc760a306cc9b608 | jdellithorpe/scripts | /percentify.py | 1,497 | 4.15625 | 4 | #!/usr/bin/env python
from __future__ import division, print_function
from sys import argv,exit
import re
def read_csv_into_list(filename, fs):
"""
Read a csv file of floats, concatenate them all into a flat list and return
them.
"""
numbers = []
for line in open(filename, 'r'):
parts ... | true |
a4bd50b4ac26814d745411ca815aa8115c058d0c | bettymakes/python_the_hard_way | /exercise_03/ex3.py | 2,343 | 4.5 | 4 | # Prints the string below to terminal
print "I will now count my chickens:"
# Prints the string "Hens" followed by the number 30
# 30 = (30/6) + 25
print "Hens", 25 + 30 / 6
# Prints the string "Roosters" followed by the number 97
# 97 = ((25*3) % 4) - 100
# NOTE % is the modulus operator. This returns the remainder ... | true |
77ff1d18e2d88269716f2eda2e09270d78d39840 | eckoblack/cti110 | /M5HW1_TestGrades_EkowYawson.py | 1,650 | 4.25 | 4 | # A program that displays five test scores
# 28 June 2017
# CTI-110 M5HW1 - Test Average and Grade
# Ekow Yawson
#
#greeting
print('This program will get five test scores, display the letter grade for each,\
\nand the average of all five scores. \n')
#get five test scores
score1 = float(input('Enter test s... | true |
40867a0b45d2f9f37f5d4bcfe0027bd954c82c36 | eckoblack/cti110 | /M6T1_FileDisplay_EkowYawson.py | 451 | 4.1875 | 4 | # A program that displays a series of integers in a text file
# 5 July 2017
# CTI-110 M6T1 - File Display
# Ekow Yawson
#
#open file numbers.txt
def main():
print('This program will open a file named "numbers.txt" and display its contents.')
print()
readFile = open('numbers.txt', 'r')
file... | true |
4fdb7741fa84ad336c029825adf0994f174aaa2b | ocean20/Python_Exercises | /functions/globalLocal.py | 602 | 4.28125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 23 16:41:56 2019
@author: cawang
"""
x = 2
def fun1():
x = 1
print("Inside function x =", x)
fun1() # Inside function x = 1
print("Outside function x =", x) # Outside function x = 2
def fun2():
print("Inside function x =", x)
fun2() ... | true |
128039caec432553bb36875e92b86d6578175728 | AndreasGustafsson88/assignment_1 | /assignments/utils/assignment_1.py | 1,179 | 4.46875 | 4 | from functools import lru_cache
"""
Functions for running the assignments
"""
def sum_list(numbers: list) -> int:
"""Sums a list of ints with pythons built in sum() function"""
return sum(numbers)
def convert_int(n: int) -> str:
"""Converts an int to a string"""
return str(n)
def recursive_sum(... | true |
fd50491b2f67bc3b76ff3b1b5391952b0bed92eb | JonSeijo/project-euler | /problems 1-9/problem_1.py | 825 | 4.34375 | 4 | #Problem 1
"""
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.
"""
MAXNUM = 1000
def findMultiples(number):
"""Return a list with the multiples of the number,
betw... | true |
ec2a73d8147e75ab14f1453c16295bb50e52a58e | JonSeijo/project-euler | /problems 50-59/problem_57.py | 1,689 | 4.125 | 4 | # -*- coding: utf-8 -*-
# Square root convergents
# Problem 57
"""
It is possible to show that the square root of two
can be expressed as an infinite continued fraction.
√ 2 = 1 + 1/(2 + 1/(2 + 1/(2 + ... ))) = 1.414213...
By expanding this for the first four iterations, we get:
1 + 1/2 = 3/2 = 1.5
1 + 1/(2 + 1/2)... | true |
a09e6de32320dca2795f35f7218ec5bd4d4f85bb | brennobrenno/udemy-python-masterclass | /Section 11/spam.py | 1,525 | 4.15625 | 4 |
def spam1():
def spam2():
def spam3():
z = " even"
z += y
print("In spam3, locals are {}".format(locals()))
return z
y = " more " + x # y must exist before spam3() is called
y += spam3() # do not combine these assignments
... | true |
1f6689ff4d8990151ca329843ec12486157182b3 | brennobrenno/udemy-python-masterclass | /Section 7 & 8/43.py | 863 | 4.21875 | 4 | # list_1 = []
# list_2 = list()
#
# print("List 1: {}".format(list_1))
# print("List 2: {}".format(list_2))
#
# if list_1 == list_2:
# print("The lists are equal")
#
# print(list("The lists are equal"))
# even = [2, 4, 6, 8]
# another_even = even
#
# another_even = list(even) # New list
# another_even2 = sorted(... | true |
7a4c6e46d471dee68f06f28956a964fd56559912 | wesbasinger/LPTHW | /ex22/interactive.py | 1,213 | 4.15625 | 4 | print "Let's just take a little quiz."
print "On this section, you were supposed to just review."
points = 0
def print_score():
print "So far you have %d points." % points
print_score()
print '''
Here's your first question. Which of the following
objects have we talked about so far?
a Strings
b Integers
b Functio... | true |
edaff19fc7b3ea2a8ab87e1ab10ad6c029009841 | wesbasinger/LPTHW | /ex06/practice.py | 739 | 4.34375 | 4 | # I'll focus mostly on string concatenation.
# Honestly, I've never used the varied types of
# string formatting, although I'm sure they're useful.
# Make the console print the first line of Row, Row, Row Your Boat
# Do not make any new strings, only use concatenation
first_part =
second_part =
# should print 'Ro... | true |
cf4a99e1a7c7562f04bb9d68cc91673f7d108309 | wesbasinger/LPTHW | /ex21/interactive.py | 1,924 | 4.28125 | 4 | from sys import exit
def multiply_by_two(number):
return number * 2
def subtract_by_10(number):
return number - 10
def compare_a_greater_than_b(first_num, second_num):
return first_num > second_num
print "So far, you've done only printing with function."
print "Actually, most of the time you will want your"
pri... | true |
50f7a379886e1b687eafe0ae37ff11c2461ec95b | wesbasinger/LPTHW | /ex40/interactive.py | 2,919 | 4.40625 | 4 | from sys import exit
print "This is point where things take a turn."
print "You can write some really great scripts and"
print "do awesome stuff, you've learned just about"
print "every major data type and most common pieces"
print "of syntax."
print "But, if you want to be a real programmer,"
print "and write applica... | true |
64bd98e9099267c2b5239a12c68a1c0108f4d92a | AmenehForouz/leetcode-1 | /python/problem-0832.py | 1,144 | 4.34375 | 4 | """
Problem 832 - Flipping an Image
Given a binary matrix A, we want to flip the image horizontally, then invert
it, and return the resulting image.
To flip an image horizontally means that each row of the image is reversed.
For example, flipping [1, 1, 0] horizontally results in [0, 1, 1].
To invert an image mea... | true |
9f489fa5b55db295368c9ea6ff621fe59f2e37e9 | AmenehForouz/leetcode-1 | /python/problem-0088.py | 625 | 4.15625 | 4 | """
Problem 88 - Merge Sorted Array
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1
as one sorted array.
"""
from typing import List
class Solution:
def merge(
self, nums1: List[int], m: int, nums2: List[int], n: int
) -> None:
"""
Do not return anything, mod... | true |
1d79a965da3406b42c492b8a9aa2bfd6ae4c1bba | nathanielam0ah/homework | /exercise009.py | 230 | 4.21875 | 4 | #!/usr/bin/env python
def maxList(Li):
currentMax = Li[0]
for index in Li:
if index > currentMax:
currentMax = index
return currentMax
myList = ['3', '4', '6', '3', '-100']
print(maxList(myList))
| true |
da6106e6aa5268cc241d03472d3ff572f0a63e58 | ucsd-cse-spis-2020/spis20-lab03-Sidharth-Theodore | /lab3Letters_pair.py | 596 | 4.5625 | 5 | #Sidharth and Theodore
#1.the "anonymous turtle" is the default turtle used if none are created in Code, or the first created if multiple are created
#2."turtle" refers to the turtle library while "Turtle()" refers to the turtle class
#3.myTurtle.sety(100)
import turtle
def drawT(theTurtle, size):
'''Takes a turtl... | true |
0c399de5188adb0418cef31a5896a2376afdf4bb | linzifan/python_courses | /misc-Stack.py | 1,487 | 4.40625 | 4 | """
Stack class
"""
class Stack:
"""
A simple implementation of a FILO stack.
"""
def __init__(self):
"""
Initialize the stack.
"""
self._items = []
def __len__(self):
"""
Return number of items in the stack.
"""
return len(self._it... | true |
2384c7c82af5eccdb070c7522a11895f2c3f4aa6 | ldocao/utelly-s2ds15 | /clustering/utils.py | 674 | 4.25 | 4 | ###PURPOSE : some general purposes function
import pdb
def becomes_list(a):
"""Return the input as a list if it is not yet"""
if isinstance(a,list):
return a
else:
return [a]
def add_to_list(list1, new_element):
"""Concatenate new_element to a list
Parameters:
----------
... | true |
e68f7daf7a588470c36b131e13606b458298906d | sunnyyants/crackingPython | /Recursion_and_DP/P9_5.py | 1,169 | 4.21875 | 4 | __author__ = 'SunnyYan'
# Write a method to compute all the permutation of a string
def permutation(string):
if string == None:
return None
permutations = []
if(len(string) == 0):
permutations.append("")
return permutations
firstcharacter = string[0]
remainder = string[1:... | true |
70269b4f1997e6509e7323da0d8a7592355e0ef5 | sunnyyants/crackingPython | /Trees_and_Graph/P4_4.py | 850 | 4.1875 | 4 | __author__ = 'SunnyYan'
# Given a binary tree, design an algorithm which creates a linked list
# of all the nodes at each depth(e.g., if you have a tree with depth D,
# you'll have D linked lists
from Tree import BinarySearchTree
from P4_3 import miniHeightBST
def createLevelLinkedList(root, lists, level):
if... | true |
2db3135898b0a57ef68bc4005a12874954b4809f | sunnyyants/crackingPython | /strings_and_array/P1_7.py | 893 | 4.40625 | 4 | __author__ = 'SunnyYan'
#
# Write an algorithm such that if an element in an M*N matrix is 0,
# set the entire row and column to 0
#
def setMatrixtoZero(matrix):
rowlen = len(matrix)
columnlen = len(matrix[0])
row = [0]*rowlen
column = [0]*columnlen
for i in range(0, rowlen):
for j in range... | true |
cf53a1b7300099ea8ecbe596ac2cb6574642e05f | sainath-murugan/small-python-projects-and-exercise | /stone, paper, scissor game.py | 1,231 | 4.21875 | 4 | from random import randint
choice = ["stone","paper","scissor"]
computer_selection = choice[randint(0,2)]
c = True
while c == True:
player = input("what is your choice stone,paper or scissor:")
if player == computer_selection:
print("tie")
elif player == ("stone"):
if computer_selection =... | true |
0bea4a359a651daeb78f174fe3fb539e118c39ad | asperaa/programming_problems | /linked_list/cll_create.py | 1,345 | 4.34375 | 4 | # class for Circular linked list node
class Node:
# function to initiate a new_node
def __init__(self, data):
self.data = data
self.next = None
# class for circular linked list
class CircularLinkedList:
# function to initialise the new_node
def __init__(self):
self.head = None... | true |
316c16a74400b553599f007f61997e65a5ed0069 | asperaa/programming_problems | /linked_list/rev_group_ll.py | 1,889 | 4.25 | 4 | """ Reverse a group of linked list """
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
# initialise the head of the linked list
def __init__(self):
self.head = None
# add a new node to the end of linked list
def add_node(self, ... | true |
f7fa6a108c3a05c476fa48b679ec81b9dab0edd7 | asperaa/programming_problems | /linked_list/rev_ll.py | 1,383 | 4.25 | 4 | # Node class
class Node:
def __init__(self, data):
self.data = data
self.next = None
# LinkedList class
class LinkedList:
def __init__(self):
self.head = None
def push(self, data):
new_node = Node(data)
new_node.next = self.head
self.head = new_no... | true |
956495f4026844ed336b34512c87aceec11c0ef8 | asperaa/programming_problems | /linked_list/reverse_first_k.py | 2,093 | 4.375 | 4 | """Reverse the first k elements of the linked list"""
# Node class for each node of the linked list
class Node:
# initialise the node with the data and next pointer
def __init__(self, data):
self.data = data
self.next = None
# Linked list class
class LinkedList:
# initialise the head of the... | true |
9bd1ec0e8941bae713a60098d73bc0d7f996bf9c | eldimko/coffee-machine | /stage3.py | 1,047 | 4.34375 | 4 | water_per_cup = 200
milk_per_cup = 50
beans_per_cup = 15
water_stock = int(input("Write how many ml of water the coffee machine has:"))
milk_stock = int(input("Write how many ml of milk the coffee machine has:"))
beans_stock = int(input("Write how many grams of coffee beans the coffee machine has:"))
cups = int(inpu... | true |
69a1845303537328dfd0db3c2379b2d094643633 | satya497/Python | /Python/storytelling.py | 1,340 | 4.15625 | 4 | storyFormat = """
Once upon a time, deep in an ancient jungle,
there lived a {animal}. This {animal}
liked to eat {food}, but the jungle had
very little {food} to offer. One day, an
explorer found the {animal} and discovered
it liked {food}. The explorer took the
{animal... | true |
0f4005420c98c407a9d02e6f601c2fccbf536114 | satya497/Python | /Python/classes and objects.py | 775 | 4.46875 | 4 | # this program about objects and classes
# a class is like a object constructor
#The __init__() function is called automatically every time the class is being used to create a new object.
class classroom:
def __init__(self, name, age): # methods
self.name=name
self.age=age
def myfunc1(s... | true |
5b7f40cc69402346f9a029c07246da2286022c7f | Vk686/week4 | /hello.py | 212 | 4.28125 | 4 | tempName = "Hello <<UserName>>, How are you?"
username = input("Enter User Name: ")
if len(username) < 5:
print("User Name must have 5 characters.")
else:
print(tempName.replace("<<UserName>>",username))
| true |
1596d1d1e7ef22f858dad005741768c7887a5a0e | wardragon2096/Week-2 | /Ch.3 Project1.1.py | 296 | 4.28125 | 4 | side1=input("Enter the first side of the triangle: ")
side2=input("Enter the second side of the triangle: ")
side3=input("Enter the thrid side of the triangle: ")
if side1==side2==side3:
print("This is an equilateral triangle.")
else:
print("This is not an equilateral triangle.")
| true |
63bcca7240f1f8464135732d795e80b3e95ddd1f | RichardLitt/euler | /007.py | 565 | 4.125 | 4 | # What is the 10001st prime?
# Import library to read from terminal
import sys
# Find if a number is prime
def is_prime(num):
if (num == 2):
return True
for x in range(2, num/2+1):
if (num % x == 0):
return False
else:
return True
# List all primes in order
def list_pri... | true |
2c91f734d48c6d0ab620b6b5a9715dc4f5e4ddb7 | smoke-hux/pyhton-codes | /2Dlistmatrixes.py | 1,044 | 4.46875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 28 05:54:12 2020
@author: root
"""
matrix = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
print(matrix[1])
matrix[0][1] = 20
print(matrix[0][1])
#we can use nested loops to iterate over every item in the list... | true |
7f44a3ce1ebc5dc682fb9a71a62413640101ed46 | mdev-qn95/python-code40 | /challenge-counter-app.py | 642 | 4.15625 | 4 | # Basic Data Types Challenge 1: Letter Counter App
print("Welcome to the Letter Counter App")
# Get user input
name = input("\nWhat's your name: ").title().strip()
print("Hello, " + name + "!")
print("I'll count the number of times that a specific letter occurs in a message.")
message = input("\nPlease enter a messa... | true |
e5162cfd848d2079cd0a2783413cdce62c365e39 | rajkamalthanikachalam/PythonLearningMaterial | /com/dev/pythonSessions/07Functions.py | 2,940 | 4.5625 | 5 | # Function: a piece of code to execute a repeated functions
# Recursion: A function calling itself
# Arguments : *arg is used to pass a single arguments
# Key words : **args is used to pass a multiple arguments in key & value format
# Lambda functions : Anonymous functions or function without name
# Function
def fun... | true |
3c83bcb69b992b68845482fbe0cf930bb0faaf22 | Japan199/PYTHON-PRACTICAL | /practical2_1.py | 257 | 4.21875 | 4 | number=int(input("enter the number:"))
if(number%2==0):
if(number%4==0):
print("number is a multiple of 2 and 4")
else:
print("number is multiple of only 2")
else:
print("number is odd")
| true |
98d91f20f106a8787e87e6e18bfb0388bb96a24e | Douglass-Jeffrey/Assignment-0-2B-Python | /Triangle_calculator.py | 499 | 4.25 | 4 | #!/usr/bin/env python3
# Created by: Douglass Jeffrey
# Created on: Oct 2019
# This program calculates area of triangles
def main():
# this function calculates the area of the triangles
# input
num1 = int(input("Input the base length of the triangle: "))
num2 = int(input("Input the height of the tri... | true |
73b8058f76913080f172dd81ab7b76b1889faa11 | ibrahimuslu/udacity-p2 | /problem_2.py | 2,115 | 4.15625 | 4 | import math
def rotated_array_search(input_list, number):
"""
Find the index by searching in a rotated sorted array
Args:
input_list(array), number(int): Input array to search and the target
Returns:
int: Index or -1
"""
def findPivot(input_list,start,end):
if start == end... | true |
b2b27d69caeab17bc3150e1afe9c1e1de3ac5d9e | aniketchanana/python-exercise-files | /programmes/listMethods.py | 922 | 4.46875 | 4 | # methods are particular to a given class
# append insert & extend
first_list = [1,2,3,4,5]
# first_list.append([1,2,3])
# print(first_list)
# [1, 2, 3, 4, 5, [1, 2, 3]] simply pushes it inside the list
# no matter what is that <<append takes in only one arguement>>
# first_list.extend([1,2,3,4])
# print(first_l... | true |
5fbbfd843c662a09a20b1e5bad1861a2a82f53fa | aniketchanana/python-exercise-files | /programmes/bouncer.py | 270 | 4.125 | 4 | age = input("How old are you")
if age :
age = int(age)
if age >= 18 and age < 21 :
print("Need a wrist band")
elif age>=21 :
print("you can enter and drink")
else :
print("too little to enter")
else :
print("Input is empty")
| true |
3b582f75705736982841af1acc369baa26287f05 | ethomas1541/Treehouse-Python-Techdegree-Project-1 | /guessing_game.py | 2,919 | 4.15625 | 4 | """
Treehouse Python Techdegree
Project 1 - Number Guessing Game
Elijah Thomas
/2020
"""
"""
Tried to make my code a bit fancy. I have a bit of knowledge beyond what's been taught to me thus
far in the techdegree, and I plan to use it to streamline the program as much as I can.
"""
#Also, fair warning, I ... | true |
7e8e5cd20755bc9967dc6800b3614fdc9c8cc8d3 | Sheax045/SWDV660 | /Week1/week-1-review-Sheax045/temp_converter.py | 371 | 4.375 | 4 | # Please modify the following program to now convert from input Fahrenheit
# to Celsius
def doConversion():
tempInFAsString = input('Enter the temperature in Fahrenheit: ')
tempInF = float( tempInFAsString )
tempInC = ( tempInF - 32 ) / 1.8
print('The temperature in Celsius is', tempInC, 'degrees')
fo... | true |
f1c33d5a000f7f70691e10da2bad54de62fc9a8d | sugia/leetcode | /Integer Break.py | 648 | 4.125 | 4 | '''
Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.
Example 1:
Input: 2
Output: 1
Explanation: 2 = 1 + 1, 1 × 1 = 1.
Example 2:
Input: 10
Output: 36
Explanation: 10 = 3 + 3 + 4, 3 × 3 × 4 = 36.
Not... | true |
a3fc906021f03ed53ad43fbc133d253f74e56daa | sugia/leetcode | /Valid Palindrome.py | 697 | 4.15625 | 4 | '''
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
Note: For the purpose of this problem, we define empty string as valid palindrome.
Example 1:
Input: "A man, a plan, a canal: Panama"
Output: true
Example 2:
Input: "race a car"
Output: false
'''
class... | true |
396253f9798266c4b6b291f272aa7b79c6fa0a0a | sugia/leetcode | /Power of Two.py | 498 | 4.125 | 4 | '''
Given an integer, write a function to determine if it is a power of two.
Example 1:
Input: 1
Output: true
Example 2:
Input: 16
Output: true
Example 3:
Input: 218
Output: false
'''
class Solution(object):
def isPowerOfTwo(self, n):
"""
:type n: int
:rtype: bool
"""
... | true |
1c59ace51e212ef319a09a5703d88b878ca494e8 | sugia/leetcode | /Group Shifted Strings.py | 1,102 | 4.15625 | 4 | '''
Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the sequence:
"abc" -> "bcd" -> ... -> "xyz"
Given a list of strings which contains only lowercase alphabets, group all strings that belong to the same shifting sequence.
Exa... | true |
cd46ca9292716451523c2fb59813627274928af3 | sugia/leetcode | /Strobogrammatic Number II.py | 1,197 | 4.15625 | 4 | '''
A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).
Find all strobogrammatic numbers that are of length = n.
Example:
Input: n = 2
Output: ["11","69","88","96"]
'''
class Solution(object):
def findStrobogrammatic(self, n):
"""
:type n... | true |
e0e326f07a8f166d9e424ddd646e563b5e817da9 | sugia/leetcode | /Solve the Equation.py | 2,867 | 4.3125 | 4 | '''
Solve a given equation and return the value of x in the form of string "x=#value". The equation contains only '+', '-' operation, the variable x and its coefficient.
If there is no solution for the equation, return "No solution".
If there are infinite solutions for the equation, return "Infinite solutions".
If t... | true |
8c3ae2289cd214e6288ede5de4a2e296f5d3983b | sugia/leetcode | /Largest Triangle Area.py | 1,047 | 4.15625 | 4 | '''
You have a list of points in the plane. Return the area of the largest triangle that can be formed by any 3 of the points.
Example:
Input: points = [[0,0],[0,1],[1,0],[0,2],[2,0]]
Output: 2
Explanation:
The five points are show in the figure below. The red triangle is the largest.
Notes:
3 <= points.length <=... | true |
55926ff3a2bebfaad166335cff41c9edc9aba9a6 | joseph-palermo/ICS3U-Assignment-02B-Python | /assignment_two.py | 527 | 4.34375 | 4 | #!/usr/bin/env python3
# Created by: Joseph Palermo
# Created on: October 2019
# This program calculates the area of a sector of a circle
import math
def main():
# This function calculates the area of a sector of a circle
# input
radius = int(input("Enter the radius: "))
angle_θ = int(input("Enter ... | true |
89a55032338f6872b581bbabdfa13670f9520666 | Derin-Wilson/Numerical-Methods | /bisection_.py | 998 | 4.375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 4 19:12:56 2020
@author: esha
"""
# Python program for implementation
# of Bisection Method for
# solving equations
# An example function whose
# solution is determined using
# Bisection Method.
# The function is x^3 - x^2 + 2
def f... | true |
b04dee090d6f39bb7ad5a6f31f8a1ad99ada9234 | clhking/lpthw | /ex4.py | 1,277 | 4.28125 | 4 | # Set a variable for the number of cars
cars = 100
# Set a variable (using a float) for space in each car
space_in_a_car = 4
# Set a variable with number of drivers
drivers = 30
# Set a variable with number of passengers
passengers = 90
# Set up the variable for cars not driven being # of cars minus number of drivers
c... | true |
e82a0d351645c38a97eb004714aae9ab377e13f4 | vaelentine/CoolClubProjects | /mags/codewars/get_middle_char.py | 1,231 | 4.3125 | 4 | """
Get the middle character
From codewars
https://www.codewars.com/kata/56747fd5cb988479af000028/train/python
You are going to be given a word. Your job is to return the middle character of the word.
If the word's length is odd, return the middle character.
If the word's length is even, return the middle 2 cha... | true |
51b06ab89a0b7a96d973ad14a2a75703697e5d2c | JMBarberio/Penn-Labs-Server-Challenge | /user.py | 2,532 | 4.15625 | 4 | class User():
"""
The user class that contains user information.
Attributes:
-----------
name : str
The name of the user.
clubs : list
The list of the clubs that the user is in
fav_list : list
The bool list of whether or not a club has been favorite... | true |
817d35dd6ee95282807850ca348a78528516beed | jhill57/Module-4-Lab-Activity- | /grading corrected.py | 1,553 | 4.4375 | 4 | # Calculating Grades (ok, let me think about this one)
# Write a program that will average 3 numeric exam grades, return an average test score, a corresponding letter grade, and a message stating whether the student is passing.
# Average Grade
# 90+ A
# 80-89 B
# 70-79 C
# 60-69 D
# 0-59 F
# Exams: 89, 90, 90
# Aver... | true |
1b48abeed7454fea2a67ed5afc2755932e093d32 | CTEC-121-Spring-2020/mod-6-programming-assignment-tylerjjohnson64 | /Prob-3/Prob-3.py | 521 | 4.125 | 4 | # Module 7
# Programming Assignment 10
# Prob-3.py
# <Tyler Johnson>
def main():
number = -1
while number <0.0:
x = float(input("Enter a positive number to begin program: "))
if x >= 0.0:
break
sum = 0.0
while True:
x = float(input("Enter a pos... | true |
c9804338656ff356407de642e3241b44cc91d085 | leon0241/adv-higher-python | /Term 1/Book-1_task-6-1_2.py | 659 | 4.28125 | 4 | #What would be the linked list for..
#'brown', 'dog.', 'fox', 'jumps', 'lazy', 'over', 'quick', 'red', 'The', 'the'
#... to create the sentence...
#'The quick brown fox jumps over the lazy dog'
linkedList = [
["brown", 2], #0
["dog.", -1], #1
["fox", 3], #2
["jumps", 5], #3
["lazy", 7], #4
["ov... | true |
b56a066a3e11ed1e8e3de30a9ed73c35975e8c2e | leon0241/adv-higher-python | /Pre-Summer/nat 5 tasks/task 6/task_6a.py | 218 | 4.1875 | 4 | name = input("what's your name? ")
age = int(input("what's your age? "))
if age >= 4 and age <= 11:
print("you should be in primary school")
elif age >= 12 and age <= 17:
print("you should be in high school")
| true |
67ef1b27449b3dd39629b8cc675e519ac462663e | RitaJain/Python-Programs | /greater2.py | 226 | 4.25 | 4 | # find greatest of two numbers using if else statment
a=int(input("enter a ?"))
b=int(input("enter b ?"))
if (a>b):
print("a is greater than b", a)
else:
print("b is greater than a",b)
| true |
1c1b6f7379b46515bab0e2bcddf0ed78bf527cc4 | vipulm124/Python-Basics | /LearningPython/LearningPython/StringLists.py | 355 | 4.40625 | 4 | string = input("Enter a string ")
#Method 1
reverse = ''
for i in range(len(string)):
reverse += string[len(string)-1-i]
if reverse==string:
print("String is a pallindrome. ")
else:
print("Not a pallindrome. ")
#Method 2
rvs = string[::-1]
if rvs == string:
print("String is a pallindrome. ")
else... | true |
5c40d587eb5bea2adab8c6a6ae27c461ec45ed74 | bhattaraiprabhat/Core_CS_Concepts_Using_Python | /hash_maps/day_to_daynum_hash_map.py | 995 | 4.40625 | 4 | """
Built in python dictionary is used for hash_map problems
"""
def map_day_to_daynum():
"""
In this problem each day is mapped with a day number.
Sunday is considered as a first day.
"""
day_dayNum = {"Sunday":1, "Monday":2, "Tuesday":3, "Wednesday":4,
"Thursday":5, "Friday":... | true |
1e6eb33a7057383f2ae698c219830b5408ba7ab5 | lilamcodes/creditcardvalidator | /ClassMaterials/parking lot/review.py | 1,563 | 4.34375 | 4 | # 1. Dictionary has copy(). What is it?
# DEEP
dict1 = {"apple": 4}
dict2 = dict1.copy()
dict1["apple"] = 3
# print("dict1", dict1)
# print("dict2", dict2)
# SHALLOW
dict1 = {"apple": [1,2,3]}
dict2 = dict1.copy()
copy = dict1
dict1["apple"].append(5)
# print("dict1", dict1)
# print("dict2", dict2)
# print("... | true |
f9ca56364b52e6da5cb52c00396872294c04e5eb | lilamcodes/creditcardvalidator | /ClassMaterials/day7/beginner_exercises.py | 1,701 | 4.59375 | 5 | # Beginner Exercises
# ### 1. Create these classes with the following attributes
# #### Dog
# - Two attributes:
# - name
# - age
# #### Person
# - Three Attributes:
# - name
# - age
# - birthday (as a datetime object)
# ### 2. For the Dog object, create a method that prints to the terminal the name... | true |
1b82d057d603672ef90d083bbc59dd34de075736 | saurabh-ironman/Python | /sorting/QuickSort/quicksort.py | 1,419 | 4.15625 | 4 | def partition(array, low, high): #[3, 2, 1] # [1, 2, 3]
# choose the rightmost element as pivot
pivot = array[high]
# pointer for greater element
i = low - 1
# traverse through all elements
# compare each element with pivot
for j in range(low, high):
if array[j] <= pivot:
... | true |
ffc17a58e989094e5a31092826b501a6b22f2652 | JayWelborn/HackerRank-problems | /python/30_days_code/day24.py | 417 | 4.125 | 4 | def is_prime(x):
if x <=1:
return False
elif x <= 3:
return True
elif x%2==0 or x%3==0:
return False
for i in range(5, round(x**(1/2)) + 1):
if x%i==0:
return False
return True
cases = int(input())
for _ in range(cases):
case ... | true |
27a8884bada5af0cb7fea5b1fcc5d6e255188150 | jeetkhetan24/rep | /Assessment/q11.py | 755 | 4.28125 | 4 | """
Write a Python program to find whether it contains an additive sequence or not.
The additive sequence is a sequence of numbers where the sum of the first two numbers is equal to the third one.
Sample additive sequence: 6, 6, 12, 18, 30
In the above sequence 6 + 6 =12, 6 + 12 = 18, 12 + 18 = 30....
Also, you can spl... | true |
6febde39059c62422f858e99718fa7471c7aa50b | Aternands/dev-challenge | /chapter2_exercises.py | 1,538 | 4.25 | 4 | # Exercises for chapter 2:
# Name: Steve Gallagher
# EXERCISE 2.1
# Python reads numbers whose first digit is 0 as base 8 numbers (with integers 0-7 allowed),
# and then displays their base 10 equivalents.
# EXERCISE 2.2
# 5---------------> displays the number 5
# x = 5-----------> assigns the value "5" t... | true |
6362fb8b4b02d0ad66a13f68f59b233cdde2038b | jgarcia524/is210_lesson_06 | /task_01.py | 847 | 4.5625 | 5 | #!usr/bin/env python
# -*- coding: utf-8 -*-
"""Listing even and odd numbers"""
import data
from data import TASK_O1
def evens_and_odds(numbers, show_even=True):
"""Creates a list of even numbers and a list of odd numbers.
Args:
numbers (list): list of numbers
show_even (bool): de... | true |
d2e2b75a85e09aab40dca105c1cf1cabe404ea07 | ScottPartacz/Python-projects | /Pick_3_Lotto.py | 2,334 | 4.1875 | 4 | # Scott Partacz 1/25/2018 ITMD 413 Lab 3
import time
import random
def check (picked,wining_numbers) :
if(wining_numbers == picked) :
win_or_lose = True
elif(wining_numbers != picked) :
win_or_lose = False
return win_or_lose;
def fireball_check(fireball,picked,wining_numbers) :
count =... | true |
92cd0001b602a0cdea7e03d6170ba6bd500aca0f | bauglir-dev/dojo-cpp | /behrouz/ch01/pr_13.py | 227 | 4.46875 | 4 | # Algorithm that converts a temperature value in Farenheit to a value in Celsius
farenheit = float(input("Enter a temperature value in Farenheit: "))
celsius = (farenheit - 32) * (100/180)
print(str(celsius) + ' Celsius.'))
| true |
d5dde1216cb6e77f8b92a47de57268447c4189c3 | V4p1d/Assignment-1 | /Exercise_4.py | 406 | 4.40625 | 4 | # Write a program that receives three inputs from the terminal (using input()).
# These inputs needs to be integers. The program will print on the screen the sum of these three inputs.
# However, if two of the three inputs are equal, the program will print the product of these three inputs.
# Example 1: n = 1, m = 2, l... | true |
2af76dc77f4cebd7d13f517141f6ef633c073700 | prakhar-nitian/HackerRank----Python---Prakhar | /Sets/Set_.intersection()_Operation.py | 2,053 | 4.3125 | 4 | # Set .intersection() Operation
# .intersection()
# The .intersection() operator returns the intersection of a set and the set of elements in an iterable.
# Sometimes, the & operator is used in place of the .intersection() operator, but it only operates on the set of elements in set.
# The set is immutable to the .int... | true |
843ddcb5a7fd997179c284d6c18074282a70ab0a | KULDEEPMALIKM41/Practices | /Python/Python Basics/67.bug.py | 295 | 4.5625 | 5 | print('before loop')
for i in range(10,0,-1): # -1 is write perameter for reverse loop.
print(i)
print('after loop')
print('before loop')
for i in range(10,0): # if we are not give iteration in range function. it is by default work
print(i) # on positive direction.
print('after loop') | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.