blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
22c635a85256152016cf90c55d2a68fb33335f24 | s-andromeda/Two-Pointers-2 | /Problem2.py | 1,120 | 4.15625 | 4 | from typing import List
"""
Student : Shahreen Shahjahan Psyche
Time Complexity : O(N)
Space Complexity : O(1)
"""
class Solution:
def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None:
"""
Do not return anything, modify nums1 in-place instead.
... | true |
0a7879e26edb46c5b55cdb9322997c8ffea49274 | rohitharyani/LearningPython | /functionAndMethodsHw.py | 1,927 | 4.28125 | 4 | import math
def volume(radius):
'''
Calculate volume of a sphere based on the formula
'''
return (4.0*math.pi*(radius**3))/3
print("Volume of sphere is: ",volume(3))
#-----------------------------------
def valueInRange(num,low,high):
'''
Check for a given value in a defined range
'''
return "Value in ran... | true |
63bc550f76e9a09cfdc638aa4969469f8068fe32 | cornel-kim/MIT_Class_October | /lesson3a.py | 820 | 4.1875 | 4 | #we have covered, variables, data types and operators.
#implement python logics. if else statements. conditinal statements
#mpesa buy airtime- account you are buying for, account balance,
# pin, okoa jahazi arrears.
# Account = input("Please input the account number:")
# Amount = input("Please input the amount or airti... | true |
11d674f105b3d7851c61a501c946be7202432ed4 | gabrielbolivar86/simple_python_scripts | /tire_volume.py | 1,815 | 4.5625 | 5 | #calculate the volume of a tire and storage it on TXT document
#Libraries
import math
from datetime import date
#1st get the data necesary to calculate the tire volume
# tire_width = float(input("Enter the width of the tire in mm (ex 205): "))
# tire_aspect = float(input("Enter the aspect ratio of the tire (ex 60): "))... | true |
894ea0771249c060f9bbd1f623d2a07b5a8c2bf2 | hubbm-bbm101/lab5-exercise-solution-b2210356108 | /Exercises/Exercise1.py | 428 | 4.15625 | 4 | number = int(input("Enter the number:"))
if number % 2 == 0:
oddnumber = number - 1
formulanumber = (oddnumber+1)/2
else:
formulanumber = (number+1)/2
sumodd = formulanumber**2
print("Sum of odd numbers:", str(sumodd))
evennumbers = range(2,number,2)
sumeven = 0
a = 0
for i in evennumbers:
... | true |
08956994c6649c0e52b64fc54fd751d59ae8ce52 | zephyr-c/oo-tic-tac-toe | /components.py | 2,326 | 4.125 | 4 | class Player():
"""A player of the tic-tac-toe game"""
def __init__(self, name, game_piece):
self.name = name
self.game_piece = game_piece
class Move():
"""A single move in the tic-tac-toe game"""
def __init__(self, author, position):
self.author = author
self.position... | true |
d0e98e7202d56fbefd7264203a5d5851a425fbaa | michellejanosi/100-days-of-code | /projects/area_calc.py | 621 | 4.3125 | 4 | # You are painting a wall. The instructions on the paint can says that 1 can of paint can cover 6 square meters of wall. Given a random height and width of wall, calculate how many cans of paint you'll need to buy.
# number of cans = (wall height ✖️ wall width) ÷ coverage per can.
import math
height = int(input("Hei... | true |
5a54831a9faa524123b5c4cc35c95b022ad8ab4b | michellejanosi/100-days-of-code | /algorithms/leap_year.py | 961 | 4.3125 | 4 | # A program that works out whether if a given year is a leap year. A normal year has 365 days, leap years have 366, with an extra day in February.
# A leap year is on every year that is evenly divisible by 4 **except** every year that is evenly divisible by 100 **unless** the year is also evenly divisible by 400
def ... | true |
50b6ab8a005c611d38156b585713391f42faa973 | Eylon-42/classic-sudoku-py | /backtrack.py | 2,746 | 4.125 | 4 | import random
def validate_sudoku(board, c=0):
m = 3
c = 0
validate = False
# check all 81 numbers
while c < 81:
i, j = divmod(c, 9) # the current cell coordinate
i0, j0 = i - i % m, j - j % m # the start position of the 3 x 3 block
current_number = board[i][j... | true |
3789a408088b094e66aa0c7591ff3c93cd1515ca | trini7y/conjecture-proofs | /collatz_conjecture/collatz_sequence.py | 480 | 4.3125 | 4 | print( '''A program to see if the collatz
conjecture is true \n''')
print ("======****=================*****======= \n")
number = int(input('Input any number: '))
def collazt(number):
while number > 0:
if number % 2 == 0:
number = number // 2
elif number % 2 == 1:
number = (3 * number) + ... | true |
9329edbb60144923e0ec8aad296650d2edacee38 | ThomasMcDaniel91/cs-sprint-challenge-hash-tables | /hashtables/ex3/ex3.py | 1,242 | 4.1875 | 4 | def intersection(arrays):
"""
YOUR CODE HERE
"""
# Your code here
# create empty dict
nums_dict = {}
# create empty list
result = []
# going through the first list in our list of lists
for num in arrays[0]:
# appending the values from the first list into our
# di... | true |
97ba0c6f0767147bca3924d5c37ac2516ea4150f | chinnagit/python | /sample.py | 610 | 4.125 | 4 | # name = raw_input('what is your name? ')
# color = raw_input('what is your favorite color ')
#
# print('Hi '+name + ' likes ' + color)
# weight = raw_input('what is your weight in pound? ')
# weight_in_kgs = float(weight)/2.25
# print('{name} weight is ' + str(weight_in_kgs))
#
# name = 'jayanth'
#
# print(name[-3:])... | true |
64257fa443d9b6aa8c7cb8553087adc29454e048 | julianruben/mycode | /dict01/dictChallenge.py | 1,199 | 4.28125 | 4 | #!/usr/bin/env python3
heroes= {
"wolverine":
{"real name": "James Howlett",
"powers": "regeneration",
"archenemy": "Sabertooth",},
"harry potter":
{"real name": "Harry Potter",
"powers": "magic",
"... | true |
b378875888e67a74f00b0e375b97d43e4e684b45 | Montenierij/Algorithms | /Bipartite.py | 1,731 | 4.15625 | 4 | ######################################################
# Jacob Montenieri
# Introduction To Algorithms
# Lab 9
# This lab goes over if a graph is bipartite or not.
# This is determined by seeing if vertices can be
# colored blue and red without having adjacent
# matching colors.
################################... | true |
eabb5ea3d79d26d0275b2a95e7136d842152c88b | elainew96/coding_exercises | /project_python/ch_01/hello.py | 840 | 4.53125 | 5 | '''
Exercise: hello, hello!
Objective: Write and call your own functions to learn how the program counter steps through code.
You will write a program that introduces you and prints your favorite number.
Write the body of the function print_favorite_number
Write a function call at the end of the program that c... | true |
40d31dc0ae389a1ee4b2a90df9d7d7ba766ec62d | MadhuriSarode/Python | /ICP1/Source Code/stringReverse.py | 712 | 4.15625 | 4 |
# Get the input from user as a list of characters with spaces as separators
input_List_of_characters = input("Enter a list elements separated by space ")
print("\n")
# Split the user list
userList = input_List_of_characters.split()
print("user list is ", userList)
# Character list to string conversion
inputString = ... | true |
7164e6216b0549046af29246d672d5e5a8df21f4 | UMDHackers/projects_langs | /factorial.py | 242 | 4.125 | 4 | #factorial
def factorial(number):
if number == 0:
return 0
if number == 1:
return 1
return number * factorial(number-1)
#main
number = input("Enter a number: ")
print("number: "+ str(number) + " factorial "+ str(factorial(number))) | true |
325b1be9213bccac043365fdea0e961fef784612 | tanvipenumudy/Competitive-Programming-Solutions | /HackerRank/Problem-Solving/equalize_the_array.py | 2,087 | 4.34375 | 4 | # Karl has an array of integers. He wants to reduce the array until all remaining elements are equal.
# Determine the minimum number of elements to delete to reach his goal.
# For example, if his array is arr = [1,2,2,3], we see that he can delete the 2 elements 1 and 3 leaving arr = [2,2].
# He could also delete bo... | true |
d8bee4e1fa1b74568c8f4f30dbb9841b699edbf4 | tanvipenumudy/Competitive-Programming-Solutions | /HackerRank/Python/python-evaluation.py | 512 | 4.4375 | 4 | # It helps in evaluating an expression.
# The expression can be a Python statement, or a code object. --->
# >>> eval("9 + 5")
# 14
# >>> x = 2
# >>> eval("x + 3")
# 5
# eval() can also be used to work with Python keywords or defined
# functions and variables. These would normally be stored as strings. -->
# >>> ... | true |
4d5d9e634d8c48382f373555a27501f490a5d941 | irisnunezlpsr/class-samples | /assignmentTester.py | 277 | 4.3125 | 4 | # creates a variable called word and sets it equal to "bird"
word = "bird"
# sets word equal to itself concatenated with itself
word = word + word
# word is now equal it itself concatenated with itself times 2
word = word + word
# should print birdbirdbirdbird
print(word)
| true |
fa981020f339414abf2c9bc1347be190638b1488 | pradeep14316/Python_Repo | /Python_exercise/ex13.py | 393 | 4.28125 | 4 | #Ask the user for a number and determine whether the number is prime or not.
def get_number():
num = int(input("Enter a number:\n"))
return num
def prime_check():
'check whether number is a prime or not'
num = get_number()
if (num % 2 != 0) and (num / num == 1):
print(num,"is a prime numbe... | true |
f93238b907911d6b990c1f03cc0050bf54c65d24 | trevllew751/python3course | /bouncer.py | 301 | 4.125 | 4 | age = input("How old are you?\n")
if age:
age = int(age)
if age >= 21:
print("You can enter and you can drink")
elif age >= 18:
print("You can enter but you need a wristband")
else:
print("You cannot come in little one")
else:
print("Please enter an age")
| true |
bc40b023ec89a51b34fcb77aa27f7d80ea8c57cf | iscoct-universidad/dai | /practica1/simples/exercise2/bubble.py | 486 | 4.46875 | 4 | import numpy as np
def bubbleSorting(array):
length = len(array)
for i in range(0, length - 1):
for j in range(i, length):
if array[i] > array[j]:
temp = array[i]
array[i] = array[j]
array[j] = temp
desiredLength = int(input("Int... | true |
5d33c4b42e2198cac51d4f22db6776218aa1a68e | CatarinaBrendel/Lernen | /curso_em_video/Module 2/exer053.py | 332 | 4.125 | 4 | print "Enter a Phrase and I'll tell you if it is a Palindrome or not"
sentence = str(raw_input("Your phrase here: > ")).strip().lower().replace(' ', '')
pal = ""
for i in sentence:
pal = i + pal
if pal == sentence:
print "'{}' is a palindrome!".format(sentence)
else:
print "'{}' is NOT a palindrome!".format... | true |
8ada8c672d4e4e5fc5d99621003aaefee3719531 | SMGuellord/PythonTut | /moreOnFunctions.py | 1,063 | 4.15625 | 4 | #argument with a default value.
def get_gender(sex='unknown'):
if sex is 'm':
sex = "Male"
elif sex is 'f':
sex = "Female"
print(sex)
#using keyword argument
def dumb_sentence(name='Bucky', action='ate', item='tuna'):
print(name, action, item)
#undefined number of arguments
def add_n... | true |
a5b66740552298a3373bfb4cd1068337577e47fd | GinaFabienne/python-dev | /Day2/mathOperators.py | 377 | 4.1875 | 4 | 3 + 5
4 - 2
3 * 2
8 / 2
#when you are dividing you almost always end up with a float
print(8 / 4)
print(type(8 / 4))
#powers
print(2 ** 2)
#PEMDAS (from left to right)
#Order of operations in python
#()
#**
#* /
#+-
#multiplication and division are priotitised the same but the one on left will happen first when they... | true |
45664a37ca38d8c7ea8af599be1958f48fd697b4 | bnoel2777/CSSI19 | /Day10/review.py | 458 | 4.125 | 4 | def Greater(x,y):
if x>=y:
return x
else:
return y
x = float(raw_input("Enter your first number"))
y = float(raw_input("Enter your second number"))
print Greater(x,y):
def Concatnation():
x = raw_input("Enter a string")
return x + x :
print Concatnation():
def Add(x,y,z):
x = (raw_input("Enter your fi... | true |
1c05ba0af10868c703e8e69eb2a9a66b37417792 | l1onh3art88/bikingIndustry | /bicycles.py | 1,393 | 4.4375 | 4 | #Classes mirror the bike industry. There are 3 classes: Bicycle, Bike Shops,
#and Customers
class Bicycle(object):
def __init__(self, model, weight, cost):
self.model = model
self.weight = weight
self.cost = cost
class BikeShop(object):
def __init__(self, name,profit):
... | true |
c88c866abdba67fee284b4f0eb3e62d286f24fc7 | AvidDollars/project-euler-solutions-python | /2_even_fibonacci_numbers.py | 1,458 | 4.125 | 4 | """
Each new term in the Fibonacci sequence is generated by adding the previous two terms.
By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four million,
find the sum of the even-valued terms.
"""
... | true |
3099801b30fc5781b0a94e2f250363cadb382477 | saramissak/GWC-mini-projects | /TextAdventure.py | 1,111 | 4.21875 | 4 |
# Update this text to match your story.
start = '''
You wake up one morning and find that you aren't in your bed; you aren't even in your room.
You're in the middle of a giant maze
A sign is hanging from the ivy: "You have one hour. Don't touch the walls."
There is a hallway to your right and to your left.'''
print(... | true |
b7b4e5ffde731bcfec622c9f55f0e18093c32a65 | RishikaMachina/MySuper30 | /Precourse 2/Exercise2.py | 997 | 4.28125 | 4 | def quicksort(arr):
#when left part of right part is left with one number or no number; stop the recursion
if (len(arr) ==0) or (len(arr)==1):
return arr
#considering first element as pivot
pivot = arr[0]
i = 0
for j in range(len(arr)):
if arr[j] < pivot:
# swap value... | true |
01b89b6636c319d4daccf5c77c840755c4dc5270 | robbiecares/Automate-the-Boring-Stuff | /07/RegexStripv2_firsttry.py | 1,070 | 4.4375 | 4 | # ! python3
# RegexStrip_firsttry.py - a regex version of the .strip method
import re
string = "***$123$***"
#string = input("Please enter a string: ")
StripChar = "*"
#StripChar = input('''Please input the character that you'd like to trim from the ends of the string. If you'd like to trim whitespace only just press... | true |
2acb1ff10853ef3a92daadb62f6e76f15cf0d061 | Bradleyjr/E2020 | /section_4/assignment_4b.py | 403 | 4.1875 | 4 | # This program draws
form turtle import *
# bgcolor() changes
bgcolor("lightblue)
color"red")
shape("turtle"
penup()
# The crawl variable is used to
crawl = 10
# The turn variable is used to
turn = 35
for i in range(50):
# stamp() is used to
stamp()
# With each loop, crawl is
crawl = crawl + 3
... | true |
3740003dc7f81406634dfb7f77d617b6dc08a5cb | ShehryarX/python-cheatsheet | /classes.py | 1,120 | 4.25 | 4 | # A class is like a blueprint for creating objects. An object has properties and methods(functions) associated with it. Almost everything in Python is an object
# Create class
class User:
# Constructor
def __init__(self, name, email, age):
self.name = name
self.email = email
self.age = age
def gre... | true |
8c08db7f77659258a8b3e0f9b61d4d7b5d271d00 | TylerA73/Shapes | /triangle.py | 2,989 | 4.25 | 4 | # Imports
import math
from shape import Shape
# Triangle class
# Contains all of the details of the Triangle
class Triangle(Shape):
# __init__: Constructor
# Construcst the Triangle
# Sides of a Triangle: a, b, c
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
... | true |
2ce3222238c8087c4a7f8584bc1077a31ef2b52e | vivsvaan/DSA-Python | /Mathematics/palindrome_number.py | 390 | 4.21875 | 4 | """
Program to check if number is palindrome
"""
def is_palindrome(number):
num = number
reverse = 0
while num != 0:
last_digit = num % 10
reverse = reverse*10 + last_digit
num = num // 10
if reverse == number:
return True
return False
number = int(input("Ente... | true |
358aab90c724826fa6b63ca69d34fc461d29c854 | ComradeMudkipz/lwp3 | /Chapter 3/instanceJoe.py | 619 | 4.21875 | 4 | # Chapter 3
# turtleInstance.py - Program which uses multiple turtles on screen.
import turtle
# Set up the window environment
wn = turtle.Screen()
wn.bgcolor('lightgreen')
wn.title('Tess & Alex')
# Create tess and set some attributes
tess = turtle.Turtle()
tess.color('hotpink')
tess.pensize(5)
# Create alex
alex ... | true |
c4d1e4b637c7fca7810d69f54fa8e42c300c9550 | ComradeMudkipz/lwp3 | /Chapter 2/alarmClockConverter.py | 623 | 4.53125 | 5 | # Chapter 2 - Exercise 8
# alarmClockConverter.py - Converts the time (24 hr) with the number of hours
# inputted and hours to pass.
# Prompt for current time and sets to an integer
timeNowPrompt = input("What time is it now? " )
timeNow = int(timeNowPrompt)
# Prompt for number of hours to pass and sets to an integer... | true |
fe8779680512758d6c1e991aab1053c3a46661f0 | khanmazhar/python-journey | /task_lab.py | 563 | 4.125 | 4 | x = input('Enter a number.')
y = input('Enter another number.')
try:
x_num = float(x)
y_num = float(y)
except:
print('Invalid Input! Try again...')
quit()
if x_num % 2 == 1 and y_num % 2 == 1:
print('Product of x and y is', x_num * y_num)
if y_num % 11 == 0 and y_num % 13 != 0:
if x_num % 11 ... | true |
3b2dd979e59a1aee6beb6552c14033aae721d0f7 | Xolo-T/Play-doh | /Python/Basics/conditions.py | 1,923 | 4.34375 | 4 | # you dont need brackets in your conditions
# elif instead of else if
# after contion we just add a ':'
# -----------------------------------------------------------------------------
# Conditional
# -----------------------------------------------------------------------------
# if, elif, els... | true |
f22f0b9803f963e0ba0283ad810a6aea49065cf0 | Xolo-T/Play-doh | /Python/Basics/generators.py | 414 | 4.21875 | 4 | # help us generate a sequence of values
# a generator is a subset of iterable
# a generator funtion is created using the range and the yeild keywords
# yield poses the funtion and returns to it when next is called
# next can only be called as much as the length of the range
def generator_fn(num):
for i in range... | true |
b403cef706ae3a3e6e47c28dbe881b374f7087af | kritik-Trellis/python-Training | /Examples/checkprime.py | 463 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jan 30 10:39:11 2020
@author: trellis
"""
import math
n=int(input("Enter the number of values you want to enter"))
values=[int(input("Enter the values")) for i in range(n)]
def checkPrime(num):
for i in range(2,int(math.sqrt(num))+1):
if(num%i==0):
re... | true |
e1ec56591180c7138000e62bcecc207664636791 | jam941/hw | /hw06/selection_sort.py | 1,818 | 4.4375 | 4 | '''
Author: Jarred Moyer <jam4936@rit.edu>
Title: selection_sort.py
Language: python3
Description: Uses selective sorting to sort a list from a file specified by the user.
Assignment: Hw07
1: Insertion sort preforms better than selection sort the more sorted the list is initially.
For example: the test case [1,2,3... | true |
2711c8cfe027ee38dd9f6125d5256513f6475ddd | ellyanalinden/mad-libs | /mad-libs/Mad Lib/mad-libs/languageparts.py | 1,554 | 4.46875 | 4 | #!/usr/bin/env python
# import modules here
import random
# Create a dictionary of language parts. It must contain: noun, verb, adjective.
# The key should be one of the types of language (e.g. noun) and the value
# should be the list of words that you choose.
lang_parts = {
'noun': ['man', 'mountain', '... | true |
2a273126ad102d44f6bb4edf63f69acae261e01c | stratosm/NLP_modules | /src/class_ratio.py | 662 | 4.25 | 4 | # Author: Stratos Mansalis
import pandas as pd
def ratio_(df, cl):
"""
Calculates the frequency by class of the dataframe
Arguments
---------
df: the given dataframe
cl: the name of the class
Usage
-----
df = ratio_(data, 'class')
Re... | true |
c3db6e40e20d3b746432443038ce632c370654b3 | stein212/turtleProject | /tryTurtle.py | 1,856 | 4.21875 | 4 | import turtle
# hide turtle
turtle.ht() # or turtle.hideturtle()
# set turtle speed to fastest
turtle.speed(0)
# fastest: 0
# fast: 10
# normal: 6
# slow: 3
# slowest: 1
# draw square manually
for i in range(4):
turtle.forward(10)
turtle.left(90)
# move turtle position
turtle.penup()
turtle.setpos(30, 0)
turtle.... | true |
956d829748aba3d4a631e871449e8468b21672bc | claudiuclement/Coursera-Data-Science-with-Python | /Week2-word-counter-problem.py | 483 | 4.46875 | 4 | #Word counter problem - Week 2
#This code is much simpler than the code provided by the course tutor
#Code used below
from collections import Counter
#opens the file. the with statement here will automatically close it afterwards.
with open("/Users/Claudiu/Downloads/word_cloud/98-0.txt") as input_file:
#build a c... | true |
669cf95f8ca83e5586452b090f1ebf1267a3c161 | farahzuot/data-structures-and-algorithms-python | /tests/challenges/test_array_shipt.py | 693 | 4.3125 | 4 | from data_structures_and_algorithms.challenges.array_shift.array_shift import insertShiftArray
"""
type of list
type of num
add a number to odd list
add a number to even list
"""
def test_list_type():
actual = insertShiftArray(5,4)
expected = 'invalid input'
assert actual == expected
def test_num_type()... | true |
00a3dd214090957c8387f75df441feb07360f7e3 | farahzuot/data-structures-and-algorithms-python | /data_structures_and_algorithms/challenges/ll_zip/ll_zip.py | 872 | 4.1875 | 4 | # from data_structures_and_algorithms.data_structures.linked_list.linked_list import Linked_list
def zipLists(first_l,sec_l):
if type(first_l) != list or type(sec_l) != list:
return "invalid input"
'''
this function takes in two linked lists as arguments. Zip the two linked lists together into one ... | true |
ff2f8db32772d21a9677160e1eb38564ddeee223 | farahzuot/data-structures-and-algorithms-python | /tests/challenges/test_ll_zip.py | 925 | 4.21875 | 4 | from data_structures_and_algorithms.challenges.ll_zip.ll_zip import zipLists
def test_happy_path():
'''
this function will test the normal path
'''
actual = zipLists([1,2,3],[1,2,3])
expected = [1,1,2,2,3,3]
assert actual == expected
def test_invilid_input():
'''
this function will tes... | true |
c630c22542fbde46f0a585d5b0e58dca12b840e0 | malloryeastburn/Python | /pw.py | 724 | 4.125 | 4 | #! python3
# pw.py - An insecure password locker program.
# password dict
PASSWORD = {'email': 'F7minlBDDuvMJuxESSKHFhTxFtjVB6',
'blog': 'VmALvQyKAxiVH5G8v01if1MLZF3sdt',
'luggage': '12345'}
import sys, pyperclip
# if user forgets to include a command line argument, instruct user
if len(sy... | true |
fd00067ec525dd0f4be2d2fa29c9b9e6e4866f5b | reisthi/python-excercises | /tuples.py | 1,258 | 4.25 | 4 | """Tuple exercises"""
# Tuples and strings are immutable
# A single item is not a tuple item. Ex: tuple = (1)
# Unless you add a comma in the end. Ex: tuple = (1,)
def get_oldest(bar1, bar2):
"""Return earliest of two MM/DD/YYYY-formatted date strings."""
year_one, year_two = bar1.split('/')[-1], bar2.split('... | true |
12c9bd5d17c032731f1c5898b22c81f0086149a3 | reisthi/python-excercises | /lists.py | 925 | 4.4375 | 4 | """List exercises"""
list_one = ['a', 'b', 'c', 1, 2, 3]
list_deux = ["Un", "deux", "trois"]
list_trois = ["Un", "deux", "trois"]
list_quatre = ["UN", "deux", "trois"]
def combine_lists(one, two):
"""Return a new list that combines the two given lists."""
return one + two
def rotate_list(my_list):
"""M... | true |
feb9c24aa6bedfcae32654759a74b239fb3e84b1 | vyashole/learn | /03-logic.py | 835 | 4.34375 | 4 | # just declaring some variables for use here
x = 5
y = 10.5
z = 5
# Booleans: Booleans are logical values that can be True or False
# you can use logical operators to check if an expression is True or False
print(y > x) # True
print(x == y) # False
print(z < x) # True
# Here are the different operators
# This will... | true |
a91cb26dbc8806d7c72744322c1075839c73fa76 | aambrioso1/CS-Projects | /tictactoe.py | 2,302 | 4.125 | 4 | # A program for solving the monkey tictactoe problem.
# A list of rows in the game board
row_list = ['COW', 'XXO', 'ABC']
# Other test games:
# row_list = ['AAA', 'BBB', 'CCC'] # single winners: 3, doublewinners: 0
# row_list = ['ABA', 'BAB', 'ABA'] # single winners: 1, doublewinners: 1
# row_list = ['... | true |
b47b3013b01d68ccd576d3fb31c2c899e6ac307f | aambrioso1/CS-Projects | /mumble.py | 771 | 4.21875 | 4 | def word_parse(text):
'Breaks up text into words defined as characters separted by a space'
low = 0 # Position of the beginning of a word
hi = 0 # Position of the end of a word
word_list = []
for i in text:
if i ==' ': # Check if we reached the end of a word
word_list.a... | true |
6045bc04be311fe39536317c887401cf2f1717f6 | thejose5/Motion-Planning-Algorithms | /Basic/BFS.py | 2,810 | 4.375 | 4 | print("DEPTH FIRST SEARCH ALGORITHM")
print("The graph is implemented using dictionaries. The structure of the dictionary is as follows: {Node1:{NeighbourNode1:[<distance b/w nodes>,<heuristic>],...},Node1:{NeighbourNode1:[<distance b/w nodes>,<heuristic>],...} and so on\n\n")
graph = {'A':['S','B'],
'B':['A'... | true |
edb281a7b109cf17fcd3e57aec82dd125b51de60 | imakash3011/PythonFacts | /Maths/DoubleDivision.py | 413 | 4.1875 | 4 | # ###################### Double division
print(-5//2)
print(-5.0//2)
# ################################# Power operator
# Right associative (right to left)
print(2**1**2)
print(1**3**2)
# ############################ No increment and decrement operators
x = 10
print(x)
# x++
x+=1
print(x)
# #################... | true |
d8eeb69854f7a00b908e5b9b209684c46a3bc887 | lyf1006/python-exercise | /7.用户输入和while循环/7.2/pizza.py | 244 | 4.125 | 4 | tip = "Please enter an ingrident you want to add: "
tip += "\n(Enter 'quit' when you are finished)"
while True:
ingrident = input(tip)
if ingrident == "quit":
break
else:
print("We will add this ingrident for you.")
| true |
8a46f1f736b1c5f782f9cfbd385ea5b01e0379e6 | DD-PATEL/AkashTechnolabs-Internship | /Basic.py | 1,156 | 4.28125 | 4 | #Task 1- printing value of variables and finding variable type
a=7
b=3.6
c= "DD"
print("value of a is :", a)
print("value of b is :", b, type)
print(c)
#Task 2- Basic string commands such as printing and slicing of string
name = "Divyesh"
print(name)
print(name[1:5])
print(name[:4])
print("Hello",... | true |
d9881c031ca58a90e6bc1407f9e935b8c23a457e | dannymccall/PYTHON | /password_generator.py | 1,852 | 4.125 | 4 | from tkinter import messagebox
import random
import tkinter as tk
def password_generator():
#Opening a try block
try:
#declaring a variable pw as a string without initialising
pw = str()
#Getting the input from the text box
length = text_field_1.get()
if length == '':
me... | true |
798e45402c0a205c7ce97410213f8402e09706cb | RomanoNRG/Cisco-DevOps-MDP-02 | /Task2/Dicts_vs_List_Time_tradeoff.py | 529 | 4.28125 | 4 | # Program to demonstrate
# space-time trade-off between
# dictionary and list
# To calculate the time
# difference
import time
# Creating a dictionary
d ={'john':1, 'alex':2}
x = time.time()
# Accessing elements
print("Accessing dictionary elements:")
for key in d:
print(d[key], end=" ")
y = time.time()
print("... | true |
118809abf08a5bdd94c9db133c55f07ae554c675 | Mullins69/SimplePYcalculator | /main.py | 1,571 | 4.25 | 4 | print("Welcome to Mullins simple Calculator")
print("Do you want to use the calc, yes or no?")
question = input("yes or no, no caps: ")
if question == "yes":
print("Which would you like to use, addition, subtraction , division or multiplication? ")
question2 = input("no caps : ")
if question2 == "ad... | true |
5cc753ba1aeb3b148cd575fbcb57c47313e15b08 | pnkumar9/linkedinQuestions | /revstring.py | 452 | 4.1875 | 4 | #!/usr/local/bin/python3
# recursive
def reverse1(mystring):
if (len(mystring) == 0):
return("")
if (len(mystring) == 1):
return(mystring)
newstring=reverse1(mystring[1:])+mystring[0]
return(newstring)
# non-recursive without a lot of adding and subtracting
def reverse2(mystring):
newstring=""
for i in rang... | true |
940dfca49d079b7fe7476807ca550de96730c0b6 | longfeili86/math487 | /Homework/HW2/funcDefs.py | 1,634 | 4.375 | 4 | # This is the starter code for homework2. Do not change the function interfaces
# and do not change the file name
#######################################################
#Problem 1
#######################################################
# write a function that solves the linear system Ax=b, where A is an n by n tridia... | true |
c6e9d1e78e796b8475a8a215709ac84e169e4935 | PeterFriedrich/project-euler | /p4.py | 1,242 | 4.1875 | 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.
# Palindrome function
def isPal(num):
numAux = num
revnum = 0
# takes number a... | true |
870e03d5aba2162f04f5ae6622d0fcee98d4daf5 | sneaker-rohit/playing-with-sockets | /multithreaded echo app/client.py | 1,094 | 4.125 | 4 | # The program is intented to get used familarised with the sockets.
# The client here sends a message to the server and prints the response received
# Client side implementation. Below are the set of steps needed for the client to connect
# 1. Connect to the address
# 2. Send a message to the server
# Author: Rohit ... | true |
960443d850e10687b32b0df36aee867bdd8544d4 | AntonioFry/messing-with-python | /main.py | 738 | 4.125 | 4 | print("Welcome to my first game!")
name = input("What is your name? ")
age = int(input("What is your age? "))
health = 10
if age >= 18:
print("You are old enough!")
wants_to_play = input("Do you want to play? ").lower()
if wants_to_play == "yes":
print("Let's play!")
left_or_right = input("First choic... | true |
e2df04dc838999bf07badb47ae8990811931f23e | makhmudislamov/coding_challanges_python3 | /module_2/last_factorial.py | 1,057 | 4.28125 | 4 | """
Prompt:
Given a non-negative number, N, return the last digit of the factorial of N.
The factorial of N, which is written as N!, is defined as the product of all of the integers from 1 to N.
Given 3 as N, the factorial is 1 x 2 x 3 = 6
Given 6 as N, the factorial is 1 x 2 x 3 x 4 x 5 x 6 = 720
Given 9 as N, the... | true |
75aa205b3e5494ce8e83effedfd0db31e08b4d98 | makhmudislamov/coding_challanges_python3 | /module_4/valid_anagram.py | 876 | 4.34375 | 4 | """
Given two strings s and t , write a function to determine if t is an anagram of s.
Example 1:
Input: s = "anagram", t = "nagaram"
Output: true
Example 2:
Input: s = "rat", t = "car"
Output: false
Note:
You may assume the string contains only lowercase letters.
Follow up:
What if the inputs contain unicode cha... | true |
75ea05edc4c6fd9a65e542a5998f8cf7efb15ad6 | makhmudislamov/coding_challanges_python3 | /module_4/find_index.py | 1,001 | 4.3125 | 4 | # -*- coding: utf-8 -*-
"""
Given a sorted array and a target value, return the index if the target is found.
If not, return the index where it would be if it were inserted in order.
You may assume no duplicates in the array.
Examples:
[1,3,5,6], 5 → 2
[1,3,5,6], 2 → 1
[1,3,5,6], 7 → 4
[1,3,5,6], 0 → 0
"""
def fin... | true |
b96f08921bedc7c0faa7810428c108fbe6b42acd | makhmudislamov/coding_challanges_python3 | /module_12_trees/balance_tree_stretch.py | 2,562 | 4.53125 | 5 | """
Given this implementation of a Binary Tree, write a function to balance the
binary tree to reduce the height as much as possible.
For example, given a tree where the nodes have been added in an order
such that the height is higher than it could be:
Nodes have been added in this order:
tree = Tree()
tree.add(No... | true |
92e2e4ebb03fae16e319447a29fe27117854d889 | jprice8/leetcode | /linked_lists/real_python.py | 1,528 | 4.15625 | 4 |
# Class to represent the Linked List
class LinkedList:
def __init__(self):
self.head = None
# method adds element to the left of the linked list
def addToStart(self, data):
# create a temp node
tempNode = Node(data)
tempNode.setLink(self.head)
self.head = tempNode... | true |
ce739ae410b3bc59a42c8fa2d7952f1951d62935 | jaeyoon-lee2/ICS3U-Unit1-04-Python | /area_and_perimeter.py | 391 | 4.28125 | 4 | #!/user/bin/env python3
# Created by: Jaeyoon
# Created on: Sept 2019
# This program calculates the area and perimeter of rectangle
# with dimensions 5m x 3m
def main():
print("If the rectangle has the dimensions:")
print("5m x 3m")
print("")
print("area is {}m^2".format(3*5))
print("perimete... | true |
67ed8715ed674b3f1ed1994989cd4650597a7226 | hemanthgr19/practise | /factorial.py | 318 | 4.125 | 4 | def fun(tea):
if tea < 0:
return 0
#print("0")
elif tea == 0 or tea == 1:
return 1
#print("the value is equal to 0")
else:
fact = 1
while (tea > 0):
fact *= tea
tea -= 1
return fact
tea = 3
print(tea, fun(tea))
#print(n)
| true |
dd45f1114aacf040a6726aab846c68f3da42a1c9 | mraps98/ants | /src/ga.py | 2,207 | 4.125 | 4 | class SimpleGA:
"""
This is an implementation of the basic genetic algorithm.
It requires a few functions need to be overriden to handle the
specifics of the problem.
"""
def __init__(self, p):
self.p = p
def nextGen(self):
"""
Create the next generation. Returns t... | true |
7f720a89090fdeddbd9e406d394b61850ba815c7 | Aliot26/HomeWork | /comprehension.py | 1,500 | 4.28125 | 4 | # This program randomly makes a number from 1 to 20 for user guessing.
import random # add random module
guesses_taken = 0 # assign 0 to guesses_taken variable
print('Hello! What is your name?') # print the message
myName = input() # assign value printed by user to myName variable
number = random.randint(1, 20) ... | true |
32826a67b046670ad85a74a4ddbfdb3ec58cedfd | Aliot26/HomeWork | /reverse.py | 324 | 4.15625 | 4 | inputS = ("The greatest victory is that which requires no battle")
def reverseString(inputString):
inputString = inputString.split()
inputString = inputString[-1::-1]
output = " ".join(inputString)
return output
print("The greatest victory is that which requires no battle")
print(reverseString(input... | true |
e55be7027d048b145d3981e2d81f7462fea954fe | ErnestoPena/Intro-Python-I | /src/13_file_io.py | 919 | 4.25 | 4 | """
Python makes performing file I/O simple. Take a look
at how to read and write to files here:
https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files
"""
# Open up the "foo.txt" file (which already exists) for reading
# Print all the contents of the file, then close the file
files = open('C:... | true |
4d5770e312d763bbc1d43ff27f521e64cbc3e2ff | Sunnyshio/2nd-year-OOP | /1st Semester Summative Assessment.py | 1,120 | 4.375 | 4 | # program that accepts the dimensions of a 3D shape (right-cyliner and sphere) and prints its volume
class Shape:
# Constructor method to process the given object: dimension
def __init__(self, *argument):
self.dimension = argument
# printVolume method: code to process/calculate the volume o... | true |
bd07f81e6c4b66c1422065c352832a6cd5561432 | yasirabd/udacity-ipnd | /stage_3/lesson_3.2_using_functions/secret_message/rename_files.py | 1,250 | 4.25 | 4 | # Lesson 3.2: Use Functions
# Mini-Project: Secret Message
# Your friend has hidden your keys! To find out where they are,
# you have to remove all numbers from the files in a folder
# called prank. But this will be so tedious to do!
# Get Python to do it for you!
# Use this space to describe your approach to the pro... | true |
c7348a4c84b5ef2de8d07b71c56816b052aa0d82 | nlewis97/cmpt120Lewis | /rover.py | 359 | 4.125 | 4 | # Introduction to Programming
# Author: Nicholas Lewis
#Date: 1/29/18
# Curiosityroverexercise.py
# A program that calculates how long it take a photo from Curiotsity to reach NASA.
def timecalculator():
speed = 186000
distance = 34000000
time = distance/speed
print("It will take", time, "seconds for... | true |
2e7421cf23a1dbc4136687af7be0a67cd149d4c7 | nlewis97/cmpt120Lewis | /madlib.py | 423 | 4.15625 | 4 | # Introduction to Programming
# Author: Nicholas Lewis
# Date: 2/2/18
# madlib.py
# A program that functions as a madlib
def madlib():
name = input("enter a name:")
verb = input("enter a verb:")
adjective = input("enter an adjective:")
street = input("enter a street name:")
print(name, "started to... | true |
2d690cd3ff70d267947be2ee1b8f7875fa1f48a0 | medhini/ECE544-PatternRecognition | /mp1/models/support_vector_machine.py | 1,600 | 4.125 | 4 | """
Implements support vector machine.
"""
from __future__ import print_function
from __future__ import absolute_import
import numpy as np
from models.linear_model import LinearModel
class SupportVectorMachine(LinearModel):
def backward(self, f, y):
"""Performs the backward operation.
By backwar... | true |
98c76a84e5362b78d5e36590990ed9de3f700add | VitaliiStorozh/Python_marathon_git | /8_sprint/Tasks/s8_1.py | 2,585 | 4.21875 | 4 | # Write the program that calculate total price with discount by the products.
#
# Use class Product(name, price, count) and class Cart. In class Cart you can add the products.
#
# Discount depends on count product:
#
# count discount
# 2 0%
# 5 5%
# 7 10%
# 10 20%
# 20 30%
# more than 20 50%
# Write unittes... | true |
626884ee70540431a1f36f56e99afd2487171c25 | VitaliiStorozh/Python_marathon_git | /3_sprint/Tasks/s3.2.py | 326 | 4.125 | 4 | # Create function create with one string argument.
# This function should return anonymous function that checks
# if the argument of function is equals to the argument of outer function.
def create(str):
return lambda str1: str1 == str
tom = create("pass_for_Tom")
print(tom("pass_for_Tom"))
print(tom("pass_for_... | true |
cdfa670aeb908033858308055aa4802dda5fc4f3 | Okreicberga/programming | /week04-flow/guess2.py | 418 | 4.25 | 4 | # Program that promts the user to guess a number
# the program tell the user if there to guess to high or too low, each time they guess.
numberToGuess = 30
guess = int(input("Please guess the number:"))
while guess != numberToGuess:
if guess < numberToGuess:
print("too low")
else:
print("too high")
gue... | true |
21a98009d75c3648b6fdac4f6ac64bc9a574b917 | Okreicberga/programming | /labs/Topic09-errors/useFib.py | 218 | 4.15625 | 4 | # Author Olga Kreicberga
# This program prompts the user for a number and
# Prints out the fibonacci sequence of that many numbers
import myFunctions
nTimes = int(input('how many:'))
print (myFunctions.fibonacci(nTimes))
| true |
8937f36dbe99019123b72af1cc0e60f0e9b1f231 | AgileinOrange/lpthw | /ex32.py | 274 | 4.28125 | 4 | # Exercise 32 Loops and Lists
the_count = [1, 2, 3, 4, 5]
fruits = ['apples', 'oranges', 'pears', 'apricots']
change = [1, 'pennies', 2, 'dimes', 3, 'quarters']
# this first kind of for-loop goes through a list
for number in the_count:
print(f'This is count {number}') | true |
9ddeb98336bc7a229d71c532ff6ca1bd544c4c67 | Mr-koding/python_note | /working_with_string.py | 792 | 4.1875 | 4 | # String formatting/manipulation
# String is an array of characters/object
# A string an immutable sequence of characters
myString = "this is a string"
"this 23 is also string"
"344"
""
" "
"True"
'I can have single quote'
"@#$%#$%&^"
"[34,34,56]"
# Strings have indices
print(myString[2]) # i
# Slicing can be per... | true |
a05f262054a8eefcddfefdbd7e8883085aee5b9d | SURYATEJAVADDY/Assignment | /assignment/assignment1_4.py | 786 | 4.28125 | 4 | # Write a class that represents a Planet. The constructor class should accept the arguments radius (in meters) and rotation_period (in seconds).
# You should implement three methods:
# (i)surface_area
# (ii)rotation_frequency
import math
class Planet:
def __init__(self):
self.radius = int(input("Ent... | true |
370325ad5443eb93ee3179152c7b8380dbdbb6c4 | aribis369/InformationSystemsLab | /numpyhw.py | 2,133 | 4.1875 | 4 | # Program to get analysing student marks for different subjects.
import numpy as np
# Generating array for 10 students and 6 subjects
A = np.random.randint(low=0, high=101, size=(10,6))
try:
choice = int(input("Enter your choice\n"
"1) Students with highest and lowest total marks\n"
... | true |
fe6f064841aa0934d61dd3f11677c84fa18f4f36 | yabur/LeetCode_Practice | /Trees/Tree_Practice/Practice_Set1/IsBST.py | 1,513 | 4.15625 | 4 | # Is It A BST
# Given a binary tree, check if it is a binary search tree (BST). A valid BST does not have to be complete or balanced.
# Consider the below definition of a BST:
# 1- All nodes values of left subtree are less than or equal to parent node value
# 2- All nodes values of right subtree are greater ... | true |
b2d231a9a260802889ed8929c62cf81429df8636 | yabur/LeetCode_Practice | /Graphs/GraphFoundation/AdjacencyList.py | 1,337 | 4.25 | 4 | # Adjascency List representation in Python
class AdjNode:
def __init__(self, value):
self.vertex = value
self.next = None
# A class to represent a graph. A graph
# is the list of the adjacency lists.
# Size of the array will be the no. of the
# vertices "V"
class Graph:
def __init__(self, ver... | true |
d29730d76c28c24a0c2be8ec32f7e9a1489b1c5a | lvonbank/IT210-Python | /Ch.03/P3_2.py | 489 | 4.125 | 4 | # Levi VonBank
## Reads a floating point number and prints “zero” if the number is zero.
# Otherwise “positive” or “negative”. “small” if it is less than 1,
# or “large” if it exceeds 1,000,000.
userInput = float(input("Enter a floating-point number: "))
if userInput == 0:
print("It's zero")
elif userInput > ... | true |
aa4fb45cf22cf8d68e6d311cf1efc7552d42bd41 | lvonbank/IT210-Python | /Ch.04/P4_5.py | 913 | 4.125 | 4 | # Levi VonBank
# Initializes variables
total = 0.0
count = 0
# Priming read
inputStr = input("Enter a value or Q to quit: ")
# Initializes the largest and smallest variables
largest = float(inputStr)
smallest = float(inputStr)
# Enters a loop to determine the largest, smallest, and average
while inputStr.upper() !=... | true |
80b94f65df7acf89744b8a1fbdbc74177e09e7ad | lvonbank/IT210-Python | /Lab07/Lab07.py | 1,144 | 4.4375 | 4 | # Levi VonBank
# Group Members: Scott Fleming & Peter Fischbach
def main():
# Obtains strings from the user
set1 = set(input("Enter a string to be used as set1: "))
set2 = set(input("Enter a string to be used as set2: "))
set3 = set(input("Enter a string to be used as set3: "))
# Determines eleme... | true |
295263667e05765c97cc89de5d6b54ed02109d48 | lvonbank/IT210-Python | /Ch.03/P3_21.py | 357 | 4.21875 | 4 | # Levi VonBank
## Reads two floatingpoint numbers and tests whether
# they are the same up to two decimal places.
number1 = float(input("Enter a floating-point number: "))
number2 = float(input("Enter a floating-point number: "))
if abs(number1 - number2) <= 0.01:
print("They're the same up to two decimal plac... | true |
92d19754dff461772d3e1a2e4f0d5d3a815cc4f5 | FredericVets/PythonPlayground | /helloPython.py | 1,036 | 4.28125 | 4 | """
Notes from Python Programming
https://www.youtube.com/watch?v=N4mEzFDjqtA
by Derek Banas
"""
print("Hello Python")
print('Hello Python') # single or double quotes are treated the same.
'''
I'm a multiline comment.
'''
name = "Frederic"
print(name)
name = 10
print(name)
# 5 main data types : Numbers String... | true |
c99a6a6246a88c7c55e13de677c4b0d9dde09c84 | eveminggong/Python-Basics | /7. Tuples.py | 924 | 4.28125 | 4 | tuple1 = (1,2,3)
tuple2 = (5,6,7)
tuple3 = ('Red', 'Blue', 'Black')
print(f'Tuple1: {tuple1}')
print(f'Tuple2: {tuple2}')
print(f'Tuple3: {tuple3}')
def add_tuple(Tuple1, Tuple2):
FinalTuple = Tuple1 + Tuple2
print(f'The tuples are added {FinalTuple}')
add_tuple(tuple1,tuple2)
def duplicate_tuple(Tuple1,... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.