Skip to main content

Posts

Showing posts from September, 2020

Python create multiple choices for if statement

How to compare multiple choices in Python if statement? In an if else statement, if case sensitivity is a concern on the response or input from the user. Then the expected response should be defined on the if statement. Of course, there’s a good workaround on this kind of scenario like converting all input to lowercase or uppercase then start comparing or matching. Basically, the code below is for illustration purposes only. Converting the input to lowercase or uppercase is a good option, if the program is expecting a string input. However, code illustrated below will not be useful if the input is a number. In which case, converting the input to lowercase or uppercase will not help. Anyway, code below uses the string T, True or true as possible input that will display this message” You must have seen the sun! Or hoping to see the sun at the end of the tunnel!” if it matches “T, True or true”. If the input is TRUE, or other letter other than the characters mentioned above it...

Python if else pass or continue after evaluating input

Beginning in Python programming? If else statement is quite a basic statement in any programming language. If else is used in evaluating conditions or basically, it will tell the program what to do next if a specified match or input is encountered. In if else statement, depends on the conditional statement that is set then the next logic will determine on what action or execution will be performed. For example, after a match pattern occurs then the next statement will execute an action but sometimes after a match occurs you don't want to do anything instead the else statement will show what action or logic to be executed. In Python "continue" statement does not mean that it will continue to execute the code after the "continue" statement, instead it will break that execution and goes to the top of the code and continue the next course of action. However, "pass" statement in Python will mean literal "pass". So, if "pass" is...

Turn off Microphone settings in Windows 10

 How to turn off or disable Mic or Microphone settings in Windows 10? Steps below shows how to turn off Microphone settings in Windows 10. One method is to type: 'settings' on the search bar See image below: Another method, to bring up the settings option is to press "Windows Key + i key" together. See image below: Either method is used to bring up the settings, once the settings window is open. Type: micro or complete the word microphone Basically, the window settings has some sort of regex that matches the string that is being typed. See image below: The image above shows how to turn off the Microphone, if the login user has admin rights then the "change" option will be enabled. To turn it back on, just slide the switch on the microphone settings and it will be turned on. To test whether the microphone is working or not, Windows 10 provided a recorder called "voice recorder" app. On the search area just type: record and the voice recorder will be...

PowerShell read text file at a specific or certain lines

Reading log files or text file is quite basic and log files should be reviewed or else recording the logs if of no point. PowerShell code below read the 2 nd line of a specific text file specified on the path.   $logs = get-content c:\dev\log1.txt   "Line number 2 in log1.txt is: {0}" -f ( $logs [ 2 ] )     PowerShell code below uses a loop to read number of lines on a specific text file. $logs = get-content c:\dev\log1.txt   ForEach ( $line_number in 0 .. 10 ) {   "Line number $line_number is : {0}" -f ( $logs [ $line_number ] )}     Using above code, 0 is equal to line 1.   So, to read the first line code should be like this:     $logs = get-content c:\dev\log1.txt   "Line number 1 in log1.txt is: {0}" -f ( $logs [ 0 ] )     To read the last line: $logs = get-content c:\dev\xtest.txt -Tail 1 $logs     If above command will return an emp...