blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
cc0b8ef1943eb8b6b5b42870be3387bbde4f8001 | MindCC/ml_homework | /Lab02/Question/lab2_Point.py | 2,008 | 4.46875 | 4 | # -*- coding: cp936 -*-
'''
ID:
Name:
'''
import math
class Point:
'''
Define a class of objects called Point (in the two-dimensional plane).
A Point is thus a pair of two coordinates (x and y).
Every Point should be able to calculate its distance
to any other Point once the second point is speci... | true |
0b57a9545507ed95c6f205e680e6436645fffc68 | jacareds/Unis | /2020.4_Atv2_Exer5.py | 278 | 4.25 | 4 | #Escreva uma função que:
#a) Receba uma frase como parâmetro.
#b) Retorne uma nova frase com cada palavra com as letras invertidas.
def inverText(text):
inversor = (text)
print(inversor[::-1])
entradInput = str(input("Digite uma frase: "))
inverText(entradInput)
| false |
dc7c432deb82bf1f07e3f6e2b0632fb515c5ed62 | DiegoAyalaH/Mision-04 | /Rectangulos.py | 1,626 | 4.25 | 4 | #Nombre Diego Armando Ayala Hernández
#Matrícula A01376727
#resumen del programa: Obtiene los datos de dos rectangulos y te da el area y el perimetor de ambos
#Calcula el área de un rectángulo
def calcularArea(altura, ancho):
area = altura * ancho
return area
#Calcula el perímetro de un rectángulo
def calcu... | false |
d29faa39dec07a25caa6383e0ecbe35edebbb4c5 | AusCommsteam/Algorithm-and-Data-Structures-and-Coding-Challenges | /Challenges/minimumDominoRotationsForEqualRow.py | 2,392 | 4.4375 | 4 | """
Minimum Domino Rotations For Equal Row
In a row of dominoes, A[i] and B[i] represent the top and bottom halves of the i-th domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.)
We may rotate the i-th domino, so that A[i] and B[i] swap values.
Return the minimum number of rota... | true |
1b399e72edc812253cacad330840ed59cf0194c9 | AusCommsteam/Algorithm-and-Data-Structures-and-Coding-Challenges | /Challenges/diameterOfBinaryTree.py | 1,290 | 4.3125 | 4 | """
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root.
Example:
Given a binary tree
1
/ \
2 3
/ \
... | true |
f490e6054c9d90343cab89c810ca2c649d8138fe | AusCommsteam/Algorithm-and-Data-Structures-and-Coding-Challenges | /Challenges/mergeIntervals.py | 1,167 | 4.125 | 4 | """
Merge Intervals
Given a collection of intervals, merge all overlapping intervals.
Example 1:
Input: [[1,3],[2,6],[8,10],[15,18]]
Output: [[1,6],[8,10],[15,18]]
Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6].
Example 2:
Input: [[1,4],[4,5]]
Output: [[1,5]]
Explanation: Intervals [1,... | true |
d86c8afbca66bd1b0731b02fbb2c1bbf551c2615 | AusCommsteam/Algorithm-and-Data-Structures-and-Coding-Challenges | /Challenges/reverseLinkedList.py | 2,118 | 4.21875 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def reverseList(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
new_head = None
while head:
he... | false |
99e25be34833e876da74bb6f53a62edf745be9a5 | AusCommsteam/Algorithm-and-Data-Structures-and-Coding-Challenges | /Challenges/sortedSquares.py | 2,053 | 4.25 | 4 | """
Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order.
Example 1:
Input: [-4,-1,0,3,10]
Output: [0,1,9,16,100]
Example 2:
Input: [-7,-3,2,3,11]
Output: [4,9,9,49,121]
Note:
1 <= A.length <= 10000
-10000 <= A[i] <= 10... | true |
33e938d5592965fa2c772c5c958ced297ee18955 | AusCommsteam/Algorithm-and-Data-Structures-and-Coding-Challenges | /Challenges/flipEquivalentBinaryTree.py | 1,531 | 4.1875 | 4 | """
Flip Equivalent Binary Trees
For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left and right child subtrees.
A binary tree X is flip equivalent to a binary tree Y if and only if we can make X equal to Y after some number of flip operations.
Write a function that deter... | true |
302f7ed1d4569abaf417efddff2c2b1721146207 | AusCommsteam/Algorithm-and-Data-Structures-and-Coding-Challenges | /Challenges/maxStack.py | 2,794 | 4.25 | 4 | """
Max Stack
Design a max stack that supports push, pop, top, peekMax and popMax.
push(x) -- Push element x onto stack.
pop() -- Remove the element on top of the stack and return it.
top() -- Get the element on the top.
peekMax() -- Retrieve the maximum element in the stack.
popMax() -- Retrieve the maximum element i... | true |
5851ff675353f950e8a9a1c730774a35ab54b8db | AusCommsteam/Algorithm-and-Data-Structures-and-Coding-Challenges | /Challenges/stringConversion.py | 2,321 | 4.25 | 4 | """
Given 2 strings s and t, determine if you can convert s into t. The rules are:
You can change 1 letter at a time.
Once you changed a letter you have to change all occurrences of that letter.
Example 1:
Input: s = "abca", t = "dced"
Output: true
Explanation: abca ('a' to 'd') -> dbcd ('c' to 'e') -> dbed ('b' to '... | true |
de1cdd7c24ce9e56af7baaf562ad915960eb246d | AusCommsteam/Algorithm-and-Data-Structures-and-Coding-Challenges | /Challenges/uniquePaths.py | 1,433 | 4.15625 | 4 | """
Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).
The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).
How many possible unique paths ... | true |
e81fb3440413a2ca42df459fec604df7d2aad8b8 | AusCommsteam/Algorithm-and-Data-Structures-and-Coding-Challenges | /Challenges/largestSubarrayLengthK.py | 1,764 | 4.1875 | 4 | """
Largest Subarray Length K
Array X is greater than array Y if the first non matching element in both
arrays has a greater value in X than Y.
For example:
X = [1, 2, 4, 3, 5]
Y = [1, 2, 3, 4, 5]
X is greater than Y because the first element that does not match is larger in X.
and if
A = [1, 4, 3, 2, 5] and K = 4... | true |
2b4e64d837993111fde673235c80dc26e3ded912 | AusCommsteam/Algorithm-and-Data-Structures-and-Coding-Challenges | /Challenges/reconstructItinerary.py | 2,112 | 4.375 | 4 | """
Reconstruct Itinerary
Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK. Thus, the itinerary must begin with JFK.
Note:
If there are multiple valid itineraries, you should ... | true |
aeab15f7f34cbad76d3a883e44b0883a1666e4d7 | nixis-institute/practice | /python/bhawna/week.py | 352 | 4.125 | 4 | number=int(input("enter the number"))
if number==1:
print("monday")
elif number==2:
print("tuesday")
elif number==3:
print("wednesday")
elif number==4:
print("thursday")
elif number==5:
print("friday")
elif number==6:
print("saturday")
elif number==7:
print("sunday")
else:
... | false |
768b7b2bb0dd863b28c6ff657a3819fc4ae6162a | akuks/Python3.6---Novice-to-Ninja | /Ch9/09-FileHandling-01.py | 634 | 4.21875 | 4 | import os
# Prompt User to Enter the FileName
fileName = str(input("Please Enter the file Name: "))
fileName = fileName.strip()
while not fileName:
print("Name of the File Cannot be left blank.")
print("Please Enter the valid Name of the File.")
fileName = str(input("Please Enter the file Name: "))
f... | true |
848ff8ae6cb99f3f6b768df53ebd4d9fd9486cfe | akuks/Python3.6---Novice-to-Ninja | /Ch8/08-tuple-01.py | 204 | 4.125 | 4 | # Create Tuple
tup = (1, 2, 3, "Hello", "World")
print(tup)
# Looping in Tuple
for item in tup:
print (item)
# in operator
b = 4 in tup
print(b)
# Not in Operator
b = 4 not in tup
print (b)
| true |
bbed894c316e17e8cdbde0ed2d0db28ddd6d2285 | pbscrimmage/thinkPy | /ch5/is_triangle.py | 1,108 | 4.46875 | 4 | '''
is_triangle.py
Author: Patrick Rummage
[patrickbrummage@gmail.com]
Objective:
1. Write a function is_triangl that takes three integers as
arguments, and prints either "yes" or "no" depending on
whether a triangle may be formed from the given lengths.
2. Write a function that promp... | true |
a3338b41d3399b462b32674111f28e465782f6f2 | abbye1093/AFS505 | /AFS505_U1/assignment3/ex16.py | 1,309 | 4.4375 | 4 | #reading and writing files
#close: closes the file, similar to file > save
#read: reads contents of files
#readline: reads just one readline
#truncate: empties the file
#write('stuff') : writes 'stuff' to file
#seek(0): moves the read/write location to the beginning of the files
from sys import argv
script,... | true |
72d72c40a3279d64be8b7677e71761aed1b7155f | ggggg/PythonAssignment- | /exchange.py | 452 | 4.1875 | 4 | # get currency
print('enter currency, USD or CAD:')
currency = input().upper()
# get the value
print('Enter value:')
value = float(input())
# usd
if (currency == 'USD'):
# make calculation and output result
print('The value in CAD is: $' + str(value * 1.27))
# cad
elif (currency == 'CAD'):
# make calculation an... | true |
efea3fc1186254cd2a2b40171114de6af466a8cd | angelaannjaison/plab | /15.factorial using function.py | 312 | 4.21875 | 4 | def fact(n):
f=1
if n==0:print("The factorial of ",n,"is 1")
elif(n<0):print("factorial does not exit for negative numbers")
else:
for i in range(1,n+1):
f=f*i
print("The factorial of ",n,"is",f)
n=int(input("To find factorial:enter a number = "))
fact(n) | true |
754c02472453ab001c18bb13f5118aa0851ada80 | angelaannjaison/plab | /17.pyramid of numbers.py | 258 | 4.15625 | 4 | def pyramid(n):
for i in range(1,n+1):#num of rows
for j in range(1,i+1):#num of columns
print(i*j,end=" ")
print("\n")#line space
n=int(input("To construct number pyramid:Enter number of rows and columns: "))
pyramid(n) | true |
e500b5ef5f72359ba07c06ed10ec2b3e12dabfb6 | angelaannjaison/plab | /to find largest of three numbers.py | 297 | 4.1875 | 4 | print("To find the largest among three numbers")
A = int(input("Enter first number = "))
B = int(input("Enter second number = "))
C = int(input("Enter third number = "))
if A>B and A>C:
print(A," is greatest")
elif B>C:
print(B," is greatest")
else:
print(C,"is greatest")
| true |
8e3aeedca99b9abff8282876fbf5b655c1f10a76 | mtouhidchowdhury/CS1114-Intro-to-python | /Homework 3/hw3q4.py | 787 | 4.46875 | 4 | #homework 3 question 4
#getting the input of the sides
a = float(input("Length of first side: "))
b = float(input("Length of second side: "))
c = float(input("Length of third side: "))
if a == b and b == c and a ==c :# if all sides equal equalateral triangle
print("This is a equilateral triangle")
elif ... | true |
e2836dded795cfd45e297f05d467e04c35901858 | mtouhidchowdhury/CS1114-Intro-to-python | /Homework 7/hw7q3.py | 1,710 | 4.1875 | 4 |
#importing module
import random
#generating a random number and assign to a variable
randomNumber = random.randint(1,100)
#set number of guesses to 0 and how many remain to 5
numberGuesses= 0
guessRemain = 5
#first guess
userGuess = int(input("please enter a number between 1 and 100: "))
# minus from guess ... | true |
a12107517ff64eb1332b2dcfcbe955419bc5d935 | kelvin5hart/calculator | /main.py | 1,302 | 4.15625 | 4 | import art
print(art.logo)
#Calculator Functions
#Addition
def add (n1, n2):
return n1 + n2
#Subtraction
def substract (n1, n2):
return n1 - n2
#Multiplication
def multiply (n1, n2):
return n1 * n2
#Division
def divide(n1, n2):
return n1 / n2
opperators = {
"+": add,
"-":substract,
"*": multiply,... | true |
36f1263ebdbaf546d5e6b6ad874a0f8fc51ef65a | andredupontg/PythonInFourHours | /pythonInFourHours.py | 1,628 | 4.1875 | 4 | # Inputs and Outputs
"""
name = input("Hello whats your name? ")
print("Good morning " + name)
age = input("and how old are you? ")
print("thats cool")
"""
# Arrays
"""
list = ["Volvo", "Chevrolet", "Audi"]
print(list[2])
"""
# Array Functions
"""
list = ["Volvo", "Chevrolet", "Audi"]
list.insert(1, "Corona")
list.remo... | true |
f4ac6f727eda468a18aaaeb59489940150419e63 | Tanushka27/practice | /Class calc.py | 423 | 4.125 | 4 | print("Calculator(Addition,Subtraction,Multiplication and Division)")
No1=input("Enter First value:")
No1= eval(No1)
No2= input("Enter Second value:")
No2= eval(No2)
Sum= No1+No2
print (" Sum of both the values=",Sum)
Diff= No1-No2
print("Difference of both values=",Diff)
prod= No1*No2
print("Product of both the values... | true |
9ab6fc2ba3ae33bc507d257745279687926d62d2 | khushbooag4/NeoAlgo | /Python/ds/Prefix_to_postfix.py | 1,017 | 4.21875 | 4 | """
An expression is called prefix , if the operator appears in the expression before the operands. (operator operand operand)
An expression is called postfix , if the operator appears in the expression after the operands . (operand operand operator)
The program below accepts an expression in prefix and outputs the cor... | true |
9adc4c2e16a6468b7c39231425c0c7f2a3b6f843 | khushbooag4/NeoAlgo | /Python/ds/Sum_of_Linked_list.py | 2,015 | 4.25 | 4 | """
Program to calculate sum of linked list.
In the sum_ll function we traversed through all the functions of the linked list and calculate
the sum of every data element of every node in the linked list.
"""
# A node class
class Node:
# To create a new node
def __init__(self, data):
self.data = data
... | true |
ca903edb902b818cd3cda5ad5ab975f12f99d467 | khushbooag4/NeoAlgo | /Python/search/three_sum_problem.py | 2,643 | 4.15625 | 4 | """
Introduction:
Two pointer technique is an optimization technique which is a really clever way of using
brute-force to search for a particular pattern in a sorted list.
Purpose:
The code segment below solves the Three Sum Problem. We have to find a triplet out of the
given li... | true |
f9e6bfee3042b3a877fe84856ed539acc1c6f687 | khushbooag4/NeoAlgo | /Python/math/Sieve-of-eratosthenes.py | 980 | 4.21875 | 4 | '''
The sieve of Eratosthenes is an algorithm for finding
all prime numbers up to any given limit. It is
computationally highly efficient algorithm.
'''
def sieve_of_eratosthenes(n):
sieve = [True for i in range(n + 1)]
p = 2
while p ** 2 <= n:
if sieve[p]:
i = p * p
whil... | false |
8d08dac477e5b8207c351650fef30b64da52c64a | khushbooag4/NeoAlgo | /Python/math/roots_of_quadratic_equation.py | 1,544 | 4.34375 | 4 | ''''
This is the simple python code for finding the roots of quadratic equation.
Approach : Enter the values of a,b,c of the quadratic equation of the form (ax^2 bx + c )
the function quadraticRoots will calculate the Discriminant , if D is greater than 0 then it will find the roots and print them otherwise it will ... | true |
e88f786eb63150123d9aba3a3dd5f9309d825ca1 | khushbooag4/NeoAlgo | /Python/math/positive_decimal_to_binary.py | 876 | 4.59375 | 5 | #Function to convert a positive decimal number into its binary equivalent
'''
By using the double dabble method, append the remainder
to the list and divide the number by 2 till it is not
equal to zero
'''
def DecimalToBinary(num):
#the binary equivalent of 0 is 0000
if num == 0:
print('0000')
r... | true |
170fef88011fbda1f0789e132f1fadb71ebca009 | khushbooag4/NeoAlgo | /Python/cp/adjacent_elements_product.py | 811 | 4.125 | 4 | """
When given a list of integers,
we have to find the pair of adjacent
elements that have the largest product
and return that product.
"""
def MaxAdjacentProduct(intList):
max = intList[0]*intList[1]
a = 0
b = 1
for i in range(1, len(intList) - 1):
if(intList[i]*intList[i+1] > max):
... | true |
99f2401aa02902befcf1ecc4a60010bb8f02bc32 | khushbooag4/NeoAlgo | /Python/other/stringkth.py | 775 | 4.1875 | 4 | '''
A program to remove the kth index from a string and print the remaining string.In case the value of k
is greater than length of string then return the complete string as it is.
'''
#main function
def main():
s=input("enter a string")
k=int(input("enter the index"))
l=len(s)
#Check whether the ... | true |
e45468bee33c3ba54bed011897de4c87cdf5b669 | GerardProsper/Python-Basics | /Lesson 1_10102020.py | 2,366 | 4.3125 | 4 |
## Intro to Python Livestream - Python Basics with Sam
name = 'Gerard'
####print(name)
##
##for _ in range(3):
## print(name)
##
##for i in range(1,5):
## print(i)
l_5=list(range(5))
##
##for i in range(2,10,2):
## print(i)
##for num in l_5:
## print(num)
## print... | false |
a5336ab6b2ac779752cab97aee3dcca16237a4d7 | dkrajeshwari/python | /python/prime.py | 321 | 4.25 | 4 | #program to check if a given number is prime or not
def is_prime(N):
if N<2:
return False
for i in range (2,N//2+1):
if N%i==0:
return False
return True
LB=int(input("Enter lower bound:"))
UB=int(input("Enter upper bound:"))
for i in range(LB,UB+1):
if is_prime(i):
print(i... | true |
204a83101aee7c633893d87a111785c3884829de | dkrajeshwari/python | /python/bill.py | 376 | 4.125 | 4 | #program to calculate the electric bill
#min bill 50rupee
#1-500 6rupees/unit
#501-1000 8rupees/unit
#>1000 12rupees/unit
units=int(input("Enter the number of units:"))
if units>=1 and units<=500:
rate=6
elif units>=501 and units<=1000:
rate=8
elif units>1000:
rate=12
amount=units*rate
if amount<50:
amou... | true |
458273bb73e4b98f097fbb87cfa531f994f55fc7 | vaishnavi59501/DemoRepo1 | /samplescript.py | 2,635 | 4.59375 | 5 | #!/bin/python3
#this scipt file contains list,tuple,dictionary and implementation of functions on list,tuple and Dictionary
#list
#list is collection of objects of different types and it is enclosed in square brackets.
li=['physics', 'chemistry', 1997, 2000]
list3 = ["a", "b", "c", "d"]
print(li[1]) #accessing first ... | true |
46d85c6a471072788ab8ec99470f0b27e9d1939d | cscosu/ctf0 | /reversing/00-di-why/pw_man.py | 1,614 | 4.125 | 4 | #!/usr/bin/env python3
import sys
KEY = b'\x7b\x36\x14\xf6\xb3\x2a\x4d\x14\x19'
SECRET = b'\x13\x59\x7a\x93\xca\x49\x22\x79\x7b'
def authenticate(password):
'''
Authenticates the user by checking the given password
'''
# Convert to the proper data type
password = password.encode()
# We... | true |
438658b5f7165211e7ec5dec55b63097c5852ede | alshore/firstCapstone | /camel.py | 527 | 4.125 | 4 | #define main function
def main():
# get input from user
# set to title case and split into array
words = raw_input("Enter text to convert: ").title().split()
# initialize results variable
camel = ""
for word in words:
# first word all lower case
if word == words[0]:
word = word.lower()
# add word to re... | true |
33735735d54ebe3842fca2fa506277e2cd529734 | georgemarshall180/Dev | /workspace/Python_Play/Shakes/words.py | 1,074 | 4.28125 | 4 | # Filename:
# Created by: George Marshall
# Created:
# Description: counts the most common words in shakespeares complete works.
import string
# start of main
def main():
fhand = open('shakes.txt') # open the file to analyzed.
counts = dict() # this is a dict to hold the words and the number of them.
... | true |
d85ef4cc9b3ec8018e4f060a1d5185782dcff088 | vikasb7/DS-ALGO | /same tree.py | 829 | 4.15625 | 4 | '''
Vikas Bhat
Same Tree
Type: Tree
Time Complexity: O(n)
Space Complexity: O(1)
'''
class TreeNode:
def __init__(self,val=0,left=None,right=None):
self.left=left
self.right=right
self.val=val
class main:
#Recursive
def sameTree(self,root1,root2):
if root1 and not ... | false |
3623a3d7e5497f9e4ce80cf559e0fdfa085c109b | Mohith22/CryptoSystem | /key_est.py | 1,438 | 4.15625 | 4 | #Diffie Helman Key Exchange
#Author : Mohith Damarapati-BTech-3rd year-NIT Surat-Computer Science
#Establishment Of Key
#Functionalities :
#1. User can initiate communication through his private key to get secretly-shared-key
#2. User can get secretly shared-key through his private key
#For Simplicity Choose -
#Pr... | false |
ddbedd13893047ab7611fe8d1b381575368680a6 | ryanSoftwareEngineer/algorithms | /arrays and matrices/49_group_anagrams.py | 1,408 | 4.15625 | 4 | '''
Given an array of strings strs, group the anagrams together. You can return the answer in any order.
An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically
using all the original letters exactly once.
Input: strs = ["eat","tea","tan","ate","nat","bat"]
Output: [["... | true |
57cd15146c5a663a0ccaa74d2187dce5c5dc6962 | PabloLSalatic/Python-100-Days | /Days/Day 2/Q6.py | 498 | 4.1875 | 4 | print('------ Q 6 ------')
# ?Write a program that accepts sequence of lines as input and prints the lines after making all characters in the sentence capitalized.
# ?Suppose the following input is supplied to the program:
# ?Hello world
# ?Practice makes perfect
# *Then, the output should be:
# *HELLO WORLD
# *PRACT... | true |
7902ec6be552b5e44af3e0c73335acd52c7cb3e7 | 44858/lists | /Bubble Sort.py | 609 | 4.28125 | 4 | #Lewis Travers
#09/01/2015
#Bubble Sort
unsorted_list = ["a", "d", "c", "e", "b", "f", "h", "g"]
def bubble_sort(unsorted_list):
list_sorted = False
length = len(unsorted_list) - 1
while not list_sorted:
list_sorted = True
for num in range(length):
if unsorted_l... | true |
90b59d5607388d4f18382624219a9fcfd7c9cf17 | LorenzoY2J/py111 | /Tasks/d0_stairway.py | 675 | 4.3125 | 4 | from typing import Union, Sequence
from itertools import islice
def stairway_path(stairway: Sequence[Union[float, int]]) -> Union[float, int]:
"""
Calculate min cost of getting to the top of stairway if agent can go on next or through one step.
:param stairway: list of ints, where each int is a cost of ap... | true |
15242cc4f007545a85c3d7f65039678617051231 | LorenzoY2J/py111 | /Tasks/b1_binary_search.py | 841 | 4.1875 | 4 | from typing import Sequence, Optional
def binary_search(elem: int, arr: Sequence) -> Optional[int]:
"""
Performs binary search of given element inside of array
:param elem: element to be found
:param arr: array where element is to be found
:return: Index of element if it's presented in the arr, N... | true |
7941328e4cb2d286fefd935541e2dab8afde61c0 | SACHSTech/ics2o1-livehack---2-Maximilian-Schwarzenberg | /problem2.py | 771 | 4.59375 | 5 | """
-------------------------------------------------------------------------------
Name: problem2.py
Purpose: To check if the inputted sides form a triangle.
Author: Schwarenberg.M
Created: 23/02/2021
------------------------------------------------------------------------------
"""
# Welcome message
print("Welcome ... | true |
9b3495345e4f4ad9648dcca17a8288e62db1220e | sriniverve/Python_Learning | /venv/tests/conditions.py | 271 | 4.21875 | 4 | '''
This is to demonstrate the usage of conditional operators
'''
temperature = input('Enter the temperature:')
if int(temperature) > 30:
print('This is a hot day')
elif int(temperature) < 5:
print('This is a cold day')
else:
print('This is a pleasant day') | true |
1140a8dd58988892ecca96673ffe3d2c1bf44564 | sriniverve/Python_Learning | /venv/tests/guessing_number.py | 395 | 4.21875 | 4 | '''
This is an example program for gussing a number using while loop
'''
secret_number = 9
guess_count = 0
guess_limit = 3
while guess_count < guess_limit:
guess_number = int(input('Guess a number: '))
guess_count += 1
if guess_number == secret_number:
print('You guessed it right. You Win!!!')
... | true |
01b3319010f240b6ddfdd0b5ae3e07f201a9a046 | sriniverve/Python_Learning | /venv/tests/kg2lb_converter.py | 285 | 4.21875 | 4 | '''
This program is to take input in KGs & display the weight in pounds
'''
weight_kg = input('Enter your weight in Kilograms:') #prompt user input
weight_lb = 2.2 * float(weight_kg) #1 kg is 2.2 pounds
print('You weight is '+str(weight_lb)+' pounds')
| true |
23d110cff79eb57616586da7f78c7ac6d4e7a957 | vmmc2/Competitive-Programming | /Sets.py | 1,369 | 4.4375 | 4 | #set is like a list but it removes repeated values
#1) Initializing: To create a set, we use the set function: set()
x = set([1,2,3,4,5])
z = {1,2,3}
#To create an empty set we use the following:
y = set()
#2) Adding a value to a set
x.add(3)
#The add function just works when we are inserting just 1 element into our ... | true |
768ce4a45879ad23c94de8d37f33f7c8c50dca24 | AmangeldiK/lesson3 | /kall.py | 795 | 4.1875 | 4 | active = True
while active:
num1 = int(input('Enter first number: '))
oper = input('Enter operations: ')
num2 = int(input('Enter second number: '))
#dict_ = {'+': 'num1 + num2', '-': 'num1 - num2', '*': 'num1 * num2', '/': 'num1 / num2'}
if oper == '+':
print(num1+num2)
elif oper == '-... | true |
230616616f10a6207b4a407b768afaabb846528a | SynthetiCode/EasyGames-Python | /guessGame.py | 744 | 4.125 | 4 | #This is a "Guess the number game"
import random
print('Hello. What is your nombre?')
nombre = input()
print('Well, ' + nombre + ', I am thining of a numero between Uno(1) y Veinte(20)')
secretNumber =random.randint(1,20)
#ask player 6 times
for guessesTaken in range(0, 6):
print ('Take a guess:' )
guess = int(inpu... | true |
fb038cc7201cd3302a5eeedf9fd86511d6ff2cf6 | mdanassid2254/pythonTT | /constrector/hashing.py | 422 | 4.65625 | 5 | # Python 3 code to demonstrate
# working of hash()
# initializing objects
int_val = 4
str_val = 'GeeksforGeeks'
flt_val = 24.56
# Printing the hash values.
# Notice Integer value doesn't change
# You'l have answer later in article.
print("The integer hash value is : " + str(hash(int_val)))
print("The stri... | true |
0e6b136b69f36b75e8088756712889eb45f1d24a | Kaden-A/GameDesign2021 | /VarAndStrings.py | 882 | 4.375 | 4 | #Kaden Alibhai 6/7/21
#We are learning how to work with strings
#While loop
#Different type of var
num1=19
num2=3.5
num3=0x2342FABCDEBDA
#How to know what type of date is a variable
print(type(num1))
print(type(num2))
print(type(num3))
phrase="Hello there!"
print(type(phrase))
#String functions
num=len(phrase)
print(p... | true |
f7aac03275b43a35f790d9698b94e76f93207e7d | abokareem/LuhnAlgorithm | /luhnalgo.py | 1,758 | 4.21875 | 4 | """
------------------------------------------
|Luhn Algorithm by Brian Oliver, 07/15/19 |
------------------------------------------
The Luhn Algorithm is commonly used to verify credit card numbers, IMEI numbers, etc...
Luhn makes it possible to check numbers (credit card, SIRET, etc.) via a control key (... | true |
a0d900a3e43322ab1e994aa82f74a5d759e8260a | AlSavva/Python-basics-homework | /homework3-4.py | 2,163 | 4.21875 | 4 | # Программа принимает действительное положительное число x и целое
# отрицательное число y. Необходимо выполнить возведение числа x в степень y.
# Задание необходимо реализовать в виде функции my_func(x, y). При
# решении задания необходимо обойтись без встроенной функции возведения числа
# в степень.
# Подсказка:... | false |
a8051d4c26e31ecb5a315948a9e3bdad44975aec | catdog001/leetcode_python | /Tree/leetcode_tree/easy/226.py | 1,546 | 4.15625 | 4 | """
翻转一棵二叉树。
示例:
输入:
4
/ \
2 7
/ \ / \
1 3 6 9
输出:
4
/ \
7 2
/ \ / \
9 6 3 1
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/invert-binary-tree
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
"""
class TreeNode(object):
def __init__(self, val):
self.val = val
... | false |
f4e4beb1d2975fd523ca7dd744aa7a96e686373a | WeiyiDeng/hpsc_LinuxVM | /lecture7/debugtry.py | 578 | 4.15625 | 4 | x = 3
y = 22
def ff(z):
x = z+3 # x here is local variable in the func
print("+++ in func ff, x = %s; y = %s; z = %s") %(x,y,z)
return(x) # does not change the value of x in the main program
# to avoid confusion, use a different symbol (eg. u) instead of x in the function
pr... | true |
6f6a83c6661a2d80a173c1e8b069004e7e8ca744 | MisterHat-89/geekBrainsPython | /Lesson_5/exam_2.py | 577 | 4.21875 | 4 | # 2. Создать текстовый файл (не программно), сохранить в нем несколько строк,
# выполнить подсчет количества строк, количества слов в каждой строке.
text = ""
f_file = open(r'dz2.txt', 'r')
print(f_file.read())
print("")
count_words = 0
lines = 0
f_file.seek(0)
for line in f_file.readlines():
lines += 1
count... | false |
f91c87f85bb2a97e6dea6d3e0d622ad4b003e239 | rasooll/Python-Learning | /azmoon4/part2.py | 364 | 4.34375 | 4 | def find_longest_word(input_string):
maxlen = 0
maxword = ""
input_list = input_string.split()
#print (input_list)
for word in input_list:
#print (len(word))
if len(word) >= maxlen:
maxlen = len(word)
maxword = word
#print (maxlen, maxword)
return maxword
print (find_longest_word("salam in ye matn az... | false |
1269f7390bfc63e8962b3bda78a114500e5f03fa | Nilesh2000/CollegeRecordWork | /Semester 2/Ex12d.py | 1,087 | 4.25 | 4 | myDict1 = {'Name':'Nilesh', 'RollNo':69, 'Dept':'IT', 'Age':18}
#print dictionary
print("\nDictionary elements : ", myDict1)
#Printing Values by passing keys
print("Student department : ", myDict1['Dept'])
#Editing dictionary elements
myDict1['Dept']="CSE"
print("After Editing dictionary elements : " , myDict1)
#Ad... | false |
f0778146abc57271d1587461b9893289fd65dc86 | bedoyama/python-crash-course | /basics/ch4__WORKING_WITH_LISTS/2_first_numbers.py | 358 | 4.375 | 4 | print("range(1,5)")
for value in range(1, 5):
print(value)
print("range(0,7)")
for value in range(0, 7):
print(value)
print("range(7)")
for value in range(7):
print(value)
print("range(3,7)")
for value in range(3, 7):
print(value)
print("range(-1,2)")
for value in range(-1, 2):
print(value)
num... | true |
8b8e3c886a6d3acf6a0c7718919c56f354c3c912 | bedoyama/python-crash-course | /basics/ch5__IF_STATEMENTS/3_age.py | 338 | 4.15625 | 4 | age = 42
if age >= 40 and age <= 46:
print('Age is in range')
if (age >= 40) and (age <= 46):
print('Age is in range')
if age < 40 or age > 46:
print('Age is older or younger')
age = 39
if age < 40 or age > 46:
print('Age is older or younger')
age = 56
if age < 40 or age > 46:
print('Age is o... | true |
2b03e816c33cfdcfd9b5167de46fda66c7dda199 | angelavuong/python_exercises | /coding_challenges/grading_students.py | 981 | 4.125 | 4 | '''
Name: Grading Students
Task:
- If the difference between the grade and the next multiple of 5 is less than 3, round grade up to the next multiple of 5.
- If the value of grade is less than 38, no rounding occurs as the result will still be a failing grade.
Example:
grade = 84 will be rounded to 85
grade = 29 will ... | true |
570b9f3e710d94baf3f4db276201a9c484da4a71 | angelavuong/python_exercises | /coding_challenges/count_strings.py | 573 | 4.125 | 4 | '''
Name: Count Sub-Strings
Task:
Given a string, S, and a substring - count the number of times the substring appears.
Sample Input:
ABCDCDC
CDC
Sample Output:
2
'''
def count_substring(string,sub_string):
counter = 0
length = len(sub_string)
for i in range(len(string)):
if (string[i] == sub_st... | true |
aa378a188bce0e97a0545221e65f148838b3650c | angelavuong/python_exercises | /coding_challenges/whats_your_name.py | 536 | 4.1875 | 4 | '''
Name: What's Your Name?
Task: You are given the first name and last name of a person on two different lines. Your task is to read them and print the following:
Hello <firstname> <lastname>! You just delved into python.
Sample Input:
Guido
Rossum
Sample Output:
Hello Guido Rossum! You just delved into python.
'... | true |
d5d229788bf6391a3be21f75c54166a1b836b3e4 | 6reg/pc_func_fun | /rev_and_normalized.py | 519 | 4.15625 | 4 | def reverse_string(s):
reversed = ""
for i in s:
reversed = i + reversed
return reversed
def normalize(s):
normalized = ""
for ch in s:
if ch.isalpha():
normalized += ch.lower()
return normalized
def is_palindrome(s):
normalized = normalize(s)
rev = reverse_... | true |
cd916150b60d80e1def43eb10aaafd65429badb1 | lumeng/repogit-mengapps | /data_mining/wordcount.py | 2,121 | 4.34375 | 4 | #!/usr/bin/python -tt
## Summary: count words in a text file
import sys
import re # for normalizing words
def normalize_word(word):
word_normalized = word.strip().lower()
match = re.search(r'\W*(\w+|\w\W+\w)\W*', word_normalized)
if match:
return match.group(1)
else:
return word_no... | true |
516721a52862c9532385d52da79d11085a759181 | EvgenyMinikh/Stepik-Course-431 | /task17.py | 1,250 | 4.1875 | 4 | """
Напишите программу, которая шифрует текст шифром Цезаря.
Используемый алфавит − пробел и малые символы латинского алфавита: ' abcdefghijklmnopqrstuvwxyz'
Формат ввода:
На первой строке указывается используемый сдвиг шифрования: целое число. Положительное число соответствует сдвигу вправо. На второй строке указывае... | false |
f65486941b6ee5852a4aaf2bf6547b7d5d863dd9 | blei7/Software_Testing_Python | /mlist/binary_search.py | 1,682 | 4.3125 | 4 | # binary_search.py
def binary_search(x, lst):
'''
Usage: The function applies the generic binary search algorithm to search if the value
x exists in the lst, and returns a list contains: TRUE/FAlSE depends on whether the x value has been found,
x value, and x position indice in list
Argume... | true |
612c8ca841d8da2fc2e8e00f1a14fb22126d1277 | sumanmukherjee03/practice-and-katas | /python/top-50-interview-questions/ways-to-climb-stairs/main.py | 2,336 | 4.1875 | 4 | # Problem : Given a staircase of n steps and a set of possible steps that we can climb at a time
# named possibleSteps, create a function that returns the number of ways a person can take to reach the
# top of the staircase.
# Ex : Input : n = 5, possibleSteps = {1,2}
# Output : 8
# Explanation : Possible ways ar... | true |
2137855080a086d767c6c1c750a92e2c50e47f5a | sumanmukherjee03/practice-and-katas | /python/top-50-interview-questions/sort/main.py | 1,234 | 4.28125 | 4 | # Problem : Sort an array
# Time complexity O(n^2)
def bubbleSort(arr):
if len(arr) <= 1:
return arr
# Run an outer loop len(arr) times
i = 0
while i < len(arr):
# Keep swapping adjacent elements, ie sort adjacent elements in the inner loop
j = 1
while j < len(arr):
... | false |
f69d4a3a4e1abadb5d462889976fcaffafbdc9f8 | ChrisStreadbeck/Python | /apps/fizzbuzz.py | 705 | 4.1875 | 4 | var_range = int(input("Enter a Number to set the upper range: "))
def fizzbuzz(upper):
for num in range(1, upper):
if num != upper:
if num % 3 == 0 and num % 5 == 0:
print('FizzBuzz')
elif num % 3 == 0:
print('Fizz')
elif num % 5 == 0:
print('Buzz')
else:
... | false |
14adf897de38f2d27bc32c8bc7d298b9f1ffbbed | ChrisStreadbeck/Python | /learning_notes/lambdas.py | 440 | 4.1875 | 4 | #Lambda is a tool used to wrap up a smaller function and pass it to other functions
full_name = lambda first, last: f'{first} {last}'
def greeting(name):
print(f'Hi there {name}')
greeting(full_name('kristine', 'hudgens'))
#so it's basically a short hand function (inline) and it allows the name to be called
# si... | true |
f91112d5f2d441cb357b52d77aa72c74d586fc73 | Shady-Data/05-Python-Programming | /studentCode/Recursion/recursive_lines.py | 928 | 4.53125 | 5 | '''
3. Recursive Lines
Write a recursive function that accepts an integer argument, n. The function should display
n lines of asterisks on the screen, with the first line showing 1 asterisk, the second line
showing 2 asterisks, up to the nth line which shows n asterisks.
'''
def main():
# Get an intger... | true |
630e3b1afa907f03d601774fa4aec19c8ae1fbbb | Shady-Data/05-Python-Programming | /studentCode/cashregister.py | 1,718 | 4.3125 | 4 | '''
Demonstrate the CashRegister class in a program that allows the user to select several
items for purchase. When the user is ready to check out, the program should display a list
of all the items he or she has selected for purchase, as well as the total price.
'''
# import the cash register and retail item class mo... | true |
443db5f0cfbc98abc074444ad8fccdf4a891491c | Shady-Data/05-Python-Programming | /studentCode/CellPhone.py | 2,681 | 4.53125 | 5 | """
Wireless Solutions, Inc. is a business that sells cell phones and wireless service.
You are a programmer in the company’s IT department, and your team is designing a program to manage
all of the cell phones that are in inventory. You have been asked to design a class that represents
a cell phone. The data that sh... | true |
915a6111d78d3bd0566d040f9342ddb59239c467 | Shady-Data/05-Python-Programming | /studentCode/Recursion/recursive_printing.py | 704 | 4.46875 | 4 | '''
1. Recursive Printing
Design a recursive function that accepts an integer argument, n, and prints the numbers 1
up through n.
'''
def main():
# Get an integer to print numbers up to
stop_num = int(input('At what number do you want this program to stop at: '))
# call the recursive print number a... | true |
c4d39fadba7f479ce554198cd60c7ce4574c2d6b | Shady-Data/05-Python-Programming | /studentCode/Recursion/sum_of_numbers.py | 874 | 4.40625 | 4 | '''
6. Sum of Numbers
Design a function that accepts an integer argument and returns the sum of all the integers from 1 up
to the number passed as an argument. For example, if 50 is passed as an argument, the function will
return the sum of 1, 2, 3, 4, . . . 50. Use recursion to calculate the sum.
'''
de... | true |
96387763eafc4c2ee210c866e43f30ebd9fbb6b5 | Vinod096/learn-python | /lesson_02/personal/chapter_4/14_pattern.py | 264 | 4.25 | 4 | #Write a program that uses nested loops to draw this pattern:
##
# #
# #
# #
# #
number = int(input("Enter a number : "))
for r in range (number):
print("#", end="",sep="")
for c in range (r):
print(" ", end="",sep="")
print("#",sep="")
| true |
d4420e85272e424bdf66086eda6912615d805096 | Vinod096/learn-python | /lesson_02/personal/chapter_3/09_wheel_color.py | 1,617 | 4.4375 | 4 | #On a roulette wheel, the pockets are numbered from 0 to 36. The colors of the pockets are
#as follows:
#• Pocket 0 is green.
#• For pockets 1 through 10, the odd-numbered pockets are red and the even-numbered
#pockets are black.
#• For pockets 11 through 18, the odd-numbered pockets are black and the even-numbered
#po... | true |
6411437fe4e73b46d8756a61d44f929a83c8dbf7 | Vinod096/learn-python | /lesson_02/personal/chapter_6/03_line_numbers.py | 386 | 4.34375 | 4 | #Write a program that asks the user for the name of a file. The program should display the
#contents of the file with each line preceded with a line number followed by a colon. The
#line numbering should start at 1.
count = 0
file = str(input("enter file name :"))
print("file name is :", file)
content = open(file, 'r'... | true |
b09e8d2cd18d517e904889ecf2809f1f1392e7eb | Vinod096/learn-python | /lesson_02/personal/chapter_4/12_population.py | 1,321 | 4.71875 | 5 | #Write a program that predicts the approximate size of a population of organisms. The
#application should use text boxes to allow the user to enter the starting number of organisms,
#the average daily population increase(as a percentage), and the number of days the
#organisms will be left to multiply. For example, assu... | true |
f5a8090ff67003d79e2f431256d4b277381c8dd7 | Vinod096/learn-python | /lesson_02/personal/chapter_3/01_Day.py | 757 | 4.40625 | 4 | #Write a program that asks the user for a number in the range of 1 through 7. The program
#should display the corresponding day of the week, where 1 = Monday, 2 = Tuesday,
#3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, and 7 = Sunday. The program should
#display an error message if the user enters a number tha... | true |
e0b176c877b9b553dbcee2b6124cfde4dd4c128c | Vinod096/learn-python | /lesson_02/personal/For_loop/scrimba.py | 220 | 4.15625 | 4 | names = ['Jane','John','Alena']
names_1 = ['John','Jane','Adeev']
text = 'Welcome to the party'
names.extend(names_1)
for name in range(1):
names.append(input("enter name :"))
for name in names:
print(name,text)
| false |
7feb19a5121eeb321f0b2a187852cae0becb4c4f | Vinod096/learn-python | /lesson_02/personal/chapter_2/ingredient.py | 1,022 | 4.40625 | 4 | total_no_of_cookies = 48
cups_of_sugar = 1.5
cups_of_butter = 1
cups_of_flour = 2.75
no_of_cookies_req = round(int(input("cookies required :")))
print("no of cookies required in roundup : {0:2f} ".format(no_of_cookies_req))
req_sugar = (no_of_cookies_req / total_no_of_cookies) * cups_of_sugar
print("no of cups of suga... | true |
dd42d5e406efde3b62d76588eeb37a7470edafe8 | Vinod096/learn-python | /lesson_02/personal/chapter_8/01_initials.py | 463 | 4.5 | 4 | #Write a program that gets a string containing a person’s first, middle, and last names,and then display their first, middle, and last initials. For example, if the user enters John William Smith the program should display J. W. S.
first_name = str(input("Enter First Name : "))
middle_name = str(input("Enter Middle N... | true |
ad1f65388986962de297bba5f1219809634fccd3 | Vinod096/learn-python | /lesson_02/personal/chapter_4/09_ocean.py | 380 | 4.28125 | 4 | #Assuming the ocean’s level is currently rising at about 1.6 millimeters per year, create an
#application that displays the number of millimeters that the ocean will have risen each year
#for the next 25 years.
rising_oceans_levels_per_year = 1.6
years = 0
for i in range (1,26):
years = rising_oceans_levels_per_ye... | true |
80906ba30bc751f48e177907ab2967803c269022 | Vinod096/learn-python | /lesson_02/personal/chapter_5/12_Maximum_of_Two_Values.py | 867 | 4.625 | 5 | #Write a function named max that accepts two integer values as arguments and returns the
#value that is the greater of the two. For example, if 7 and 12 are passed as arguments to
#the function, the function should return 12. Use the function in a program that prompts the
#user to enter two integer values. The program ... | true |
83b9e523b3ff90d47c7689f3293b77a16d05a965 | Vinod096/learn-python | /lesson_02/personal/chapter_5/06_calories.py | 1,078 | 4.65625 | 5 | #A nutritionist who works for a fitness club helps members by evaluating their diets. As part
#of her evaluation, she asks members for the number of fat grams and carbohydrate grams
#that they consumed in a day. Then, she calculates the number of calories that result from
#the fat, using the following formula:
#calorie... | true |
11a462649f8ebd34f0d29ab619e6d36bc98160af | Moandh81/python-self-training | /tuple/9.py | 494 | 4.34375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Write a Python program to find the repeated items of a tuple.
mytuple = ("dog", "cat", "cow", "fox", "hen", "cock", "lion" , "zebra","duck" ,"bull", "sheep", "cat", "cow", "fox", "lion")
frequency = {}
for item in mytuple:
if item.lower() not in frequency:
... | true |
ac6d44000cce88e231a9a85d082c8538b44fd515 | Moandh81/python-self-training | /datetime/32.py | 272 | 4.375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Write a Python program to calculate a number of days between two dates.
from datetime import date
t1 = date(year = 2018, month = 7, day = 12)
t2 = date(year = 2017, month = 12, day = 23)
t3 = t1 - t2
print("t3 =", t3)
| true |
fee021a37c322579ad36109a92c914eaf4a809b7 | Moandh81/python-self-training | /functions/1.py | 657 | 4.375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*
# Write a Python function to find the Max of three numbers.
import re
expression = r'[0-9]+'
numberslist = []
number1 = number2 = number3 = ""
while re.search(expression, number1) is None:
number1 = input('Please input first number: \n')
while re.search(expressio... | true |
4a43f7f498cda12296b75247c5b6d45941519527 | Moandh81/python-self-training | /conditional-statements-and-loops/5.py | 268 | 4.375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Write a Python program that accepts a word from the user and reverse it.
word = input("Please input a word : \n")
newword = ""
i = len(word)
while i > 0:
newword = newword + word[i-1]
i = i - 1
print(newword) | true |
c78566301e0cc885f89c65310e9245fb5072dce1 | Moandh81/python-self-training | /dictionary/24.py | 517 | 4.5 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Write a Python program to create a dictionary from a string. Go to the editor
# Note: Track the count of the letters from the string.
# Sample string : 'w3resource'
# Expected output: {'3': 1, 's': 1, 'r': 2, 'u': 1, 'w': 1, 'c': 1, 'e': 2, 'o': 1}
txt = input('Please... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.