# IT & IoT Security | Cloud | It's all about the life itself

## Python – Valid character list

Hi, let us check the given string against a valid character list. There might be numerous way to do this. Here is a sample one.   str_to_check = “1234-3*33?3+—-!” valid_chars

## Python – Average word count 2

Hi, here is a kind of follow up for the 1st one. We, in this exercise , deal with leading space(s) , Boolean and punctuation. def average_word_length(my_string): space_sayisi = 0

## Python – Error Handling 2

Hi all, here are more examples for error handling. my_value = 10 try: print(1 / my_value) print(“No error occurred!”) except NameError: print(“A NameError occurred!”) except ZeroDivisionError: print(“A ZeroDivisionError occurred!”) except

## Python – Error Handling 1

Hi all, here are the samples for error handling with try/catch. my_value = “0” try: print(10 / my_value) except ZeroDivisionError: print(“Can’t divide by zero”) except: print(“Not possible”) When you run

## Python – Average word count

Hi  all, this a function usage sample and it aims to find average word count in a given string.  We call word_count and letter_count functions in average_word_length function. That’s all 🙂

## Python – get current date

Hi, here is a sample for getting current date and print it. There are various string formating that you can choose regarding to your needs. In order to drop the

## Python – Let’s count a word in a string

Hi, I guess this is not the best practice but it works 🙂 Let’s count “cat” in a given string. mystery_string = “why cat wy dog cat cacacat cacacat o

## Python- multiplication / time table

Hi, here is a time table code for a given value. The tricky part is the 2nd print() function. It starts a new line. my_int = 5 for i in

## Python – ord() and chr() functions

Hi, these functions, for example , convert a letter into its corresponding ascii code and vice versa. ord(A) –> give the value of 65 chr(65) –> would give “A” Here

## Python – guess hidden number

Hi, I am sure there are numerous way to solve this. Here is a way: import random keepPlaying=”y” while keepPlaying == “y”: print(“Game start!”) hiddenNumber = random.randint(1,100) userGuess=0 while not