blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
334e3b803269c9bd6680449731217a8808e7503c | Sameer2898/Data-Structure-And-Algorithims | /Placement Prepration/Stack/reverse_a_string.py | 434 | 4.125 | 4 |
def reverse(string):
stack = []
for ch in string:
stack.append(ch)
reverse = ''
while len(stack):
reverse += stack.pop()
return reverse
if __name__=='__main__':
t = int(input('Enter the number of test cases:- '))
for i in range(t):
str1 = input('Enter the strin... | true |
b9f4adeebf8aaad1e795d00c091e69a4d018dbdc | zhangzhentctc/crawl_hkexnews | /samples/single_select.py | 2,046 | 4.4375 | 4 | from tkinter import *
# This is a demo program that shows how to
# create radio buttons and how to get other widgets to
# share the information in a radio button.
#
# There are other ways of doing this too, but
# the "variable" option of radiobuttons seems to be the easiest.
#
# note how each button has a value it set... | true |
5437ea12e15311eddce36aa4088a9836d49fdb1a | Ananth3A1/Hkfst2k21 | /calculatorOfGrades.py | 1,131 | 4.3125 | 4 | # program that requests entry with a student's name,
# after entry enter 10 student grades (all must be entered by the program user)
# and after having the grade list for the student show at the end of the program,
# the student's average, the maximum grade, the minimum grade, the first and the last grade assigned to t... | true |
506e3d63c06c48166bb57894ee5f85892699cdef | acctwdxab/project-4b | /fib.py | 420 | 4.125 | 4 | # Dan Wu
# 10/19/2020
# To create a function that takes a positive integer parameter and returns the number at that position of the Fibonacci sequence.
def fib(num):
"""The fib function returns the positive number at the position of the fibonacci sequence."""
first_num, second_num = 0 , 1
for i in range (... | true |
7b29f544f5f3d581af92347194d4da2d9fcae53a | Anna-Pramod/LeetCode_Solutions | /isomorphic_strings.py | 1,909 | 4.125 | 4 | #Given two strings 'str1' and 'str2', check if these two strings are isomorphic to each other.
#Two strings str1 and str2 are called isomorphic if there is a one to one mapping possible for every character of str1 to every character of str2 while preserving the order.
#Note: All occurrences of every character in ‘str1’... | true |
e0e1f4f3272c7ecbf5e59d89f6a1ba4112d1de0c | baymer2600/python_challenges | /divisor.py | 358 | 4.1875 | 4 | #Practice Program
#Create a program that asks the user for a number and then prints out a list of all the divisors of that number.
user_input = input("Please provide a number: ")
def divisor(number):
a = []
x = number
while x > 0:
if number % x == 0:
a.append(x)
x -= 1
retu... | true |
6c859b128b1b5fcfb37dfcdc152841d7b791043e | usmanwardag/prep | /5_twos_complement.py | 1,666 | 4.3125 | 4 | # Why do we need 2's complement?
# https://www.youtube.com/watch?v=lKTsv6iVxV4
#
# Two's complement is used to store signed numbers.
#
# How should be store signed numbers in bits?
# One idea is to assign the highest bit 0 or 1
# depending on whether the number is +ve or -ve.
#
# This idea has two problems.
# 1- There... | true |
1679b4e34a398a81aa293ff2c8471d151d8f5fc4 | Shamyukthaaaa/Python_assignments | /fruits_set.py | 1,334 | 4.1875 | 4 | # To Be Implemented Set methods
fruits=set()
num=int(input("Enter the number of elements to be present in the set: "))
for i in range(num):
fruits_set=input("Enter fruit {} :".format(i+1))
fruits.add(fruits_set)
print(fruits)
#add method
print(fruits.add("papaya"))
#update method
veggies=["potato","... | true |
47ad5edd172c6f1951efbd159b398cf090eadfbc | minddrummer/leetcode | /single questions/SearchInsertPosition.py | 909 | 4.15625 | 4 | # 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.
# Here are few 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
class Solution(obj... | true |
ab2eee9e92e20cae6d71e6ccd6c57bfe64be3de0 | Deependrakumarrout/Small-Assignment | /Simple project/cheak prime number.py | 2,714 | 4.3125 | 4 |
#Making a function to restart
def restart():
try:
num=int(input("Enter a number:"))
if num>1:
for i in range (2,num):
if (num%i)==0:
print(num,"is not a prime number..")
print(i,"x",num//i,"is",num)
... | true |
da062560647d69b8fac9d0686270087b1851023f | TjeerdH/Number-guess-game | /guess.py | 2,830 | 4.125 | 4 | import random
x = random.randrange(100)
while True:
count = 0
guess = input("Guess a number between 0 and 100 ")
try:
if x != int(guess):
if x % 2 == 0:
print("It is an even number!")
count += 1
break
else:
p... | true |
d8d759f9ee97a09a1d1d03d79e9c996ae287ebd9 | davidbUW/Intro-to-Python-Class | /hw3.py | 915 | 4.21875 | 4 | evenlist = "-"
evenlist = list(evenlist)
oddlist = "-"
oddlist = list(oddlist)
def number_program():
while True:
start = int(input("Enter a starting number: "))
end = int(input("Enter an ending number: "))
if start < 1:
print("ERROR: Starting number must be greater than 1")
... | true |
5decd85f916fceade200d88af89eb62385a59cf1 | DonyTawil/LPTHW | /ex.py/ex5.py | 631 | 4.15625 | 4 | dt_name='dony'
dt_height=163 #centimiters
dt_heights=dt_height/2.54 #to convert centimiters into inches for extra credit from tutorial.
dt_age=18
dt_weight=55
dt_weights=dt_weight*2.2 #extra cr. kilo into pounds
dt_eyes='brown'
dt_teeth='white'
dt_hair='dark brown'
print ('lets talk about %s.'%dt_name)
print ("he's %d... | true |
8f988e4a800f92702f77f0df4f36ad84e84f108a | DonyTawil/LPTHW | /ex.py/ex12.py | 254 | 4.1875 | 4 | name=input('what is your name? ')
age=input("what is your age? ")
height=input('''how tall are you? ''')
weight=input('how much do you weigh? ')
print ("so %s ,you're %s years old ,%s centimiters tall, and you weigh %s kilos"%(name,age,height,weight))
| true |
475778c024e9a48bbf4d902ff3d8f76f78f5c975 | omakasekim/python_algorithm | /00_자료구조 구현/chaining용 연결리스트.py | 1,719 | 4.15625 | 4 | # 해시테이블에서 충돌이 일어날 경우를 위한 chaining 용 링크드리스트 구현
class Node:
def __init__(self, key, value):
self.key = key
self.value = value
self.next = None
self.prev = None
class LinkedList:
def __init__(self):
self.head = None
self.tail = None
def find_node_with_key(self... | true |
e32b155a9b4b06ed347ed5412658796f8435abd1 | Jayaprakash1998/Python-practice-problems-set-5 | /Prison Security Protocol.py | 2,171 | 4.21875 | 4 | ''' QUESTION:
Prison Security Protocol :
There is a highly secure prison that holds the most dangerous criminals in the world. On 2nd November 2019,
the prison officials received a warning that there was an attack planned on the prison to free the criminals.
So, the prison officials planned a quick evacuation... | true |
205a7325dec447cab3994b95ab5ae41234425a93 | JustonSmith/Coding_Dojo | /python_stack/learn_assignments/functions_basics_I/functions_basic_I.py | 1,652 | 4.125 | 4 | # #1
# def number_of_food_groups():
# return 5
# print(number_of_food_groups())
# # The terminal will return 5.
# #2
# # There is an undefined variable so the function will not run.
# #3
# def number_of_books_on_hold():
# return 5
# return 10
# print(number_of_books_on_hold())
# # The terminal will r... | true |
32ad867849b95f3aa479b09c73ae7abb4d033955 | 757u/CSE | /Hangman(Jazmin Ambriz).py | 1,589 | 4.34375 | 4 | import random
# This is a guide of how to make hangman
# 1. Make a word bank - 10 items (checked)
# 2. Select a random item to guess (checked)
# 3. take in a letter and add it to a list of letters_guessed (checked)
# -up to ten incorrect guesses (checked)
# guesses_left = 10 (checked)
# list of letters that you have g... | true |
7b4f8e15418b7571c7d126127cbb8779f2924238 | hmanoj59/python_scripts | /circle_linkedlist.py | 785 | 4.28125 | 4 | def circle_node(node):
marker1 = node
marker2 = node
while marker2 != None and marker2.nextnode != None:
marker1 = marker1.nextnode
marker2 = marker2.nextnode.nextnode
if marker1 == marker2:
return True
return False
#Initializing node
class Node(object):
de... | true |
3c8a9c05f9caf0bc70b7f52762fb64198f0994be | Sharks33/HackerRankSolutions | /Python/staircase.py | 822 | 4.65625 | 5 | '''
Consider a staircase of size n = 4:
#
##
###
####
Observe that its base and height are both equal to n, and the image is drawn
using # symbols and spaces. The last line is not preceded by any spaces.
Write a program that prints a staircase of size n.
INPUT FORMAT
A single integer, n, denoting the size of ... | true |
9b6eb3dfa5fef600879b57f509abef3f6f6b6ccc | davidgower1/Python | /Ex3.py | 968 | 4.5 | 4 | #This line prints a statement about counting my chickens
print("I will now count my chickens:")
# These lines count the chickens, Hens and Roosters
print("Hens", float(26) + float(30) / float(6))
print("Roosters", float(100)-float(25) * float(3) % float(4))
# Here I am makeing the statement about counting the eggs
prin... | true |
1019f29bd5a5f767ece688fbef960be1ab4625da | Prakhar-Saxena/ProjectEulerSolutions | /quickSort | 290 | 4.28125 | 4 | #!/usr/bin/env python3
#This is an amazing way to write the quick sort method.
def quickSort(arr):
if len(arr) <= 1:
return arr
else:
return quickSort( [x for x in arr[1:] if x < arr[0]]) + [arr[0]]+quickSort([x for x in arr[1:] if x>=arr[0]])
print quickSort([3,1,4,1,5,9,2,6,5])
| true |
cdf04a7b1ff723776c2433516bc0eb0490344835 | sidneykung/python_practice | /01_easy/checking_x.py | 555 | 4.25 | 4 | # 1. is_even
# Define a function is_even that will take a number x as input.
# If x is even, then return True.
# Otherwise, return False
def is_even(x):
if x%2 == 0:
return True
else:
return False
print is_even(5) # False
print is_even(6) # True
# 2. is_int
# Define a function is_int that takes a numbe... | true |
49067afca8940e388ff099ed58b68726868d22e8 | thekingmass/OldPythonPrograms | /timedateModule.py | 287 | 4.21875 | 4 | from datetime import datetime
from datetime import date
'''
datetime function for time and time function for date
'''
time = datetime.now()
print(time)
print(date.today())
print(date.today().weekday()) # this will give the week date for today as it counts monday as 0 and saturday as 6
| true |
3e0173ac2ea4d30aafdbc6851636cb3a96f922e7 | supriyo-pal/Joy-Of-Computing-Using-Python-All-programms | /binary search by recursion.py | 1,226 | 4.1875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Oct 20 21:03:53 2020
@author: Supriyo
binary search always takes sorted list as input
"""
#start=0 and end=last
def binary_search(l,x,start,end): #l is the list and x is the searching elelment
#base case: 1 element is in the list , start==end
if start == ... | true |
cc472c44fff5813680b7019dda413e81df991634 | abhishekbajpai/python | /even-odd.py | 301 | 4.40625 | 4 | # Ask the user for a number.
# Depending on whether the number is even or odd,
# print out an appropriate message to the user.
numb = int(input("Please enter a number to check if even or odd: "))
if numb%2 == 0:
print("Entered number is even. ")
else:
print("You have enetered odd number") | true |
d78a468f240b5a01b8da3bf5b05abefe449f99e0 | ryanlntn/mitx.6.00.1x | /l3.problem9.py | 714 | 4.15625 | 4 | # L3 Problem 9
low = 0
high = 100
guess = (low + high) / 2
print "Please think of a number between " + str(low) + " and " + str(high) + "!"
while True:
print("Is your secret number " + str(guess) + "?")
print "Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low.",
answ... | true |
c0f2b4cc267623aacdb13b188350ada0efc44311 | vipingujjar1/python-edsystango | /homework/29 July 2019/greaterDigit.py | 270 | 4.15625 | 4 | # find greater digit from three digit no.
num1=int(input("Enter a three digit no. :"))
for i in range(3):
if i==0:
max=num1%10
num1=num1//10
else:
temp=num1%10
if temp>max:
max=temp
num1=num1//10
print(max)
| true |
27e9c6ae86496fd733f0f1aa7181af06afdd1e82 | nspofford1/tech-savvy | /Assignment3.py | 1,246 | 4.125 | 4 | #Excercise5
def any_lowercase1(s):
for c in s:
if c.islower():
return True
else:
return False
#lowercase1 is seeing if the first letter is lowercase, if it is, it returns True and does not check any other letter
def any_lowercase2(s):
for c in s:
if 'c'.islower()... | true |
ff3b61e30c9f266ca478636bb0c7c15631bbe402 | kristuben/PythonFolder | /drawshapes.py | 622 | 4.3125 | 4 | from turtle import *
import math
#Name your turtle
ke=Turtle()
colormode(255)
#Set Up your screen and starting position.
setup(500,300)
ke.setposition(0,0)
### Write you code below:
color=input('Enter the color of the shapes:')
ke.pendown()
ke.pencolor(color)
length = input('Enter the length of the shapes:')
for nu... | true |
cd9faf9eac1d1fa9932a9e577708ece3f085a976 | annkon22/chapter4 | /ex12.py | 1,832 | 4.46875 | 4 | #Modify the Tower of Hanoi program using turtle graphics to animate the movement of the disks.
#Hint: You can make multiple turtles and have them shaped like rectangles.
import turtle as t
def move_tower(height, from_pole, to_pole, with_pole):
if height >=1:
move_tower(height - 1, from_pole, with_... | true |
0045217a7a04f74694ad26615f502be10bcff7db | MMVonnSeek/Hacktoberfest2021_beginner | /Python3-Learn/list_manipulation_DFRICHARD.py | 1,121 | 4.34375 | 4 | // AUTHOR: Richard
// Python3 Concept: Manipulating data in lists
// GITHUB: https://github.com/DFRICHARD
//Add your python3 concept below
domestic_animals = [] #creating an empty list to contain domestic animals
domestic_animals.append("dog") #adding dog to the list domestic_animals
print(domestic_animals) # The res... | true |
21b8e68f4d4820cb47c3ed171c6d287819c33018 | MMVonnSeek/Hacktoberfest2021_beginner | /Python3-Learn/SortAlphabeticalOrder_erarijit.py | 305 | 4.5625 | 5 | # Program to sort alphabetically the words form a string provided by the user
# take input from the user
my_str = input("Enter a string: ")
# breakdown the string into a list of words
words = my_str.split()
# sort the list
words.sort()
# display the sorted words
for word in words:
print(word)
| true |
fbc976c9592476b372056343a82fa714b065fcac | MMVonnSeek/Hacktoberfest2021_beginner | /Python3-Learn/Palindrome_Shyam-2001.py | 375 | 4.1875 | 4 | // AUTHOR: Devendra Patel
//Python3 Concept: Palindrome
// GITHUB: https://github.com/github-dev21
print("Enter the Number ")
num = int(input())
temp = num
reverse = 0
while(num>0):
dig = num%10
reverse = reverse*10+dig
num = num//10
print(reverse)
if temp==reverse:
print("Number is i... | true |
2a2d5262d2828aa4649aaa8bd6b6ff66ea24891c | MMVonnSeek/Hacktoberfest2021_beginner | /Python3-Learn/magic_number-sumitbro.py | 939 | 4.1875 | 4 | # Python3-Learn
// AUTHOR: Sumit Sah
// Python3 Concept: Check Magic number
// GITHUB: https://github.com/sumitbro
# Magic number concept
#A magic number is that number whose repeated sum of its digits till we get a single digit is equal to 1.
# Example:
# original number= 1729
# sum of digits= 1+7+2+9=19
# ... | true |
ea434795e0deee584fff9e426d35cfce5ef36024 | rajatrj16/PythonCode | /PythonCode/AddNumber.py | 248 | 4.1875 | 4 | value=1
summ=0
print("Enter Numbers to add to the sum")
print("Enter 0 to quit.")
while value !=0:
print("Current Sum: ",summ)
value=int(input("Enter Number? "))
summ+=value
print("---")
print("Total Sum is: ",summ)
| true |
59d1c057abf78be9d606f4aaf7d96d811210834c | AC740/Py | /python37/priorityQueue.py | 691 | 4.28125 | 4 | customers = []
customers.append((2, "Harry")) #no sort needed here because 1 item.
customers.append((3, "Charles"))
customers.sort(reverse=True)
#Need to sort to maintain order
customers.append((1, "Riya"))
customers.sort(reverse=True)
#Need to sort to maintain order
customers.append((4, "Stacy"))
customers... | true |
0c5de4f5507edac29ad3840714173cfdaf61ac47 | sahasatvik/assignments | /CS2201/problemset01/problem01.py | 389 | 4.15625 | 4 | #!/usr/bin/env python3
"""
Input your IISER email in format name-rollno@iiserkol.ac.in, extract the name,
roll no using split() and print them.
"""
email = input("Enter your email in the format name-rollno@iiserkol.ac.in : ")
try:
name_roll, domain = email.split("@")
name, rollno = name_roll.split("-")
pr... | true |
dbb34903bf5365ba09f52c12de86f32d94c37ff0 | Algorant/leetcode | /07_reverse_integer.py | 519 | 4.34375 | 4 | '''
Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0.
'''
def reverse(x):
#check if negative
neg_check = 1
# ignoring negative sign, convert to str
if x < 0:
neg_check... | true |
b5ec7405a7c8b68560146a9fa9565063defaa165 | Kitrinos/Ch.05_Looping | /5.1_Coin_Toss.py | 778 | 4.3125 | 4 | '''
COIN TOSS PROGRAM
-----------------
1.) Create a program that will print a random 0 or 1.
2.) Instead of 0 or 1, print heads or tails. Do this using if statements. Don't select from a list.
3.) Add a loop so that the program does this 50 times.
4.) Create a running total for the number of heads and the number of ta... | true |
6e2b7809c92d27cadc9618ed4ccee34432ab6f02 | jmsaavedra/Interactive-Prototyping-S15 | /python/inclass.py | 268 | 4.3125 | 4 |
x = raw_input("Please enter an integer: ")
x = int(x)
if x < 0:
x = 0
print 'no negative numbers allowed!'
elif x == 2:
print 'x is 2!!'
elif x > 10:
print 'x is greater than 10!'
else:
print 'x is less than 10, greater 0 and NOT 2'
print 'done! exiting now.'
| true |
e5862c30d80f3886aa2a6ee34c200e40d0276259 | ankitchoudhary49/Daily-Assignments | /Assignment-9.py | 1,739 | 4.21875 | 4 | #Assignment 9
'''
Question 1:Name and handle the exception occured in the following program:
a=3
if a<4:
a=a/(a-3)
print(a)
'''
#Exception: ZeroDivisionError
a=3
if a<4:
try:
a=a/(a-3)
except:
a=int(input("please enter a value other than 3. "))
a=a/(a-3)
print(a)
'''
Question 2... | true |
d9f193db5866194f1f3a2a3917a6a1317de589c6 | ankitchoudhary49/Daily-Assignments | /assignment-4.py | 1,307 | 4.3125 | 4 | #Asignment 4
#Question 1: Reverse the List.
print("*"*50)
list1=[1,2,3,4,5]
print(list1[::-1]) #list1.reverse() was not working so i had to use slice operator.
print("*"*50)
#Question 2: Extract all the uppercase letters from a string.
str1='My name is ANKIT CHOUDHARY.'
for i in str1:
if i.isupper()==True:
... | true |
022081786817ba3b960d45b0f1125692cff1a3bb | mcbishop/calculator_2 | /arithmetic.py | 1,516 | 4.15625 | 4 | import math
# def add(num1,num2,*therestnums):
# new_num = 0
# for i in therestnums:
# i = int(i)
# new_num = (int(new_num) + i)
# return (int(num1)+int(num2)+int(new_num))
#next task: change functions to use reduce().
# we will want to convert both arguments into a list along with theres... | true |
a16201f040fee1cee135952b9c1de1fc28c013b4 | mag389/holbertonschool-higher_level_programming | /0x06-python-classes/2-square.py | 528 | 4.25 | 4 | #!/usr/bin/python3
"""square with attribute file"""
class Square:
"""
Square - the square class
Currently blank class
__init__ - makes instance
"""
def __init__(self, _Square_size=0):
"""
creates square instance
_Square_size: self explanatory
"""
if t... | true |
8f04b4b1214f2eb4ab3fdb6fe62d5d18ec264aff | joeywangzr/File_Sorter | /file_sorter.py | 1,473 | 4.28125 | 4 | # Import necessary directories
import os, shutil
# Change working directory to user choice
dir = input('Please input the name of the directory you would like to sort: ')
os.chdir(dir)
print('Sorting files...')
# Check number of files in the directory
num_files = len([f for f in os.listdir('.') if os.path.isfile(f)])... | true |
02892e3a0ccc9faa07184ba3599a036804c65402 | theskinnycoder/python_crash_course | /7_DataStructures/5_MemberShipOperators.py | 1,077 | 4.53125 | 5 | # NOTE: MEMEBRSHIP OPERATORS : in, not in
# - In Strings :
my_string = 'She sells sea shells in the sea shore'
if 'sea' in my_string:
print('Present')
else:
print('Not present')
# - In Lists :
my_list = [1, 3 + 4j, 3.4, 'Rahul']
if 1 in my_list:
print('Present')
else:
print('Not present')
# - In Tup... | true |
092784978eccd9e9483ec1d318631c590253c53f | geog3050/matchison | /Quizzes/matchison_G5055_Quiz1.py | 583 | 4.125 | 4 | climate = input("Please input the climate (in lowercase) and then press enter: ")
temp_string = input("Please input all temperature measurements for this climate as a list enclosed in brackets (i.e. [24.7, 44, 76]): ")
temp_float = eval(temp_string)
print("climate: ", climate)
print("temperatures: ", temp_float)
if cli... | true |
4a1510182817ca687e96b12c6ff1764e5413ae40 | mikebpedersen/python_med_gerth | /uge_5/opgave8_4.py | 1,624 | 4.34375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Exercise 8.4* (validate leaf-labeled binary trees)
Assume we want to represent binary trees, where each leaf has a string as a
label, by a nested tuple. We require the leaves are labeled with distinct
non-empty strings and all non-leaf nodes have exactly two children... | true |
d9c23e09c23090d9f1b4da7686f5c1bae152392d | mikebpedersen/python_med_gerth | /uge_2/opgave2_7.py | 1,572 | 4.28125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 28 12:20:09 2020
@author: JensTrolle
"""
"""
import math
n = float(input("Write a number equal to or above 1 here "
"to approximate the square root: "))
while n <= 1: # Check for
n = float(input("Yo... | true |
7042e40fc79bca2079f52355dfdf1ce45e0a8cd0 | mikebpedersen/python_med_gerth | /uge_5/opgave7_1.py | 715 | 4.3125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Exercise 7.1 (average)
"""
"""
Write a function average2(x,y) that computes the average of x and y,
i.e. (x+y)/2.
"""
def average2(x, y):
return (x+y)/2
print(average2(2, 6))
"""
Write a function list_average(L) that computes the average of the numbers in
th... | true |
ad28a851eca6e4bbf663c671666248c0f56d82d0 | mikebpedersen/python_med_gerth | /uge_4/opgave5_2.py | 490 | 4.375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Given a list of first names first = ['Donald', 'Mickey', 'Scrooge'] and last
names last = ['Duck', 'Mouse', 'McDuck'], use list comprehension, zip, and
sorted to generate an alphabetically sorted list of names
'lastname, firstname', i.e. generates the list:
['Duck, Don... | true |
1e30df646d4e07c84f2becbacc64ae255da06a6a | Suleiman99Hesham/Algorithms-Foundations | /factorial.py | 303 | 4.3125 | 4 | def power(num,pwr):
if (pwr==0):
return 1
else:
return num*(power(num,pwr-1))
def factorial(num):
if num==0:
return 1
else:
return num*factorial(num-1)
print("{} to the power of {} is {}".format(2,3,power(2,3)))
print("{}! is {} ".format(3,factorial(3))) | true |
7f8bf75aac959e0a15af1349d1a53b1c9928a39a | Isabellajones71/plhme | /animal.py | 485 | 4.25 | 4 | #Abstraction is displaying only essential information to the user and hiding
# the details from the user
class Animal():
animal_kind = "Canine"
def __init__(self,name,age):
self.name = name
self.age = age
def eat(self):
return("{}SaysI am eating Chicken".format(self.name))
# Dog1... | true |
964545ad94e3ec490a1c24a8bf40aeeb29780983 | mondaya/CodingCojo | /pythonstack/fundamentals/tasks/PythonFundamnetals/fun_with_function.py | 1,245 | 4.71875 | 5 | """
Create a function called odd_even that counts from 1 to 2000. As your loop executes have your program print the number of that iteration and specify whether it's an odd or even number.
"""
def odd_even() :
for num in range(1,2001):
if num % 2 == 1 :
print "Number is {}.".format(num), "This... | true |
d1d63d749bc4669cc9e4ca06975805fdd9a26b50 | alex-dsouza777/Python-Basics | /Chapter 5 - Dictionary & Sets/05_set_methods.py | 514 | 4.21875 | 4 | #Creating empty set
b = set()
print(type(b))
#Adding values to an empty set
b.add(4)
b.add(5)
b.add(5) #Set is a collection of non repatative items so it will print 5 only once
b.add(5)
b.add(5)
b.add((4,5,6)) #You can add touple in set
#b.add({4:5}) # Cannot add list or dictionary to sets
print(b)
#Length of set
pri... | true |
bc2db92500488ec07b4034dd8118d1b824989470 | alex-dsouza777/Python-Basics | /Chapter 7 - Loops in Python/12_pr_03.py | 202 | 4.40625 | 4 | #Program to print multiplication table of a given number using while loop
num = int(input("Enter the number "))
i=1
while i<=10:
a = num * i
print(f"{num} X {i} = {num*i}")
i=i+1
| true |
3605e055d5a03b1c1e8ea12a482e328336918086 | alex-dsouza777/Python-Basics | /Chapter 3 - Strings/09_pr_05.py | 295 | 4.15625 | 4 | #Format the following letter using escape sequence characters
#letter = "Dear Root, welcome to python course. Thank You!"
letter = "Dear Root, welcome to python course. Thank You!"
print(letter)
formatted_letter = "Dear Root, \n\tWelcome to python course.\n Thank You!"
print(formatted_letter) | true |
270444411a071df27ae14699aa4ffeab8bd4a74d | alex-dsouza777/Python-Basics | /Chapter 7 - Loops in Python/10_pr_01.py | 228 | 4.46875 | 4 | #Program to print multiplication table of a given number using for loop
num = int(input("Enter the number "))
for i in range(1, 11):
# print(str(num) + " X " +str(i) + " = " + str(i*num))
print(f"{num} X {i} = {num*i}") | true |
44ee90743a5ab2acf930418db50b534793cbec12 | alex-dsouza777/Python-Basics | /Chapter 13 - Advanced Python 2/09_pr_02.py | 459 | 4.4375 | 4 | #Write a program to input name, marks and phone number of a student and format it using the format function like below:
# “The name of the student is Root, his marks are 72 and the phone number is 99999888”
name = input("Enter Your Name: ")
marks = int(input("Enter Your Marks: "))
phone = int(input("Phone Number: "))
... | true |
becf87c41cb32dcb20746b06c89951b9b6998b03 | Mikes-new/automate-stuff | /regexStrip.py | 505 | 4.15625 | 4 | #! python3
# regexStrip.py - performs same task as strip string method, using regexStrip
import re
def regexStrip(s, side=None): # s is string to be processed; side is left/right side of string
whitespaceRegex = re.compile(r'(\s*)(\S+.*\S+)(\s*)')
mo = whitespaceRegex.match(s)
if mo == None:
return... | true |
637d88d2a950499b8b521069973da7ea65097516 | sanidhya-singh/sample-code-in-every-language | /python/quick-sort.py | 769 | 4.125 | 4 | """
SORTING ALGORITHM : QUICK SORT
TIME COMPLEXITY : O(nlogn)
"""
# implementation
def quicksort(arr):
if len(arr) <= 1: # base line for recursion
return arr
else:
pivot = arr.pop() # pivot, in this place last item in array
item_lower = [] # list having elements lower than piv... | true |
64551fe02f2c244f9a89655e4e8720c5edaae789 | ajh1143/FireCode_Solutions | /Level_1/RepeatedArrayElements.py | 620 | 4.375 | 4 | """
Write a function - duplicate_items to find the redundant or repeated items in a list and return them in sorted order.
This method should return a list of redundant integers in ascending sorted order (as illustrated below).
Examples:
duplicate_items([1, 3, 4, 2, 1]) => [1]
duplicate_items([1, 3, 4, 2, 1, 2, 4]) ... | true |
e4807875c3365081448a756183814d528622bc27 | rodneygauna/palomar-CSIT175-Python | /10/10-7.py | 719 | 4.59375 | 5 | # 10.7 - Basic Coding Skills
# 1. Code a program in a .py file that displays "Hello Python" on the console
print("Hello Python")
# 2. Change that program to use two print statements... the first displays "Hello" and the second displays "Python" on the next line of the console.
print("Hello")
print("Python")
# 3. Ch... | true |
eab2f2aa2eaafdffd80e09e80594a5f4fabafe12 | rodneygauna/palomar-CSIT175-Python | /10/gauna_asgn1.py | 1,290 | 4.65625 | 5 | # Assignment 1
# Rodney Gauna // February 5, 2021
# Please carefully read the Instructions and Grading Criteria.
# Write a program that determines approximately how many years of your life you have been asleep.
# Name your program yourlastname_asgn1.py (obviously, replace "yourlastname" with your last name!)
# 1. Coll... | true |
45f5a8f8848572354be4ed6c191dfd5d179a0b25 | PdxCodeGuild/class_mouse | /1 Python/solutions/practice1.py | 2,084 | 4.25 | 4 |
# Write a function that tells whether a number is even or odd (hint, compare a/2 and a//2, or use a%2)
def is_even(a):
if a % 2 == 0:
return True
else:
return False
# while a != 1 and a !=0:
# a //= 2
# if a == 0:
# return True
# elif a == 1:
# ... | true |
2d18633081d491981fcf8adc3a99f70bb60eff15 | Igor-Zhelezniak-1/ICS3U-Assignment-2-Python-Program | /program.py | 530 | 4.5 | 4 | #!/usr/bin/env python3
# Created by: Igor
# Created on: Oct 2021
# This program calculates the area of a rectangle
# where the user gets to enter the length and width in mm
import math
def main():
# main function
print("We will be calculating the area of a rectangle. ")
# input
length = int(input("E... | true |
27a3da7ffae3c001f3de463c3b31f0af99012de7 | QMSS-G5072-2020/cipher_Zhou_Xuanyi | /cipher_xz2959/cipher_xz2959.py | 906 | 4.40625 | 4 | def cipher(text, shift, encrypt=True):
"""
Encrypt the text using shift coding.
Args:
text (str): represent the source text
shift (int): the shift size
encrypt (bool): True for encrypt and False for decrypt
Returns:
str: represent the cipher
Examples:
... | true |
c60eb356afc847057629ec1d0365bfedfc6e93b9 | Navaneeth1706/Agile_notes | /datatype.py | 1,185 | 4.28125 | 4 | #Day2 in training
# 1. Print function displays the contents
# 2. type function display data type of the variable
no = 10
print(no)
print(type(no))
no = 4.5
print(no)
print(type(no))
result = True
print(result)
print(type(result))
name = 'navanee'
print(name)
print(type(name))
print(id(name))
no = 2
print(no)... | true |
5436afe22ed781d05b56c883689085b7c2e0ecd5 | IsFilimonov/Interviews | /LeetCode/Python/101-Symmetric_Tree.py | 1,239 | 4.25 | 4 | from typing import Optional
# Definition for a binary tree node.
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def isSymmetric(self, root: Optional[TreeNode]) -> bool:
def is_equal(L, R):
... | true |
f16f0128f3a8ef33871daddf811ee4ab20396fa7 | stur-na/wordguess_game | /word_game.py | 1,383 | 4.15625 | 4 | '''This project taught me about the open module and the readline method
and also the random shuffle method'''
#import the random shuffle module for shuffling the dictionary list
from random import shuffle
#Start game
def start_game():
print('Welcome to the word guess game, guess a word from the dictionary')
pr... | true |
4ef99db04a657a26292c03880b8656a67e96e60f | rex-mcall/Learn-Python-Course | /ex32.py | 682 | 4.59375 | 5 | the_count = [1,2,3,4,5]
fruits = ['apples', 'oranges', 'pears', 'apricots']
change = [1, 'pennies', 2, 'dimes', 3, 'quarters']
#this for loop goes through a list
for number in the_count:
print(f"This is count {number}")
for fruit in fruits:
print(f"A fruit type: {fruit}")
#We can go through mixed lists too
#We ... | true |
3dc4eaecee2a1b71b7fbeb16f7429ea04ae8e8e0 | upeismcschatbot/upeismcschatbot | /chatbot/Chatbot_Server_Code.py | 825 | 4.1875 | 4 | """
This code receives an argument from a PHP code (could be any code really though. Since a sentence is received as an array it appends
the array together to get one string called result.
It is important to note that the Website will grab the first print statement it sees and return that to the user.
THERE SHOU... | true |
a536eff68fa30383df537430136a0d8c4ad56dbc | TechArpit20/Python-Playlist | /operators1.py | 1,725 | 4.46875 | 4 | '''
Operatore are basically used to perform various operations on the values contained in different variables
Types of Operators:
1. Arithmetic operators=> Addition(+), Subtraction(-), Multiplication(*), Division(/), Modulus(%), Exponential(**), Floor Division(//)
2. Assignment => (=), (+=), (-=),
3. Comparison ... | true |
b15a11759446e52d6f0ac0a12f9f9527de5e10ea | diamondjaxx/PyNet_Test1 | /ex7_yaml_json.py | 596 | 4.1875 | 4 | #!/usr/bin/env python
'''
Write a Python program that reads both the YAML file and the JSON file created in exercise6 and pretty prints the data structure that is returned.
'''
import yaml
import json
from pprint import pprint
def main():
yaml_file = 'my_file.yml'
json_file = 'my_file.json'
with open(yam... | true |
9454af19a1bdb0c7072603a7eca55ffdb1122dbb | pirategiri/30daysOfPython | /day2/lengthcon.py | 1,836 | 4.21875 | 4 | # Python Programming Course : GUI Applications
# -Kiran Giri
# Length Converter ( Meter <-> Inch <-> Foot )
from tkinter import *
# Main window
App = Tk()
App.title("Length Converter")
App.geometry('350x150')
# Scales to be used
scales = ['Meters', 'Inches', 'Foot']
# The scale of th... | true |
8d050db21f700046e4f19488aa3beef872ab3cd6 | Prabin-Neupane/task1.py | /task5.py | 1,672 | 4.21875 | 4 | # bird = ['crows','pigeon','eagles','falcon','pigeon','falcon','falcon']
# Remove all the duplicates from the following list using while.
bird = ['crows','pigeon','eagles','falcon','pigeon','falcon','falcon']
new =[]
while bird:
x = bird.pop()
if x not in new:
new.append(x)
print(new)
#Deli: Make a lis... | true |
927338a47736e15dba2ce0efd15725f725563fd0 | analien-16/LearnCodingInPython | /Lesson-one/fibonacci.py | 255 | 4.28125 | 4 | # Write a program to generate the Fibonacci series up to a number
a, b = 0, 1
x = int (input("What is the last term you would like to display up to? " ))
print (0,1,end=' ')
while True:
c = a + b
a = b
b = c
if c > x: break
print(c, end=' ')
| true |
c754668b054d5bbe0a48f28a7c5f335d6fc6dc1a | ZandbergenM/Homework-week-5_Zandbergen | /Part 1 Exercise 9.2.py | 832 | 4.1875 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
#9.2 Write a function called has_no_e that returns True if the given word doesn't have the letter "e" in it
# Write a program that reads words.txt and prints only the words that have no "e", Compute the percentage of words in the list that have no "e"
# In[67]:
def ... | true |
a3f618fbdfbc1b9980ff08eeea6bb158437837dd | UWPCE-PythonCert-ClassRepos/Wi2018-Classroom | /students/Harry_Maher/Python210B/Session03/slicing.py | 1,191 | 4.34375 | 4 | #!/usr/bin/env python3
"""
Write some functions that take a sequence as an argument, and return a copy of that sequence:
with the first and last items exchanged.
with every other item removed.
with the first 4 and the last 4 items removed, and then every other item in between.
with the elements reverse... | true |
4c5141f78846558468c0d0063838394610fe74dc | UWPCE-PythonCert-ClassRepos/Wi2018-Classroom | /students/TracyA/session03/list_lab3.py | 602 | 4.15625 | 4 | #!/usr/bin/env python
# Programming in python B Winter 2018
# February 5, 2017
# list Lab #3
# Tracy Allen - git repo https://github.com/tenoverpar/Wi2018-Classroom
# Series 3 of list lab exercises
# Create a list with Apples, Pears, Oranges, and Peaches. Print the list.
fruits3 = ["Apples", "Pears", "Oranges", "Peac... | true |
f54058443bbc32eb2457e05b8e71ae49127e0ffc | UWPCE-PythonCert-ClassRepos/Wi2018-Classroom | /students/jchristo/session11/range_iterator_assignment.py | 1,514 | 4.5625 | 5 | #!/usr/bin/env python
import itertools
"""
Simple iterator examples
"""
class IterateMe_1:
"""
About as simple an iterator as you can get:
returns the sequence of numbers from zero to 4
( like range(4) )
"""
def __init__(self, stop=5):
self.current = -1
self.stop = stop
... | true |
ea92968b66755c86da0f93dac46e7ef7fe5a84af | UWPCE-PythonCert-ClassRepos/Wi2018-Classroom | /students/alxsk/session04/File_exercise.py | 744 | 4.25 | 4 | '''
Read file exercise
A script that reads students.txt and generates a list of the languages students know.
'''
languages=set()
with open('students.txt', 'r') as file_name:
for line in file_name:
line_split = line.split(":") #creates list
keep_lang=line_split.pop() # removes and returns la... | true |
112aa1ed121e19113544074b4fae75ae239162ed | UWPCE-PythonCert-ClassRepos/Wi2018-Classroom | /solutions/Session03/string_formatting.py | 1,647 | 4.59375 | 5 | #!/usr/bin/env python
"""
String formatting lab:
This version using the format() method
"""
#####
# Write a format string that will take the tuple:
# (2, 123.4567, 10000, 12345.67)
# and produce:
# 'file_002 : 123.46, 1.00e+04, 1.23e+04'
#####
print("file_{:03d} : {:10.2f}, {:.2e}, {:.3g}".format(2, ... | true |
eadafa5a48a4a2eba2e37d3713d21d651a9962d4 | UWPCE-PythonCert-ClassRepos/Wi2018-Classroom | /students/jchristo/session03/list_lab.py | 1,273 | 4.21875 | 4 | #List Lab
#!/usr/bin/env python3
"""
Series 1
Create a list that contains “Apples”, “Pears”, “Oranges” and “Peaches”.
Display the list (plain old print() is fine…).
Ask the user for another fruit and add it to the end of the list.
Display the list.
Ask the user for a number and display the number back to the user and ... | true |
d5e535b0b668e17c434ed6af84632736550b6e90 | UWPCE-PythonCert-ClassRepos/Wi2018-Classroom | /students/maria/test.py | 2,311 | 4.1875 | 4 | # Return a copy of the sequence given after ordering transformation.
def split(s,x):
"""Given a sequence break into three variables."""
first = s[:x]
last = s[-x:]
middle = s[x:-x]
return first, last, middle
def first_last(s):
"""Return a copy of a given sequence with first and last items swa... | true |
a42b9f46df26cdbb91b2625ee4ab6b44b55d9d89 | IshpreetKGulati/100DaysOfCode | /day7.py | 1,259 | 4.3125 | 4 | """
Monotonic Array
Write a function that takes in an array of integers and returns a boolean representing whether the array is monotonic.
An array is said to be monotonic if its elements, from left to right, are entirely non-increasing or entirely non -decreasing.
Sample Input:
array = [-1, -5, -10, -1100, -1100, -11... | true |
18bb62cde4bf84e4734d3cb1cd05ae236c57a0bb | IshpreetKGulati/100DaysOfCode | /day29.py | 1,565 | 4.1875 | 4 | """
Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image.
Example:
Input:
[
[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]
]
Output: [1,2,4,7,5,3,6,8,9]
Explanation:
Will share image in whatsapp group
Note:
The total number of elements of th... | true |
83462da197bb2f281be4cb41779ea530cdf64fa9 | eduOSS/configuration_files | /Documents/python/git/forExce/guessNumber.py | 1,896 | 4.21875 | 4 | #template for "Guess the number" mini-project
# input will come from buttons and an input field
# all output for the game will be printed in the console
import random
import simplegui
# initialize global variables used in your code
range_num = 100
# helper function to start and restart the game
def new_game(... | true |
b1bfaeefd86ff33e4f6435d12811422df64d7741 | Joey-Marcotte/ICS3U-Unit4-03-Python | /to_the_power_of.py | 712 | 4.5 | 4 | #!/usr/bin/env python3
# Created by: Joey Marcotte
# Created on: October 2019
# This program shows the factorial of a number
def main():
power_of_number = 0
total_number = 0
# input
number = input("Input the number: ")
try:
number_as_number = int(number)
if number_as_number ... | true |
20311467d24015b8ebcc512a6c899f163a142d5b | Lwarren51/cti110 | /P3HW2_SoftwareSales_WarrenLorenzo.py | 1,898 | 4.1875 | 4 | # CTI-110
# P3HW2 - Software Sales
# Lorenzo Warren
# March 11, 2018
# Get the quantity of the packages purchased 1.
quantity10_19 = float(input('Enter the number of packages purchased 1: '))
# Calculate the amount the discount total purchased.
discount = quantity10_19 * 99
# Display the discount.
print('The discoun... | true |
51fc1d9a5e2f1933b89a9a9874c86a41f1b37b58 | sbtries/Class_Polar_Bear | /Code/Ryan/python/python3_lab_1.py | 1,403 | 4.15625 | 4 | score = input('Please enter a number representing the score (0-100): ')
# Need to do an input validation if a letter is typed in this will be taught in 102 and requires
# a 'try' / 'except' structure to see if using the float() function on the str would produce an error.
try:
score = float(score)
except ValueError:... | true |
6f4fbbe0cec197d63d5f8b212595075817e45bd9 | sbtries/Class_Polar_Bear | /Code/Ryan/python/blackjack_advice.py | 2,404 | 4.375 | 4 | # Let's write a python program to give basic blackjack playing advice during a game by asking the player for cards. First, ask the user for three playing cards (A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, or K). Then, figure out the point value of each card individually. Number cards are worth their number, all face cards are... | true |
c9ecc1d15bc842832d7845476a70018f99b961f8 | sbtries/Class_Polar_Bear | /2 Python/demo/hello.py | 359 | 4.1875 | 4 | "Hello" # string
4 # int
2.5 # float
True # boolean / False
None # none
x = input("Enter a number: ")
try:
x = int(x)
except ValueError:
print("That was not a number...")
exit()
if x > 0:
print("This number is positive")
print("😎")
elif x == 0:
print('The number is 0')
else:... | true |
66c40980c69ca5004482cf638ff8c92172a15288 | Shingirai98/Digital-Factorial-Summer- | /factorial-digits.py | 1,128 | 4.125 | 4 | # -------------------------------------------------------
# | Name: Digital Factorial Sum |
# | @Author: Shingirai Denver Maburutse |
# | Date: 18/07/2021 |
# -----------------------------------------------------
import numpy as n... | true |
826c4375823225cd442946ed45c02ee9a87f0b9d | raadzi/comp110-21ss1-workspace | /projects/pj01/data_utils.py | 1,699 | 4.125 | 4 | """Data utility functions."""
__author__ = "730429363"
from csv import DictReader
def read_csv_rows(path: str) -> list[dict[str, str]]:
"""Read a CSV file and return a table that is a list of its rows (dicts)."""
file_handle = open(path, "r", encoding="utf8")
csv_reader = DictReader(file_handle)
ta... | true |
94d312e5bde0f084dd1fb9351e04ef5c4d408542 | Zhaoyubao/Onsite-Python | /Python OOP/Bike.py | 807 | 4.1875 | 4 | class Bike(object):
def __init__(self, price, max_speed):
self.price = price
self.max_speed = max_speed
self.miles = 0
def displayinfo(self):
print "Bike's Price:", self.price
print "Bike's Maximum Speed:", self.max_speed
if self.miles < 0:
self.miles ... | true |
bf50bc2d83fc835fe197b3b0a6031eb875a37970 | green-fox-academy/Simon--Kerub88 | /week-04/day-3/E_02_Sum.py | 696 | 4.21875 | 4 | # Create a sum method in your class which has a list of integers as parameter
# It should return the sum of the elements in the list
# Follow these steps:
# Add a new test case
# Instantiate your class
# create a list of integers
# use the assertEquals to test the result of the created sum method
# Run ... | true |
162050d2f9723d5194ccbb8b654f100809ab0cc5 | green-fox-academy/Simon--Kerub88 | /week-02/day-5/Guess_my_number.py | 1,978 | 4.3125 | 4 | # Write a program where the program chooses a number between 1 and 100. The player is then asked to enter a guess. If the player guesses wrong, then the program gives feedback and ask to enter an other guess until the guess is correct.
#
# Make the range customizable (ask for it before starting the guessing).
# You can... | true |
53b5bd025757649396f7dce0f3321fa6bb8925c1 | green-fox-academy/Simon--Kerub88 | /week-02/day-2/E_11_seconds-in-a-day.py | 399 | 4.28125 | 4 | current_hours = 14;
current_minutes = 34;
current_seconds = 42;
# Write a program that prints the remaining seconds (as an integer) from a
# day if the current time is represented bt the variables
TotalDaySeconds = 60*60*24
print(TotalDaySeconds)
current_seconds = (14*60*60) + (34*60) + 42
print(current_seconds)
prin... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.