Skip to content

Instantly share code, notes, and snippets.

@KatiGithub
KatiGithub / StrAndIntCalc.py
Created October 8, 2018 13:42
This Python file calculates the number of letters and integers in an input or string
strchar = []
intchar = []
inpt = input("Input: ")
inpt = list(inpt)
for i in range(0, len(inpt)):
if inpt[i].isalpha():
strchar.append(inpt[i])
elif inpt[i].isdigit():
@KatiGithub
KatiGithub / 1 to 6skip3and6.py
Created October 8, 2018 13:20
This gist prints out the number 1 to 6 but skips the numbers 3, 6 using the continue statement in the if loop which is nested in the for loop.
for x in range(0,7):
if x == 3 or x == 6:
continue
print(x)
count_odd = 0
count_even = 0
numbers = [1,2,3,4,5,6,7,8,9,10]
x = 0
for x in numbers:
if x % 2 == False:
count_odd = count_odd + 1
@KatiGithub
KatiGithub / RandomIntGuess
Created October 5, 2018 08:38
Guess numbers 1 to 9 until you get it correct!
import sys
import random
randint = random.randint(1, 9)
x = int(input("What is your first guess between 1 to 9: "))
if x == randint:
print("Correct!")
@KatiGithub
KatiGithub / Multi7and5between 1500 and 2700.py
Last active October 5, 2018 08:25
This code finds all the multiples of 7 and 5 between the number 1500, 2700 using For loop.
nl = []
for x in range(1500, 2701):
if (x%7==0) and (x%5==0) == True:
nl.append(x)
print(nl)
@KatiGithub
KatiGithub / googletranswithlanguagechange.py
Created July 19, 2018 04:24
To work with this you need to do pip install googletrans and if using VSCode make sure to go into the directory at C:\Python\Python36\Lib\site-packages and take the folders correlated with googletrans API and copy and paste into your python workspace folder.
from googletrans import Translator
import sys
import codecs
import os.path
translator = Translator()
language = str(input("Language code: "))
file_Exist = str(input("Filename: "))
import os.path
import sys
read_or_write = str(input("Read or Write? (read/write)"))
exist_or_not = 0
if read_or_write == "read":
which_one = str(input("Which file would you like to read?"))
exist_or_not = os.path.exists(which_one)
@KatiGithub
KatiGithub / addorsubtractandrestart.py
Created June 29, 2018 13:28
This program is a simple addition and subtraction calculator and and will ask whether you want to subtract or add and after done with the first set of numbers it will ask to restart and you can either break or do it again. This loop is only two times.
answer = input("Do you want to subtract or add:")
def add_numbers():
first_number = int(input("What would be your first number to add? "))
second_number = int(input("What would be your second number to add? "))
total = first_number + second_number
print(total)
def subtract_numbers():
first_number = int(input("What would be your first number to subtract? "))
@KatiGithub
KatiGithub / OddorEven.py
Created June 28, 2018 13:03
This code has a for loop that runs through the people list and then seperate the list into even and odd indexes.
people = [
"A",
"B",
"C",
"D",
"E",
]
odd_people = []
even_people = []
@KatiGithub
KatiGithub / Lessthan10.py
Created June 20, 2018 09:17
This code asks for an input and then tells you numbers less than that on the list.
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
num = int(input("Choose a number from 1 to 10: "))
new_list = []
for i in x:
if i < num:
new_list.append(i)
print(new_list)