Installing Windows OS and Guest OS using VMware

Installing Operating System

 

Steps to install Windows 10 operating system

 

1.    To connect the Windows 10 installation media, insert DVD into the drive.

2.    Boot the PC into the BIOS. Under Boot tab, select the device from which to boot as CD-ROM Drive or Optical Drive option as the first choice.

3.    Save the settings and Exit.

4.    Restart the computer.

5.    The Windows Setup will load and will display a Setup window...

6.    Choose the Windows Setup options / Select the Regional Settings
(preferred language, keyboard type, and time/currency format), then click Next.

7.    Click the ‘Install Now’ button.

8.    Enter the Windows Product Key, then click Next.

9.    Read over the Microsoft Software License Terms. To accept the License Terms check 'I accept the license terms' checkbox and click Next.

10. Select the Custom installation.

11. Select the hard drive and partition to install Windows on and click Next.

12. Windows will begin installing.

13. After installation completes, the system will restart. Adjust the personalization, location, browser, protection, connectivity and error reporting settings.

14. Specify who the owner of the device is and sign in to Windows 10 with your Microsoft account.

15. Click Finish/Restart and remove the Windows Install Media

16. On restarting the system will run the new Windows operating system.

 


 

Steps to install Linux as a guest OS in Windows 10 OS using VMware.

 

1.    Download and Install the VMware Workstation Player and launch it.

2.    Create a VM by clicking “Create a New Virtual Machine”. Browse and select the Installer disc image file (iso) of Linux OS. Click Next

3.    In “Select a guest OS”, choose the guest OS (Linux) and its version. Click Next

4.    Under Specify Disk Capacity adjust Maximum disk size as required. Click Next and Confirm the selected size in next window.

5.    Click finish to add the Linux virtual machine to VMware Workstation Player.

6.    Open the VMware Workstation Player settings and customize the VM hardware as required.

7.    To launch the Linux virtual machine use the Play button in VMware Workstation Player.

 

Python standard libraries

 Python Standard Libraries 


OSI Model

 OSI REFERENCE MODEL


TCP / IP Protocol Suite

 TCP / IP Protocol suite




Unique words in a file sorted alphabetically

 # Unique words in a file


fp = None


try:

fp = open("fileipt.txt","r")

except IOError as e:

print("File opening error : ", e)

except:

print("unknown error")


else:

fdata = fp.read()

fdata = fdata.replace('.',"")

fdata = fdata.replace('-',"")

fdata = fdata.replace(',',"")

fdata = fdata.lower()

Words = fdata.split()

UniqueWords = list(set(Words))

list.sort(UniqueWords)

print("Number of Unique Words = ",len(UniqueWords))

print("Unique Words:")

print(UniqueWords)

finally:

if(fp):

fp.close()


"""

Sample input

Input file: fileipt.txt


File handling in Python has several functions for creating, reading, updating, and deleting files. Read - Default value. Opens a file for reading, error if the file does not exist. Append - Opens a file for appending, creates the file if it does not exist. Write - Opens a file for writing, creates the file if it does not exist. Create - Creates the specified file, returns an error if the file exists.


>python File9.py

Number of Unique Words =  36

Unique Words:

['a', 'an', 'and', 'append', 'appending', 'create', 'creates', 'creating', 'default', 'deleting', 'does', 'error', 'exist', 'exists', 'file', 'files', 'for', 'functions', 'handling', 'has', 'if', 'in', 'it', 'not', 'opens', 'python', 'read', 'reading', 'returns', 'several', 'specified', 'the', 'updating', 'value', 'write', 'writing']


"""



Modules - Arithmetic operations

# Creating modules 

# Arithmetic operations 


# arithopns.py


def fnadd(a,b):

return a+b


def fnsub(a,b):

return a-b


def fnmul(a,b):

return a*b


def fndiv(a,b):

return a/b


def fnmod(a,b):

return a%b


def fntruncdiv(a,b):

return a//b




# Main program

# importing modules 


from arithopns import *


a = eval(input("Enter value: "))

b = eval(input("Enter value: "))


print("Sum =",fnadd(a,b))

print("Difference =",fnsub(a,b))

print("Product =",fnmul(a,b))

print("Division =",round(fndiv(a,b),4))

print("Modulo reminder =",fnmod(a,b))

print("Truncation division =",fntruncdiv(a,b))


"""

Sample output

>python modpgmAO.py

Enter value: 7

Enter value: 6

Sum = 13

Difference = 1

Product = 42

Division = 1.1667

Modulo reminder = 1

Truncation division = 1


"""


Retail shop billing

# File handling 
# Retail shop billing 

import sys
import math

stock=None
order=None

