blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
0240ac7b4e98d5bf5a77247acd82bd4845b05638 | lordzizzy/leet_code | /04_daily_challenge/2021/01-jan/week3/longest_palindromic_substring.py | 2,376 | 4.28125 | 4 | # https://leetcode.com/explore/challenge/card/january-leetcoding-challenge-2021/581/week-3-january-15th-january-21st/3609/
# Longest Palindromic Substring
# Given a string s, return the longest palindromic substring in s.
# Example 1:
# Input: s = "babad"
# Output: "bab"
# Note: "aba" is also a valid answer.
# Examp... | true |
2c66d493db17934dd11fcb234879c2973389c5e6 | lordzizzy/leet_code | /04_daily_challenge/2021/01-jan/week3/count_sorted_vowel_strings.py | 2,456 | 4.21875 | 4 |
# https://leetcode.com/explore/challenge/card/january-leetcoding-challenge-2021/581/week-3-january-15th-january-21st/3607/
# Count Sorted Vowel Strings
# Given an integer n, return the number of strings of length n that consist only of vowels (a, e, i, o, u) and are lexicographically sorted.
# A string s is lexicog... | true |
c3ddb3bf94ebf1718c478cc0f1dbf22e6f36c684 | lordzizzy/leet_code | /04_daily_challenge/2021/04-apr/week4/power_of_three.py | 2,113 | 4.40625 | 4 | # # https://leetcode.com/explore/challenge/card/april-leetcoding-challenge-2021/596/week-4-april-22nd-april-28th/3722/
# Power of Three
# Given an integer n, return true if it is a power of three. Otherwise, return
# false.
# An integer n is a power of three, if there exists an integer x such that n ==
# 3x.
# Examp... | true |
705f19655e764983cd30ec9cc85fa1c1b71d058d | lordzizzy/leet_code | /04_daily_challenge/2021/07-july/week4/beautiful_array.py | 2,660 | 4.1875 | 4 | # https://leetcode.com/explore/challenge/card/july-leetcoding-challenge-2021/611/week-4-july-22nd-july-28th/3829/
# Beautiful Array
# An array nums of length n is beautiful if:
# nums is a permutation of the integers in the range [1, n].
# For every 0 <= i < j < n, there is no index k with i < k < j where 2 *
# nums... | true |
8eed14a8dec53b19bc3f644868f4646c1cda8935 | JudoboyAlex/python_fundamentals1 | /exercise6.2.py | 1,667 | 4.4375 | 4 | # You started the day with energy, but you are going to get tired as you travel! Keep track of your energy.
# If you walk, your energy should increase. If you run, it should decrease. Moreover, you should not be able to run if your energy is zero.
# ...then, go crazy with it! Allow the user to rest and eat. Do whatever... | true |
15de37c13d5b459e5cd75ec427a4345ec6d2294f | Lukas-N/Projects | /L5.py | 429 | 4.15625 | 4 | Bottles = int(input("How many green bottles are there: "))
while Bottles > 1:
print(Bottles, "green bottles hanging on the wall, and if one green bottle were to accidently fall, there would be", (Bottles -1), "green bottle(s) hanging on the wall")
Bottles = Bottles -1
print("1 green bottle hanging on the wa... | true |
4d1ca25ab9bd4f77a4a415fdd9dd14db66f2e4c5 | Rishik999/BSc_IT_Python | /pracs/unit_1/prac_1c_fibonacci.py | 311 | 4.1875 | 4 | # PYTHON PROGRAM TO GENERATE FIBONACCI SERIES
# user input
num = int(input("Enter a number: "))
# initializing variables
old = 0
new = 1
count = 0
# while loop to run until counter reaches the given number
while count <= num:
next = old + new
print(old)
old = new
new = next
count += 1
| true |
5f91500b1d550a84eb01f20e8af063f2273e8192 | Rishik999/BSc_IT_Python | /pracs/unit_1/prac_1b_odd_even.py | 313 | 4.4375 | 4 | # PYTHON PROGRAM TO CHECK IF THE NUMBER IS EVEN OR ODD
# user input
num = input("Please enter a number: ")
# using modulus operator to check if the remainder is 0 i.e. if it is divisible by 2
if int(num) % 2 == 0:
print("Entered number is an even number")
else:
print("Entered number is an odd number")
| true |
6c14e816e6bd5251daec42c8d71c3fd00c474981 | Rishik999/BSc_IT_Python | /pracs/unit_4/prac_4c_clone_list.py | 344 | 4.4375 | 4 | # PYTHON PROGRAM TO CLONE A LIST
# initializing lists
list_1 = [44, 54, 22, 71, 67, 89, 20, 99]
list_2 = [] # empty list to store elements from list_1
# for loop to iterate list_1
for x in list_1:
list_2.append(x) # append each element (x) from list_1 to list_2
# output
print("Original list: ", list_1)
print("Cl... | true |
59270649836a6f75ba96305618e67b36535a7af8 | Rishik999/BSc_IT_Python | /pracs/unit_7/prac_7a_class_student.py | 851 | 4.3125 | 4 | # CLASS STUDENT TO STORE AND DISPLAY INFORMATION
class Student:
# The __init__ is a special method used to initialise any class
# The parameters passed in the init method are necessary to create an instance of that class
def __init__(self, first, last, score):
self.first = first
self.last ... | true |
469f876e7eb620c0875414d8444c3e246977dec9 | Ghroznak/python_practice | /hangman.py | 1,608 | 4.1875 | 4 | # Hangman
import random
def make_a_word(strng): #create a def or remove it again? revert strng to secret_word if removed.
word_File_path = '/Users/RogerMBA/PycharmProjects/Hangman/english3.txt'
f = open('english3.txt', 'r')
lines = f.readlines()
for index, line in enumerate(lines):
lines[index] = line.strip('\n'... | true |
026bb3b7be0ea9e4d0577e90096a3edd68b8015b | sunny-g/ud036 | /lesson2/lesson2a.py | 2,399 | 4.4375 | 4 | ''' lesson 2 - building a movie website
build a site that hosts movie trailers and their info
steps:
1. we need:
title
synopsis
release date
ratings
this means we need a template for this data,
ex: avatar.show_info(), toyStory.show_trailer()
but we dont want to use s... | true |
7a305cdf89b311875b172dc6c4e74188ab6b0355 | greenfox-zerda-lasers/bereczb | /week-04/day-3/09.py | 504 | 4.15625 | 4 | # create a 300x300 canvas.
# create a square drawing function that takes 1 parameter:
# the square size
# and draws a square of that size to the center of the canvas.
# draw 3 squares with that function.
from tkinter import *
def draw_square(a):
canvas.create_rectangle(150 - a / 2, 150 - a / 2, 150 + a / 2, 150 +... | true |
9a890f9b78d267a5736ee72bcae20c51ac68cbb2 | FigX7/digital_defense | /application/core/helpers.py | 542 | 4.375 | 4 | # https://www.geeksforgeeks.org/python-make-a-list-of-intervals-with-sequential-numbers/
# Python3 program to Convert list of
# sequential number into intervals
import itertools
def intervals_extract(iterable):
iterable = sorted(set(iterable))
for key, group in itertools.groupby(enumerate(iterable... | true |
89a2a8bb4638493f1af993a622a97962cffbef25 | uccser/codewof | /codewof/programming/content/en/prime-numbers/solution.py | 378 | 4.25 | 4 | number = int(input("Enter a positive integer: "))
if number < 2:
print('No primes.')
else:
print(2)
for possible_prime in range(3, number + 1):
prime = True
for divisor in range(2, possible_prime):
if (possible_prime % divisor) == 0:
prime = False
... | true |
9f245e8df74b53459c8a0c35cd136707132a6dcd | urvish6119/Python-Algorithms-problem | /Binary Search.py | 576 | 4.125 | 4 | # Binary Search is only useful on ordered list.
def binary_search(list1, ele):
if len(list1) == 0:
return False
else:
mid = len(list1) / 2
if list1[mid] == ele:
return True
else:
if ele < list1[mid]:
return binary_search(list1[:mid], ele)
... | true |
2f2878c4e9129f76ab87f5eeb05d5632699a3618 | LeakeyMokaya/Leakey_BootCamp_Day_4 | /Missing_Number/missing_number.py | 885 | 4.125 | 4 | def find_missing(list1, list2):
if isinstance(list1, list) and isinstance(list2, list):
list1_length = len(list1)
list2_length = len(list2)
# return 0 if the lists are empty
if list1_length == 0 and list2_length == 0:
return 0
else:
# Convert lists to... | true |
3ca889f0fbe4b6a823a7cb47d0f4dbfdb4dfccaa | pyaephyokyaw15/PythonFreeCourse | /chapter5/tuple_operator.py | 906 | 4.25 | 4 | one_to_ten = range(0,5)
my_tuple = tuple(one_to_ten)
print("Tuple constructor from range ",my_tuple)
another_tuple = tuple(range(20,25))
print("Another tuple ",another_tuple)
third_tuple = my_tuple + another_tuple
print("Third tuple ",third_tuple)
fruits = ("Orange","Apple","Banaa")
fruits_repeated = fruits * 3
prin... | true |
3e1d2cad58d37d35dd69a6249dbf1845069cfa97 | hendry-ref/python-topic | /references/printing_ref.py | 2,319 | 4.28125 | 4 | from string import Template
from helper.printformatter import pt
"""
Ref: https://pyformat.info/ for all string formatting purposes
Topics:
- basic printing
- format printing ( % , f"..", format, template)
- string template
- escape character
"""
@pt
def basic_print():
my_var = "hello world"
print("Hello ... | true |
be759543df287c17d99fd51899e6b4025b2a4a5b | VamsiKrishna04/Hacktoberfest-2021 | /hill-cipher-encryption.py | 2,052 | 4.3125 | 4 | ## cryptography - Hill cipher encryption algorithm implementation
## input - any plaintext and a key(mostly used of size 9)
## Matrix of 3*3 is formed
## Output is a ciphertext generated using hill cipher encryption algorithm
## Characters considered for encryption are A-Z and ".,!" So mod 29 method is used
## eg. Sa... | true |
1a0ec0505034f369127272a25f326f437c9ce2c6 | kjeelani/YCWCodeFiles | /Basic Warmups/basics1.py | 1,012 | 4.40625 | 4 | #Console is ----> where things are printed
print("Hello World")
print("----")
#variables are defined by one equal sign, and have a certain variable type. For now, you will work with strings and ints
#strings(words)
#ints(whole numbers)
message = "Hello World"
print(message)
x = 4
print(x)
print("----")
"""Note: Never ... | true |
4b1191685db24a1a1b5183b470d26d72681794ed | teachandlearn/dailyWarmups | /switch_two_variables.py | 465 | 4.15625 | 4 | # Super easy, but it might be a good activity for my students.
# Ask: show me (on paper, but better on a whiteboard) how you would swap the values of two variables.
# https://stackoverflow.com/questions/117812/alternate-fizzbuzz-questions
# Variables
var_one = 25
var_two = 35
placeholder = 0
# Switch the values
place... | true |
ad33794460a934c50149f07b36abff6dc5633557 | teachandlearn/dailyWarmups | /multiples_of_three_and_five.py | 1,074 | 4.3125 | 4 | # 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.
# Warm up prompt: https://projecteuler.net/problem=1
# variables
sum_of_multiples = 0
multiples_of_three_num = 0
multiples_of_... | true |
0e6709c2fb734b287082be951487108f6cb2ee22 | andrexburns/DojoProjects | /codingdojo_python/pytonoop/bikeoop.py | 589 | 4.15625 | 4 | class bike(object):
def __init__(self, price, max_speed, miles):
self.price = price
self.max_speed = max_speed
self.miles = miles
def displayinfo(self):
print self.price , self.max_speed, self.miles
def ride(self):
self.miles += 10
return self
def reverse(self):
self.miles -= 5
... | true |
d7a16f08027805d5bce4aa3006719027c4902a6f | NelsonDayan/Data-Structures-and-Algorithms | /Stack and Queue/Queue.py | 633 | 4.15625 | 4 | #Implementation of a queue
stack=[]
tmp_stack=[]
top=0
while True:
option=input("Choose your option:\n1.enqueue\n2.dequeue\n3.exit")
if option=="enqueue" | "2":
element=input("Enter element for insertion: ")
stack.append(element)
top+=1
print(stack)
elif option=="dequeue" | "... | true |
93c64e96afc91df10f31b256c04585fcb14ea709 | cchauve/Callysto-Salish-Baskets | /notebooks/python_scripts/atomic_chevron.py | 1,211 | 4.15625 | 4 | # Function: For Chevron Pattern - Creates a single row of the Chevron Pattern
# Input: The height and number of colors used for the Chevron as well as the row number of the row to be created
# Output: A string containing a row of a Chevron Pattern
def create_row(height, num_colors, row_num):
# Each row of the ... | true |
91b77d715f14e5c0ce42b811eda03119b5763f22 | Malcolm-Tompkins/ICS3U-Unit5-02-Python-Area_Triangle | /area_triangle.py | 843 | 4.1875 | 4 | #!/usr/bin/env python3
# Created by Malcolm Tompkins
# Created on May 26, 2021
# Calculates the area of a triangle with functions
def area_of_triangle(user_base, user_height):
area = user_base * user_height / 2
print("The area of your triangle is: {:.0f}mm²".format(area))
def main():
user_input1 = (inp... | true |
09119f0a6e1775a39d3987891a5c8d6e717e63db | akshaygepl1/Python-codes | /Chapter2/Word_count_unique_sorted.py | 340 | 4.1875 | 4 | # Get a list of words with their count in a sentence .
# The word should be in a sorted order alphabetically.Word should not be repeated.
# Assume space as separator for words.
User_input = input("Enter the sentence on which the operation will be performed :")
temp = list(set(User_input.split()))
t1 = temp
t1.s... | true |
1b9b8f6ff4f1d41e7dc45049f1a10a6d1d11eb49 | akshaygepl1/Python-codes | /Chapter2/Lab1.py | 285 | 4.375 | 4 | # Input a sentence and display the longest word
User_Intput = input("Enter a sentence")
Longest = ""
Length = 0
List_Of_Words = [x for x in User_Intput.split()]
print(List_Of_Words)
for i in List_Of_Words:
if(len(i)>Length):
Longest = i
print(Longest) | true |
e09b59ea41fffe88da96705f2775cb55b2930149 | bpl4vv/python-projects | /OddOrEven.py | 997 | 4.375 | 4 | # Ask the user for a number. Depending on whether the number is even or odd, print out an appropriate message to the user.
# Hint: how does an even / odd number react differently when divided by 2?
# Extras:
# 1. If the number is a multiple of 4, print out a different message.
# 2. Ask the user for two numbers: one ... | true |
0f737d2e2c66a0bce9d4318769d3794e45aad765 | fabianomalves/python_introduction | /exerc_307.py | 277 | 4.28125 | 4 | """
Create a code asking two integers. Print the sum of these numbers.
"""
number1 = int(input('Type the first integer number: '))
number2 = int(input('Type the second integer number: '))
sum_of_numbers = number1 + number2
print('The sum of two numbers are: ', sum_of_numbers)
| true |
fb4f176453ce41f7cf1447d255850ddc8030b4f6 | tashadanner/magic8 | /magic8.py | 997 | 4.1875 | 4 | import random
name = input('What is your name?')
question = input('What is your question?')
answer = ""
random_number = random.randint(1,11)
if random_number == 1:
answer = "Yes - definitely."
elif random_number == 2:
answer = "It is decidely so."
elif random_number == 3:
answer = "Without a doubt."
elif random... | true |
e9544452230461195b198545c237d9968785ebe8 | davisbradleyj/my-class-repo | /22-ruby-python-break-outs/activities/01-python/06-Ins_List/Demo/lists.py | 832 | 4.3125 | 4 | # Create a variable and set it as an List
myList = ["Tony Stark", 25, "Steve Rodgers", 80]
print(myList)
# Adds an element onto the end of a List
myList.append("Thor")
myList.append("Thor")
myList.append("Thor Nolan")
print(myList)
# Returns the index of the first object with a matching value
print(myList.index("Thor... | true |
19c0ac5125a333fe6815e0e31c113e084bba8c10 | davisbradleyj/my-class-repo | /22-ruby-python-break-outs/activities/01-python/02-Stu_HelloVariableWorld/Unsolved/HelloVariables.py | 784 | 4.34375 | 4 | # Create a variable called 'name' that holds a string
name = "Brad"
# Create a variable called 'country' that holds a string
country = "USA"
# Create a variable called 'age' that holds an integer
age = 37
# Create a variable called 'hourly_wage' that holds an integer
hourly_wage = 50
# Calculate the daily wage for ... | true |
be6e5c7ccfb3ac5b942a3d5774fcbcd61f8ce15f | JaysonGodbey/ConsoleTicketingSystem | /master_ticket.py | 1,142 | 4.1875 | 4 | SURCHARGE = 2
TICKET_PRICE = 10
tickets_remaining = 100
def calculate_price(number_of_tickets):
return (number_of_tickets * TICKET_PRICE) + SURCHARGE
while tickets_remaining >= 1:
print("There are {} tickets remaining.".format(tickets_remaining))
name = input("What is your name? ")
number_of_tickets... | true |
f5cff0bb472b1a69b31bec58186988d1438af64b | TonyLijcu/Practica | /Prac_04/inte1.py | 336 | 4.125 | 4 | Number = []
for i in range(5):
number = int(input("Write a number: "))
Number.append(number)
print("The first number is", Number[0])
print("The last number is", Number[-1])
print("The smallest number is", min(Number))
print("The largest number is", max(Number))
print("The average of the numbers is", sum(Number... | true |
0e5443af8ea48ffa7887a0e2d18c265dfa0f1d49 | liangming168/leetcode | /DFSandBacktracking/Q257_binaryTreePath.py | 1,499 | 4.28125 | 4 | # -*- coding: utf-8 -*-
"""
Q257 binary tree path
Given a binary tree, return all root-to-leaf paths.
Note: A leaf is a node with no children.
Example:
Input:
1
/ \
2 3
\
5
Output: ["1->2->5", "1->3"]
Explanation: All root-to-leaf paths are: 1->2->5, 1->3
"""
'''
method dfs
... | true |
dbd656bbc0123cd6da290253433f10d7d05e4cf4 | liangming168/leetcode | /heap/Q114_flattenBT2SingleList.py | 832 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Q114 flatten BT into a linked lsit
Given a binary tree, flatten it to a linked list in-place.
For example, given the following tree:
1
/ \
2 5
/ \ \
3 4 6
The flattened tree should look like:
1
\
2
\
3
\
4
\
5
... | true |
974d05f7d5514d19dcc3ab8038ad3fedd794c321 | ashwinchidambaram/PythonCode | /projecteuler/Question3.py | 1,696 | 4.125 | 4 | # Ashwin Chidambaram ##
# Task: What is the largest prime factor of the number 600851475143 ##
######################################################################
import math
# [1] - Create a list to hold the factors of 600851475143
factorList = []
# Create a variable... | true |
e38b587fdfb591b5ef8726e9cd0506bdb97cecf4 | KamrulSh/Data-Structure-Practice | /linked list/palindromLinkedList.py | 2,991 | 4.21875 | 4 | # Function to check if a singly linked list is palindrome
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def appendAtHead(self, value):
newNode = Node(value)
newNode.next = self.hea... | true |
69cdb419707c0d1429e6796e5b85569b12e0d321 | NAyeshaSulthana/11morning | /conditionalstatements.py | 1,986 | 4.1875 | 4 | #conditional statements-statements will be executed based on conditions..
#3 statements:
#1-if statement
#2-if else statement
#3-if elif else statement
#If statement:
#block of statement in python is represented using indentation
"""
Syntax:-
#it automatically takes space in next line with 4 spaces after i... | true |
1ba8750f36f3187b97c0e6f34785839e4ac56864 | NAyeshaSulthana/11morning | /day2.py | 842 | 4.125 | 4 | print("5"+"5")
print("aye"+"sha")
print(5+5)
print(5-3)
print(5/2)
print(5%2)
print(5//2)
print(5**3)
print(1, 2, 3, "4", 5.0)
print(1, 2, 3, "4", 5.0, "hello")
print("hello")
print("\n")
print(3)
print("hello", end="\t")
print(3)
print("hello", end="")
print(3, end =" ")
print(5)
#boolean data type
... | true |
93433b16fca42c2f452beae88797b761655770cf | wissenschaftler/PythonChallengeSolutions | /Level 3/charbychar.py | 2,445 | 4.15625 | 4 | # The URL of this level: http://www.pythonchallenge.com/pc/def/equality.html
# Character by character processing,without using re module
# Written by Wei Xu
strFile = open("equality.txt",'r') # equality.txt is where the data is
wholeStr = strFile.read()
countLeft = 0 # the number of consecutive capital letters on the ... | true |
18e747d7699378d5b3ac278945484c6ed0f22431 | RajendraBhagroo/Algorithmic_Thinking | /Algorithms_Sedgewick_Python/Chapter_1/binary_search.py | 2,646 | 4.4375 | 4 | import unittest
# Lists MUST Be Sorted Prior To Use
# Name: Binary Search [Iterative]
# Runtime Analysis: O(Log N)
def binary_search_iterative(list_: "List Of Integers", key: "Value To Find Within List") -> "Index Of Value Within List If Exists, Or -1":
"""
Searches For Key Within List.
If The Search Is ... | true |
42654e0f5ceee9de50fed1a4a44617c870d0d6bb | raosindhu/lpth | /Ex16.py | 1,111 | 4.25 | 4 | from sys import argv
print len(argv)
script, filename = argv
print argv[0]
print argv[1]
print "I'M GOING TO ERASE THE FILE"
raw_input("?")
print "OPENING THE FILE..."
target = open(filename, 'w')
print "Now i'm entering three lines"
line1 = raw_input("line 1: ")
line2 = raw_input("line 2: ")
line3 = raw_input... | true |
7fdf58c747a7fcf276e9d2c0e51159c2d40c89bf | raosindhu/lpth | /Ex20.py | 867 | 4.25 | 4 | from sys import argv
script, input_file = argv
def print_file(f): # function to print the file
print f.read()
def rewind(f): # function to rewind the already read file to first line
f.seek(0)
def print_line(no_of_lines, f): # print specific number of lines from a file
print no_of_lines, f.readline(), #... | true |
d2b3371f40e60f971cfcf48c4f60ad990bccbb28 | deepprakashp354/python | /python/class/Avengers.py | 1,131 | 4.1875 | 4 | class Avenger:
avengersCount=0
def __init__(self, name, power):
Avenger.avengersCount +=1
self.name = name
self.power = power
def howMany():
print("Total Avengers %d" % Avenger.avengersCount)
def getName(self):
print("Avenger Name : "+self.name+" Have power "+self.power)
hulk=Avenger("Hulk","Angryness... | true |
008a37d2233d0170b3344dd89a32496549e0ece7 | Notch1/Python_courses_H_Augustin | /Course #2 (Python Data Structures)/assignment_8.4_words.py | 538 | 4.4375 | 4 | # Open the file romeo.txt and read it line by line. For each line, split the line into a list of words
# using the split() method. The program should build a list of words. For each word on each line check to see
# if the word is already in the list and if not append it to the list. When the program completes,
# sor... | true |
6e2aeb52ebc3c8faf21237f54523fa3c7334a91d | KarlCF/python-challenge | /03-python/for.py | 337 | 4.1875 | 4 | cardapio = ['Carne', 'Queijo', 'Frango', 'Calabresa', 'Pizza', 'Carne Seca']
print ('')
print ('---')
print ('')
for recheio in cardapio:
print (f'Recheio de pastel sabor {recheio}')
# Code below only to show that letters are "lists"
# for letter in recheio:
# print (letter)
print ('')
print... | true |
468cdcc5d427ba6633fcabcab2a26b439d348bd6 | an5558/csapx-20191-project1-words-an5558-master | /src/letter_freq.py | 1,844 | 4.125 | 4 | """
CSAPX Project 1: Zipf's Law
Computes the frequency of each letter across the total occurrences of all words over all years.
Author: Ayane Naito
"""
import argparse
import sys
import os
from src import words_util
import numpy as np
import matplotlib.pyplot as plt
def main():
"""
Adds positional and optio... | true |
d05438425a192b47b8fdf6edef3bcf6c575d71f5 | jason-jz-zhu/dataquest | /Data Scientist/Working With Large Datasets/Spark DataFrames.py | 2,886 | 4.25 | 4 | ### Unlike pandas, which can only run on one computer, Spark can use distributed memory (and disk when necessary)
### to handle larger data sets and run computations more quickly.
### Spark DataFrames allow us to modify and reuse our existing pandas code to scale up to much larger data sets.
# step1
### Print the... | true |
b36f1a7aa9c1035c6a5291af765138862dcbf9f5 | blafuente/Python | /inputFromUsers.py | 260 | 4.375 | 4 | # Getting input from users
# For python 3, it will be input("Enter your name")
name = input("Enter your name: ")
age = input("Enter your age: ")
# Python 2, uses raw_input()
# name = raw_input("Enter your name: ")
print("Hello " + name + ". You are " + age) | true |
4f157f649af3d4de3cdcc6b7dc60b27785d68ef4 | chrispy124/210CT-Coursework | /Question 6.py | 417 | 4.15625 | 4 | def WordRev (Words) : #defines the function
WordsL = len(Words) #variable is equal too length of 'words'
if WordsL == 1:
return Words #if only one word is given then it will only print that word
else:
return [Words[-1]]+ WordRev(Words[:-1]) #calls the function to reorder
ListInput = ["this"... | true |
6c6a9ae9d46a966a8426ec143e186bbad5645976 | huang147/STAT598Z | /Lecture_notes/functions.py | 1,697 | 4.625 | 5 | # Usually we want to logically group several statements which solve a
# common problem. One way to achieve that in Python is to use
# functions. Below we will show several features of functions in Python.
# Some examples are from: http://secant.cs.purdue.edu/cs190c:notes09
# A simple function definition begins with ... | true |
1f57de85dadeadecc1edb497d4a173c3f7c5a873 | huang147/STAT598Z | /HW/HW1/stat598z_HW1_Jiajie_Huang/hw1p3.py | 1,138 | 4.21875 | 4 | #!/opt/epd/bin/python
from random import randint
print "I have a card in mind. Let's see if you are smart."
# randomly generate the sign (an integer in 1-4) and number (an integer in 1-13)
sign = randint(1, 4)
number = randint(1, 13)
# first guess the sign
while 1: # make sure the guessing goes on until get to the ... | true |
ec54838c3ea396310dedc64b80028450c136e346 | jawaff/CollegeCS | /CS111_CS213/SimpleEncryptDecrypt/encrypt-decrypt.py | 2,205 | 4.34375 | 4 | '''
program: encryption and decryption
author:Jake Waffle
Encrypt and decrypt lower and uppercase alphabets
1. Constants
none
2. Input
filename
distance
filename2
condition
filename3
3. Computations
Encrypting a message
Decrypting a message
4. Display
encrypted message
decrypted... | true |
3fb0005d04e5c254ee42b9203dd79520a1aaa630 | jawaff/CollegeCS | /CS111_CS213/ArtGeneration/Ch7Proj4.py | 1,809 | 4.1875 | 4 | '''
Author:Jacob Waffle, Carey Stirling
Program:Ch7 project4
Generating a piece of art
Constants
width
height
Inputs
level
Compute
pattern() directs the drawing of the squares
Display
Shows the generated picture
'''
from turtlegraphics import Turtle
import random
def fillSquare(turtle, oldX, oldY,... | true |
97ea0884f579e0eb760c7f5a4bca9d6c56fda76c | Alriosa/PythonCodesPractice | /codes/emailValid.py | 218 | 4.375 | 4 | valid_email = False
print("Enter your email")
email = input()
for i in email:
if(i=="@" and i=="."):
valid_email = True
if valid_email == True:
print("Valid Email")
else:
print("Invalid Email")
| true |
ebf5c51d81b55acc43687cb5b5d0cdafe1df460d | ThomasMcDaniel91/cs-module-project-iterative-sorting | /src/searching/searching.py | 1,526 | 4.34375 | 4 | def linear_search(arr, target):
# Your code here
for i in range(len(arr)):
# go through the values in the list one at a time
# and check if any of them are the target value
if arr[i] == target:
return i
# once the function has run through all the values return -1
... | true |
9cc019b37f7e338e6b7b6e38b859fe63422dbd57 | csusb-005411285/CodeBreakersCode | /caesar-cipher-encryptor.py | 721 | 4.40625 | 4 | def caesarCipherEncryptor(string, key):
# Write your code here.
# intialize a list to store the results
encrypted_str = ''
# normalize the key by using the modulo operator
key = key % 26
unicode_val = 0
# loop through the string
for char in string:
# if the unicode value + key is greater than 122
if o... | true |
1dc02bedb8ffac742b29dece043b265e3419220e | csusb-005411285/CodeBreakersCode | /find-three-largest-numbers.py | 1,228 | 4.28125 | 4 | def findThreeLargestNumbers(array):
# Write your code here.
# init a list to store the three largest numbers
three_largest_nums = [None, None, None]
# loop through the array
for num in array:
# for each number check
# if it is greater than the last element of result list
if three_largest_nums[2] is No... | true |
1f21d9b77e2eb8e4b26677bef8807b9bf1bf7a97 | cvang1231/dicts-word-count | /wordcount.py | 825 | 4.3125 | 4 | from sys import argv
from string import punctuation
def count_words(filename):
"""Prints the number of shared words in a text file.
Usage: python3 wordcount.py <textfile.txt>
"""
# Open the file
file_data = open(filename)
word_dict = {}
for line in file_data:
# Tokenize data... | true |
a122b229a31f80fc64a9beb1421834fbca46f130 | vinaygaja/gaja | /sqr root of 3digit number.py | 419 | 4.15625 | 4 | #squareroot of a 3 digitnumber
num=625
while num!=0:
num=input('enter 3 digit number:')
num=int(num)
#print(num)
if num !=0:
if num>=100 and num<1000:
sqrt=num**0.5
print(sqrt)
num=input('enter the number:')
num=int(num)
else:
... | true |
839b16b73a47c29bfcfbffdd9c8c62f15da2915e | vinaygaja/gaja | /S08Q02findingdigits&adding numbers.py | 1,140 | 4.4375 | 4 | #Question:
##Ask the user to enter a number.
##- If the number is a single digit number, add 7 to it,
## and print the number in its unit’s place
##- If the number is a two digit number, raise the number to the power of 5,
## and print the last 2 digits
##- If the number is a three digit number, ask user to e... | true |
1cebc874862b63ff8e528cc3fb2372d2517f7631 | python-elective-fall-2019/Lesson-02-Data-structures | /exercises/set.py | 1,569 | 4.3125 | 4 | # Set exercises.

1. Write a Python program to create a set.
2. Write a Python program to iteration over sets.
3. Write a Python program to add member(s) in a set.
4. Write a Python program to remove item(s) ... | true |
a532914fa167397c1814e253bb84fa340f4d168e | mwtichen/Python-Scripts | /Scripts/slope.py | 434 | 4.21875 | 4 | #calculates the slope given two points
#by Matthew Tichenor
#for exercise 3.10
def main():
print("This program calculates the slope given two points")
x1, y1 = input("Enter the first pair of coordinates: ").split(",")
x2, y2 = input("Enter the second pair of coordinates: ").split(",")
x1, y1, x2, y2 = ... | true |
d18c2900fdf811aef8d8544c7feb4abcd87ce1dc | mwtichen/Python-Scripts | /Scripts/wordcount.py | 708 | 4.125 | 4 | #answer to exercise 4.18
#File wordcount.py
#by Matthew Tichenor
#need to fix number of words
import math
def main():
print("This program calculates the number of words, characters \
and lines in a file")
fileName = input("Enter a file (full file extension): ")
infile = open(fileName, 'r')
c1 = 0
... | true |
72d842793cc3ca932114e0aced84f43cee062dbc | COMPPHYS-MESPANOL/comp-phys | /sorted_stars.py | 2,240 | 4.46875 | 4 | '''The function sortList takes the list 'data' and adds the elements in that list to new lists which are sorted by distance, apparent brightness, and absolute brightness. First 'counter' is intialized to 1,and the 'counter' is increased by 1
after every running of the while loop. As the 'counter' is less than 3, the w... | true |
d32d6f7baa8b01678300a6d99bb7d317d6b5e816 | Kiwinesss/100-Days-of-Python | /Day 07/hangman_part2.py | 647 | 4.21875 | 4 | #Coding the second part of the hangman game
import random
word_list = ["aardvark", "baboon", "camel"]
chosen_word = random.choice(word_list)
#Testing code
print(f'Pssst, the solution is {chosen_word}.\n')
display = list() #create an empty list
for letter in (chosen_word): #create hangman grid to show the use how m... | true |
e5b1fede2e5407983602688a614eeccc265a477c | Kiwinesss/100-Days-of-Python | /Day 04/treasure-map.py | 1,534 | 4.15625 | 4 | # 🚨 Don't change the code below 👇
row1 = ["⬜️","⬜️","⬜️"]
row2 = ["⬜️","⬜️","⬜️"]
row3 = ["⬜️","⬜️","⬜️"]
map = [row1, row2, row3]
print(f"{row1}\n{row2}\n{row3}")
position = input("Where do you want to put the treasure? ")
# 🚨 Don't change the code above 👆
#Write your code below this row 👇
row = int(position[0])... | true |
91d0e99762217d718ba256b5883c3d01d27c34a8 | domspad/hackerrank | /apple_disambiguation/which_apple.py | 1,613 | 4.3125 | 4 | #!/usr/bin/env python
"""
(Basic explanation)
"""
def whichApple(text) :
"""
Predicts whether text refers to apple - the fruit or Apple - the company.
Right now only based on last appearance of word "apple" in the text
Requires: 'apple' to appear in text (with or without capitals)
Returns: 'fruit' or 'computer-c... | true |
f5312edb17f4c6ff5b974058bd85deae2e9473c0 | PanMaster13/Python-Programming | /Week 6/Sample Files/Sample 7.py | 552 | 4.21875 | 4 | #Tuple - iterating over tuple
from decimal import Decimal
num = (1,2,3,4,5,6,7,8,21,18,19,54,74)
#count Odd and Even numbers
c_odd = c_even = t_odd = t_even = 0
for x in num:
if x % 2:
c_odd += 1
t_odd += x
else:
c_even += 1
t_even += x
print("Number of Even numbers:", c_even... | true |
58b6e992c7991394f8d8b7289c4e301fccf55996 | Andrew-McCormack/DT228-Computer-Science-Year-4-Files | /Advanced Security/Lab 1 - Caesar Cipher/CaesarCipher.py | 1,319 | 4.5 | 4 | import enchant
# PyEnchant is a package which uses dictionaries to check whether a string is a specific language
# it is used for brute forcing caesar cipher solutions where the key is unknown
def main():
while(True):
selection = raw_input('\nAre you encrypting or decrypting the message? (Enter e for encr... | true |
5a81d14e1ac721143e7d9b258975509aad5e8ec5 | brittanyrjones/cs-practice | /postorder_tree_traversal.py | 1,022 | 4.15625 | 4 | # A class that represents an individual node in a
# Binary Tree
"""
Postorder traversal is used to delete the tree.
Please see the question for deletion of tree for details.
Postorder traversal is also useful to get the postfix expression of an expression tree.
Please see http://en.wikipedia.org/wiki/Reverse_Poli... | true |
f7347d873755fe0962835c2a99d61a23d4e33b0c | adechan/School | /Undergrad/Third Year/Python 2020/Lab 6/exercise6.py | 733 | 4.28125 | 4 | # Write a function that, for a text given as a parameter, censures
# words that begin and end with voices. Censorship means replacing
# characters from odd positions with *.
import re
def function6(text):
vowels = "aeiouAEIOU"
words = re.findall("[a-zA-Z0-9]+", text)
matchedWords = []
for word in wor... | true |
e27d4ffc45282bee535c3b3adab0d8d8bb49d6d7 | adechan/School | /Undergrad/Third Year/Python 2020/Lab 5/exercise5.py | 393 | 4.15625 | 4 | # Write a function with one parameter which represents a list.
# The function will return a new list containing all the numbers
# found in the given list.
def function5(list):
numbers = []
for element in list:
if type(element) == int or type(element) == float:
numbers.append(element)
r... | true |
fd0b2dd32ecd4e1b68ece51a610abf69fcaf9fb0 | rooslucas/automate-the-boring-stuff | /chapter-10/chapter_project_10b.py | 1,248 | 4.53125 | 5 | # Chapter project chapter 10
# Project: Backing Up a Folder into a ZIP FIle
import zipfile
import os
# Step 1: Figure Out the ZIP File's Name
def backup_to_zip(folder):
# Back up the entire contents of "folder" into a ZIP file.
folder = os.path.abspath(folder) # make sure folder is absolute
# Figure o... | true |
291d9482b70ad8fbb43a01f84ce797f9dbdb880f | rooslucas/automate-the-boring-stuff | /chapter-3/practice_project_3.py | 400 | 4.5 | 4 | # Practice project from chapter 3
# The Collatz Sequence
def collatz(number):
if number % 2 == 0:
return number // 2
else:
return 3 * number + 1
try:
print('Enter number: ')
number_input = int(input())
while number_input != 1:
number_input = collatz(number_input)
... | true |
1ce7f62caadbf660124cadcf016748e6f53ac8e5 | RinkuAkash/Basic-Python-And-Data-Structures | /Data_Structures/Dictionary/11_list_to_dictionary.py | 250 | 4.125 | 4 | '''
Created on 11/01/2020
@author: B Akash
'''
'''
Problem statement:
Write a Python program to convert a list into a nested dictionary of keys.
'''
List=[1,2,3,4,5,6,7,8,9]
Dictionary={}
for key in List:
Dictionary[key]={key}
print(Dictionary) | true |
af59163f87a659242b8d4069903056a9a0f63c78 | RinkuAkash/Basic-Python-And-Data-Structures | /Data_Structures/Sets/09_symmetric_difference.py | 250 | 4.21875 | 4 | '''
Created on 13/01/2020
@author: B Akash
'''
'''
Problem statement:
Write a Python program to create a symmetric difference
'''
Set1={1,2,3,4,5,6}
Set2={4,5,6,7,8,9}
print("Symmetric difference of Set1 and Set2 : ",Set1.symmetric_difference(Set2)) | true |
d1f2bcda4a9dbbb59a6b7d576dba6039a4b73029 | AzeemShahzad005/Python-Basic-Programs-Practics | /Palindrome.py | 231 | 4.15625 | 4 | num=int(input("Enter the number:"))
temp=num
rev=0
while(num>0):
digit=num%10
rev=rev*10+digit
num=num//10
if(temp==rev):
print("The number is a Palindrome")
else:
print("The number is not a palindrome")
| true |
62d50bdca1c053e8fadb9381e6388cd0b7cc5ac4 | eyenpi/Trie | /src/LinkedList.py | 1,845 | 4.21875 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def pushBack(self, data):
"""
a method that find end of a linked list and add a Node after it
:param data: data that we want to b... | true |
f3899af018b0a0f6ab7216feec57d84342cb9d86 | Spartabariallali/Pythonprograms | /pythonSparta/tuples.py | 382 | 4.3125 | 4 | # Tuples - same as lists but they are immutable
# tuples cant be modified
# should be used when data cannot be manipulated
# tuples are declared by ()
date_of_birth = ("name","dob","passport number")
print(date_of_birth)
#convert the tuple into a string
#add your name into the list at 0 index
dob = list(date_... | true |
af1c28cd78d3ad35a5c7473bfc323900ecc325c6 | Spartabariallali/Pythonprograms | /calculatoroop/calc_functions.py | 1,059 | 4.28125 | 4 | # phase 1 - create a simple calculator
class Python_Calcalutor:
# should have add, divide,multiply,subtract and remainder
def number_subtraction(number1,number2):
return (number1 - number2)
def number_division(number1,number2):
return (number1/number2)
def number_remainder(number1,numb... | true |
ff4fbd4b69001d74a64a11638e188d4434bb62df | Ramnirmal0/python | /palindrome using reveresed number.py | 456 | 4.25 | 4 | def reverse(num):
temp=num
rev=0
while(num>0):
rem=num%10
rev=(rev*10)+rem
num=num//10
print("/n Reversed Number is = ",rev)
check(temp,rev)
def check(num,rev):
if(num == rev):
print("The number is palindrome")
... | true |
e8279cccbd36f1566264f1ce71e3c31a9ed814d9 | johntelforduk/deep-racer | /cartesian_coordinates.py | 1,765 | 4.28125 | 4 | # Functions for manipulating cartesian coordinates expressed as [x, y] lists.
import math
def translation(vertex, delta):
"""Move, or slide, a coordinate in 2d space."""
[vertex_x, vertex_y] = vertex
[delta_x, delta_y] = delta
return [vertex_x + delta_x, vertex_y + delta_y]
def scale(vertex, scale_... | true |
12406ed670cbd6fbceb212e80e297d56a67c2167 | chinmoy159/Python-Guide | /Algorithms/Sorting/selection_sort.py | 912 | 4.375 | 4 | # Program in Python to demonstrate Selection Sorting algorithm
# Guide: https://www.geeksforgeeks.org/selection-sort/
#
# author: shubhojeet
# date: Oct 31, 2020: 2000 hrs
import random
def selection_sort(arr):
size_of_array = len(arr)
for i in range(0, size_of_array - 1):
pos = i
for j in ra... | true |
dff052ce6e6e448eedfdbfad408cd3591fe78bb0 | beckahenryl/Data-Structures-and-Algorithms | /integerbubblesort.py | 459 | 4.28125 | 4 | '''
check if an array at one element is greater than
the element after it, then move it to check against
the next array. If the array is not, then keep it
the same
'''
array = [4,5,1,20,19,23,21,6,9]
def bubbleSort (array):
for i in range(len(array)):
for j in range(0, len(array)-i-1):
if array[j] >... | true |
f4baff695988cb5240325a0dbfaac65da03a05e7 | soni653/cs-module-project-hash-tables | /applications/word_count/word_count.py | 555 | 4.125 | 4 | def word_count(s):
# Your code here
dict = {}
special_chars = '" : ; , . - + = / \ | [ ] { } ( ) * ^ &'.split()
s2 = ''.join(c.lower() for c in s if not c in special_chars)
for word in s2.split():
dict[word] = dict[word] + 1 if word in dict else 1
return dict
if __name__ == "__main_... | true |
559b25244991703f4f70032df9516bd4b28048b7 | elminson/hackerrank | /find-pair-of-numbers/solution.py | 794 | 4.21875 | 4 | # Input: A list / array with integers. For example:
# [3, 4, 1, 2, 9]
# Returns:
# Nothing. However, this function will print out
# a pair of numbers that adds up to 10. For example,
# 1, 9. If no such pair is found, it should print
# "There is no pair that adds up to 10.".
def pair10(given_list):
a = []
... | true |
fc930865974fb10e85e4793868954262a736c3b9 | morrrrr/CryptoMasters | /11_Diffie-Hellman_key_agree.py | 1,804 | 4.15625 | 4 | import math
from sympy import nextprime
# UTILS
def exponentiation_by_squaring(base, exponent) :
res = 1
while exponent > 0 :
if exponent & 1 == 1:
res = (res * base)
exponent = (exponent - 1) // 2
base = (base * base)
else:
exponent ... | true |
e62a10bb91d6210ac2cbce790ec2a995d867c4e2 | mtholder/eebprogramming | /lec2pythonbasics/factor.py | 991 | 4.28125 | 4 | #!/usr/bin/env python
import sys
if len(sys.argv) != 2:
sys.exit(sys.argv[0] + ": Expecting one command line argument -- the integer to factor into primes")
n = int(sys.argv[1])
if n < 1:
sys.exit(sys.argv[0] + "Expecting a positive integer")
if n == 1:
print 1
sys.exit(0)
def get_smallest_prime_fac... | true |
e4ba425daaa585b36e16ce7d12bd071e4843e9e4 | shiningPanther/Project-Euler | /Problem2.py | 1,118 | 4.15625 | 4 | '''
Problem 2:
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-value... | true |
f4c33344856ee099cca55c02b9c4bec38dfd841f | st-pauls-school/python | /5th/turtles-intro/turtle-intro.py | 1,674 | 4.4375 | 4 | #the turtle library
import turtle
# run (F5) this file
# type one of the function names from the shell
# note that if you close the turtle window, you will need to re-run this
# to make new functions, copy the simple() function and replace the text in between the comments to do
# the different new mov... | true |
e5b991906748f48551b8036f7fdb10b4b98b03e4 | yuhan1212/coding_practice | /coding_practice_private/binary_tree_traversal/depth_first/postorder.py | 1,274 | 4.1875 | 4 | # Construct Node class
class Node(object):
def __init__(self, value):
self.value = value
self.left = None
self.right = None
# Construct BinaryTree class
class BinaryTree(object):
def __init__(self, root):
self.root = Node(root)
# Instanciate a tree:
tree = BinaryTree(1)... | true |
9aac2cf63015eaea8939a87c23f6e213176a261d | yuhan1212/coding_practice | /coding_practice_private/binary_tree_traversal/breadth_first/levelorder.py | 1,576 | 4.125 | 4 | # Construct Node class
class Node(object):
def __init__(self, value):
self.value = value
self.left = None
self.right = None
# Construct BinaryTree class
class BinaryTree(object):
def __init__(self, root):
self.root = Node(root)
# Instanciate a tree:
tree = BinaryTree(1)... | true |
d9ed648b9f57c03cbe17743590720fb0213c3f2b | brucekkk/python_scripts | /txt_operate.py | 1,053 | 4.28125 | 4 | # -*- coding: utf-8 -*-
'''
Created on 2019.11.19
@author: BMA
this is a script to modify txt file, including replace one word and
delete some column. Notice that if we give 1 to the delete column,it means
printing first column, 2 means printing first and second columns, etc.
'''
file_path = '10-1.txt' # change fi... | true |
97b815570d2524c5ecd78a8d52ebc18276a45f97 | mingyyy/crash_course | /week2/martes/7-5.py | 637 | 4.125 | 4 | '''
7-5. Movie Tickets: A movie theater charges different ticket prices depending on a person’s age .
If a person is under the age of 3, the ticket is free; if they are between 3 and 12, the ticket is $10;
and if they are over age 12, the ticket is $15 .
Write a loop in which you ask users their age, and then tell them... | true |
be43bcf5880b9f59cbddfa6052de53120aaef7cc | mingyyy/crash_course | /week1/ChangingGuestList.py | 1,149 | 4.40625 | 4 | '''
3-5. Changing Guest List: You just heard that one of your guests can’t make the dinner,
so you need to send out a new set of invitations . You’ll have to think of someone else to invite .
• Start with your program from Exercise 3-4 .
Add a print statement at the end of your program stating the name of the guest w... | true |
d46f4f18129728b15fa6a391e17344a459898628 | mingyyy/crash_course | /week2/viernes/class_9_6.py | 857 | 4.53125 | 5 | '''
9-6. Ice Cream Stand: An ice cream stand is a specific kind of restaurant .
Write a class called IceCreamStand that inherits from the Restaurant class you wrote in Exercise 9-1 (page 166)
or Exercise 9-4 (page 171) . Either version of the class will work; just pick the one you like better .
Add an attribute called ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.