Friday, November 19, 2021

Python WHILE CONTINUE and BREAK Example

# CONTINUE to allow user to withdraw and display balance until value 0 is used to exit(BREAK)

 balance=10000;
while True:
    print('****Continue example *****')
    print('Enter amount to withdraw :')
    val=input()
    if(int(val)<0):
        continue
    elif(int(val)==0):
        print('Exiting program')
        break
    else:
        balance=balance-int(val)
        print('balance is now :'+str(balance))

print('****End of balance****')

Python IF ELSE WHILE BREAK

Breaks out of the loop

 while True:
    print('***** BEGIN ******')
    print('Program to find if the person is a Minor, Teenager or Adult.')
    print('Enter a value :')
    age=int(input())
    
    if(age>0 and age<13):
        print('Participant is a Child')
    elif(age>13 and age <18):
        print('Participant is a Teenager')
    elif(age>18):
        print('Participant is an Adult')
    elif(age==0):
        break;

print('*** EXIT END OF PROGRAM *****')

Python Flow statements IF ELSE ELIF

 print('***** BEGIN ******')
    print('Program to find if the person is a Minor, Teenger or Adult.')
    print('Enter a value :')
    age=int(input())
    
    if(age>0 and age<13):
        print('Participant is a Child')
    elif(age>13 and age <18):
        print('Participant is a Teenager')
    elif(age>18):
        print('Participant is an Adult')
    elif(age==0):
        break;

Tuesday, November 16, 2021

Unix shell variables parameters and loops

 The following site is a good link for someone who is aware of programming but wants a quick insight into the shell constructs of programming

https://www.baeldung.com/linux/use-command-line-arguments-in-bash-script



Wednesday, November 10, 2021

Clear the command entered in a Terminal on Mac Ctrl+U and Ctrl+C

 example:

 xyz-mac:~user: mac abc/vbs/vjbad/jkbsjkn/skdnasldn/sdjkkjbasdb

Lets say you want to clear this on a Mac terminal.

Use : Ctrl + U or Ctrl + C

 Note: Use Ctrl key not Command key

 Source: https://superuser.com/questions/192490/clear-command-from-terminal-in-os-x

 Additional Keys:

Ctrl+K clears the screen 


https://osxdaily.com/2006/12/19/command-line-keyboard-shortcuts-for-mac-os-x/