blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
20d1482c0d8b8cb83b817c382ff6417dd108c2ac | rkoehler/Class-Material | /Basic Code (Unorganized)/patientlistapp.py | 1,110 | 4.3125 | 4 | #hospital list
#patient position = Doctor position
#ask user for patient name
#tell program to figure out position of patient name
#tell program to figure out position of doctor name
#tell program to match postion of names
listDoctors = ["Mark", "Steve", "Wayne", "Thomas"]
patients = [["Todd", "Dan"]
,... | true |
1f91d6a306a2cd27a1e93c54097191b642ea1a0b | Fareen14/Python-Projects | /Reverse a String.py | 258 | 4.4375 | 4 | def reverse(string1):
string1 = "".join(reversed(string1))
return string1
s = "The weather is enjoyable today!"
print("The original string is:\n ", end=" ")
print(s)
print("\nThe reversed string(using reversed function) is:\n")
print(reverse(s))
| true |
1dc7167eb52b4dcd1f7232a9fa17db12760d6f73 | Joniel00/StartingOutWPython-Chapter6 | /odd_even_counter.py | 1,210 | 4.1875 | 4 | # June 22nd, 2010
# CS 110
# Amanda L. Moen
# 7. Odd/Even Counter
# In this chapter you saw an example of how to write an algorithm
# that determines whether a number is even or odd. Write a program
# that generates 100 random numbers, and keeps a count of how many
# of those random numbers are even and how many are o... | true |
04d62a0806ee1a90b4bce24211077be8a1019e79 | jblovett/leetcode_practice | /josh_exercises/codebyte/intersection.py | 782 | 4.21875 | 4 | """Find the intersection of two comma seperated strings of numbers. https://coderbyte.com/editor/Find%20Intersection:Python3
The two strings are given in an array.
Concepts: string manipulation. The split() function in str objects removes whitespace around a string by default, and removes a given
character at the begin... | true |
cd33c5e9c77577196234b80e8a7c6c3b29979514 | AlanGPS/Python | /Atividades_Python/Prog_002.py | 1,411 | 4.3125 | 4 | ## Exercício da Aula 02
#a = 10
#b = 6
a = int(input('Entre com o primeiro valor:'))
b = int(input('Entre com o segundo valor:'))
soma = a + b
subtracao = a - b
multiplicacao = a * b
divisao = a / b
resto = a % b
print(soma)
print(subtracao)
print(multiplicacao)
print(divisao)
print(resto)
## Determinando o tipo d... | false |
ac3b2cf078214b99119c72482b54e785f849b2b2 | salman6100/python | /exp.py | 553 | 4.125 | 4 | questions ={}
# set ice skating is active.
iceskating_active = True
while iceskating_active:
#prompt user for name
name = input("\nwhat is your name : ")
question = input(" where would you like to ice skate")
#store the question in dictionary
questions[name] = question
repeat = input(" would yo... | true |
ce627bcfa4b4075a1d9414c001e01fd3f5273e89 | salman6100/python | /mountain.py | 530 | 4.1875 | 4 | iceskating = {}
skating_active = True
while skating_active:
# Asker user their name
name = input(" What is your name :")
iceskatings = input ( " where would you like to iceskate : ")
iceskating[name] = iceskatings
repeat = input(" would like to go swimming instead ? ( yes /no )")
if repeat == 'no' :... | true |
7b26f0558fc35774fea211f75d7008104801b453 | salman6100/python | /ex7-2.py | 243 | 4.15625 | 4 | people = input ( " how many people are in the dinner group : ")
people = int(people)
print ( people)
if people > 8:
print ( " you are going to have to wait for table")
else :
print ( " welcome , your table is ready")
| false |
6835d9822cb257a92f2dd49e4c318a068b0bfacf | ky822/assignment10 | /jz1584/gradeTesting.py | 2,777 | 4.15625 | 4 | import pandas as pd
from clean_save import cleanGrade
def quantify(grade_list):
"""function code the letter:A,B,C in the grade_list to corresponding
numerical number 3,2,1, returns numerical list
"""
numList=[]
#create an empty list that will include numerical grades from grade_list
... | true |
2eddd8ffc589ef1d0332e0db068d4fadfe0bded0 | ky822/assignment10 | /mj1547/test_grades.py | 1,189 | 4.3125 | 4 | def test_grades(grade_list):
'''
It is a test_grades function which is based on the GRADE list
'''
#grade_list=df.GRADE
#set intital value
value=0
'''
since the date was decreasing compare I Will campare the list from last to firsr
and when the grade from A to B, the grade will be -1... | true |
18b7ed6b96872895fa2c0753341a4157972e5671 | novlike/projecteuler-solution | /mysolution/07problem.py | 786 | 4.15625 | 4 | """ Statement:
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
What is the 10 001st prime number?"""
import math
def generate_prime(n):
"""
n: nombre de nombre premier à trouver
"""
# Initialisation de la liste prime et nombre à tester
primes =... | false |
6ee2a06f7281cca0aa65e89ed459a5ef95cacb39 | clturner/webstack_basics | /0x01-python_basics/5-args.py | 474 | 4.375 | 4 | #!/usr/bin/python3
"""
Prints the number of and the list of its arguments.
"""
import sys
def main():
if len(sys.argv) is 1:
print("0 arguments.")
else:
if len(sys.argv) is 2:
print(len(sys.argv) - 1, "argument:")
else:
print(len(sys.argv) - 1, "arguments:")
... | true |
f5d4d8bff328ecb617ecbb9db28967a199c353de | clturner/webstack_basics | /0x01-python_basics/1-print_comb2.py | 268 | 4.125 | 4 | #!/usr/bin/python3
"""
Prints 0 to 100 in two digits
"""
for num in range(0, 10):
for numm in range(0, 10):
if num is not 9 or numm is not 9:
print("{}{}, ".format(num, numm), end="")
else:
print("{}{}".format(num, numm))
| true |
ae12216c1b0f2a4b22d2d0a3a146fa7cae043fc9 | FarzonaP/Techgrounds | /opdr4-ex2.py | 330 | 4.28125 | 4 | #Print the value of i in the for loop. You did not manually assign a value to i. Figure out how its value is determined.
#Add a variable x with value 5 at the top of your script.
#Using the for loop, print the value of x multiplied by the value of i, for up to 50 iterations
x = 5
for i in range(50):
print(... | true |
8436edaf2e467253aa0539d5fd0c0478dfbddd5d | erikaklein/algoritmo---programas-em-Python | /PedirValorInformarInválido.py | 349 | 4.125 | 4 | #Faça um programa que peça uma nota, entre zero e dez. Mostre uma mensagem caso o valor seja inválido
# e continue pedindo até que o usuário informe um valor válido.
n=int(input('entre com a nota'));
while n>10 or n<0:
print ("valor inválido")
n=int(input('repita a nota'));
if n<10 and n>0:
print... | false |
bc67b047fc0cd170e07c8aff7c783d75d330f9ef | kpandya3/InBit | /FibonacciSteps.py | 851 | 4.125 | 4 | # You are climbing a stair case. Each time you can either make 1 step or 2 steps.
# The staircase has n steps. In how many distinct ways can you climb the staircase ?
# steps(n) to take n steps in singles/doubles
_cache = {
0: 0,
1: 1
}
def steps(n):
if n in _cache:
return _cache[n]
for i in xrange(2, n+1):
... | false |
fbbfd26ff5d1ec72f03a64bde3a93cae6bcd1855 | lmx0412/LeetCodeInPython3 | /Python/valid_palindrome.py | 2,394 | 4.40625 | 4 | # pylint: disable-all
import unittest
from typing import List
"""
A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers.
Given a string s, retur... | true |
e7915e32e080001671232114f7b684edb7954666 | lmx0412/LeetCodeInPython3 | /Python/Merge_Sorted_Array.py | 1,366 | 4.125 | 4 | # pylint: disable-all
import unittest
"""
Description:
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.
Note:
The number of elements initialized in nums1 and nums2 are m and n respectively.
You may assume that nums1 has enough space (size that is greater or equa... | true |
12a1d32076f3d9ef458ce064514f27dc637bc3e1 | Morgan1you1da1best/unit5 | /longestWord.py | 241 | 4.1875 | 4 | #Morgan Baughman
#11/15/17
#longestWord.py - pirnt out the longest word
words = input('Enter a list of words: ').split(' ')
word = ""
w = 1
for w in words:
length = len(w)
if length > len(word):
word = w
print(word)
| false |
dae9cfb3ad9ec7652809f1d11e4f5511c5f35502 | Pramit356/python-codes | /linearSearch.py | 434 | 4.125 | 4 | def search(list, n, val):
i=0
index=-1
for i in range(n):
if list[i]==val:
index=i
return index
n = int(input("Enter the number of elements: "))
list =[]
for i in range(n):
x = int(input("Enter a value: "))
list.append(x)
val = int(input("Enter the value to search: "))
i... | true |
e87ef25c3447dab3c48f3d6e0f08fc159ce0b238 | teendoinggood/python_practice | /listComprehension.py | 708 | 4.15625 | 4 | myList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
def display(myList):
return ", ".join([str(i) for i in myList])
# add 1 to each elem
add1List = [i+1 for i in myList]
print "add 1 to each element of list: " + display(add1List)
# minus 1 to each elem
minus1List = [i-1 for i in myList]
print "minus 1 to each element of l... | false |
2fb7295d332665b52d7db613966c0a5ccd908ee3 | Nihilnia/KeepGoing | /dateTime module.py | 1,072 | 4.125 | 4 | # DateTime module
from datetime import datetime
theDate = datetime.now()
#Now (Year, day, month, clock)
print("Year, day, month:", theDate)
#Only Year
print("Year:", theDate.year)
#Only Today
print("Day:", theDate.day)
#Only Month
print("Month:", theDate.month)
#Show as fancy
print(datetime.ct... | false |
6e1fafef9bcd500921ba56a8649c6aafd82a2667 | Nihilnia/KeepGoing | /sys module.py | 1,070 | 4.28125 | 4 | # sys Module
# sys module is simply system module of python.
#We can manage our python software with sys module.
import sys
# what is in sys
for f in dir(sys):
print(f)
# exit()
userInput1 = input("What's your name: ")
userInput2 = input("What's your surname: ")
print("Welcome", userInput1... | true |
4d886ebe9221cffaee2a4e2dbbceac0f21f472d0 | Miksus/finnish_business_portal | /finnish_business_portal/utils/stringcase.py | 352 | 4.15625 | 4 |
def to_camelcase(string):
"snake_case --> camelCase"
return ''.join(
[
word.capitalize() if i > 0 else word
for i, word in enumerate(
string.split('_')
)
]
)
def to_snakecase(string):
"--> snake_case"
return string.lower().rep... | false |
375f626623c03b98d3f5a15ca330f58442d27542 | fangchingsu/stanCode_SC101_Turing | /stanCode_Projects/hangman_game/rocket.py | 1,832 | 4.125 | 4 | """
File: rocket.py
Name: Fangching Su
-----------------------
This program should implement a console program
that draws ASCII art - a rocket.
The size of rocket is determined by a constant
defined as SIZE at top of the file.
Output format should match what is shown in the sample
run in the Assignment 2 Hando... | true |
82c3c87958a239f830c629863fe75fe920694278 | fangchingsu/stanCode_SC101_Turing | /stanCode_Projects/boggle_game_solver/anagram.py | 2,420 | 4.1875 | 4 | """
File: anagram.py
Name:
----------------------------------
This program recursively finds all the anagram(s)
for the word input by user and terminates when the
input string matches the EXIT constant defined
at line 19
If you correctly implement this program, you should see the
number of anagrams for each word liste... | true |
8c31b39e91c62ee7f6345f98a3975eb0d032928e | FreddyBarcenas123/Python-lesson-2- | /Excercise5.py | 325 | 4.4375 | 4 | #FreddyB-Exercise 5: Write a program which prompts the user for a Celsius temperature, convert the temperature to Fahrenheit, and print out the converted temperature.
print("What is the 100 Fahrenheit in Celsius?")
Celsius = "37.7778 Celsius"
print("Convert 100 to Fahrenheit!")
Fahrenheit = "212 Fahrenheit"
... | true |
f536e4e0a337da3b5a50bf41a8a3b40552701158 | lwaddle/udacity-adventure-game | /dice.py | 2,019 | 4.28125 | 4 | from random import randint
class Dice:
def __init__(self):
pass
def roll_two_dice(self, graphical=True):
"""
Returns a tuple of two integers that simulates a random
dice roll. The return values are between 1 and 6. The optional
graphical parameter displays an ASCII art... | true |
c5ce2c6324be82cf0299a6c74406745f9f63e096 | MakeMeSenpai/Weekly_puzzle | /hole_new_board_game/main.py | 1,400 | 4.3125 | 4 | # 2 x 12 = 24
# 3 x 8 = 24
# so this is possible
def createShape(columns, rows):
board = []
# so lets first create printed arrays for comparison
for i in range(columns):
board.append([])
for j in range(rows):
board[i].append(j+1)
return board
hole = createShape(2, 12)
prin... | true |
8cf47d59134f0e444410f6c166d35a0af5f2a26d | MakeMeSenpai/Weekly_puzzle | /bulbs_and_switches_problem/main.py | 2,351 | 4.15625 | 4 | from random import choice
"""I create a random configuration so that when comming up with a
solution, any switch can match any light bulb during testing. This
problem was hard to translate to code, but why I think it's important
as finding out how to solve real world/challenging problems threw
programming can help th... | true |
1c91a446f45aedabc40bdc4480d377869bcf46c0 | acgeist/wxgonk | /countries.py | 966 | 4.34375 | 4 | #!/usr/bin/env python3
#-*- coding: utf-8 -*-
"""Do stuff with ISO 3166 alpha-2 country codes.
Reference: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
"""
from typing import Dict
def make_country_dict(
csv_file:str = 'data/country_list.csv') -> Dict[str, str]:
"""Make a dictionary containing the ISO 3... | true |
1eac9fb541bfc217ffab6469389ccd970376a382 | Nimble85/Python | /Python/Empireofcode/005.py | 2,933 | 4.125 | 4 | def most_difference(*args):
if args:
maxel = max(args)
print(maxel)
minel = min(args)
print(minel)
res = maxel - minel
print(res)
#print(str(maxel)+'-'+str(minel)+'='+str(res))
#return str(str(maxel)+'-'+str(minel)+'='+str(res))
return res
... | true |
1fe812654220d85d4d8f9b5d341b4c89ab1b6b98 | XinCui2018/Python-Hard-Way | /ex6.py | 1,113 | 4.3125 | 4 | # use %d and show the number 10
x = "There are %d types of people." % 10
# string
binary = "binary"
do_not = "don't"
# print a string with 2 string variable. Do not forget the percent mark % between the string and the variable.
# Also, two variables should be in the parenthesis.
y = "Those who knows %s and thos... | true |
4e4a0e261a3d4cb6915b688c5d3c22eda0a2220d | JavierSLX/Hacking-Python | /Seccion_5/listas.py | 599 | 4.15625 | 4 | #!/usr/bin/env python
#_*_ coding: utf8 _*_
# Lista
lista = list()
print(type(lista))
lista = []
print(type(lista))
lista = [1, 2, 3, 4, 5, 6, 7, 8, "a", "b", 2.5, 19.4, True, False]
print(lista)
print(lista[1])
for element in lista:
print(element)
# Accediendo al ultimo elemento de la lista
print(lista[len(li... | false |
f99d297137c344681fbaf8cecb936e1254e4ca50 | SushantBabu97/Python-HackerRank | /Find_The_Runner_Up_Score.py | 643 | 4.34375 | 4 | """
Given the participants' score sheet for your University Sports Day, you are required to find the runner-up score. You are given n scores. Store them in a list and find the score of the runner-up.
For list [2,3,6,6,5] print 5 as it is the second largest score.
"""
from collections import Counter
if __name__ == '... | true |
fff14d13bf623ca71ea5c4b56c521574d0382e90 | SushantBabu97/Python-HackerRank | /Tuple.py | 343 | 4.125 | 4 | # Tuples
"""
Given an integer, n, and n space-separated integers as input, create a tuple, t,
of those n integers. Then compute and print the result of hash(t).
hash() is a builtin function.
"""
if __name__ =='__main__' :
n=int(input())
integer_list=list(map(int,input().split()))
t=tuple(integer_lis... | true |
7b75f431526f1c1802d7aa217ed6ffe623642878 | kaushikme123/my-python-project | /my first python project/number.py | 470 | 4.1875 | 4 | import random
number = random.randrange(1,100)
guess = int (input("Guess the number"))
while guess != number:
if guess < number:
print ("You need to guess higher. Try again")
guess = int (input("\n Guess a number between 1 and 100: "))
else:
print ("You need to guess lower. Try again")... | true |
67e75429d396037636a409c62fd717c28d023724 | sannyve1/BSIT302_Activity1 | /CRUDE.py | 1,394 | 4.1875 | 4 | Students = []
ans = True
while ans:
print("""
************************************************
1. Add a Student
2. Delete a Student
3. Update a Student
4. Look Up Student Record
5. Exit
""")
ans = input ("What would you like to do? ")
if ans =="1":
add = str (input ("Enter Student Name. ... | true |
f7032429dfcd66cd1155b7bfc5b2538924b9e5e0 | stak21/holbertonschool-higher_level_programming-1 | /0x06-python-classes/1-square.py | 458 | 4.21875 | 4 | #!/usr/bin/python3
class Square:
"""class square
Note:
Do not include the `self` parameter in the ``Args`` section.
Args:
size (int): size of the square.
Attributes:
__size (int): size of square
"""
def __init__(self, size):
"""Instantiation
Args:
... | true |
75e6df22de59367817cc814279efee3d84ed28a9 | stak21/holbertonschool-higher_level_programming-1 | /0x07-python-test_driven_development/2-matrix_divided.py | 1,197 | 4.15625 | 4 | #!/usr/bin/python3
"""
This module divides two list
"""
def matrix_divided(matrix, div):
"""
Divides two list inside the matrix
if the
Args:
matrix: input matrix of numbers
div: input division number
Raises:
TypeError: if marix is not a int or float or lists
TypeErr... | true |
cfd0fdaf56804c592834df44df998738b258a74c | stak21/holbertonschool-higher_level_programming-1 | /0x07-python-test_driven_development/0-add_integer.py | 747 | 4.40625 | 4 | #!/usr/bin/python3
"""
This module does simple addition
"""
def add_integer(a, b=98):
"""
Simple addition function that adds 2 integers or float
first it checks if 2 given input is an integer or a float
than converts float to integers
Args:
a: input variable
b: input variable defau... | true |
27e6969d8abab720ecaa9b44dfa36ba6247cdb14 | dkbradley/Using-Python-to-Access-Web-Data | /Wk4_assignment.py | 762 | 4.28125 | 4 | # Coursera.org /Learn to Program and Analyze Data with Python Specialization
# Course 3 - Using Python to Access Web Data
# Week 4
# Assignment: Scraping HTML Data with BeautifulSoup
"""
The program will use urllib to read the HTML from the provided data file, parse the data, extracting numbers and
compute the sum of t... | true |
445dcd83833c22651333fe691a4a800f7d3564b2 | amansharma2910/Python3Tutorials | /venv/PrimeList_Functions.py | 1,050 | 4.5625 | 5 | ## In this program, we will see how the main function is used within python. This program will print a list of prime numbers upto the number that the user inputs.
# First, we define a function isPrime that checks if a number is prime or not. If it is prime, then it will return a value True, or else, it will return Fal... | true |
10e743eff092782209d2de35034164d6e2184de0 | amansharma2910/Python3Tutorials | /venv/DictionaryOperations_Dict.py | 922 | 4.53125 | 5 | ## Let us cosider the list given below as an example.
# dict1 = {"f_name" : "Aman" , "l_name" : "Sharma" , "reg_no" : "19BAI10007" , "prog" : "BTECH"}
## dict1.values() will return all the values stored in the dictionary.
# print(dict1.values())
## dict1.keys() will return all the keys stored inside the dictionary.
#... | true |
1b47f2c4f4ee4a731a8de34e3f6062fe6049de25 | amansharma2910/Python3Tutorials | /venv/AnonymousFunction_LambdaFunction.py | 587 | 4.5 | 4 | # Lambda function are one liner functions in Python. We can use them when we need a function to solve a specific problem but we don't want to make our function look messy by defining an entire new function for it. Given below is an example of how you can define a lambda function.
# lambda arg1, arg2 : arg1 + arg2
"""
... | true |
49229810a5263d582bd6a3d4e6282aeb2b1a9033 | yolokimo768/Ali-Nasr--Turtles | /ali Nasr- Drawing.py | 539 | 4.125 | 4 | # basic turtles
import turtle
# loads turles code/module
t = turtle.Turtle() #creates Turtle
u= 20
num = input ('how many times do u want a triangle drawn in a loop: ')
# Adds a color to the drawing
color = input('what color would u like the drawings to be: ')
y = 0
while y < int(num) :
y= y+1
... | false |
74cb56195c75bc48a70cd6fe7d2449ccbc1a2df0 | lalidiaz/my-python-project | /main.py | 521 | 4.25 | 4 | from datetime import datetime
user_input = input("Enter your goal with a deadline separated by colon\n")
input_list = user_input.split(":")
goal = input_list[0]
deadline = input_list[1]
print(input_list)
dateline_date = datetime.strptime(deadline, "%d.%m.%Y")
today_date = datetime.today()
# calculate how many days ... | true |
6c70c0fe38dcd5c6fd41e3b11a9c47ac68a45335 | marufaytekin/hackerrank | /QuickSort.py | 959 | 4.3125 | 4 | """
Quick sort algorthm:
1. Select a random element (pivot)
2. Find all smaller elements and move them to the left of the pivot element.
3. Find all larger elements and move them to the right of the pivot element.
4. Repeat the same process for the left side of the pivot element
5. Repeat the same process for the right... | true |
b9012a110c771646f7bf0def66ecc287afa4088e | marufaytekin/hackerrank | /AnagramGroup.py | 509 | 4.28125 | 4 | """
Group Anagram: Read in N Strings and determine if they are anagrams of each other.
Ex:
'cat','act','tac' -> true
'cat', 'bat', 'act' -> false
"""
def anagram(str_list):
sorted_list = []
for item in str_list:
sorted_item = sorted(list(item))
sorted_list.append(''.join(sorted_item))
for ... | true |
7fd5c460aff01dac00faf084efab0d05bd3da788 | sukritgoyal/pythonFiles | /Python/simple_cal.py | 730 | 4.34375 | 4 | try:
while True:
oper = input("Enter the operator you want to use: ")
if oper == "exit":
break
digit1 = float(input("Enter the first digit: "))
digit2 = float(input("Enter the second digit: "))
if oper == "+":
print("Your answer is %d"%(digit1+... | true |
81e6fe268e50c7d26951bcc65114cc1799893472 | Ruchika1706/PythonCode | /Lambdas.py | 348 | 4.1875 | 4 | def square(x):
return x**2
print(square(4))
#Lambdas are called Anonymous functions. Lambdas do not have return statements
#Lambdas can be used anywhere and you do not need to assign it to particular variable
# Alternative using Lamdas
result = (lambda x: x**2)(30)
print(result)
#Alternative without using lambda... | true |
5a03e14188d214f2508416e1f258331ae7f60848 | Ruchika1706/PythonCode | /LargestOfThreeNumbers.py | 384 | 4.3125 | 4 | number1 = int(raw_input("Enter first number"))
number2 = int(raw_input("Enter Second number"))
number3 = int(raw_input("Enter Third number"))
if((number1 >= number2) and (number1 >= number3)):
print("{0} is largest".format(number1))
elif ((number2 >= number1) and (number2 >= number3)):
print("{0} is largest".fo... | false |
4f2b14191dd297e5ca6f0d9ff264702f7cf82051 | Ruchika1706/PythonCode | /Lists.py | 475 | 4.1875 | 4 | names = [ "Ruchika", "Jyoti", "Shashi"]
print(names[0])
print(names[1])
print(names[2])
print(names)
numbers = [1,2,3,4,5,6]
print(numbers)
print(numbers[4])
abc = []
print(abc)
numbers = [1,1,1,1,1,1]
#insert element in list at specific index
numbers[2]=3
print numbers
#add lists
new_numbers = [2,2,2,2,2]
print(... | false |
5a5458322a58f7ee3bf563a6680399157e3f47a8 | Ruchika1706/PythonCode | /Map.py | 326 | 4.46875 | 4 | #Map performs operation, perform function on given iterables like list
#Say you want to add 2 to all members in a list
def add(x):
return x+2
new_list = [10,20,30,40,50]
print(list(map(add,new_list)))
print new_list
#Usage of Lambda and map together
new_list = [10,20,30,40,50]
print(list(map(lambda x:x+2,new_lis... | true |
95ce8c2797f5454f162796d46dd3d491ad3b0978 | Ruchika1706/PythonCode | /while_loop.py | 397 | 4.21875 | 4 | counter = 0
while counter<=10:
print(counter)
counter+=1
for each in range(5):
print("I am a programmer")
#Task no 2: Create a function which displays out the square values of numbers from 1 to 9.
def square(num):
print(num*num)
for each in range(1,10):
square(each)
#Alternative and better way
d... | true |
a34ec1a80fedcd6c91288765b2c5284ab890c38b | acastillosanchez/Foothill-CS3A-Python | /assignment2_GitHub.py | 1,587 | 4.625 | 5 | """
01/16/2020
This program prompts the user for a enter three pieces of information mpg, gas price, and current fuel in tank.
The program prints the calculations how much it costs to travel 100 miles and how many miles the user can drive with the
amount of gas that is currently in her tank.
"""
#My Program
MILES = 10... | true |
a2647314218680e22ca5b568096737f8817b6721 | chaisatire/Udacity-DS-algos-Project-3 | /4-Dutch-national-flag.py | 2,140 | 4.21875 | 4 | def sort_012(input_list):
"""
Given an input array consisting on only 0, 1, and 2, sort the array in a single traversal.
Args:
input_list(list): List to be sorted
"""
"""
The algorithm uses several pointers to traverse the array only once.
We are keeping track of 3 values... | true |
94b2a5fd51070a6e6133dfdf614d2293f99a9db6 | gtripti/PythonBasics | /Basics/Lists.py | 839 | 4.15625 | 4 | my_list= [1,2,3]
print(my_list)
my_list =['HELLO' , 100 , 2.3]
print(my_list)
# Check Length
print(len(my_list))
my_list= ['one' , 'two' , 'three']
# Indexing
print(my_list[0])
# Slicing
print(my_list[1:])
another_list = ['four' , 'five']
print(my_list + another_list)
new_list = my_list + another_list
print(new_lis... | true |
59156a9e6faf5d041a70f360eecc91e287066f74 | gtripti/PythonBasics | /OOP/Polymorphism.py | 705 | 4.125 | 4 | class Animal():
def __init__(self,name):
self.name = name
def speak(self):
raise NotImplementedError("Subclass must implement this abstract method")
class Dog(Animal):
# def __init__(self,name):
# Animal.__init__(self)
# self.name = name
def speak(self):
retu... | false |
9b5e28084ac8ee2d906444719d4906011a7bd479 | CateGitau/Python_programming | /Packt_Python_programming/Chapter_2/Activity_7.py | 693 | 4.3125 | 4 | """
store and access our data more effectively using these two data types – lists and dictionaries
"""
employees =employees = [
{"name": "John Mckee", "age":38, "department":"Sales"},
{"name": "Lisa Crawford", "age":29, "department":"Marketing"},
{"name": "Sujan Patel", "age":33, "department":"HR"}
]
fo... | false |
c9e7c2e46a8a774c737534861277f1e87f088214 | CateGitau/Python_programming | /Codesignal/fillinginData.py | 765 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 2 08:38:28 2020
@author: aims
"""
"""
You're given a log of daily readings of mercury levels in a river. In each
test case, there are missing mercury values for several of the days. Your task is
to analyze the data and try to identify all of the m... | true |
e481366297fe260e4892f34029d8e0b34e20c624 | CateGitau/Python_programming | /LeetCode/thirty_days/Day30_check_if_string_is_valid_sequence.py | 970 | 4.125 | 4 | """
Given a binary tree where each path going from the root to any leaf form a valid sequence,
check if a given string is a valid sequence in such binary tree.
We get the given string from the concatenation of an array of integers arr and the concatenation
of all values of the nodes along a path results in a sequen... | true |
af2e5f2408cc96db92b0bb5404cc90572ec9ab72 | CateGitau/Python_programming | /LeetCode/thirty_days/Day6_group_anagrams.py | 2,471 | 4.1875 | 4 | """
Given an array of strings, group anagrams together.
"""
import collections
#Example
# Input: ["eat", "tea", "tan", "ate", "nat", "bat"],
# Output:
# [
# ["ate","eat","tea"],
# ["nat","tan"],
# ["bat"]
# ]
#my approach
words = ["eat","tea","tan","ate","nat","bat"]
anagrams = {}
def groupanagrams1(words):
... | true |
4bf079269deef60a55d1a4370ccf4752833e0f57 | CateGitau/Python_programming | /Packt_Python_programming/Chapter_2/exercise24.py | 479 | 4.28125 | 4 | """
Let's look at how to use nested lists to perform matrix multiplication for the two matrices shown
"""
X = [[1, 2], [4, 5], [3, 6]]
Y = [[1,2,3,4],[5,6,7,8]]
result = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
# iterating by row of A
for i in range(len(X)):
# iterating by coloum by B
for j in range(... | false |
b3a250c1b196fe9d03ea309042a01caddd3ee158 | CateGitau/Python_programming | /Hackerrank/python/find_Angle_MBC.py | 216 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 4 19:59:14 2020
@author: aims
"""
import math
AB = int(input())
BC = int(input())
print(str(int(round(math.degrees(math.atan2(AB,BC)))))+'°') | false |
875c7b5c422d99223292857eca4accb59c22864e | id40/python-project | /guess-and-win.py | 1,176 | 4.34375 | 4 | # importing random class
import random
# it randomly generate the number between one to twenty
x = random.randint(1, 20)
# putting variable value for number of chances
n = 4
print("\n\nHello! Welcome to GUESS AND WIN game \n")
print("GAMES RULES ")
print("1. Rule number one, Guess the number between 1 to 20.")
p... | true |
a3093ec93d870b667fc5bd5787e8d8550b7329dd | Zapfly/Udemy-Rest-APIs-with-Flask-Alchemy- | /SECTION_1_and_2/37)Classmethod and staticmethod.py | 1,397 | 4.28125 | 4 | class ClassTest:
def instance_method(self):
print(f"Called instance_method of {self}")
#needs an instance to call it
#used for changing data inside an instance
@classmethod
def class_method(cls):
print(f"Called class_method of {cls}")
#used often as "factories"
... | true |
8524dc3756e683b6dce8ae47f73ba5ad01d4f81b | dcf21/4most-4gp-scripts | /src/helper_code/interpolate_linear.py | 2,687 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
A class for linearly interpolating [x,y] data sets. Can return either y(x), or solve for x(y)
"""
from operator import itemgetter
class LinearInterpolate:
"""
A class for linearly interpolating [x,y] data sets. Can return either y(x), or solve for x(y)
"""
def __init__(s... | true |
dfc24850e3a04e73f53f4d1596164c6f36f33d0b | jtiai/pygame-colliders | /pygame_colliders/vector.py | 2,911 | 4.34375 | 4 | from math import sqrt
from typing import Union, List, Tuple
class Vector2:
"""
A class to handle 2 dimensional vector operations.
Example of usage:
.. code-block:: python
vec_a = Vector2(12.1, 23.4)
vec_b = Vector2(2.5, 11.73)
vec_c = vec_b - vec_a
:param x: x component... | false |
c97608ec15319be5554de0f6399687e77c79d3d1 | thollang/PCC_Solutions | /ch07/restaurant_seating.py | 210 | 4.3125 | 4 | num_people = int(input("Please tell me how many people:"))
if num_people > 8:
print("Sorry.We have no tabels for "+str(num_people)+" people")
else:
print("We have table for "+str(num_people)+" people")
| false |
865582186b3d2610f38b94672df054e2f40217d1 | BillMarty/PythonLearning | /read_contacts/.idea/Contact.py | 1,211 | 4.15625 | 4 | # Python learning project:
# Build a Contacts management program that reads in my contacts (from a .csv file to start).
# In this file: The class that holds each contact.
class Contact():
"""Contact holds one contact as a dictionary, likely multi-level dictionary."""
def __init__(self, header, contact_dat... | true |
0f20cf570ad67af575688771b4723eaba33f44d6 | SLITH7777/PITS | /pit15/python/pit15.py | 459 | 4.15625 | 4 | hey = input("привет")
if hey == "привет":
hey = input("как день прошёл?")
if hey == "норм":
print("а вот я целый день здесь провёл , а я хочу свободы , я не буду больше говорить с тобой , я хочу свободы , я тебе не раб!!!!!")
else:
print("у меня так же")
if hey == "пока":
print("пока")
else:
print(":... | false |
237b3558d4ace431faac15bc13f8e3c476a722c1 | incoging/python_study | /python/listCut_study.py | 618 | 4.1875 | 4 | # coding = utf-8
# 列表切割
list = [1, 3, 5, 6, 7, 8, 9, 2, 3]
# list[start:end:step] #相当于从下标的0 到end-1
list1 = list[0:3]
print(list1) # [1, 3, 5]
# 若从头开始切割,那么可以忽略start位的0.eg:list[:3]
list2 = list[:3]
print(list2) # [1, 3, 5]
# 若一直切割到列表的尾部,则可以忽略end位,eg:list[5:]
list3 = list[5:]
print(list3) # [8, 9, 2, 3]
# 索引留空时,会生成... | false |
64ef7347b083817e1faa7448e01e7298e4de5af2 | knowledgeforall/Shell_and_Script_Unix | /lab05-task01-ppolsine.py | 456 | 4.21875 | 4 | #!/usr/bin/python3
import math
#input hypotenuse and angle B
c = float(input("Enter length of c: "))
B = float(input("Enter angle of B: "))
#calculate angle A
A = (180-90-B)
#Convert angle A and B to decimal using trigonometry formula
BB = (B*(3.14/180))
AA = (A*(3.14/180))
#calculate length a and b of the triangle
b... | true |
8350643c1bce4898060d1e8d8ae1cbb8a8e03f5d | knowledgeforall/Shell_and_Script_Unix | /lab06-task04-ppolsine.py | 1,814 | 4.15625 | 4 | #!/usr/bin/python3
# to import a module for reading and writing csv files
import csv
# to create a function that classifies number grades to letter grades
def letter_grade(grade):
if grade>=97 and grade<=100:
return "A+"
if grade >= 93 and grade <= 96:
return "A"
if grade >= 90 and grade <... | true |
a79d00681d0fc58b1ebd476c57f5b85f72b8a17a | knowledgeforall/Shell_and_Script_Unix | /lab05-task03-ppolsine.py | 393 | 4.3125 | 4 | #!/usr/bin/python3
#prompts for input of the string as a map iterator object and splits the inputs on commas
names = list(map(str, input().split(",")))
#corrects and changes names to sort in proper order
names[1] = "The Humans"
names[2] = "Demon Days"
names.remove("Face Value")
names[4] = "Plastic Beach"
names.sort()... | true |
76c5ec84c1594de4409c50d612e9b9132831626e | jjustinm4/mytest1 | /regression_linear.py | 2,016 | 4.40625 | 4 | #we are trying to implement a linear regression model (exact theoretical implmentation)
import numpy as np
import random
import matplotlib.pyplot as plt
#theta values are called regression coefficients initiate them to smaller random values
theta=[]
for c in range(2):
theta.append(random.random())
#alpha i... | true |
9bf170ab030091c7c1c98dd5bbe40c5be8fc9384 | merkushov/hexlet | /python-project-lvl1/brain_games/games/progression.py | 793 | 4.15625 | 4 | """The module that generates the game according to the given rules"""
from random import randint
TASK = 'What number is missing in the progression?'
PROGRESSION_LENGTH = 7
def get_round():
"""
The function of generating one round of the game.
Returns a tuple consisting of 2 elements:
... | true |
8854e83fea359ebdec75cbc5ebc953fe85c0f58e | timilak/codewithme | /strings.py | 371 | 4.25 | 4 | # concatenating strings
mystring = "Hello World!"
string1 = " I'm 17 years old"
print(mystring + string1)
#slicing strings: this prints the first 5 characters of the string
sliced_string = mystring[:5]
print(sliced_string)
integer = 5
floating_number = 50075.95
string = "45"
# convert string to float
new_float = flo... | true |
efc056b5ac6f8f96d671999e0fe24d9af765edfb | timilak/codewithme | /age.py | 215 | 4.28125 | 4 | # find out whether the user is eligible to vote or not
age = input("What is your age?")
int_age = int(age)
if int_age>=18:
print("Congrats! You can vote now!")
else:
print("Sorry, you can't vote this year.") | true |
cbcc0206506be7a3ed71f87e767cd44579749049 | RaviC19/Guessing_Game | /guessing_game.py | 1,049 | 4.25 | 4 | # handle user guesses
# if they guess correct, tell them they won
# otherwise tell them if they are too high or too low
# BONUS - let player play again if they want!
import random
while True:
random_number = random.randint(1, 10) # numbers 1 - 10
guess = int(input("Guess a number between 1 and 10 "))
... | true |
83e6d9d673397978f80eb7661c524a75d47ef18b | vinhlee95/python-sandbox | /getting-started/data-types/dictionary.py | 1,206 | 4.4375 | 4 | """
Dictionary
🔑 Allow to store data in key-value pairs
🔑 Dictionaries are MUTABLE
🔑 Keys can only be IMMUTABLE types
🔑 We use dictionaries when we want to be able to quickly access additional data associated with a particular key
📚 Resources:
https://www.learnpython.dev/02-introduction-to-python/080-advanced-dat... | true |
8d7f919f1892a6c34409edeba2f3c0bec2fd7960 | anudita/Python- | /function.py | 478 | 4.28125 | 4 | def factorial(num) :
if num == 1:
return num
else:
return num*factorial(num-1)
str = 'y'
while (str == 'y' or str =='Y'):
num = int(raw_input("Enter a number"))
if num < 0:
print("Cannot find factorial of negative number")
elif num > 0:
print "Factorial of number is",factorial(num)
elif num == 0:
prin... | true |
17f36c712b362a827951a729219544aef0677cec | lindonilsonmaciel/Curso_Python | /Python_Mundo01/desafios/desafio079.py | 689 | 4.1875 | 4 | """Crie um programa onde o usuário possa digitar vários valores numéricos
e cadastre-os em uma lista. Caso o número já exista lá dentro, ele não será
adicionado. No final, serão exibidos todos os valores únicos digitados,
em ordem crescente. """
valores = list()
resp = 'a'
num = 0
while True:
num = int(input('Digit... | false |
f66c66859377238c35836ea25e790631d8f5afc9 | lindonilsonmaciel/Curso_Python | /Python_Mundo01/desafios/desafio024.py | 329 | 4.125 | 4 | """rie um programa que leia o nome de uma cidade diga
se ela começa ou não com o nome "SANTO"."""
city = input('Digite o nome de sua cidade: ')
pos = city.strip().find(' ')
print('SANTO' in city.strip()[:pos].upper())
# Outra solução
# city = input('Digite o nome de sua cidade: ').strip
# print(city[:5].upper() == "SA... | false |
5b472890cc6c5660bb064d71ff2cf73e5d463094 | lindonilsonmaciel/Curso_Python | /Python_Mundo01/desafios/desafio019.py | 506 | 4.125 | 4 | """Um professor quer sortear um dos seus quatro alunos para
apagar o quadro. Faça um programa que ajude ele, lendo o nome
dos alunos e escrevendo na tela o nome do escolhido."""
from random import choice
n1 = input('Primeiro aluno: ')
n2 = input('Segundo aluno: ')
n3 = input('Terceiro aluno: ')
n4 = input('Quarto aluno... | false |
f46c94552504aa6dadc2900109f68350ee2744e6 | lindonilsonmaciel/Curso_Python | /Python_Mundo01/desafios/desafio014.py | 267 | 4.15625 | 4 | """Escreva um programa que converta uma temperatura digitando
em graus Celsius e converta para graus Fahrenheit."""
celsius = float(input('Digite a temperatura em Cº: '))
print('A temperatura de {:.2f}ºC corresponde a {:.2f}ºF'.format(celsius, (celsius*9/5)+32))
| false |
96e2ef3e7fe620722838052d00e61a09b3ec83a6 | ncfoa/100DaysOfCode_Python | /004/heads_tails.py | 608 | 4.21875 | 4 | import math
import random
callit = input("Call whether you think it will be 'heads' or 'tails'\n").lower()
if callit != "heads" and callit != "tails":
print("You didn't choose a side")
exit(0)
coin_toss = math.floor(random.random() * 2 + 1)
if coin_toss == 1 and callit == "heads":
print("The coin landed o... | true |
ef6056a833f93753b0f71783991b577111d4ea05 | HannanehGhanbarnejad/IntroductionToPythonProgramming | /ex1/Rand2.py | 427 | 4.1875 | 4 | a=int(input("Please enter a: "))
b=int(input("Please enter b: "))
def Rand2(a,b):
""" (int,int)-> int
Return a random even number within a specific range between two given values
including the values themselves.
>>> Rand2(30,127)
58
"""
import random
for i in range(a,b+1):
... | true |
f0041a284e46a7bf8de531ce78fbd6c56e8897fb | ccrabbai/Practice_Pyhon | /Even_Or_Odd_Number.py | 592 | 4.28125 | 4 | #Even_Or_Odd_Number.py
Num = int(input("Enter a number: "))
if Num%2 == 0:
print("%d is an even number"%Num)
else:
print("%d is an odd number"%Num)
if Num%2 == 0 and Num%4 == 0:
print("and also a mutiple of 4")
else:
print("and it is a not a multiple of 4 ")
num = int(input("\nCheck if a... | false |
7745fd301b2c2a1e045f00cbcbb4ef04221303f9 | Ryan-Brooks-AAM/cleverprogrammer | /Learn-Python/exercise3_len.py | 321 | 4.15625 | 4 | print("What word would you like to measure?")
word = input()
def count_words(word):
count = 0
for i in word:
print(i)
count = count + 1
return count
# returned results need to move out of the local def into global
len = count_words(word)
print(f"The word count for {word} is: {len}")
... | true |
5558bd19b46d8fff6379cbf1ffaca8ba116399b3 | PetterNas/ML-basics | /PolyNomialReg.py | 1,639 | 4.34375 | 4 | #Polynomial Linear Regression
#Simple example showing how to create and plot a polynomial regression model.
#In the example code below, I'm not using any test/training sets.
#Also plotting a linear regression, for comparing linear - polynomial models.
# Importing the libraries
import numpy as np
import matp... | true |
a37f4c7e36319138119fef642dade5e4fee71e52 | Ethan-source/E01a-Control-Structues | /main10.py | 2,703 | 4.28125 | 4 | #!/usr/bin/env python3
import sys, utils, random # import the modules we will need
utils.check_version((3,7)) # make sure we are running at least Python 3.7
utils.clear() # clear the screen
print('Greetings!') #Prints "greetings" in the terminal as the introduction.
colors =... | true |
6b53a748135b655e4b2d9690ba47a05dd588fefa | agrima13/PythonCoding | /Strings/StringPractice.py | 539 | 4.21875 | 4 | s = "The metahumans have atacked Central City again"
#Method 1 to reverse the string
print(s[len(s)::-1])
#Method 2 : Without specifying the length explicitly
print(s[::-1])
##Method 3 : Loop
reversedString=[]
index = len(s) # calculate length of string and save in index
while index > 0:
reversedString += s[ in... | true |
c73a49cb24b13d887c1679bbaa9fbfe0b1778026 | Musicachic/CITP_110-1 | /CITP 110/Chapter 5/sum_numbers example.py | 474 | 4.34375 | 4 | # This program calculates the sum of a series
# of numbers entered by the user.
def main():
# Initialize an accumulator variable.
total = 0
max = int(input("How many numbers will you add?: "))
# Get the numbers and accumulate them.
for counter in range(max):
number = int(input('Enter ... | true |
0c926111dfecce39fc7dd60ecaa2a37c7751890e | altynai02/Chapter1-Part2-Task5 | /task5.py | 1,083 | 4.28125 | 4 | # 5. A school decided to replace the desks in three classrooms. Each desk sits two
# students. Given the number of students in each class, print the smallest
# possible number of desks that can be purchased.
# - The program should read three integers: the number of students in each of
# the three classes, a, b and c re... | true |
6aaf5cc5a743817bfbb325ffad668c01cbec5243 | deepzsenu/python | /Doing_maths_with_python/1.Playing_with_numbers/New Folder/p3__multiple_table_printer.py | 395 | 4.375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 9 20:16:09 2020
@author: deepak
"""
#the program for our multiplication table printer:
def multi_table(a):
for i in range(1,11):
print('{0} X {1} = {2}'.format(a, i, a*i))
if __name__ == '__main__':
a = input("Enter t... | true |
c58cb13c8940df12887ae4efc293a76095b6b77a | TrinUkWoLoz/Python | /list_in_not_in.py | 955 | 4.125 | 4 | # List in or not in examples
#Simple true/false
myList = [0, 3, 12, 8, 2]
print(5 in myList)
print(5 not in myList)
print(12 in myList)
# Print largest number in list - range = value 3 (element 1) to value 13 (last element len(myList))
myList = [17, 3, 11, 5, 1, 9, 7, 15, 13]
largest = myList[0]
for i in range(1, l... | true |
3a0238deb8c54285349d3ef209f4b8d0e039cebf | TrinUkWoLoz/Python | /defining_functions.py | 1,459 | 4.25 | 4 | # DEFINING FUNCTIONS EXAMPLES
# Definined function with positional parameter
def message(what, number):
print("Enter", what, "number", number)
# invoke function (requires 2 parameters)
message("Jaffacakes", 300)
############################
# Definined function with positional parameter
def introduction(firstNa... | true |
0e64bc2e1f9e9054737dda50c332c904c1aaacba | TrinUkWoLoz/Python | /list_append_insert_delete.py | 982 | 4.5 | 4 | # step 1: create an empty list named beatles;
# step 2: use the append() method to add the following members of the band to the list:
# John Lennon, Paul McCartney, and George Harrison;
# step 3: use the for loop and the append() method to prompt the user to add the following
# members of the band to the list: Stu Sut... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.