try:
stock = open(sys.argv[1],"r")
# create dictionary
PriceList={}
for line in stock:
item,price = line.split()
PriceList[item]=int(price)
# print(PriceList)
billamt=0
for i in range(2,len(sys.argv)):
order = open(sys.argv[i],"r")
print("S.no\tItem\t\tRate\tQuantity\tAmount")
i=1
for line in order:
item,qty=line.split()
price = int(qty)*PriceList[item]
print(i,"\t",item.ljust(10),"\t",PriceList[item],"\t",int(qty),"\t\t",price)
billamt = billamt+price
                        i+=1
print("Total Amount =", billamt)
cgst = round(billamt*.09,2)
sgst = round(billamt*.09,2)
print("cgst =",cgst)
print("sgst =",sgst)
print("Net Amount =",math.floor(billamt+cgst+sgst))
print("**"*30)
except IOError as e:
print("File opening error : ", e)
except:
print("unknown error")
else:
print("\nThank you for shopping with us\n")
print("**"*30)

finally:
if(stock):
stock.close()
if(order):
order.close()
"""
Sample output:
input file: (3)

ShopPricelist.txt 
Walnut 700
Figs 520
Raisins 400
Chashewnut 680
Almond 700
Pistachio 1400
Dates 440
Apricot 650
Kiwi 680
Cardamon 3000
Pepper 480

custorder1.txt 
Walnut 1
Raisins 4
Almond 7
Dates 2

custorder2.txt
Apricot 2
Kiwi 4
Cardamon 5
Pepper 3



>python retailshopbilling.py ShopPricelist.txt custorder1.txt custorder2.txt

S.no    Item                Rate    Quantity        Amount
1        Walnut             700         1                   700
2        Raisins             400         4                   1600
3        Almond            700         7                   4900
4        Dates                440         2                   880

Total Amount = 8080
cgst = 727.2
sgst = 727.2
Net Amount = 9534
************************************************************

S.no    Item                Rate    Quantity        Amount
1        Apricot             650          2                   1300
2        Kiwi                  680         4                   2720
3        Cardamon        3000       5                   15000
4        Pepper              480         3                   1440

Total Amount = 20460
cgst = 1841.4
sgst = 1841.4
Net Amount = 24142
************************************************************

Thank you for shopping with us

************************************************************


"""

Pygame tool

PYGAME

 

Aim: To study about Pygame tool

 

Introduction to Pygame

Python is the most popular programming language and has vast libraries for various fields such as Machine Learning (Numpy, Pandas, Matplotlib), Artificial intelligence (Pytorch, TensorFlow), and Game development (Pygame, Pyglet).

Pygame was officially written by Pete Shinners. Pygame is a cross-platform set of Python modules designed for writing video games. Pygame adds functionality on top of the SDL library. Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D. Pygame, together with SDL, allows users to create fully featured games and multimedia programs in the python language. Pygame is highly portable and runs on nearly every platform and operating system.

 

Pygame core modules

Pygame modules provide abstract access to specific hardware on user system, as well as uniform methods to work with that hardware. Important Pygame Modules include

cursors

load cursor images, includes standard cursors

display

control the display window or screen

draw

draw simple shapes onto a Surface

event

manage events and the event queue

font

create and render TrueType fonts

image

save and load images

joystick

manage joystick devices

key

manage the keyboard

mouse

manage the mouse

sndarray

manipulate sounds with numpy

surfarray

manipulate images with numpy

time

control timing

transform

scale, rotate, and flip images

 

 

General steps to creating a Pygame based program

1.    Importing and Initializing PyGame

1.    import the pygame library and initialize all the functions in the pygame modules. This allows pygame to connect its abstractions to user specific hardware.

2.    Setting Up the Display

1.    Create a screen / surface object on which the graphical operations will be performed.

3.    Draw objects / Load images on the surface object

4.    Create a clock and set the framerate

5.    Sound Effects

1.    pygame provides mixer to handle all sound-related activities. classes and methods in mixer provides background music and sound effects for various actions. music sub-module is used to stream individual sound files in a variety of formats.

6.    Using .blit() and .flip()

1.    blit stands for Block Transfer. blit is the process to render the game object onto the surface. The .blit() takes two arguments – The Surface to draw and the location (coordinates) at which to draw it on the source Surface.

2.    flip() updates the entire screen with everything that’s been drawn since the last flip.

7.    Setting Up the Game Loop – The game loop performs four very important functions:

    1. Processing Events.
      1. Process user input (Key presses, mouse movements, joystick movements) using the pygame event system.
      2. All events in pygame are placed in the event queue, which can then be accessed and manipulated.
    2. Updates the state of all game objects in response to the user input
    3. Updates the display and audio output
    4. Maintains the speed of the game
      1. Every cycle of the game loop is called a frame. The number of frames handled each second is called the frame rate.
      2. Frames continue to occur until some condition to exit the game is met. Example – The player closes the window.
  1. Terminate the program.