blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
d98a3ed1340c1f29690a906bff05c3406d152357 | nicob825/Bruno_Nico | /Lesson_04/idCard.py | 593 | 4.125 | 4 | def formater(firstname,lastname,title,year,subject,site):
print("*"*26)
print("*{:<12}{:<12}*".format(site, year))
print("*{:<12}{:<12}*".format(firstname, lastname))
print("*{:<12}{:<12}*".format(title, subject))
print("*"*26)
firstname=input(format("Enter your first name:"))
lastname=input(forma... | true |
25981a052a1533bf8c9c5a79ad81239d4b32e997 | nicob825/Bruno_Nico | /Lesson_04/4.2/average4.3.py | 256 | 4.1875 | 4 |
num1=int(input("Enter the first number:"))
num2=int(input("Enter the second number:"))
num3=int(input("Enter the third number:"))
def AVG():
return (num1+num2+num3)/3
def calcAVG():
print("The average of your numbers is",AVG())
AVG()
calcAVG()
| true |
eb39b89e8ec384e489e8baf04f92b0dca89d74b1 | mrtuanphong/learning-python | /Programming Foundations with Python/lesson-3/draw-a-square-2.py | 637 | 4.1875 | 4 | # Steps:
# 1. Move forward -> Turn right
# 2. Move forward -> Turn right
# 3. Move forward -> Turn right
# 4. Move forward -> Turn right
import turtle
def draw_square(my_turtle):
for i in range(1,5):
my_turtle.forward(100)
my_turtle.right(90)
def draw_art():
window = turtle.Screen()
windo... | true |
f445073f5b9cf45466d8cd20c7a91bb90480f5d0 | kmurudi/Python-Basics | /replaceEmail.py | 533 | 4.15625 | 4 | import re
str = input('Enter email ID: ')
# Pattern to match -> xxxx@XXXX.com
# Task -> Change end of email, domains to ncsu.edu
matchObj1 = re.match(r'(^[a-z][a-z0-9_]*)[@]([a-z]+).(com)', str)
# Use of groups() function to obtain different parts of an email id to easily replace them
if matchObj1:
prin... | true |
61c9155a087b939dfe1e54bab0437da0b3da3634 | meganandree88/tobinary | /tobinary.py | 1,348 | 4.28125 | 4 | '''
File name: tobinary.py
Homework #4
Problem #2
This file provides the necessary functions to convert a decimal number (base-10)to the binary number (base-2).
'''
import math
def toBinary(num):
'''
This function takes a decimal number and converts it to a binary number. The binary number is returned as a s... | true |
2b47733325f6401bb554aa5f030a392620784760 | gitlearn212/My-Python-Lab | /Python/linkedincourse/sequence.py | 1,466 | 4.25 | 4 | # list is a mutable function so value can be re assigned but in tuple the value is not re assignable.Tuple is immutable
x = [1, 2, 3, 4, 5]
for i in x:
#or print(i, end= ' ', flush=True)
# or print(f'{i}',end= ' ')
print('i is {}'.format(i),end = ' ')
# ====>Re assigning the value of list x <=======
x = [1... | true |
25c2fff7bd1899d84b74282c65ae15f9e2fc24aa | gitlearn212/My-Python-Lab | /Python/Functions/Ex20_count_chars_given_num_time.py | 308 | 4.1875 | 4 | # Count the string for the given number of times
def count_string(str, n):
result = " "
for x in range(n):
result += str
return result
strings = input('Enter a string: ')
n = int(input('Entaer a value: '))
# print(strings)
print(count_string(strings, n))
print(count_string('abc ', n))
| true |
114b497e8a8c04c0b3e2ba820c7cd8354d3380fb | gitlearn212/My-Python-Lab | /Python/linkedincourse/for_chap6_1_additional cont.py | 633 | 4.125 | 4 |
# For loop Chapter 6 using Tuple Tuple is () list is [] Dictionary is {}
animals = ('bear', 'bunny', 'dog', 'cat', 'velociraptor')
for pet in animals:
if pet == 'dog': continue # this will not print the dog from the list because it shorcut the loop
if pet == 'cat': break # this will break the loop once re... | true |
c7aa7a753246b729e31294c3c7c2a8088067c6f6 | sagarjoshi19969/OnlineSite | /factorial.py | 309 | 4.25 | 4 | number=int(input("please enter a number: "))
factorial=1
if number<0:
print("sorry, factorial does not exist for negative numbers")
elif number==0:
print("the factorial of 0 is 1")
else:
for i in range(1,number+1):
factorial=factorial*i
print("the factorial of",number,"is",factorial)
| true |
15758ecc7348e2cb18036fa725588ad5e88e4386 | TyranSchmidt/developers_institute | /week_4/day_3/daily_challenge/daily_challenge.py | 490 | 4.4375 | 4 | user_input = input("Do you want to encrypt or decrypt (text-sensitive)?: ")
user_text = input("Please enter the text: ")
enc_text = ""
dec_text = ""
for i in range(len(user_text)):
character = user_text[i]
if user_input == "encrypt":
enc_text += chr(ord(character) + 3)
elif user_input == "decrypt":
dec_text +... | true |
7789ddfc47e3ff5b292f8cb7048fcc864d48b601 | Anchals24/General-Basic-Programs | /Reversing a list.py | 2,049 | 4.6875 | 5 | """
Reversing a list:
Various methods of reversing a list :
- by creating another list.
- by updating the existing list.
"""
# Method1: using range function(iterating towards backward) property:
#>> does not update the existing list
L1 = [1,2,3,4]
Reverselist = []
leng = len(L1)-1
for i in range(leng ,... | true |
28dc48fedd142b4cd9cd1362649fabe88b810373 | delvingdeep/data-structures-and-algorithm | /1_linked_list/04_circular_linked_list.py | 1,409 | 4.21875 | 4 | class Node:
def __init__(self, value):
self.value = value
self.next = None
class CircularLinkedList:
def __init__(self):
self.head = None
def append(self, value):
if self.head is None:
self.head = Node(value)
else:
node = self.head
... | true |
9c777f705591967b9e8d757403c962ca49486c65 | delvingdeep/data-structures-and-algorithm | /misc/00_string.py | 1,973 | 4.46875 | 4 | def string_reverser(input_string):
"""
Reverse the input string
Args:
input_string(string): String to be reversed
Returns:
string: The reversed string
"""
return input_string[::-1]
def anagram_checker(str1, str2):
"""
Check if the input strings are anagrams of each other... | true |
4e922089207f03f24abf118f3d56ebba12352215 | H602602/AI-Python- | /session 8/P1.py | 1,216 | 4.21875 | 4 | print("Hello I am a mini calculator")
print("I can do addition subtraction multiplication etc")
a=int(input("enter 1-addition 2-subtraction 3-multiplication 4-division 5-power 6-odd and even: "))
if a==1:
b=int(input("Enter a number you want to add"))
c=int(input("Enter second number you want to add with f... | true |
5dab1c8dbaa164c906aa6538e6665e0da55e70f7 | MagicTearsAsunder/playground | /insert_position.py | 799 | 4.21875 | 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.
"""
def searchinsert(nums: list, target: int) -> int:
if not nums:
return None
if target in nums:
... | true |
d7be71cc6f1a97ced9966e0c5478635d186e4e3f | mkennedy2013/UTA-VIRT-CYBER-PT-06-2021-U-LOL | /00/Python/1/Activities/05-Stu_VariableAddress/Unsolved/UNSOLVED_VariableAddress.py | 722 | 4.125 | 4 | # Create a web address and store it in a variable
url = "https://google.com"
# Store the IP address within a string variable
ip = "192.168.1.1"
# Create some variables to store how many times the site was visited each day
monday = 1000
tuesday = 2000
wednesday = 3000
thursday = 1000
friday = 200
saturday = 900000
sun... | true |
5df10dc6fc2c335c07a85523314876302df81512 | Sujankhyaju/IW_pythonAssignment2 | /12.py | 296 | 4.375 | 4 | # 12. Create a function, is_palindrome, to determine if a supplied word is
# the same if the letters are reversed
def is_palindrome(word):
if word == word[::-1]:
return "Palindrome"
else:
return "Not Palindrome"
word =input("Enter a word::")
print(is_palindrome(word))
| true |
15e56685b0d85024faabf0da552f7a8593f121d8 | Sujankhyaju/IW_pythonAssignment2 | /5.py | 752 | 4.59375 | 5 | # 5. Create a tuple with your first name, last name, and age. Create a list, people, and append your tuple to it.
# Make more tuples with the corresponding information from your friends and append them to the list. Sort the list.
# When you learn about sort method, you can use the key parameter to sort by any field i... | true |
7a6e4fb6e9c14b696046c66d0023263f5d84b3b9 | Anuhitha13/palindrome.py | /palindrome.py | 213 | 4.40625 | 4 | string = input('enter the string:')
rev_string = string[ : : -1]
print('reversed string:',rev_string)
if string == rev_string:
print('string is palindrome')
else:
print('string is not a palindrome') | true |
7df1ecb4a1db1ec2cd08b801161811e7fb7a96a2 | roshangardi/Leetcode | /143. Reorder List.py | 2,359 | 4.21875 | 4 | # TO solve this problem we have 3 Step algorithm.
# 1) Find the middle of the linked list and divide it into 2 different linked list from the middle.
# 2) Reverse the second divided part of the linked list.
# 3) Merge both the linked list in such a manner that it takes one element from each list at a time.
# To summari... | true |
c97c081a959a626a34695765e56725ae59ad6381 | shubb30/snippets | /python/data/_closures.py | 695 | 4.15625 | 4 | """ A closure is where a function contains a nested function that is able to access
variables outside of its local scope.
"""
def add_it_up():
""" Returns a function that will take a single argument, and
add the number to a running total, and return the total.
"""
numbers = []
# closure
... | true |
51b3bea2e1e99afda2f7931e8b6e85e213aa6ff3 | srikanthpragada/PYTHON_07_JAN_2019_DEMO | /sum_even_odd_numbers.py | 235 | 4.21875 | 4 | # print sum of even numbers and odd numbers
even_sum = odd_sum = 0
for i in range(1, 6):
num = int(input("Enter a number :"))
if num % 2 == 0:
even_sum += num
else:
odd_sum += num
print(even_sum, odd_sum)
| true |
9242d462e4ee0325aff207540261066eabf32a7f | JamesWalter/AdventOfCode | /2017/day8.py | 2,986 | 4.375 | 4 | """ Advent of Code 2017 Day 8 I Heard You Like Registers """
# You receive a signal directly from the CPU. Because of your recent
# assistance with jump instructions, it would like you to compute the result
# of a series of unusual register instructions.
#
# Each instruction consists of several parts: the register to ... | true |
3c64ecec40cf2eae5b8bbaabd47ff81f0ed5caf0 | JamesWalter/AdventOfCode | /2016/day3.py | 2,667 | 4.1875 | 4 | """Advent of Code 2016 Day 3: Squares with Three Sides"""
# Now that you can think clearly, you move deeper into the labyrinth of
# hallways and office furniture that makes up this part of Easter Bunny HQ.
# This must be a graphic design department; the walls are covered in
# specifications for triangles.
#
# Or are... | true |
a23016a2db218cd5200613b4a856df9e2f623ff6 | KR4705/Python_hardway | /ex18.py | 568 | 4.46875 | 4 | #this one like the argv
#takes multiple arguments
def print_two(*args):
arg1, arg2 = args # unpacking args into arg1 and arg2
#args is like a tuple
print type(args)
print "arg1: %r, arg2: %r"%(arg1,arg2)
#we can also do like this
def print_two_again(arg1,arg2):
print type(arg1)#this type is dependent on the inp... | true |
a2978404063d6219cf2c3f9e568598bf47515c56 | SoumyJim/Data-Structures-and-Algorithms-in-Python | /1.Python Primer/P-1.31.py | 943 | 4.28125 | 4 | #Write a Python program that can make change. Your program should
#take two numbers as input, one that is a monetary amount charged and the
#other that is a monetary amount given. It should then return the number
#of each kind of bill and coin to give back as change for the difference
#between the amount given and the ... | true |
7227b517db789a445db9c9fe65e3fa0bc944c715 | atliSig/T809DATA_2021 | /00_introduction/examples.py | 681 | 4.25 | 4 | import matplotlib.pyplot as plt
import numpy as np
def plot_multiple():
'''
Draws three plots on the same figure by calling
the function power_plot three times.
'''
def power_plot(x_range: np.ndarray, power: int):
'''
Plot the function f(x) = x^<power> on the given
range
... | true |
87e947d35b85bcbd7829b03ed8e2e0e620ea916f | Glico21/Napoleon_task | /roman_to_int.py | 2,572 | 4.125 | 4 | # python3.6
# coding: utf-8
import re
class Solution:
def correct_roman_str(self, s):
"""
Checks string for letters that are Roman Numerals and follow the rules.
Returns False if string isn't correct Roman Numeral.
"""
regex = re.compile(r"^(M{0,3})(D?C{0,3}|C[DM])(L?X{0,... | true |
90d4aec5f7ccc48bad55bb2d9d8ffc2330478007 | edmanf/Cryptopals | /src/cryptopals/convert.py | 861 | 4.1875 | 4 | """ This class contains methods for converting from one format to another """
import base64
def hex_string_to_bytes(hex_str):
""" Convert the hex string to a bytes object and return it.
Keyword arguments:
hex_str -- a String object comprised of hexadecimal digits
"""
return bytes.fromhex(h... | true |
f7ce5f6b3a89546cdbe2549e88f619d609bb4969 | fordham-css/Python_Workshop | /resources/math/arithmetic.py | 373 | 4.40625 | 4 | # Shows how arithmetic operations work in python
# All of these work exactly like you'd expect
print(2 + 3)
print(10 / 2)
print(3 * 7)
print(3 - 19)
# If you're used to C++, this might work differently
# than you'd expect
print(11 / 2)
# If you want integer division, use //
print(11 // 2)
# Python also has a cool e... | true |
dccb0b057551c2c585563ab56d511d88f5e55e32 | sophiaterbio/squaresum | /Terbio_1_3.py | 230 | 4.21875 | 4 | def squaresum(n):
sqrsum = 0
for x in range(1, n+1):
sqrsum = sqrsum + (x*x)
return sqrsum
n = int(input('Enter number of natural numbers: ' ))
print ('The sum of squares is ', squaresum(n)) | true |
65617c30e5a38c9159ca5d4b8fc67d15668ed6bf | benbenben1010/rackjam-killer-word | /killer.py | 1,186 | 4.125 | 4 | #!/usr/bin/python2
import os, sys
def find_optimal_word(words, sequence):
# high score = 26
# best words = []
# for each word in words,
# score_of_this_word = get_score_of_word
# is this score better
print "words are: ", words
print "sequence is: ", sequence
return words[0]
def is_word_still_elig... | true |
b42e428d37960e665b06afc64d01828296a91ab3 | ajaykumar011/python-course | /classes/inheritance2.py | 1,166 | 4.375 | 4 | # So far we have created a child class that inherits the properties and methods from its parent.
# We want to add the __init__() function to the child class (instead of the pass keyword).
# Note: The __init__() function is called automatically every time the class is being used to create a new object.
class Person: #P... | true |
b16821900fdfb223bb4f9741701ba48d317dfce9 | ajaykumar011/python-course | /functions/function.py | 821 | 4.34375 | 4 | def my_func():
print("hello World")
def convert(text):
return text.upper()
def my_sum(x,y):
return x+y
my_func()
x=convert("love") #Arguments are often shortened to args in Python documentations.
print(x)
print(my_sum(10,20))
#If the number of arguments is unknown, add a * before the parameter name:
#A... | true |
5938d52b603ce4cda1eca048a08b0e67918bd15b | AmithSahadevan/String_Capitalizer | /Capi.py | 304 | 4.125 | 4 | Input = input("Enter a sentance in lower case: ").lower()
u = Input.replace(".", " ") #replacing . ,if there are any
l = u.split(" ") #splitting the words in the Input string.
for i in l:
print(i.capitalize()," ", end = "") #the capitalize method will make the first letter of a word Capital.
print() | true |
38510d3f17cd602d9252a0b919747b3d0fbb94f5 | jayjanodia/LeetCode | /Easy/21. Merge Two Sorted Lists/Solution.py | 1,397 | 4.25 | 4 | #Runtime: 32 ms, faster than 92.73% of Python3 online submissions for Merge Two Sorted Lists.
#Memory Usage: 14.3 MB, less than 30.89% of Python3 online submissions for Merge Two Sorted Lists.
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# ... | true |
c2f2df8a27b85cdb743550c366125617118e5f2f | adam-dziedzic/bandlimited-cnns | /pytorch_tutorials/transfer_learning/intro.py | 1,260 | 4.25 | 4 | """
Transfer Learning tutorial
see: http://nnlib.github.io/transfer-learning/
Author: Sasank Chilamkurthy
In this tutorial, you will learn how to train your network using transfer learning. You can read more about
the transfer learning at nnlib notes.
Quoting these notes,
In practice, very few people train an ... | true |
ce25abeba86ef92fa246c8cbe82f79b9f8e441b7 | Chrisgarlick/Python_Projects | /My_Projects/Simple_Calc_guess.py | 1,316 | 4.1875 | 4 | import random
guessed = 0
score = 0
num1 = random.randint(1, 9)
num2 = random.randint(1, 9)
def randgen():
operation = [addition(num1, num2), subtraction(num1, num2), multiplication(num1, num2), division(num1, num2)]
return random.choices(operation)
def addition(num1, num2):
return num1 + num2
def ... | true |
899d665233904d7530eccea8d0ecd009959abe61 | Chrisgarlick/Python_Projects | /My_Projects/R_P_S.py | 2,072 | 4.15625 | 4 | import random
def ready():
ready = input("Are you ready to play?: Yes or No: ")
if ready == 'yes':
return False
else:
return True
start = ready()
# Scores
myscore = 0
opponent_score = 0
# Game play
while start == False:
# Opponents choice
opponent = ["rock", "paper", "scissors... | true |
c7570061a96c9da6324304c747cfa9fc65ac1dfe | Domino2357/daily-coding-problem | /#14.py | 890 | 4.28125 | 4 | """
This problem was asked by Google.
The area of a circle is defined as πr^2. Estimate π to 3 decimal places using a Monte Carlo method.
Hint: The basic equation of a circle is x2 + y2 = r2
"""
# had to google what a Monte Carlo method is: essentially one creates random points .
import random
from math import sqrt
... | true |
04996d19e325693d52d9f61137e5f81657561185 | Domino2357/daily-coding-problem | /#22.py | 1,651 | 4.15625 | 4 | """
This problem was asked by Microsoft.
Given a dictionary of words and a string made up of those words (no spaces), return the original sentence in a list.
If there is more than one possible reconstruction, return any of them. If there is no possible reconstruction,
then return null.
For example, given the set of w... | true |
5b8269eb2d3a59c0d9011d010ac63bef2914f7e2 | ojedajif9581/cti110 | /P5T2_FeetToInches_FreddyOjeda.py | 537 | 4.4375 | 4 | # This program converts Feet to Inches
# July 12 2019.
# CTI-110 P5T2_Feet to Inches
# Ojeda Freddy
# Conversion factor
INCHES_PER_FOOT = 12
# The main function
def main():
# Get a number of feet from the user.
feet = int (input('Enter a number of feet: ' ))
# Convert that to inches.
... | true |
69c7bbbf976723a7328088798b406c2c7fcd2b56 | sgrmshrsm7/MyPython | /pe/largestpalindromeproduct.py | 610 | 4.125 | 4 | #A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
#Find the largest palindrome made from the product of two 3-digit numbers.
def rev(a):
n=0
b=a
while b != 0:
n = n*10 + b%10
b = (b - b%10) / 10
... | true |
2dbab16b3b2f3d56641730720be3bcd4dbd10c18 | dinabseiso/HW04 | /HW04_ex00.py | 1,327 | 4.25 | 4 | #!/usr/bin/env python
# HW04_ex00
# Create a program that does the following:
# - creates a random integer from 1 - 25
# - asks the user to guess what the number is
# - validates input is a number
# - tells the user if they guess correctly
# - if not: tells them too high/low
# - only lets t... | true |
5812af37e65215b09a6f0676536d7cbc15a624c1 | AliveSphere/Introductory_PyCharm_Files | /Practicing/L14 practice.py | 1,179 | 4.28125 | 4 | # This program demonstrates records and text files with numbers
# Each record of the birthdays file has four fields
# name, month of birth as integer, day of birth as integer
# year of birth as integer
def main():
birthday_file = open("birthdays.txt", "w")
again = "y"
while again == "y" or again == "Y":
... | true |
fa033d1fe5e7db6d1fb405497e1fd9348230d8f8 | AliveSphere/Introductory_PyCharm_Files | /Practicing/test prep.py | 1,680 | 4.15625 | 4 | # Charles Buyas cjb8qf
print("Add two integers:", 4 + 4)
print("Add two strings:", "four" + "four")
print("Concatenate a string and an int or float:", "four" + str(4), "or", "four" + str(float(4)))
print("Replicate a string:", "four"*4)
print("Multiply two floating point numbers:", float(4.4*4.4))
print("Divide two f... | true |
1c19717166b057344a57d7976a581e90ee90afe6 | glen-s-abraham/sem3record | /7.py | 1,027 | 4.40625 | 4 | """String operations"""
str1=input("Enter a string?")
print("Length of string is:",len(str1))
print("Lowercase of string is:",str1.lower())
print("Uppercase of string is:",str1.upper())
print("Swapcase of string is:",str1.swapcase())
print("capitalized string is:",str1.capitalize())
print("Title string is:",str1.titl... | true |
c6fc71e9106af82c4e921736737e6f7306b78d2e | glen-s-abraham/sem3record | /21.py | 373 | 4.125 | 4 | """Polymorphism"""
class Parrot:
def fly(self):
print("Parrot can fly")
def swim(self):
print("Parrot can't swim")
class Penguin:
def fly(self):
print("Penguins can't fly")
def swim(self):
print("Penguins can swim")
def func(obj):
obj.fly()
obj.swim()
obj_parrot=Parrot()
obj_penguin=P... | true |
5ddcddd2b77054134c6e6546f10b88ef64fe1af8 | pvanh80/intro-to-programming | /round11/CSV.py | 1,389 | 4.125 | 4 | # intro to programming
# CSV lib
# Phan Viet Anh
# 256296
import csv
def main():
try:
converted = False
file_name = input("Enter the name of the input file: ")
dialect_class =input("and its dialect: ")
file_converted =input('Enter the name of the output file: ')
dialect_c... | true |
46aef23975b29a6ce3ae97ab126d6045161d4a9d | natalijascekic/Midterm-Exam-2 | /task3.py | 623 | 4.125 | 4 | """
=================== TASK 3 ====================
* Name: Recursive Sum
*
* Write a recursive function that will sum given
* list of integer numbers.
*
* Note: Please describe in details possible cases
* in which your solution might not work.
*
* Use main() function to test your solution.
=========================... | true |
c184b9aa08855c7661426ca53c72e2df1246c4fd | vinodreddem/PythonPractice | /Oops/Exercise_Fresco.py | 2,286 | 4.4375 | 4 | import math
"""
Define the class Point that represents x, y, and z coordinates of 3D coordinate system.
Hint : Define the initializer method, __init__ that takes three values and assigns them to attributes x, y and z respectively.
Now create an object p1 = Point(4, 2, 9) and print it using the statement print(p1).
""... | true |
498313d1129c9a99fb99ecdf6f739a198d0163ea | vinodreddem/PythonPractice | /Sorting/LinkedList_Demo.py | 2,649 | 4.25 | 4 | # Like arrays, Linked List is a linear data structure.
# Unlike arrays, linked list elements are not stored at a contiguous location;
# the elements are linked using pointers.
class Node():
def __init__(self,data):
self.data = data
self.next = None
class LinkedList():
def __init__ (self):
... | true |
32a3f7727f049e01b44848fe8ec7ce436d42d041 | vinodreddem/PythonPractice | /Core_Python/ControlStatements_Demo.py | 1,179 | 4.21875 | 4 | #If Condition in python
import math
if True:
print("Inside If")
# If -Else Condition.
x = int(input("Enter the Number"))
r = x % 2
if(r == 0):
print("Inside inside If -it is even ")
else:
print("Inside Else")
#If -elif -else Statements
inp = int(input("Enter your values "))
if(inp ==1):
print("in... | true |
c382c66b2656f3fb61a45f64914894270a6389e7 | vinodreddem/PythonPractice | /Interview_Problems/Exercise2_Fresco.py | 1,000 | 4.375 | 4 | import unittest as ut
"""
Define the function isEven which returns True, if a given number is even and returns False, if the number is odd.
Define a simple class TestIsEvenMethod derived from unittest.TestCase class.
Hint : Import unittest module and use TestCase utility of it. You may type python3.5 to use the late... | true |
8cec1a36df50e8ab531a539713461f868621fccd | vinodreddem/PythonPractice | /Oops/AbstractClasss_Demo.py | 2,975 | 4.78125 | 5 | from abc import ABC ,abstractmethod
"""
abc --Anstract Base classes
Abstract Class: A class contains a abstract methods without implementation.
Implementation is done on derived classes.
Abstract class is created by deriving a class from abc Module (ABC -Abstract Bse Classs)
"""
class A(ABC):
@abstractmethod
... | true |
53a04737309a779eb32b410a95504d6ded490751 | rcbhowal/pythonforeveryone-Chapter-3-Solution | /P3.2.py | 567 | 4.4375 | 4 | # Write a program that reads a floating point number and prints 'zero' if the number
# is zero. Otherwise, print 'positive' or negative'. Add 'small' if the absolute value
# value of that number is less than 1, or 'large' if exceeds 1,000,000.
# Take the input from user
x=float(input('Enter a number it could be p... | true |
9f35e46c7134520d35d356be3ccc15950fff89b4 | ahadahmedkhan/Solution | /chapter 5/ex 5.10.py | 1,103 | 4.4375 | 4 | # Do the following to create a program that simulates
# how websites ensure that everyone has a unique username.
# • Make a list of five or more usernames called current_users.
# • Make another list of five usernames called new_users. Make sure one or
# two of the new usernames are also in the current_users list.
... | true |
a251c0d6b3207e9869d42b7b62f059f02f198e72 | CRloong/CheckIO | /home/House_Password.py | 1,199 | 4.25 | 4 | """
Stephan and Sophia forget about security and use simple passwords for everything. Help Nikola develop a password security check module. The password will be considered strong enough if its length is greater than or equal to 10 symbols, it has at least one digit, as well as containing one uppercase letter and one lo... | true |
112777a2370bcf4fe2eb1253d47d7c44bb9429c8 | Allamaris0/Algorithms | /statistics/quartiles.py | 684 | 4.375 | 4 | def quartile(array: list, quart: 1 or 2 or 3):
"""The function uses the method with excluding a median when length of an array is odd"""
array = sorted(array)
length = len(array)
half = length // 2
def median(some_array):
l = len(some_array)
h = l // 2
if l % 2 == 0:
... | true |
689a92f1b6538e928a0d15890612feffd4d2bcea | vanpana/stratec-problem-2018 | /src/path_finder.py | 2,489 | 4.125 | 4 | from src.Direction import Direction
def fill_matrix_with_possible_paths(matrix, current_x, current_y, value, destination_x, destination_y):
"""
Applies Lee's algorithm and fills the matrix with the distances from the starting point
:rtype: Filled matrix with possible distances
"""
if current_x == ... | true |
e234339b5189001c589420e545ccef0b7b512360 | mohammed-saleek/Python | /Python Tutorials/python_intro.py | 589 | 4.375 | 4 | # compare with other programming language python syntax is easy to write
# we no need to follow any header or curly braces to write a code
"""
For simple print statements
"""
print("Hello World!!!") # it will print the statement given with in the double quotes
print('Hello World!!!') # it will print the statement ... | true |
5abcc58f107e4620760070df68cdef8e65d1b84d | mohammed-saleek/Python | /Python Tutorials/premitive_loops.py | 650 | 4.15625 | 4 | """
python has two primitive loops
* while
* for loop
"""
"""
While loop
"""
num = int(input("Enter the num value: "))
while num <= 10:
print(f"The output is {num}")
num += 1
"""
for loop
"""
start_range = int(input("Enter the start range: "))
end_range = int(input("Enter the end... | true |
9ad30d69c01486b6cdac7785c1771219863769ae | manoj244u/Pythonexmpl | /PythonExample/Factorial.py | 242 | 4.34375 | 4 | def factorial(num):
if num == 1:
return num
else:
return num * factorial(num-1)
Number = int(input("Enter the number to find Recurdion:"))
#result=recursion(Number)
result = factorial(Number)
print "recursion factorial is ", result
| true |
33d44b7411697963547657aead0f95c7cfe78086 | pascalmcme/pands-problem-sheet | /es.py | 1,826 | 4.53125 | 5 |
# provides tools to support command line arguements, for example sys.arg.
import sys
# sys.argv[1] contains the first item on the list of command line arguements after the name of the python programme.
# the user will enter the python programme they wish to run "python es.py" followed by the text file "example.txt"... | true |
6513aea4d09e8eca3cda880a9414e828f8df301d | jkuatdsc/Python101 | /1.Intro_to_python/4.user_input.py | 484 | 4.34375 | 4 | # 1. Using input() function to get user input
my_name = input('Enter your name: ')
print(f'Hello, {my_name} ')
age = input('Enter your age: ')
# Added a new function age to convert a string into an integer
age_num = int(age)
print(f'You have lived for {age_num * 12} months {my_name}')
""" Another cleaner way to do... | true |
7dcadf4145d61a28f94f627613201c393989cb2c | jkuatdsc/Python101 | /6.Files_in_python/1.intro.py | 619 | 4.34375 | 4 | """
Intro into files in python
# Open()....Read() | Write()....Close() -->Remember to CLOSE the file
"""
# Reading data from text files --> (I've created a new text file and called it data.txt) this is the file i'll read from
my_file = open('data.txt', 'r')
file_contents = my_file.read()
my_file.close()
print(file_... | true |
ff31734cf5fdd7e9761a35cc796c18ad6073ee38 | degavathmamatha/LOOP_PY | /loop17.py | 420 | 4.375 | 4 | # the sum of the factorial of each of the digits of the number equals the given number,
# then such a number is called a strong number.
# Example is 145 as 1!
num=int(input("enter the strong number"))
a=num
sum=0
while num>0:
i=1
f=1
b=num%10
while i<=b:
f=f*i
i=i+1
sum=sum+f
... | true |
5f510feeb5e3097bb5d7d1f9db1d805b94e77600 | ImrulKayes/DataStructuresAlgorithms | /AVL-height balanced BST.py | 2,984 | 4.21875 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution1:
# Height balanced tree is also called AVL tree
# http://webdocs.cs.ualberta.ca/~holte/T26/avl-trees.html shows how to create an AVL ... | true |
e0d3fd0e0b7563cdde1016e0236299cb0d3b6369 | wangdingqiao/programmer-evolution-plan | /algorithm/python-algorithm/other-tools/turtle-graphics/drawOlypicSymbol.py | 1,583 | 4.71875 | 5 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
来自: http://www.blog.pythonlibrary.org/2012/08/06/python-using-turtles-for-drawing/
代码有调整
"""
import turtle
class MyTurtle(turtle.Turtle):
""""""
def __init__(self):
"""Turtle Constructor"""
self.screen = turtle.Screen()
self.screen.bgcol... | true |
45715b126714ec978b402150d36a119a3a3e5176 | Thrianadh/Testing | /slice_split_and_Join.py | 2,548 | 4.34375 | 4 | ###########################################
######### SLICE APLIT AND JOIN ############
###########################################
# index,slicing and stride #
# Both split and join string methods which perform opposing operations
# THe slice built-in python function
# Membership operator IN and nverse boolean opera... | true |
e620607bfd3d5e8c588efdda9470715cee96aa39 | ah-med/python_sandbox | /conditionals.py | 1,439 | 4.5 | 4 | # If/ Else conditions are used to decide to do something based on something being true or false
# Comparison Operators (==, !=, >, <, >=, <=) - Used to compare values
x = 10
y = 10
# simple if
if x == y:
print (f'{x} is equal to {y}')
# if/else
if x > y:
print(f'{x} is greater than {y}')
else:
print(f'... | true |
80df9875d8c1f2dc11ba085233ad1d27dc58c5d6 | Priya-sahni/git-jenkins-integration | /B2G1.py | 813 | 4.1875 | 4 | username = input("Please enter your name :")
print("Hello ", username)
cost1 = int(input("Please enter cost of product 1 :"))
cost2 = int(input("Please enter cost of product 2 :"))
cost3 = int(input("Please enter cost of product 3 :"))
total=cost1+cost2+cost3
if (cost1!=0) and (cost2!=0) and (cost3!=0):
print("Yo... | true |
1212b598ce30a7fd68b72e0b9b4a26d2d3e50d96 | Tyulalex/learnpython | /lesson1/info.py | 1,194 | 4.125 | 4 | import sys
def validate_input(input_value):
if not input_value.isalpha():
print('Incorrect value has been entered, only letters are allowed')
sys.exit()
if len(input_value)>30:
print('Too long name, max 30')
sys.exit()
def is_name_valid(raw_name, max_name_length=30):
retur... | true |
b0ed2de0744db60e69d8f5189e2e1fa6d991fd50 | PedroAlejandroUicabDiaz/Python | /Numpy/NP_Solution_02.py | 558 | 4.125 | 4 | #create two matrices where the size is entered by the user, the elements of each matrix will be placed randomly and then perform the multiplication.
import numpy as np
def ask_for_values():
r=int(input("Rows: "))
c=int(input("Columns: "))
#print('[',r,',',c,']')
create_matrix(r,c)
def create_matrix(r,c):
m... | true |
11326042cedf81eba4f246fc3c27d3964091e0f1 | RossMcKay1975/intro_to_python | /beatles.py | 1,972 | 4.40625 | 4 | beatles = [
{"name": "John Lennon", "birth_year": 1940, "death_year": 1980, "instrument": "piano"},
{"name": "Paul McCartney", "birth_year": 1942, "death_year": None, "instrument": "bass"},
{"name": "George Harrison", "birth_year": 1943, "death_year": 2001, "instrument": "guitar"},
{"name": "Ringo Starr... | true |
bd391d7069a9b40eeeb028da5f1c269860db2e29 | kyungjaeson/project1wchad | /main.py | 838 | 4.1875 | 4 | #! /usr/bin/python3
import module.questions
import questions
def main():
print("""
This is the monthly mortgage calculator.
Find out what you need to pay every month to go towards your mortgage
Let's Begin.
""")
principal = questions.question_principal()
length = questions.question_mortga... | true |
a5f1743e8abc88151212df1b2b0d3b9263ffbc82 | CharlesBayley/ProjectEuler-Python3 | /problems/p001/main.py | 421 | 4.28125 | 4 | #!/usr/bin/python3
# Problem 1
# ---------
# Multiples of 3 and 5
# ====================
# If we list of 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.
#
def main(lib):
rsum = 0
f... | true |
81797f900aeb4bc0bb43a60e34f5d8a5dd068249 | CharlesBayley/ProjectEuler-Python3 | /problems/p004/main.py | 585 | 4.15625 | 4 | #!/usr/bin/python3
# Problem 4
# ---------
# Largest palindrome product
# ==========================
# A palindrome number reads the same way both ways. The largest palindrome
# made from the product of two 2-digit numbers is `9009 = 91 * 99`
#
# Find the largest palindrome made from the product of two 3-digit numbers... | true |
6b7670069b378ff10984c584a7dfe881b138e35c | tatikondarahul2001/py | /base/11.py | 271 | 4.21875 | 4 | # input number in binary format and
# converting it into decimal format
try:
num = int(input("Input binary value: "), 2)
print("num (decimal format):", num)
print("num (binary format):", bin(num))
except ValueError:
print("Please input only binary value...")
| true |
e0a8a25dbb0c9e3f3dff934164633c91c942ff1d | kronos455/stunning-winner | /Q4.py | 1,423 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Mar 2 13:05:11 2017
@author: Brandon Mithell blm150430
Assignment 1, Q4
"""
"""
Write a program that reads an integer and displays all its smallest factors,
also known as prime factors. For example, if the input integer is 120, the
output should be as follows: 2, 2, 2, 3, ... | true |
644e260d76e16f61b2ecebe1d6dd75f84648825e | scotttgregg/full_stack_bootcamp | /average_numbers.py | 413 | 4.21875 | 4 | # average_number.py
nums = []
while True:
user_input = input('Enter a number, or "done": ')
if user_input != 'done':
number = int(user_input)
nums.append(number)
elif user_input == 'done':
for i in range(len(nums)):
total = sum(nums)
average = total / ... | true |
f103288a94cfd43341d1d05c2377b3591872e59f | RossMaybee/ICPUP | /Ch2_4_largestOdd.py | 818 | 4.3125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Dec 12 18:34:54 2016
@author: rossm
Introduction to Computation and Programming Using Python
Finger Exercise 2.4
Finding Largest of 10 Odd Numbers
"""
print 'This program will receive an input of 10 numbers and return the largest odd'
numbers = [input('Enter a n... | true |
dff0441051d9918da839aff8d6d8fca4943fc020 | matthigg/leetcode | /blank/Valid-Anagram.py | 1,501 | 4.125 | 4 | # Given two strings s and t , write a function to determine if t is an anagram
# of s.
#
# Example 1:
#
# Input: s = "anagram", t = "nagaram"
# Output: true
# Example 2:
#
# Input: s = "rat", t = "car"
# Output: false
# Note:
# You may assume the string contains only lowercase alphabets.
#
# Follow up:
# What if the i... | true |
29890b047309be9245a402a923f70ff889503444 | Jeetendranani/yaamnotes | /facebook/0494_target_sum.py | 2,197 | 4.28125 | 4 | """
494. Target Sum
You are given a list of non-negative integers, a1, a2, ... an, and a target S. Now you have 2 symbols + and -. For each
integer, you should choose one from + or - as its new symbol.
Find our how many ways to assign symbols to make sum of integers equal to target S.
Example 1:
input: nums is [1, 1... | true |
77780c234fe125acd6e046bf4ad300facdff0fca | amermalas/Python | /Exercise Files/Ch3/timedeltas_start.py | 1,140 | 4.15625 | 4 | #
# Example file for working with timedelta objects
#
from datetime import date
from datetime import time
from datetime import datetime
from datetime import timedelta
# construct a basic timedelta and print it
delta=timedelta(days=365,hours=5,minutes=1)
print(delta)
# print today's date
today = datetime.now()
print(... | true |
13b7251263f81274079728ee0f01eb0c7620faf4 | Nckflannery/Intro-Python-I | /src/13_file_io.py | 1,179 | 4.3125 | 4 | """
Python makes performing file I/O simple. Take a look
at how to read and write to files here:
https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files
"""
# Open up the "foo.txt" file (which already exists) for reading
# Print all the contents of the file, then close the file
# Note: pay close... | true |
7019485623050ab8de9cd09594f5cecb8e3e7ee7 | pwildenhain/advent-of-code-2020 | /day18/first attempt.py | 1,984 | 4.125 | 4 | from typing import List, Literal, Tuple
test_input1 = """1 + 2 * 3 + 4 * 5 + 6"""
expected_answer1 = 71
test_equation1 = test_input1.split()
test_input2 = """1 + (2 * 3) + (4 * (5 + 6))"""
expected_answer2 = 51
test_equation2 = [char for char in test_input2 if char != " "]
def solve_equation(equation: List[str], id... | true |
916b2790ae23cae91e823e354f974353201a5f30 | Marina1408/Python_exercises | /list_dir_file_input_path.py | 287 | 4.3125 | 4 | #!/usr/bin/python3
"""This program find all files and directories in the directory,
which is entered by the user.
"""
from pathlib import Path
c = input("Input the path in the format /_/_ : \n")
p = Path(c)
lst = [f for f in p.iterdir() if f.is_dir() or f.is_file()]
print(lst)
| true |
eef60905a5d8de48577dabfd070155dac21cd6e6 | harshaveeturi/DataStructures_Algorithms_Python | /stacks/linkedlist_stack.py | 2,085 | 4.21875 | 4 | class Node:
def __init__(self,element):
self.element=element
self.next=None
class Stack:
def __init__(self):
self.top=None
def push(self,push_element):
'''this function pushes the elements in to the stack'''
if self.top is None:
self.top=Node(push_elemen... | true |
1678c37d27aeeef85305a3e9e87f7135853bc8dc | nihathalici/Break-The-Ice-With-Python | /Python-Files/Day-2/Question-4.py | 803 | 4.28125 | 4 | """
Question 4
Question:
Write a program which accepts a sequence of comma-separated numbers from console
and generate a list and a tuple which contains every number.
Suppose the following input is supplied to the program:
34,67,55,33,12,98
Then, the output should be:
['34', '67', '55', '33', '12', '98']
('34', '67... | true |
ef7c72e425d47646e2c81038ad84001f002367a0 | nihathalici/Break-The-Ice-With-Python | /Python-Files/Day-3/Question-12-alternative-solution-3.py | 672 | 4.15625 | 4 | """
Question 12
Question:
Write a program, which will find all such numbers between 1000 and 3000 (both included)
such that each digit of the number is an even number.The numbers obtained should be printed
in a comma-separated sequence on a single line.
Hints:
In case of input data being supplied to the question, it s... | true |
b611864dfa00c4083892f57996e0c13cc62be2ab | nihathalici/Break-The-Ice-With-Python | /Python-Files/Day-17/Question-66.py | 354 | 4.125 | 4 | """
Question 66
Question
Please write a program which accepts basic mathematic expression
from console and print the evaluation result.
Example: If the following n is given as input to the program:
35 + 3
Then, the output of the program should be:
38
Hints
Use eval() to evaluate an expression.
"""
expression = i... | true |
9f1ca23fad9260d3d84d777c5f630383d09a9a4d | nihathalici/Break-The-Ice-With-Python | /Day_07.py | 2,438 | 4.5 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Question 20
#
# ### **Question:**
#
# > **_Define a class with a generator which can iterate the numbers, which are divisible by 7, between a given range 0 and n._**
#
# ---
#
# ### Hints:
#
# > **_Consider use class, function and comprehension._**
#
# ---
#
#
#
# **S... | true |
242159f9acee4751aed66e2cbdaa8f963fa59230 | nihathalici/Break-The-Ice-With-Python | /Python-Files/Day-6/Question-18.py | 1,783 | 4.25 | 4 | """
Question 18
Question:
A website requires the users to input username and password to register.
Write a program to check the validity of password input by users.
Following are the criteria for checking the password:
At least 1 letter between [a-z]
At least 1 number between [0-9]
At least 1 letter between [A-Z]
At ... | true |
debe78de31d1ef894ede7a6f281aea3782427d12 | nihathalici/Break-The-Ice-With-Python | /Python-Files/Day-6/Question-18-alternative-solution-1.py | 1,557 | 4.15625 | 4 | """
Question 18
Question:
A website requires the users to input username and password to register.
Write a program to check the validity of password input by users.
Following are the criteria for checking the password:
At least 1 letter between [a-z]
At least 1 number between [0-9]
At least 1 letter between [A-Z]
At ... | true |
8e2886d38fd1b4b88fb947893956a68a71540a50 | nihathalici/Break-The-Ice-With-Python | /Python-Files/Day-7/Question-21-alternative-solution.py | 1,302 | 4.4375 | 4 | """
Question 21
Question:
A robot moves in a plane starting from the original point (0,0). The robot can move toward UP, DOWN, LEFT and RIGHT with a given steps. The trace of robot movement is shown as the following:
UP 5
DOWN 3
LEFT 3
RIGHT 2
The numbers after the direction are steps. Please write a program to comput... | true |
52771e507451a69ccadda4c761d5ee102555da77 | nihathalici/Break-The-Ice-With-Python | /Python-Files/Day-23/Question-96.py | 633 | 4.40625 | 4 | """
Question 96
Question
You are given a string S and width W.
Your task is to wrap the string into a paragraph of width.
If the following string is given as input to the program:
ABCDEFGHIJKLIMNOQRSTUVWXYZ
4
Then, the output of the program should be:
ABCD
EFGH
IJKL
IMNO
QRST
UVWX
YZ
Hints
Use wrap function of tex... | true |
de2f4062547f2fa7e380623b6f83ad1a74ad035e | Hongyin-bug/Phys-cs-15B-Electronics-lab | /liu_3418183_hw1/p3_hw1.py | 203 | 4.1875 | 4 | while True:
try:
x = float(input("x = "))
except ValueError:
print("Not a number, please enter again.")
else:
break
result = 2*(x**2) - 3*x + 2
print(result)
| true |
62106c67d4a00391ea0c34cf48e12e62f8de7d64 | aglebionek/UdemyPython | /Generators/script.py | 1,465 | 4.5 | 4 | # this method creates the list - meaning it calculates every element and stores all of them in the memory
def list_of_cubes(upper_bound):
return [x**3 for x in range(upper_bound)]
print(list_of_cubes(10))
# this method is a generator - meaning it calculates the elements as they are called for (I think it also ret... | true |
3db52d96143cd1ded6a171092d8fc742cbf8085b | SharonKeane1410/play_with_python | /getting_started/module1/Break_Continue.py | 700 | 4.375 | 4 | student_name = ["James", "Katarina", "Jessica", "Mark", "Bort", "Frank Grimes", "Max Power"]
print("Checks ALL Elements in the List for 'Mark' even after finding it will stay looking")
for name in student_name:
if name == "Mark":
print("Found him! " + name)
print("Currently testing " + name)
print("Che... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.