├── 7Segment.asm ├── CN ├── Client.class ├── Client.java ├── Client1.class ├── Client1.java ├── Commands.txt ├── Cost.tcl ├── DistanceVector.tcl ├── Lab 5 TCPdump.pdf ├── LinkState.tcl ├── Packetdrop.tcl ├── Readme.md ├── Server.class ├── Server.java ├── Server1.class ├── Server1.java ├── StarTopology.tcl ├── Tcp&udp-Star.tcl ├── UDPClient.class ├── UDPClient.java ├── UDPServer.class ├── UDPServer.java ├── Wireshark.pdf ├── mytcp.tcl ├── myudp.tcl ├── nslab.tcl ├── nslab2.tcl └── nslab3.tcl ├── MPL ├── BcdADD.asm ├── Count1&0.asm ├── EvenOdd.asm ├── Factorial.asm ├── Logisim │ ├── ADDR CIRCUITS.circ │ ├── BasicLogicGates.circ │ ├── DEMULTIPLEXER.circ │ ├── DEMULTIPLEXER2.circ │ ├── MULTIPLEX.circ │ ├── MULTIPLEXER2.circ │ └── SUBR CIRCUITS.circ ├── MoveNumbers.asm ├── Palindrome.asm └── UnpackedBCD.asm ├── NJQB ├── a1.pdf ├── a2.pdf ├── bar1.py ├── bar2.py ├── commonChar.py ├── countRepeatChar.py ├── dictSort.py ├── einst.py ├── intRoman.py ├── lambda.py ├── lambda2.py ├── panda1.py ├── pascal.py ├── progressbar.py └── tkinter1.py ├── Python ├── 10_CalculatorGUI.py ├── 10_CalculatorGUI2.py ├── 11_MysqlPython.py ├── 12_Histogram.py ├── 12_Piechart.py ├── 12_bargraph.py ├── 13_Pandas.py ├── 14_Scipy1.py ├── 14_Scipy2.py ├── 15_FlaskWeb1 │ ├── app.py │ ├── book.json │ ├── requirements.txt │ └── templates │ │ └── books.html ├── 15_FlaskWeb2 │ ├── app.py │ └── requirements.txt ├── 1_NameManipulate.py ├── 1_Pattern.py ├── 2_DictTuples.py ├── 2_Dictionary.py ├── 2_ListComprehension.py ├── 2_ListOperations.py ├── 3_Numpy1.py ├── 3_NumpyMatrix.py ├── 4_Function1.py ├── 4_Function2.py ├── 4_Function3.py ├── 5_Classes.py ├── 5_Hierarchicalinheritance.py ├── 6_AbstractMethod.py ├── 6_OperatorOverloading.py ├── 7_Package1.py ├── 7_Package2.py ├── 8_Exception1.py ├── 8_Exception2.py ├── 9_FileHandling.py ├── IMG-20230119-WA0001.jpg ├── Mypackage │ ├── Listpackage │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-310.pyc │ │ │ └── listops.cpython-310.pyc │ │ └── listops.py │ ├── Shapes.py │ ├── __init__.py │ └── __pycache__ │ │ ├── Shapes.cpython-310.pyc │ │ └── __init__.cpython-310.pyc ├── README.md └── bookdata.txt ├── README.md └── Unix ├── Perl ├── KeyValue.pl ├── Months.pl ├── PowerTable.pl ├── Prime.pl └── VariableContext.pl ├── Shell ├── Addition.sh ├── Calculator.sh ├── ElementPresent.sh ├── EqualString.sh ├── Factorial.sh ├── Filecount.sh ├── FunctionSum.sh ├── IsFile,Dir.sh ├── Largest2.sh ├── LargestInArray.sh ├── LeapYear.sh ├── MultiplicationTable.sh ├── Rectangle.sh ├── Simpleinterest.sh └── SumToN.sh ├── aGold ├── AWK in UNIX.pdf ├── Grep command in Unix.pdf ├── PERL Scripting.pdf ├── Shell Programing in UNIX (1).pdf └── sed in Unix.pdf └── awk,grep,sed ├── GrepFileCount.sh ├── GrepSpecificTypeFile.sh └── student.lst /7Segment.asm: -------------------------------------------------------------------------------- 1 | DATA SEGMENT 2 | PORTA EQU 00H 3 | PORTB EQU 02H 4 | PORTC EQU 04H 5 | PORT_CON EQU 06H 6 | DATA ENDS 7 | CODE SEGMENT 8 | MOV AX,DATA 9 | MOV DS, AX 10 | 11 | ORG 0000H 12 | START: 13 | 14 | MOV DX, PORT_CON 15 | MOV AL, 10000010B; port C (output), port A (output) in mode 0 and PORT B (INPUT) in mode 0 16 | OUT DX, AL 17 | 18 | MOV AL, 11000000B 19 | MOV DX, PORTA 20 | OUT DX,AL 21 | JMP XX 22 | XX: 23 | MOV DX, PORTB 24 | IN AL, DX 25 | CMP AL, 11111110B 26 | JZ S0 27 | IN AL, DX 28 | CMP AL, 11111101B 29 | JZ S1 30 | IN AL, DX 31 | CMP AL, 11111011B 32 | JZ S2 33 | IN AL, DX 34 | CMP AL, 11110111B 35 | JZ S3 36 | IN AL, DX 37 | CMP AL, 11101111B 38 | JZ S4 39 | IN AL, DX 40 | CMP AL, 11011111B 41 | JZ S5 42 | IN AL, DX 43 | CMP AL, 10111111B 44 | JZ S6 45 | IN AL, DX 46 | CMP AL, 01111111B 47 | JZ S7 48 | JMP XX 49 | 50 | 51 | S0: 52 | MOV AL, 11000000B 53 | MOV DX, PORTA 54 | OUT DX,AL 55 | JMP XX 56 | S1: 57 | MOV AL, 11111001B 58 | MOV DX, PORTA 59 | OUT DX,AL 60 | JMP XX 61 | S2: 62 | MOV AL, 10100100B 63 | MOV DX, PORTA 64 | OUT DX,AL 65 | JMP XX 66 | S3: 67 | MOV AL, 10110000B 68 | MOV DX, PORTA 69 | OUT DX,AL 70 | JMP XX 71 | S4: 72 | MOV AL, 10011001B 73 | MOV DX, PORTA 74 | OUT DX,AL 75 | JMP XX 76 | S5: 77 | MOV AL, 10010010B 78 | MOV DX, PORTA 79 | OUT DX,AL 80 | JMP XX 81 | S6: 82 | MOV AL, 10000010B 83 | MOV DX, PORTA 84 | OUT DX,AL 85 | JMP XX 86 | S7: 87 | MOV AL, 11111000B 88 | MOV DX, PORTA 89 | OUT DX,AL 90 | JMP XX 91 | JMP START 92 | CODE ENDS 93 | END 94 | -------------------------------------------------------------------------------- /CN/Client.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/CN/Client.class -------------------------------------------------------------------------------- /CN/Client.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.net.*; 3 | 4 | public class Client { 5 | public static void main(String[] args) throws IOException { 6 | // create a socket and connect to the server on port 8888 7 | Socket socket = new Socket("localhost", 8888); 8 | System.out.println("Connected to server."); 9 | 10 | // create input and output streams for the socket 11 | BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); 12 | PrintWriter out = new PrintWriter(socket.getOutputStream(), true); 13 | 14 | // read input from user and send to the server 15 | BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in)); 16 | String userInput; 17 | while ((userInput = stdIn.readLine()) != null) { 18 | out.println(userInput); 19 | System.out.println("Server says: " + in.readLine()); 20 | } 21 | 22 | // close the connection 23 | out.close(); 24 | in.close(); 25 | stdIn.close(); 26 | socket.close(); 27 | System.out.println("Disconnected from server."); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /CN/Client1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/CN/Client1.class -------------------------------------------------------------------------------- /CN/Client1.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.net.*; 3 | 4 | public class Client1 { 5 | public static void main(String[] args) throws IOException { 6 | Socket socket = new Socket("localhost", 8888); 7 | System.out.println("Connected to server."); 8 | 9 | PrintWriter out = new PrintWriter(socket.getOutputStream(), true); 10 | BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); 11 | 12 | BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in)); 13 | String userInput; 14 | while ((userInput = stdIn.readLine()) != null) { 15 | // Split the user input into two numbers 16 | String[] numbers = userInput.split(" "); 17 | int num1 = Integer.parseInt(numbers[0]); 18 | int num2 = Integer.parseInt(numbers[1]); 19 | 20 | // Send the two numbers to the server 21 | out.println(num1 + " " + num2); 22 | 23 | // Receive the sum from the server and print it 24 | String sum = in.readLine(); 25 | System.out.println("Sum of " + num1 + " and " + num2 + " is " + sum); 26 | } 27 | 28 | out.close(); 29 | in.close(); 30 | stdIn.close(); 31 | socket.close(); 32 | System.out.println("Disconnected from server."); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /CN/Commands.txt: -------------------------------------------------------------------------------- 1 | Ping: "Ping" is a computer networking tool that is used to test the reachability of a networked device and measure the time it takes for packets of data to travel from the source to the destination and back. The "ping" command sends a series of small packets of data to the target device and measures the time it takes for the device to respond to each packet. The time it takes for the packets to travel to the target and back is known as the "round-trip time," and this information can be used to diagnose network connectivity problems, determine the speed and reliability of a network connection, or evaluate the performance of a device. 2 | -a : Resolve addresses to hostnames. 3 | -w timeout : Timeout in milliseconds to wait for each reply. 4 | -f : Set Don't Fragment flag in packet (IPv4-only). 5 | -i : Specifies the value of the Time To Live (TTL) field in the IP header for echo Request messages sent. The default is the default TTL value for the host. The maximum TTL is 255. 6 | -n size: This option is used to control the number of packets sent to the target device. 7 | 8 | Ipconfig: IPCONFIG stands for Internet Protocol Configuration. This is a command-line application which displays all the current TCP/IP (Transmission Control Protocol/Internet Protocol) network configuration, refreshes the DHCP (Dynamic Host Configuration Protocol) and DNS (Domain Name Server). It also displays IP address, subnet mask, and default gateway for all adapters. 9 | /all: Displays the full TCP/IP configuration for all adapters. Adapters can represent physical interfaces, such as installed network adapters, or logical interfaces, such as dial-up connections 10 | /displaydns: Displays the contents of the DNS client resolver cache, which includes both entries preloaded from the local Hosts file and any recently obtained resource records for name queries resolved by the computer. The DNS Client service uses this information to resolve frequently queried names quickly, before querying its configured DNS servers. 11 | /flushdns: Flushes and resets the contents of the DNS client resolver cache. During DNS troubleshooting, you can use this procedure to discard negative cache entries from the cache, as well as any other entries that have been added dynamically. 12 | /release : Releases the current IP address assigned to the computer, effectively resetting the IP configuration. This parameter sends a request to the DHCP server to abandon the active lease(s) and removes it (or them) from your system. 13 | /renew: Requests a new IP address from the DHCP server. 14 | 15 | Tracert: This diagnostic tool determines the path taken to a destination by sending Internet Control Message Protocol (ICMP) echo Request or ICMPv6 messages to the destination with incrementally increasing time to live (TTL) field values. 16 | a)-d: Stops attempts to resolve the IP addresses of intermediate routers to their names. This can speed up the return of results. 17 | b)-h: Specifies the maximum number of hops in the path to search for the target (destination). The default is 30 hops. 18 | c)-w: Specifies the amount of time in milliseconds to wait for the ICMP time Exceeded or echo Reply message corresponding to a given echo Request message to be received. If not received within the time-out, an asterisk (*) is displayed. The default time-out is 4000 (4 seconds). 19 | d)-4: Specifies that tracert.exe can use only IPv4 for this trace. 20 | e) -j : Specifies a loose source route for the trace, allowing you to specify the intermediate hops that packets should take along the way. 21 | The tracepath and traceroute terminal programs are crucial in network diagnostics. Both commands map the network and display possible packet routes and transit delays from a source to a destination. 22 | 23 | 4)nslookup: Displays information that you can use to diagnose Domain Name System infrastructure. The nslookup command-line tool has two modes: interactive and noninteractive. 24 | a)-d2: This performs a lookup of all addresses associated with the specified hostname. 25 | b) -query=mx : This performs a lookup of the mail exchange (MX) records associated with the specified domain, which are used to route email for that domain. 26 | c)-type=ns: By checking the NS records, you can see which is the authoritative server for a specific domain. 27 | d)-type=soa: you can see the start of authority and get information about the zone. 28 | 29 | 5)netstat: Netstat stands for “network statistics”. If you’re having difficulties accessing the internet, the netstat command can help you identify where the problem lies. Netstat will display all of your computer’s active network connections and the status of those connections. If a connection is not working, netstat can often provide more information about why it is not working. 30 | a)-a: Shows all active connections and listening ports on the computer 31 | b)-e: Displays Ethernet statistics, including the number of bytes and packets sent and received. 32 | c)-n: Shows active connections and their associated IP addresses and port numbers. The ‘-n’ option causes ‘netstat’ to display addresses and port numbers in numerical form, rather than resolving them to hostnames and service names. 33 | d)-s: Displays a summary of all network statistics, including information on the number of segments received, errors, and more. 34 | 35 | 6)route: The ‘route’ command is used to manipulate the IP routing table in Windows.With the ‘route’ command, you can view the current routing table, add new routes, modify existing routes, and delete routes.The ‘route’ command is often used in advanced network configuration scenarios, such as setting up VPN connections, specifying custom routes for specific networks, or resolving connectivity issues. 36 | 37 | 7)hostname: The ‘hostname’ command is used to display or set the hostname of a computer in windows. When run without any options, the ‘hostname’ command will display the current hostname of the computer. 38 | 39 | 8)ARP: The arp command displays and modifies the Internet-to-adapter address translation tables used by the Address in Networks and communication management. The arp command displays the current ARP entry for the host specified by the HostName variable. 40 | a)-a: Displays the current ARP (Address Resolution Protocol) cache, which maps IP addresses to MAC addresses on the local network. 41 | b)-v: Displays the ARP cache in verbose mode, including additional information such as the type of ARP entries (dynamic or static) and the interface used for each entry. 42 | 43 | 9)curl: It is a command-line tool powered by the libcurl library to transfer data to and from the server using various protocols, such as HTTP, HTTPS, FTP, FTPS, IMAP, IMAPS, POP3, POP3S, SMTP, and SMTPS. It is highly popular for automation and scripts due to its wide range of features and protocol support. 44 | a)curl : Downloads the content of the specified URL and displays it in the console. 45 | b)curl -o: Downloads the content of the specified URL and saves it to a file with the specified name. 46 | 47 | 10)whois : It allows you to perform lookup of owner information of a website by querying databases that stores the registered users of a domain or IP address. 48 | a) whois -H : Retrieves information about the specified domain name, but suppresses the inclusion of headers and footers. 49 | 50 | 11)Dig: dig command stands for Domain Information Groper. It is used for retrieving information about DNS name servers. It is basically used by network administrators. It is used for verifying and troubleshooting DNS problems and to perform DNS lookups. Dig command replaces older tools such as nslookup and the host. 51 | 52 | 12)mtr: The mtr command is a combination of ping and traceroute commands. It is a network diagnostic tool that continuously sends packets showing ping time for each hop. It also displays network problems of the entire route taken by the network packets. 53 | 54 | 13)tcpdump: tcpdump is a packet sniffing and packet analyzing tool for a System Administrator to troubleshoot connectivity issues in Linux. It is used to capture, filter, and analyze network traffic such as TCP/IP packets going through your system. It is many times used as a security tool as well. It saves the captured information in a pcap file, these pcap files can then be opened through Wireshark or through the command tool itself. 55 | 56 | 14)ss: A replacement for the deprecated netstat command, ss gives you detailed information about how your computer communicates with other computers, networks, and services. ss displays statistics for Transmission Control Protocol (TCP), User Datagram Protocol (UDP), Unix (interprocess), and raw sockets. Raw sockets operate at the network OSI level, which means TCP and UDP headers have to be handled by the application software, not by the transport layer. Internet Control Message Protocol (ICMP) messages and the ping utility both use raw sockets. 57 | 58 | 15) Wget: Wget is the non-interactive network downloader which is used to download files from the server even when the user has not logged on to the system and it can work in the background without hindering the current process. 59 | 60 | 16) route: Command in Linux is used when you want to work with the IP/kernel routing table. It is mainly used to set up static routes to specific hosts or networks via an interface. It is used for showing or update the IP/kernel routing table. 61 | 62 | 17) Host: The host command also displays any aliases associatd with the HostName parameter. If the local host is using the DOMAIN protocol, the local or remote name server database is queried before searching the local /etc/hosts file. The host command may also return other name records found in the DNS (Domain Name System). 63 | 64 | 18) ifconfig: veryh much similar to ipconfig 65 | -------------------------------------------------------------------------------- /CN/Cost.tcl: -------------------------------------------------------------------------------- 1 | set ns [new Simulator] 2 | $ns rtproto DV 3 | 4 | set nf [open tout.tr w] 5 | $ns trace-all $nf 6 | set np [open tout.nam w] 7 | $ns namtrace-all $np 8 | 9 | proc finish {} { 10 | global ns np nf 11 | $ns flush-trace 12 | close $nf 13 | close $np 14 | exec nam tout.nam & 15 | exit 0 16 | } 17 | 18 | set n0 [$ns node] 19 | set n1 [$ns node] 20 | set n2 [$ns node] 21 | set n3 [$ns node] 22 | set n4 [$ns node] 23 | 24 | $ns duplex-link $n0 $n2 10Mb 10ms DropTail 25 | $ns duplex-link $n0 $n1 10Mb 10ms DropTail 26 | $ns duplex-link $n0 $n3 10Mb 10ms DropTail 27 | $ns duplex-link $n3 $n2 10Mb 10ms DropTail 28 | $ns duplex-link $n1 $n3 10Mb 10ms DropTail 29 | $ns duplex-link $n3 $n4 10Mb 10ms DropTail 30 | 31 | $ns queue-limit $n0 $n2 10 32 | $ns queue-limit $n0 $n1 10 33 | $ns queue-limit $n0 $n3 10 34 | $ns queue-limit $n3 $n2 10 35 | $ns queue-limit $n1 $n3 10 36 | $ns queue-limit $n3 $n4 10 37 | 38 | $ns duplex-link-op $n0 $n2 orient right 39 | $ns duplex-link-op $n0 $n1 orient down 40 | $ns duplex-link-op $n0 $n3 orient right-down 41 | $ns duplex-link-op $n3 $n2 orient up 42 | $ns duplex-link-op $n1 $n3 orient right 43 | $ns duplex-link-op $n3 $n4 orient right 44 | 45 | $n0 label "A" 46 | $n1 label "B" 47 | $n2 label "C" 48 | $n3 label "D" 49 | $n4 label "E" 50 | 51 | $ns cost $n0 $n1 11 52 | $ns cost $n0 $n2 1 53 | $ns cost $n0 $n3 27 54 | $ns cost $n3 $n2 2 55 | $ns cost $n0 $n3 3 56 | $ns cost $n3 $n4 1 57 | 58 | set tcp [new Agent/TCP] 59 | $tcp set fid_ 1 60 | $ns attach-agent $n0 $tcp 61 | set sink [new Agent/TCPSink] 62 | $ns attach-agent $n4 $sink 63 | $ns connect $tcp $sink 64 | 65 | set ftp [new Application/FTP] 66 | $ftp attach-agent $tcp 67 | $ftp set type_ FTP 68 | $ftp set packetSize_ 1000 69 | $ftp set rate_ 1mb 70 | 71 | $ns color 1 red 72 | $ns at 1.0 "$ftp start" 73 | $ns rtmodel-at 1.5 down $n2 $n3 74 | $ns rtmodel-at 2.5 up $n2 $n3 75 | $ns at 3.0 "$ftp stop" 76 | 77 | $ns at 5.0 "finish" 78 | 79 | $ns run 80 | -------------------------------------------------------------------------------- /CN/DistanceVector.tcl: -------------------------------------------------------------------------------- 1 | set ns [new Simulator] 2 | 3 | $ns rtproto DV 4 | 5 | set nf [open out1.nam w] 6 | $ns namtrace-all $nf 7 | set np [open out1.tr w] 8 | $ns trace-all $np 9 | 10 | proc finish { } { 11 | global ns nf np 12 | $ns flush-trace 13 | close $nf 14 | exec nam out1.nam & 15 | exit 0 16 | } 17 | 18 | set n0 [$ns node] 19 | set n1 [$ns node] 20 | set n2 [$ns node] 21 | set n3 [$ns node] 22 | 23 | $n0 label "D" 24 | $n1 label "C" 25 | $n2 label "A" 26 | $n3 label "B" 27 | 28 | $ns duplex-link $n0 $n1 10Mb 20ms DropTail 29 | $ns duplex-link $n0 $n2 10Mb 20ms DropTail 30 | $ns duplex-link $n1 $n3 10Mb 20ms DropTail 31 | $ns duplex-link $n3 $n2 10Mb 20ms DropTail 32 | $ns duplex-link $n0 $n3 10Mb 20ms DropTail 33 | 34 | $ns queue-limit $n0 $n1 10 35 | $ns queue-limit $n1 $n3 10 36 | $ns queue-limit $n0 $n2 10 37 | $ns queue-limit $n3 $n2 10 38 | $ns queue-limit $n0 $n3 10 39 | 40 | $ns duplex-link-op $n0 $n1 orient right 41 | $ns duplex-link-op $n0 $n2 orient down 42 | $ns duplex-link-op $n1 $n3 orient down 43 | $ns duplex-link-op $n3 $n2 orient left 44 | $ns duplex-link-op $n0 $n3 orient right-down 45 | 46 | set tcp [new Agent/TCP] 47 | $tcp set class_ 2 48 | $ns attach-agent $n0 $tcp 49 | set sink [new Agent/TCPSink] 50 | $ns attach-agent $n3 $sink 51 | $ns connect $tcp $sink 52 | 53 | set ftp [new Application/FTP] 54 | $ftp attach-agent $tcp 55 | $ftp set type_ FTP 56 | $ftp set packet_size_ 1000 57 | $ftp set rate_ 1mb 58 | $ns at 1.0 "$ftp start" 59 | $ns rtmodel-at 2.0 down $n0 $n3 60 | $ns rtmodel-at 3.0 up $n0 $n3 61 | $ns at 4.0 "$ftp stop" 62 | 63 | $ns at 5.0 "finish" 64 | 65 | $ns run 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /CN/Lab 5 TCPdump.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/CN/Lab 5 TCPdump.pdf -------------------------------------------------------------------------------- /CN/LinkState.tcl: -------------------------------------------------------------------------------- 1 | set ns [new Simulator] 2 | 3 | set nf [open lsr.nam w] 4 | $ns namtrace-all $nf 5 | 6 | $ns rtproto LS 7 | 8 | proc finish {} { 9 | global ns nf 10 | $ns flush-trace 11 | close $nf 12 | exec nam lsr.nam & 13 | exit 0 14 | } 15 | 16 | set n0 [$ns node] 17 | set n1 [$ns node] 18 | set n2 [$ns node] 19 | set n3 [$ns node] 20 | set n4 [$ns node] 21 | 22 | $ns duplex-link $n0 $n1 10Mb 10ms DropTail 23 | $ns duplex-link $n1 $n2 10Mb 10ms DropTail 24 | $ns duplex-link $n2 $n3 10Mb 10ms DropTail 25 | $ns duplex-link $n3 $n4 10Mb 10ms DropTail 26 | $ns duplex-link $n4 $n0 10Mb 10ms DropTail 27 | $ns duplex-link $n1 $n3 20Mb 10ms DropTail 28 | $ns duplex-link $n1 $n4 20Mb 10ms DropTail 29 | 30 | $ns duplex-link-op $n0 $n1 orient right-up 31 | $ns duplex-link-op $n1 $n2 orient right-down 32 | $ns duplex-link-op $n2 $n3 orient down 33 | $ns duplex-link-op $n3 $n4 orient left 34 | $ns duplex-link-op $n4 $n0 orient up 35 | $ns duplex-link-op $n1 $n3 orient left-up 36 | $ns duplex-link-op $n1 $n4 orient right-up 37 | 38 | set tcp [new Agent/TCP] 39 | $ns attach-agent $n1 $tcp 40 | $tcp set Class_ 2 41 | 42 | set sink [new Agent/TCPSink] 43 | $ns attach-agent $n4 $sink 44 | 45 | $ns connect $tcp $sink 46 | 47 | set ftp [new Application/FTP] 48 | $ftp attach-agent $tcp 49 | $ftp set type_ FTP 50 | $ftp set packet_size_ 1000 51 | $ftp set rate_ 1Mb 52 | 53 | $ns at 0.2 "$ftp start" 54 | $ns rtmodel-at 0.5 down $n1 $n4 55 | $ns rtmodel-at 1.5 up $n1 $n4 56 | $ns at 1.8 "$ftp stop" 57 | $ns at 2.0 "finish" 58 | 59 | $ns run -------------------------------------------------------------------------------- /CN/Packetdrop.tcl: -------------------------------------------------------------------------------- 1 | set ns [new Simulator] 2 | 3 | $ns color 1 Blue 4 | $ns color 2 Red 5 | 6 | set nf [open prac4.nam w] 7 | $ns namtrace-all $nf 8 | 9 | proc finish {} { 10 | global ns nf 11 | $ns flush-trace 12 | close $nf 13 | exec nam prac4.nam & 14 | exit 0 15 | } 16 | 17 | set n0 [$ns node] 18 | set n1 [$ns node] 19 | set n2 [$ns node] 20 | set n3 [$ns node] 21 | 22 | $ns duplex-link $n0 $n2 20Mb 10ms DropTail 23 | $ns duplex-link $n1 $n2 20Mb 10ms DropTail 24 | $ns duplex-link $n3 $n2 5Mb 10ms DropTail 25 | 26 | $ns queue-limit $n2 $n3 5 27 | 28 | $ns duplex-link-op $n0 $n2 orient right-down 29 | $ns duplex-link-op $n1 $n2 orient right-up 30 | $ns duplex-link-op $n2 $n3 orient right 31 | 32 | $ns duplex-link-op $n2 $n3 queuePos 1 33 | 34 | set tcp [new Agent/TCP] 35 | $ns attach-agent $n0 $tcp 36 | set sink [new Agent/TCPSink] 37 | $ns attach-agent $n3 $sink 38 | $ns connect $tcp $sink 39 | 40 | $tcp set fid_ 1 41 | 42 | set ftp [new Application/FTP] 43 | $ftp attach-agent $tcp 44 | $ftp set type_ FTP 45 | $ftp set rate_ 1mb 46 | 47 | set udp [new Agent/UDP] 48 | $ns attach-agent $n1 $udp 49 | set null [new Agent/Null] 50 | $ns attach-agent $n3 $null 51 | $ns connect $udp $null 52 | 53 | $udp set fid_ 2 54 | 55 | set cbr [new Application/Traffic/CBR] 56 | $cbr attach-agent $udp 57 | $cbr set type_ CBR 58 | $cbr set packet_size_ 1000 59 | $cbr set rate_ 1mb 60 | 61 | $ns at 1.0 "$ftp start" 62 | $ns at 1.5 "$cbr start" 63 | $ns at 2.0 "$ftp stop" 64 | $ns at 3.0 "$cbr stop" 65 | 66 | $ns at 5.0 "finish" 67 | 68 | $ns run -------------------------------------------------------------------------------- /CN/Readme.md: -------------------------------------------------------------------------------- 1 | https://www.guru99.com/wireshark-passwords-sniffer.html -------------------------------------------------------------------------------- /CN/Server.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/CN/Server.class -------------------------------------------------------------------------------- /CN/Server.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.net.*; 3 | 4 | public class Server { 5 | public static void main(String[] args) throws IOException { 6 | ServerSocket serverSocket = new ServerSocket(8888); 7 | System.out.println("Server started. Listening on port 8888."); 8 | 9 | while (true) { 10 | Socket clientSocket = serverSocket.accept(); 11 | System.out.println("Client connected."); 12 | 13 | PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true); 14 | BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); 15 | 16 | String inputLine; 17 | while ((inputLine = in.readLine()) != null) { 18 | System.out.println("Client says: " + inputLine); 19 | out.println("Server received: " + inputLine); 20 | } 21 | 22 | out.close(); 23 | in.close(); 24 | clientSocket.close(); 25 | System.out.println("Client disconnected."); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /CN/Server1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/CN/Server1.class -------------------------------------------------------------------------------- /CN/Server1.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.net.*; 3 | 4 | public class Server1 { 5 | public static void main(String[] args) throws IOException { 6 | ServerSocket serverSocket = new ServerSocket(8888); 7 | System.out.println("Server started. Listening on port 8888."); 8 | 9 | while (true) { 10 | Socket clientSocket = serverSocket.accept(); 11 | System.out.println("Client connected."); 12 | 13 | PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true); 14 | BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); 15 | 16 | String inputLine; 17 | while ((inputLine = in.readLine()) != null) { 18 | // Split the input line into two numbers 19 | String[] numbers = inputLine.split(" "); 20 | int num1 = Integer.parseInt(numbers[0]); 21 | int num2 = Integer.parseInt(numbers[1]); 22 | // Compute the sum and send it back to the client 23 | int sum = num1 + num2; 24 | out.println(sum); 25 | } 26 | 27 | out.close(); 28 | in.close(); 29 | clientSocket.close(); 30 | System.out.println("Client disconnected."); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /CN/StarTopology.tcl: -------------------------------------------------------------------------------- 1 | set ns [new Simulator] 2 | 3 | set nf [open startopology.nam w] 4 | $ns namtrace-all $nf 5 | 6 | proc finish {} { 7 | global ns nf 8 | $ns flush-trace 9 | close $nf 10 | exec nam startopology.nam & 11 | exit 0 12 | } 13 | 14 | set n0 [$ns node] 15 | set n1 [$ns node] 16 | set n2 [$ns node] 17 | set n3 [$ns node] 18 | 19 | $ns duplex-link $n0 $n2 10Mb 10ms DropTail 20 | $ns duplex-link $n1 $n2 10Mb 10ms DropTail 21 | $ns duplex-link $n2 $n3 10Mb 10ms DropTail 22 | 23 | $ns duplex-link-op $n0 $n2 orient right-down 24 | $ns duplex-link-op $n1 $n2 orient right-up 25 | $ns duplex-link-op $n2 $n3 orient right 26 | 27 | $ns at 1.0 "finish" 28 | 29 | $ns run -------------------------------------------------------------------------------- /CN/Tcp&udp-Star.tcl: -------------------------------------------------------------------------------- 1 | set ns [new Simulator] 2 | 3 | set nf [open startopology.nam w] 4 | $ns namtrace-all $nf 5 | 6 | proc finish {} { 7 | global ns nf 8 | $ns flush-trace 9 | close $nf 10 | exec nam startopology.nam & 11 | exit 0 12 | } 13 | 14 | set n0 [$ns node] 15 | set n1 [$ns node] 16 | set n2 [$ns node] 17 | set n3 [$ns node] 18 | 19 | $ns duplex-link $n0 $n2 10Mb 10ms DropTail 20 | $ns duplex-link $n1 $n2 10Mb 10ms DropTail 21 | $ns duplex-link $n2 $n3 10Mb 10ms DropTail 22 | 23 | $ns duplex-link-op $n0 $n2 orient right-down 24 | $ns duplex-link-op $n1 $n2 orient right-up 25 | $ns duplex-link-op $n2 $n3 orient right 26 | 27 | set tcp [new Agent/TCP] 28 | $tcp set class_ 2 29 | $ns attach-agent $n0 $tcp 30 | 31 | set sink [new Agent/TCPSink] 32 | $ns attach-agent $n3 $sink 33 | 34 | $ns connect $tcp $sink 35 | 36 | set ftp [new Application/FTP] 37 | $ftp attach-agent $tcp 38 | $ftp set type_ FTP 39 | $ftp set packet_size_ 1000 40 | $ftp set rate_ 1mb 41 | 42 | set udp [new Agent/UDP] 43 | $ns attach-agent $n1 $udp 44 | 45 | set null [new Agent/Null] 46 | $ns attach-agent $n3 $null 47 | 48 | $ns connect $udp $null 49 | 50 | set cbr [new Application/Traffic/CBR] 51 | $cbr attach-agent $udp 52 | $cbr set type_ CBR 53 | $cbr set packet_size_ 1000 54 | $cbr set rate_ 1mb 55 | 56 | $ns at 0.5 "$ftp start" 57 | $ns at 1.0 "$ftp stop" 58 | $ns at 1.5 "$udp start" 59 | $ns at 2.0 "$udp stop" 60 | $ns at 2.5 "finish" 61 | 62 | $ns run -------------------------------------------------------------------------------- /CN/UDPClient.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/CN/UDPClient.class -------------------------------------------------------------------------------- /CN/UDPClient.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.net.*; 3 | 4 | public class UDPClient { 5 | public static void main(String[] args) throws IOException { 6 | DatagramSocket socket = new DatagramSocket(); 7 | InetAddress serverAddress = InetAddress.getByName("localhost"); 8 | int serverPort = 8888; 9 | 10 | BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in)); 11 | 12 | while (true) { 13 | // Read in two numbers from the user 14 | System.out.print("Enter two numbers (separated by a space): "); 15 | String userInput = stdIn.readLine(); 16 | String[] numbers = userInput.split(" "); 17 | int num1 = Integer.parseInt(numbers[0]); 18 | int num2 = Integer.parseInt(numbers[1]); 19 | 20 | // Convert the two numbers to bytes 21 | byte[] buffer = (num1 + " " + num2).getBytes(); 22 | 23 | // Create a datagram packet to send to the server 24 | DatagramPacket packet = new DatagramPacket(buffer, buffer.length, serverAddress, serverPort); 25 | 26 | // Send the packet to the server 27 | socket.send(packet); 28 | 29 | // Receive the sum from the server 30 | byte[] receiveBuffer = new byte[1024]; 31 | DatagramPacket receivePacket = new DatagramPacket(receiveBuffer, receiveBuffer.length); 32 | socket.receive(receivePacket); 33 | 34 | // Convert the sum to a string and print it 35 | String sum = new String(receivePacket.getData(), 0, receivePacket.getLength()); 36 | System.out.println("Sum of " + num1 + " and " + num2 + " is " + sum); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /CN/UDPServer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/CN/UDPServer.class -------------------------------------------------------------------------------- /CN/UDPServer.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.net.*; 3 | 4 | public class UDPServer { 5 | public static void main(String[] args) throws IOException { 6 | DatagramSocket socket = new DatagramSocket(8888); 7 | System.out.println("Server started. Listening on port 8888."); 8 | 9 | while (true) { 10 | // Receive the datagram packet from the client 11 | byte[] buffer = new byte[1024]; 12 | DatagramPacket packet = new DatagramPacket(buffer, buffer.length); 13 | socket.receive(packet); 14 | 15 | // Convert the received bytes to two numbers 16 | String inputLine = new String(packet.getData(), 0, packet.getLength()); 17 | String[] numbers = inputLine.split(" "); 18 | int num1 = Integer.parseInt(numbers[0]); 19 | int num2 = Integer.parseInt(numbers[1]); 20 | 21 | // Compute the sum of the two numbers 22 | int sum = num1 + num2; 23 | 24 | // Convert the sum to bytes 25 | byte[] sumBytes = ("" + sum).getBytes(); 26 | 27 | // Send the sum back to the client 28 | DatagramPacket sumPacket = new DatagramPacket(sumBytes, sumBytes.length, packet.getAddress(), packet.getPort()); 29 | socket.send(sumPacket); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /CN/Wireshark.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/CN/Wireshark.pdf -------------------------------------------------------------------------------- /CN/mytcp.tcl: -------------------------------------------------------------------------------- 1 | set ns [new Simulator] 2 | 3 | set nf [open mytcp.tr w] 4 | $ns trace-all $nf 5 | set np [open mytcp.nam w] 6 | $ns namtrace-all $np 7 | 8 | proc finish {} { 9 | global ns nf np 10 | $ns flush-trace 11 | close $nf 12 | close $np 13 | exec nam mytcp.nam & 14 | exit 0 15 | } 16 | 17 | set n0 [$ns node] 18 | set n1 [$ns node] 19 | set n2 [$ns node] 20 | set n3 [$ns node] 21 | 22 | $ns duplex-link $n0 $n2 10Mb 10ms DropTail 23 | $ns duplex-link $n1 $n2 10Mb 10ms DropTail 24 | $ns duplex-link $n2 $n3 10Mb 10ms DropTail 25 | 26 | $ns queue-limit $n0 $n2 10 27 | $ns queue-limit $n1 $n2 10 28 | $ns queue-limit $n2 $n3 10 29 | 30 | $ns duplex-link-op $n0 $n2 orient right-down 31 | $ns duplex-link-op $n1 $n2 orient right-up 32 | $ns duplex-link-op $n2 $n3 orient right 33 | 34 | 35 | set tcp [new Agent/TCP] 36 | $tcp set class_ 2 37 | $ns attach-agent $n0 $tcp 38 | set sink [new Agent/TCPSink] 39 | $ns attach-agent $n3 $sink 40 | $ns connect $tcp $sink 41 | 42 | set ftp [new Application/FTP] 43 | $ftp attach-agent $tcp 44 | $ftp set type_ FTP 45 | $ftp set packet_size_ 1000 46 | $ftp set rate_ 1mb 47 | 48 | $ns at 1.0 "$ftp start" 49 | $ns at 3.0 "$ftp stop" 50 | 51 | $ns at 5.0 "finish" 52 | 53 | $ns run 54 | 55 | -------------------------------------------------------------------------------- /CN/myudp.tcl: -------------------------------------------------------------------------------- 1 | set ns [new Simulator] 2 | 3 | set nr [open outu.tr w] 4 | $ns trace-all $nr 5 | set nf [open outu.nam w] 6 | 7 | $ns namtrace-all $nf 8 | proc finish {} { 9 | global ns nr nf 10 | $ns flush-trace 11 | close $nf 12 | close $nr 13 | exec nam outu.nam & 14 | exit 0 15 | } 16 | 17 | for { set i 0 } { $i<4} { incr i 1 } { 18 | set n($i) [$ns node]} 19 | 20 | $ns duplex-link $n(0) $n(3) 1Mb 10ms DropTail 21 | $ns duplex-link $n(0) $n(2) 1Mb 10ms DropTail 22 | $ns duplex-link $n(2) $n(3) 1Mb 10ms DropTail 23 | $ns duplex-link $n(3) $n(1) 1Mb 10ms DropTail 24 | 25 | $ns duplex-link-op $n(0) $n(2) orient right 26 | $ns duplex-link-op $n(2) $n(3) orient left-down 27 | $ns duplex-link-op $n(0) $n(3) orient right-down 28 | $ns duplex-link-op $n(3) $n(1) orient left-down 29 | 30 | set tcp [new Agent/TCP] 31 | $ns attach-agent $n(3) $tcp 32 | 33 | set sink [new Agent/TCPSink] 34 | $ns attach-agent $n(2) $sink 35 | $ns connect $tcp $sink 36 | $tcp set fid_ 3 37 | 38 | set ftp [new Application/FTP] 39 | $ftp attach-agent $tcp 40 | $ftp set type_ FTP 41 | 42 | 43 | set udp0 [new Agent/UDP] 44 | $ns attach-agent $n(0) $udp0 45 | set cbr0 [new Application/Traffic/CBR] 46 | $cbr0 set packetSize_ 500 47 | $cbr0 set interval_ 0.005 48 | $cbr0 attach-agent $udp0 49 | set null0 [new Agent/Null] 50 | $ns attach-agent $n(2) $null0 51 | $ns connect $udp0 $null0 52 | 53 | set udp1 [new Agent/UDP] 54 | $ns attach-agent $n(1) $udp1 55 | set cbr1 [new Application/Traffic/CBR] 56 | $cbr1 set packetSize_ 500 57 | $cbr1 set interval_ 0.005 58 | $cbr1 attach-agent $udp1 59 | 60 | set null1 [new Agent/Null] 61 | $ns attach-agent $n(3) $null1 62 | $ns connect $udp1 $null1 63 | 64 | $udp0 set fid_ 1 65 | $udp1 set fid_ 2 66 | 67 | 68 | $ns color 1 Blue 69 | $ns color 2 Red 70 | $ns color 3 Green 71 | 72 | $ns at 0.1 "$cbr1 start" 73 | $ns at 0.5 "$cbr0 start" 74 | $ns at 4.0 "$cbr1 stop" 75 | $ns at 3.5 "$cbr0 stop" 76 | $ns at 1.0 "$ftp start" 77 | $ns at 4.5 "$ftp stop" 78 | 79 | $ns at 45 "finish" 80 | $ns run 81 | -------------------------------------------------------------------------------- /CN/nslab.tcl: -------------------------------------------------------------------------------- 1 | set ns [new Simulator] 2 | set nf [open out.nam w] 3 | $ns namtrace-all $nf 4 | set tr [open out.tr w] 5 | $ns trace-all $tr 6 | proc finish {} { 7 | global nf ns tr 8 | $ns flush-trace 9 | close $tr 10 | exec nam out.nam & 11 | exit 0 12 | } 13 | set n0 [$ns node] 14 | set n1 [$ns node] 15 | set n2 [$ns node] 16 | set n3 [$ns node] 17 | 18 | $n0 label "D" 19 | $n1 label "C" 20 | $n2 label "A" 21 | $n3 label "B" 22 | 23 | $ns duplex-link $n0 $n1 10Mb 20ms DropTail 24 | $ns duplex-link $n0 $n2 10Mb 20ms DropTail 25 | $ns duplex-link $n1 $n3 10Mb 20ms DropTail 26 | $ns duplex-link $n3 $n2 10Mb 20ms DropTail 27 | $ns duplex-link $n0 $n3 10Mb 20ms DropTail 28 | 29 | $ns queue-limit $n0 $n1 10 30 | $ns queue-limit $n1 $n3 10 31 | $ns queue-limit $n0 $n2 10 32 | $ns queue-limit $n3 $n2 10 33 | $ns queue-limit $n0 $n3 10 34 | 35 | $ns duplex-link-op $n0 $n1 orient right 36 | $ns duplex-link-op $n0 $n2 orient down 37 | $ns duplex-link-op $n1 $n3 orient down 38 | $ns duplex-link-op $n3 $n2 orient left 39 | $ns duplex-link-op $n0 $n3 orient right-down 40 | 41 | 42 | 43 | 44 | set tcp [new Agent/TCP] 45 | $ns attach-agent $n0 $tcp 46 | set ftp [new Application/FTP] 47 | $ftp attach-agent $tcp 48 | set sink [new Agent/TCPSink] 49 | $ns attach-agent $n3 $sink 50 | set udp [new Agent/UDP] 51 | $ns attach-agent $n2 $udp 52 | set cbr [new Application/Traffic/CBR] 53 | $cbr attach-agent $udp 54 | set null [new Agent/Null] 55 | $ns attach-agent $n3 $null 56 | $ns connect $tcp $sink 57 | $ns connect $udp $null 58 | $ns rtmodel-at 1.0 down $n1 $n3 59 | $ns rtmodel-at 2.0 up $n1 $n3 60 | $ns rtproto LS 61 | $ns at 0.0 "$ftp start" 62 | $ns at 0.0 "$cbr start" 63 | $ns at 5.0 "finish" 64 | $ns run 65 | -------------------------------------------------------------------------------- /CN/nslab2.tcl: -------------------------------------------------------------------------------- 1 | set ns [new Simulator] 2 | 3 | $ns rtproto DV 4 | 5 | set nf [open out1.nam w] 6 | $ns namtrace-all $nf 7 | set np [open out1.tr w] 8 | $ns trace-all $np 9 | 10 | proc finish { } { 11 | global ns nf np 12 | $ns flush-trace 13 | close $nf 14 | exec nam out1.nam 15 | exit 0 16 | } 17 | 18 | set n0 [$ns node] 19 | set n1 [$ns node] 20 | set n2 [$ns node] 21 | set n3 [$ns node] 22 | 23 | $n0 label "D" 24 | $n1 label "C" 25 | $n2 label "A" 26 | $n3 label "B" 27 | 28 | $ns duplex-link $n0 $n1 10Mb 20ms DropTail 29 | $ns duplex-link $n0 $n2 10Mb 20ms DropTail 30 | $ns duplex-link $n1 $n3 10Mb 20ms DropTail 31 | $ns duplex-link $n3 $n2 10Mb 20ms DropTail 32 | $ns duplex-link $n0 $n3 10Mb 20ms DropTail 33 | 34 | $ns queue-limit $n0 $n1 10 35 | $ns queue-limit $n1 $n3 10 36 | $ns queue-limit $n0 $n2 10 37 | $ns queue-limit $n3 $n2 10 38 | $ns queue-limit $n0 $n3 10 39 | 40 | $ns duplex-link-op $n0 $n1 orient right 41 | $ns duplex-link-op $n0 $n2 orient down 42 | $ns duplex-link-op $n1 $n3 orient down 43 | $ns duplex-link-op $n3 $n2 orient left 44 | $ns duplex-link-op $n0 $n3 orient right-down 45 | 46 | set tcp [new Agent/TCP] 47 | $tcp set class_ 2 48 | $ns attach-agent $n0 $tcp 49 | set sink [new Agent/TCPSink] 50 | $ns attach-agent $n3 $sink 51 | $ns connect $tcp $sink 52 | 53 | set ftp [new Application/FTP] 54 | $ftp attach-agent $tcp 55 | $ftp set type_ FTP 56 | $ftp set packet_size_ 1000 57 | $ftp set rate_ 1mb 58 | $ns at 1.0 "$ftp start" 59 | $ns rtmodel-at 2.0 down $n0 $n3 60 | $ns rtmodel-at 3.0 up $n0 $n3 61 | $ns at 4.0 "$ftp stop" 62 | 63 | $ns at 5.0 "finish" 64 | 65 | $ns ru 66 | -------------------------------------------------------------------------------- /CN/nslab3.tcl: -------------------------------------------------------------------------------- 1 | # create a simulator object 2 | set ns [new Simulator] 3 | 4 | # open Nam trace file 5 | set nf [open out.nam w] 6 | $ns namtrace-all $nf 7 | set np [open out.tr w] 8 | $ns trace-all $np 9 | 10 | #Define a 'finish' procedure 11 | proc finish {} 12 | { 13 | global ns nf np 14 | $ns flush-trace 15 | # close the NAM trace file 16 | close $nf 17 | #Execute NAM on Trace file 18 | exec nam out.nam & 19 | exit 0 20 | } 21 | # create two nodes 22 | set n0 [$ns node] 23 | set n1 [$ns node] 24 | 25 | #create a link 26 | $ns duplex-link $n0 $n1 2mb 10ns Drop Tail 27 | 28 | #set size of queue 29 | $ns queue-limit $n0 $n1 5 30 | 31 | #monitor the queue 32 | $ns duplex-link-op $n0 $n1 33 | queuepos 0.5 34 | 35 | #set up TCP connection 36 | set tcp[new agent/TCP] 37 | $ns attachment $n0 $tcp 38 | set sink[new agent/TCP sink] 39 | $ns attachment $n1 sink 40 | $ns connect $tcp sink 41 | 42 | #set up FTP over TCP connection 43 | set tcp[new Application/FTP] 44 | $FTP attachment tcp 45 | 46 | #Schedule an event for ftp 47 | $ns at 0.1 "$FTP start" 48 | $ns at 4.0 "$ftp stop" 49 | 50 | #call the procedure to finish after 5s of time 51 | $ns at 5.0 "finish" 52 | 53 | #To run the file call ns 54 | $ns run 55 | -------------------------------------------------------------------------------- /MPL/BcdADD.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .data 3 | a dw 3629H 4 | b dw 4738H 5 | .code 6 | mov ax, @data ; Initialize data section 7 | mov ds, ax 8 | mov ax, a ; Load number1 in ax 9 | mov bx, b ; Load number2 in bx 10 | add al, bl; add lower two digits. Result in al 11 | daa ; adjust result to valid bcd 12 | mov bl, al ; store result in bl 13 | adc ah, bh ; add upper two digits. Result in ah 14 | mov al, ah; al=ah as daa works on al only 15 | daa ; adjust result to valid BCD 16 | mov bh, al; store result in bh 17 | mov ch, 04h ; Count of digits to be displayed 18 | mov cl, 04h ; Count to roll by 4 bits cl, 04h 19 | l2:rol bx, cl ; roll bl so that msb comes to lsb 20 | mov dl, bl ; load dl with data to be displayed 21 | and dl, 0fH ; get only lsb dl, 0fH 22 | cmp dl, 09 ; check if digit is 0-9 or letter A-F 23 | jbe l4 24 | add dl, 07 ; if letter add 37H else only add 25 | l4: add dl, 30H 26 | mov ah, 02 ; Function 2 under INT 21H (Display character) 27 | int 21H 28 | dec ch ; Decrement Count 29 | jnz l2 30 | mov ah, 4cH ; T ; Terminate Program 31 | int 21H 32 | end -------------------------------------------------------------------------------- /MPL/Count1&0.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .data 3 | n1 db 31h 4 | zeros db 1 dup(0) 5 | ones db 1 dup(0) 6 | .code 7 | Start: 8 | mov ax,@data 9 | mov ds,ax 10 | mov cl,08h 11 | mov ah,00h 12 | mov al,n1 13 | mov dx,0000h 14 | up: rcl al,01H 15 | JC next 16 | inc dl 17 | jmp down 18 | next: inc dh 19 | down: loop up 20 | mov zeros, dl 21 | mov ones,dh 22 | int 03H 23 | end Start 24 | -------------------------------------------------------------------------------- /MPL/EvenOdd.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .data 3 | array db 12h, 23h, 26h, 63h, 25h, 36h, 2fh, 33h, 10h, 35h 4 | .code 5 | start: MOV ax,@data 6 | MOV ds,ax 7 | MOV cl,10 8 | MOV SI,2000h 9 | MOV DI,2008h 10 | LEA BP,array 11 | back: MOV AL,DS:[BP] 12 | MOV BL,AL 13 | AND AL,01H 14 | JZ next 15 | MOV [DI],bl 16 | INC DI 17 | JMP skip 18 | next: MOV [SI],bl 19 | INC SI 20 | skip: INC BP 21 | DEC CL 22 | JNZ back 23 | int 03H 24 | end start -------------------------------------------------------------------------------- /MPL/Factorial.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .data 3 | num dw 05h 4 | .code 5 | MOV ax, @data ; initialize the data segment 6 | MOV ds, ax 7 | MOV ax, 01 ; initialize ax = 1 8 | MOV bx, num ; load the number in cx 9 | CALL fact ; call procedure 10 | MOV di, ax ; store lsb of result in di 11 | MOV bp, 2 ; initialize count for no of times display is called 12 | MOV bx, dx ; store msb of result in reg bx 13 | MOV bx, di ; store lsb of result in bx 14 | DEC bp ; decrement bp 15 | MOV ah,4ch 16 | Int 21h 17 | Fact proc near ;function for finding the factorial 18 | CMP bx,01 ;if bx=1 19 | JZ l11 ;if yes ax=1 20 | l12: MUL bx ;find factorial 21 | DEC bx ; decrement bx 22 | CMP bx,01 ;multiply bx=1 23 | JNE l12 24 | RET 25 | l11:MOV ax,01 ;initialize ax=1 26 | RET ;return to called program 27 | fact ENDP ;end procedure 28 | END ;end program -------------------------------------------------------------------------------- /MPL/Logisim/ADDR CIRCUITS.circ: -------------------------------------------------------------------------------- 1 | 2 | 3 | This file is intended to be loaded by Logisim (http://www.cburch.com/logisim/). 4 | 5 | 6 | 7 | 8 | 9 | 10 | addr/data: 8 8 11 | 0 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /MPL/Logisim/BasicLogicGates.circ: -------------------------------------------------------------------------------- 1 | 2 | 3 | This file is intended to be loaded by Logisim (http://www.cburch.com/logisim/). 4 | 5 | 6 | 7 | 8 | 9 | 10 | addr/data: 8 8 11 | 0 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /MPL/Logisim/DEMULTIPLEXER.circ: -------------------------------------------------------------------------------- 1 | 2 | 3 | This file is intended to be loaded by Logisim (http://www.cburch.com/logisim/). 4 | 5 | 6 | 7 | 8 | 9 | 10 | addr/data: 8 8 11 | 0 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /MPL/Logisim/DEMULTIPLEXER2.circ: -------------------------------------------------------------------------------- 1 | 2 | 3 | This file is intended to be loaded by Logisim (http://www.cburch.com/logisim/). 4 | 5 | 6 | 7 | 8 | 9 | 10 | addr/data: 8 8 11 | 0 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /MPL/Logisim/MULTIPLEX.circ: -------------------------------------------------------------------------------- 1 | 2 | 3 | This file is intended to be loaded by Logisim (http://www.cburch.com/logisim/). 4 | 5 | 6 | 7 | 8 | 9 | 10 | addr/data: 8 8 11 | 0 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /MPL/Logisim/MULTIPLEXER2.circ: -------------------------------------------------------------------------------- 1 | 2 | 3 | This file is intended to be loaded by Logisim (http://www.cburch.com/logisim/). 4 | 5 | 6 | 7 | 8 | 9 | 10 | addr/data: 8 8 11 | 0 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /MPL/Logisim/SUBR CIRCUITS.circ: -------------------------------------------------------------------------------- 1 | 2 | 3 | This file is intended to be loaded by Logisim (http://www.cburch.com/logisim/). 4 | 5 | 6 | 7 | 8 | 9 | 10 | addr/data: 8 8 11 | 0 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /MPL/MoveNumbers.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .code 3 | start: 4 | MOV SI,2000h 5 | MOV DI,4000h 6 | MOV CL,05h 7 | LOOP1: MOV bl,[SI] 8 | MOV [DI],bl 9 | INC SI 10 | INC DI 11 | DEC CL 12 | JNZ LOOP1 13 | int 03h 14 | end start -------------------------------------------------------------------------------- /MPL/Palindrome.asm: -------------------------------------------------------------------------------- 1 | .MODEL SMALL 2 | .STACK 100H 3 | .DATA ; The string to be printed 4 | STRING DB 'Madam', '$' 5 | STRING1 DB 'String is palindrome', '$' 6 | STRING2 DB 'String is not palindrome', '$' 7 | .CODE 8 | MAIN PROC FAR 9 | MOV AX, @DATA 10 | MOV DS, AX 11 | ; check if the string is; 12 | ;palindrome or not 13 | CALL Palindrome 14 | ;interrupt to exit 15 | MOV AH, 4CH 16 | INT 21H 17 | MAIN ENDP 18 | Palindrome PROC 19 | ; load the starting address 20 | ; of the string 21 | MOV SI, OFFSET STRING 22 | ; traverse to the end of; 23 | ;the string 24 | LOOP1 : 25 | MOV AX, [SI] 26 | CMP AL, '$' 27 | JE LABEL1 28 | INC SI 29 | JMP LOOP1 30 | ;load the starting address; 31 | ;of the string 32 | LABEL1 : 33 | MOV DI, OFFSET STRING 34 | DEC SI 35 | ; check if the string is palindrome; 36 | ;or not 37 | LOOP2 : 38 | CMP SI, DI 39 | JL OUTPUT1 40 | MOV AX, [SI] 41 | MOV BX, [DI] 42 | CMP AL, BL 43 | JNE OUTPUT2 44 | DEC SI 45 | INC DI 46 | JMP LOOP2 47 | OUTPUT1: 48 | ;load address of the string 49 | LEA DX,STRING1 50 | ; output the string; 51 | ;loaded in dx 52 | MOV AH, 09H 53 | INT 21H 54 | RET 55 | OUTPUT2: 56 | ;load address of the string 57 | LEA DX,STRING2 58 | ; output the string 59 | ; loaded in dx 60 | MOV AH,09H 61 | INT 21H 62 | RET 63 | Palindrome ENDP 64 | END MAIN -------------------------------------------------------------------------------- /MPL/UnpackedBCD.asm: -------------------------------------------------------------------------------- 1 | .model small 2 | .data 3 | a db 13H 4 | .code 5 | mov ax, @data ; Initialize data section 6 | mov ds, ax 7 | mov al, a ; Load number1 in al 8 | and al, 0f0h ; mask lower nibble 9 | mov cl, 04h 10 | rcr al, cl ; rotate it 4 times to right to make it 09h 11 | mov bh, al ; store result in bh 12 | call disp ; display the upper nibble 13 | mov al, a ; Load number1 in al 14 | and al, 0fh ; mask upper nibble 15 | mov bh, al ; store result in bh 16 | call disp ; display the lower nibble 17 | mov ah, 4cH ; Terminate Program 18 | int 21H 19 | disp proc near 20 | mov ch, 02h ; Count of digits to be displayed 21 | mov cl, 04h ; Count to roll by 4 bits 22 | l2: rol bh, cl ; roll bl so that msb comes to lsb 23 | mov dl, bh ; load dl with data to be displayed 24 | and dl, 0fH ; get only lsb 25 | cmp dl, 09 ; check if digit is 0-9 or letter A-F 26 | jbe l4 27 | add dl, 07 ; if letter add 37H else only add 30H 28 | l4: add dl, 30H 29 | mov ah, 02 ; Function 2 under INT 21H (Display character) 30 | int 21H 31 | dec ch ; Decrement Count 32 | jnz l2 33 | mov ah, 02h 34 | mov dl, ' ' 35 | int 21h 36 | endp 37 | ret 38 | end -------------------------------------------------------------------------------- /NJQB/a1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/NJQB/a1.pdf -------------------------------------------------------------------------------- /NJQB/a2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/NJQB/a2.pdf -------------------------------------------------------------------------------- /NJQB/bar1.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | 3 | x = ['Java', 'Python', 'PHP', 'JavaScript', 'C#', 'C++'] 4 | popularity = [22.2, 17.6, 8.8, 8, 7.7, 6.7] 5 | 6 | #index not necessary 7 | x_pos = [i for i, _ in enumerate(x)] 8 | 9 | plt.bar(x_pos, popularity, color='blue') 10 | plt.xlabel("Languages") 11 | plt.ylabel("Popularity") 12 | plt.title("PopularitY of Programming Language\n" + "Worldwide, Oct 2017 compared to a year ago") 13 | plt.xticks(x_pos, x) 14 | # Turn on the grid 15 | # plt.minorticks_on() 16 | # plt.grid(which='major', linestyle='-', linewidth='0.5', color='red') 17 | # # Customize the minor grid 18 | # plt.grid(which='minor', linestyle=':', linewidth='0.5', color='black') 19 | plt.show() -------------------------------------------------------------------------------- /NJQB/bar2.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import numpy as np 3 | 4 | w = 0.4 5 | x = ["CS", "IT", "AI&DS", "EXTC", "Chemical"] 6 | boys = [100, 40, 60, 240, 300] 7 | girls = [200, 70, 30, 120, 15] 8 | bar1 = np.arange(len(x)) 9 | bar2 = [i + w for i in bar1] 10 | 11 | plt.bar(bar1, boys, w, label="boys") 12 | plt.bar(bar2, girls, w, label="girls") 13 | plt.xlabel("Courses") 14 | plt.ylabel("Students") 15 | plt.title("Student vs Courses") 16 | plt.xticks(bar1 + w/2, x) 17 | plt.legend() 18 | plt.tight_layout() 19 | plt.show() -------------------------------------------------------------------------------- /NJQB/commonChar.py: -------------------------------------------------------------------------------- 1 | str1 = 'Java' 2 | str2 = 'PHP' 3 | 4 | # Find common characters 5 | common_chars = sorted(set(str1) & set(str2)) 6 | 7 | # Check if there are any common characters 8 | if len(common_chars) == 0: 9 | print("No common characters") 10 | else: 11 | print("Common characters:", ", ".join(common_chars)) 12 | -------------------------------------------------------------------------------- /NJQB/countRepeatChar.py: -------------------------------------------------------------------------------- 1 | def count_repeated_chars(s): 2 | char_count = {} 3 | for c in s: 4 | if c in char_count: 5 | char_count[c] += 1 6 | else: 7 | char_count[c] = 1 8 | 9 | repeated_chars = {} 10 | for c in char_count: 11 | if char_count[c] > 1: 12 | repeated_chars[c] = char_count[c] 13 | 14 | return repeated_chars 15 | 16 | # Example usage: 17 | s = "thequickbrownfoxjumpsoverthelazydog" 18 | result = count_repeated_chars(s) 19 | print(result) # Output: {'l': 3, 'o': 2} 20 | -------------------------------------------------------------------------------- /NJQB/dictSort.py: -------------------------------------------------------------------------------- 1 | import operator 2 | 3 | d = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0} 4 | print('Original dictionary : ',d) 5 | 6 | sorted_d = sorted(d.items(), key=operator.itemgetter(1)) 7 | print('Dictionary in ascending order by value : ',sorted_d) 8 | 9 | sorted_d = dict( sorted(d.items(), key=operator.itemgetter(1),reverse=True)) 10 | print('Dictionary in descending order by value : ',sorted_d) -------------------------------------------------------------------------------- /NJQB/einst.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | a = np.array([1,2,3]) 4 | b = np.array([0,1,0]) 5 | 6 | print("Original 1-d arrays:") 7 | print(a) 8 | print(b) 9 | result = np.einsum("n,n", a, b) 10 | 11 | print("Einstein’s summation convention of the said arrays:") 12 | print(result) 13 | 14 | 15 | x = np.arange(9).reshape(3, 3) 16 | y = np.arange(3, 12).reshape(3, 3) 17 | 18 | print("Original Higher dimension:") 19 | print(x) 20 | print(y) 21 | result = np.einsum("ma,an", x, y) 22 | 23 | print("Einstein’s summation convention of the said arrays:") 24 | print(result) 25 | -------------------------------------------------------------------------------- /NJQB/intRoman.py: -------------------------------------------------------------------------------- 1 | class py_solution: 2 | def int_to_Roman(self, num): 3 | val = [ 4 | 1000, 900, 500, 400, 5 | 100, 90, 50, 40, 6 | 10, 9, 5, 4, 7 | 1 8 | ] 9 | syb = [ 10 | "M", "CM", "D", "CD", 11 | "C", "XC", "L", "XL", 12 | "X", "IX", "V", "IV", 13 | "I" 14 | ] 15 | roman_num = '' 16 | i = 0 17 | while num > 0: 18 | for _ in range(num // val[i]): 19 | roman_num += syb[i] 20 | num -= val[i] 21 | i += 1 22 | return roman_num 23 | 24 | print(py_solution().int_to_Roman(1)) 25 | print(py_solution().int_to_Roman(4000)) 26 | -------------------------------------------------------------------------------- /NJQB/lambda.py: -------------------------------------------------------------------------------- 1 | subject_marks = [('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)] 2 | print("Original list of tuples:") 3 | print(subject_marks) 4 | subject_marks.sort(key = lambda x: x[1]) 5 | print("\nSorting the List of Tuples:") 6 | print(subject_marks) -------------------------------------------------------------------------------- /NJQB/lambda2.py: -------------------------------------------------------------------------------- 1 | # Get number of students 2 | num_students = int(input("Enter the number of students: ")) 3 | 4 | # Initialize lists for storing student names and total marks 5 | names = [] 6 | marks = [] 7 | 8 | # Get student names and marks 9 | for i in range(num_students): 10 | name = input("Enter the name of student {}: ".format(i+1)) 11 | names.append(name) 12 | marks_list = [] 13 | for j in range(3): 14 | mark = int(input("Enter the mark for subject {}: ".format(j+1))) 15 | marks_list.append(mark) 16 | marks.append(marks_list) 17 | 18 | # Calculate total marks for each student using lambda and store them in a list 19 | total_marks = list(map(lambda x: sum(x), marks)) 20 | 21 | # Get the second lowest total marks 22 | second_lowest_marks = sorted(set(total_marks))[1] 23 | 24 | # Find the students with the second lowest marks and print their names 25 | for i in range(num_students): 26 | if sum(marks[i]) == second_lowest_marks: 27 | print(names[i]) 28 | -------------------------------------------------------------------------------- /NJQB/panda1.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import numpy as np 3 | 4 | exam_data = {'name': ['Anastasia', 'Dima', 'Katherine', 'James', 'Emily', 'Michael', 'Matthe','al','uff','kya'], 5 | 'score': [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19], 6 | 'attempts' : [1, 3, 2, 3, 2, 3, 1, 1, 2, 1], 7 | 'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']} 8 | 9 | labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'] 10 | df = pd.DataFrame(exam_data , index=labels) 11 | 12 | print("Number of attempts in the examination is greater than 2:") 13 | print(df[df['attempts']>2]) 14 | -------------------------------------------------------------------------------- /NJQB/pascal.py: -------------------------------------------------------------------------------- 1 | def pascal_triangle(n): 2 | triangle = [] 3 | for i in range(n): 4 | row = [1] 5 | if i > 0: 6 | for j in range(1, i): 7 | row.append(triangle[i-1][j-1] + triangle[i-1][j]) 8 | row.append(1) 9 | triangle.append(row) 10 | 11 | # Determine maximum number of digits for formatting 12 | max_digits = len(str(triangle[-1][len(triangle[-1])//2])) 13 | 14 | # Print triangle with proper spacing 15 | for row in triangle: 16 | for num in row: 17 | print(f"{num:^{max_digits}}", end=" ") 18 | print() 19 | 20 | # example usage 21 | pascal_triangle(5) 22 | -------------------------------------------------------------------------------- /NJQB/progressbar.py: -------------------------------------------------------------------------------- 1 | import tkinter as tk 2 | root = tk.Tk() 3 | text_var = tk.DoubleVar() 4 | 5 | spin_box = tk.Spinbox( 6 | root, 7 | from_=0.6, 8 | to=50.0, 9 | increment=.01, 10 | textvariable=text_var 11 | ) 12 | spin_box.pack() 13 | root.mainloop() -------------------------------------------------------------------------------- /NJQB/tkinter1.py: -------------------------------------------------------------------------------- 1 | import tkinter as tk 2 | 3 | # create the main window 4 | root = tk.Tk() 5 | 6 | # create a Text widget with some initial text 7 | text_widget = tk.Text(root, height=10, width=50) 8 | text_widget.insert(tk.END, "Hello, world!\n") 9 | 10 | # insert a string at the beginning of the text 11 | text_widget.insert("1.0", "Insert at beginning\n") 12 | 13 | # insert a string at the current position 14 | text_widget.insert(tk.INSERT, "Insert at current position") 15 | 16 | # delete the first character of the text 17 | text_widget.delete("1.0") 18 | 19 | # delete the last character of the text 20 | text_widget.delete(tk.END+"-2c") 21 | 22 | # pack the Text widget and start the main loop 23 | text_widget.pack() 24 | root.mainloop() 25 | -------------------------------------------------------------------------------- /Python/10_CalculatorGUI.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | 3 | def button_click(number): 4 | current = e.get() 5 | e.delete(0,END) 6 | e.insert(0,str(current)+str(number)) 7 | 8 | def button_add(): 9 | first = e.get() 10 | global fnum 11 | fnum = float(first) 12 | global math 13 | math = "addition" 14 | e.delete(0,END) 15 | 16 | def button_sub(): 17 | first = e.get() 18 | global fnum 19 | fnum = float(first) 20 | global math 21 | math = "subtraction" 22 | e.delete(0,END) 23 | def button_mul(): 24 | first = e.get() 25 | global fnum 26 | fnum = float(first) 27 | global math 28 | math = "multiplication" 29 | e.delete(0,END) 30 | def button_div(): 31 | first = e.get() 32 | global fnum 33 | fnum = float(first) 34 | global math 35 | math = "division" 36 | e.delete(0,END) 37 | def button_clear(): 38 | e.delete(0,END) 39 | 40 | def button_equal(): 41 | snum = float(e.get()) 42 | e.delete(0,END) 43 | if math == "addition": 44 | answer = fnum + snum 45 | e.insert(0,f"{fnum}+{snum}={answer}") 46 | elif math == "subtraction": 47 | answer = fnum - snum 48 | e.insert(0,f"{fnum}-{snum}={answer}") 49 | elif math == "multiplication": 50 | answer = fnum * snum 51 | e.insert(0,f"{fnum}x{snum}={answer}") 52 | elif math == "division": 53 | answer = fnum / snum 54 | e.insert(0,f"{fnum}/{snum}={answer}") 55 | else: 56 | e.insert(0,"Math Error") 57 | 58 | def butn_end(): 59 | exit() 60 | root= Tk() 61 | root.title("Simple Calculator-Python") 62 | # root.geometry("330x500") 63 | # root.resizable(0,0) 64 | 65 | e = Entry(root,borderwidth=5,width=65) 66 | e.grid(row=0,column=0,columnspan=4,padx=5,pady=10) 67 | 68 | button_1 = Button(root,text="1",padx=40,pady=20,command=lambda: button_click(1),font=12) 69 | button_2 = Button(root,text="2",padx=40,pady=20,command=lambda: button_click(2),font=12) 70 | button_3 = Button(root,text="3",padx=44,pady=20,command=lambda: button_click(3),font=12) 71 | button_4 = Button(root,text="4",padx=40,pady=20,command=lambda: button_click(4),font=12) 72 | button_5 = Button(root,text="5",padx=40,pady=20,command=lambda: button_click(5),font=12) 73 | button_6 = Button(root,text="6",padx=44,pady=20,command=lambda: button_click(6),font=12) 74 | button_7 = Button(root,text="7",padx=40,pady=20,command=lambda: button_click(7),font=12) 75 | button_8 = Button(root,text="8",padx=40,pady=20,command=lambda: button_click(8),font=12) 76 | button_9 = Button(root,text="9",padx=44,pady=20,command=lambda: button_click(9),font=12) 77 | button_0 = Button(root,text="0",padx=40,pady=20,command=lambda: button_click(0),font=12) 78 | 79 | btn_add = Button(root,text="*",padx=42,pady=20,command=button_mul,font=12) 80 | btn_sub = Button(root,text="-",padx=44,pady=20,command=button_sub,font=12) 81 | btn_div = Button(root,text="/",padx=40,pady=20,command=button_div,font=12) 82 | btn_mul = Button(root,text="+",padx=42,pady=20,command=button_add,font=12) 83 | btn_equal = Button(root,text="=",padx=42,pady=20,command=button_equal,font=12) 84 | btn_clear = Button(root,text="Clear",padx=20,pady=20,command=button_clear,font=8) 85 | 86 | button_7.grid(row=1,column=0) 87 | button_8.grid(row=1,column=1) 88 | button_9.grid(row=1,column=2) 89 | 90 | button_4.grid(row=2,column=0) 91 | button_5.grid(row=2,column=1) 92 | button_6.grid(row=2,column=2) 93 | 94 | button_1.grid(row=3,column=0) 95 | button_2.grid(row=3,column=1) 96 | button_3.grid(row=3,column=2) 97 | 98 | button_0.grid(row=4,column=0) 99 | 100 | btn_add.grid(row=1,column=3) 101 | btn_sub.grid(row=2,column=3) 102 | btn_mul.grid(row=3,column=3) 103 | btn_div.grid(row=4,column=3) 104 | btn_clear.grid(row=4,column=1) 105 | btn_equal.grid(row=4,column=2) 106 | 107 | 108 | root.mainloop() 109 | -------------------------------------------------------------------------------- /Python/10_CalculatorGUI2.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | 3 | # Let's create the Tkinter window 4 | window = Tk() 5 | 6 | # Then, you will define the size of the window in width(312) and height(324) using the 'geometry' method 7 | window.geometry("347x423") 8 | 9 | # In order to prevent the window from getting resized you will call 'resizable' method on the window 10 | #window.resizable(0, 0) 11 | 12 | #Finally, define the title of the window 13 | window.title("Calculator") 14 | 15 | 16 | # Let's now define the required functions for the Calculator to function properly. 17 | 18 | # 1. First is the button click 'btn_click' function which will continuously update the input field whenever a number is entered or any button is pressed it will act as a button click update. 19 | def btn_click(item): 20 | global expression 21 | expression = expression + str(item) 22 | input_text.set(expression) 23 | 24 | # 2. Second is the button clear 'btn_clear' function clears the input field or previous calculations using the button "C" 25 | def btn_clear(): 26 | global expression 27 | expression = "" 28 | input_text.set("") 29 | 30 | # 3. Third and the final function is button equal ("=") 'btn_equal' function which will calculate the expression present in input field. For example: User clicks button 2, + and 3 then clicks "=" will result in an output 5. 31 | def btn_equal(): 32 | global expression 33 | result = str(eval(expression)) # 'eval' function is used for evaluating the string expressions directly 34 | # you can also implement your own function to evalute the expression istead of 'eval' function 35 | input_text.set(result) 36 | expression = "" 37 | 38 | expression = "" 39 | # In order to get the instance of the input field 'StringVar()' is used 40 | input_text = StringVar() 41 | 42 | # Once all the functions are defined then comes the main section where you will start defining the structure of the calculator inside the GUI. 43 | 44 | # The first thing is to create a frame for the input field 45 | input_frame = Frame(window, width = 312, height = 50, bd = 0, highlightbackground = "black", highlightcolor = "black", highlightthickness = 1) 46 | input_frame.pack(side = TOP) 47 | 48 | 49 | # Then you will create an input field inside the 'Frame' that was created in the previous step. Here the digits or the output will be displayed as 'right' aligned 50 | input_field = Entry(input_frame, font = ('arial', 18, 'bold'), textvariable = input_text, width = 50, bg = "#eee", bd = 0, justify = RIGHT) 51 | input_field.grid(row = 0, column = 0) 52 | input_field.pack(ipady = 10) # 'ipady' is an internal padding to increase the height of input field 53 | 54 | 55 | # Once you have the input field defined then you need a separate frame which will incorporate all the buttons inside it below the 'input field' 56 | btns_frame = Frame(window, width = 312, height = 272.5, bg = "grey") 57 | btns_frame.pack() 58 | 59 | 60 | # The first row will comprise of the buttons 'Clear (C)' and 'Divide (/)' 61 | clear = Button(btns_frame, text = "C", fg = "black", width = 32, height = 3, bd = 0, bg = "#eee", cursor = "hand2", command = lambda: btn_clear()).grid(row = 0, column = 0, columnspan = 3, padx = 1, pady = 1) 62 | divide = Button(btns_frame, text = "/", fg = "black", width = 10, height = 3, bd = 0, bg = "#eee", cursor = "hand2", command = lambda: btn_click("/")).grid(row = 0, column = 3, padx = 1, pady = 1) 63 | 64 | 65 | # The second row will comprise of the buttons '7', '8', '9' and 'Multiply (*)' 66 | seven = Button(btns_frame, text = "7", fg = "black", width = 10, height = 3, bd = 0, bg = "#fff", cursor = "hand2", command = lambda: btn_click(7)).grid(row = 1, column = 0, padx = 1, pady = 1) 67 | eight = Button(btns_frame, text = "8", fg = "black", width = 10, height = 3, bd = 0, bg = "#fff", cursor = "hand2", command = lambda: btn_click(8)).grid(row = 1, column = 1, padx = 1, pady = 1) 68 | nine = Button(btns_frame, text = "9", fg = "black", width = 10, height = 3, bd = 0, bg = "#fff", cursor = "hand2", command = lambda: btn_click(9)).grid(row = 1, column = 2, padx = 1, pady = 1) 69 | multiply = Button(btns_frame, text = "*", fg = "black", width = 10, height = 3, bd = 0, bg = "#eee", cursor = "hand2", command = lambda: btn_click("*")).grid(row = 1, column = 3, padx = 1, pady = 1) 70 | 71 | 72 | # The third row will comprise of the buttons '4', '5', '6' and 'Subtract (-)' 73 | four = Button(btns_frame, text = "4", fg = "black", width = 10, height = 3, bd = 0, bg = "#fff", cursor = "hand2", command = lambda: btn_click(4)).grid(row = 2, column = 0, padx = 1, pady = 1) 74 | five = Button(btns_frame, text = "5", fg = "black", width = 10, height = 3, bd = 0, bg = "#fff", cursor = "hand2", command = lambda: btn_click(5)).grid(row = 2, column = 1, padx = 1, pady = 1) 75 | six = Button(btns_frame, text = "6", fg = "black", width = 10, height = 3, bd = 0, bg = "#fff", cursor = "hand2", command = lambda: btn_click(6)).grid(row = 2, column = 2, padx = 1, pady = 1) 76 | minus = Button(btns_frame, text = "-", fg = "black", width = 10, height = 3, bd = 0, bg = "#eee", cursor = "hand2", command = lambda: btn_click("-")).grid(row = 2, column = 3, padx = 1, pady = 1) 77 | 78 | 79 | # The fourth row will comprise of the buttons '1', '2', '3' and 'Addition (+)' 80 | one = Button(btns_frame, text = "1", fg = "black", width = 10, height = 3, bd = 0, bg = "#fff", cursor = "hand2", command = lambda: btn_click(1)).grid(row = 3, column = 0, padx = 1, pady = 1) 81 | two = Button(btns_frame, text = "2", fg = "black", width = 10, height = 3, bd = 0, bg = "#fff", cursor = "hand2", command = lambda: btn_click(2)).grid(row = 3, column = 1, padx = 1, pady = 1) 82 | three = Button(btns_frame, text = "3", fg = "black", width = 10, height = 3, bd = 0, bg = "#fff", cursor = "hand2", command = lambda: btn_click(3)).grid(row = 3, column = 2, padx = 1, pady = 1) 83 | plus = Button(btns_frame, text = "+", fg = "black", width = 10, height = 3, bd = 0, bg = "#eee", cursor = "hand2", command = lambda: btn_click("+")).grid(row = 3, column = 3, padx = 1, pady = 1) 84 | 85 | 86 | # Finally, the fifth row will comprise of the buttons '0', 'Decimal (.)', and 'Equal To (=)' 87 | zero = Button(btns_frame, text = "0", fg = "black", width = 21, height = 3, bd = 0, bg = "#fff", cursor = "hand2", command = lambda: btn_click(0)).grid(row = 4, column = 0, columnspan = 2, padx = 1, pady = 1) 88 | point = Button(btns_frame, text = ".", fg = "black", width = 10, height = 3, bd = 0, bg = "#eee", cursor = "hand2", command = lambda: btn_click(".")).grid(row = 4, column = 2, padx = 1, pady = 1) 89 | equals = Button(btns_frame, text = "=", fg = "black", width = 10, height = 3, bd = 0, bg = "#eee", cursor = "hand2", command = lambda: btn_equal()).grid(row = 4, column = 3, padx = 1, pady = 1) 90 | 91 | 92 | window.mainloop() -------------------------------------------------------------------------------- /Python/11_MysqlPython.py: -------------------------------------------------------------------------------- 1 | import mysql.connector as sql 2 | #connection 3 | 4 | try: 5 | connection=sql.connect( 6 | user="root", 7 | password="Root@1234", 8 | host="localhost", 9 | port="3306", 10 | database="altaf" 11 | ) 12 | if(connection.is_connected()): 13 | print("Connection established") 14 | 15 | except Exception as e: 16 | print("Connection cannot be established") 17 | 18 | cursor = connection.cursor(); 19 | 20 | #table create 21 | 22 | query="create table booksdata(\ 23 | id int primary key auto_increment,\ 24 | title varchar(30),\ 25 | author varchar(30),\ 26 | publication varchar(50),\ 27 | yearofpublication int,\ 28 | price int\ 29 | );" 30 | 31 | try: 32 | cursor.execute(query) 33 | connection.commit() 34 | except Exception as e: 35 | print(e) 36 | 37 | 38 | #insert into 10 values 39 | insert_query="insert into booksdata(title,author,publication,yearofpublication,price) values (%s,%s,%s,%s,%s)" 40 | 41 | values=[('Love story','altaf','pikachu',2023,1000000),('Cryptography','alt','pika',2022,1000),('Pokemon','Pikachu','togepi',2003,1000)] 42 | try: 43 | cursor.executemany(insert_query,values) 44 | connection.commit() 45 | 46 | except Exception as e: 47 | print("table insertion not done") 48 | 49 | #print data 50 | 51 | data_query="select * from booksdata" 52 | 53 | try: 54 | cursor.execute(data_query) 55 | d1 = cursor.fetchall() 56 | print("\n\n\n all the datas is :") 57 | 58 | for i in d1: 59 | print(i) 60 | 61 | except Exception as e: 62 | print(e) 63 | 64 | 65 | 66 | #search data1 67 | 68 | search_query1="select * from booksdata where publication='TMH' " 69 | 70 | try: 71 | cursor.execute(search_query1) 72 | s1 = cursor.fetchall() 73 | print("\n\n\n searched pika is :") 74 | 75 | for i in s1: 76 | print(i) 77 | except Exception as e: 78 | print(e) 79 | 80 | 81 | #search data2 82 | 83 | search_query1="select * from booksdata where yearofpublication between 2001 and 2020 " 84 | 85 | try: 86 | cursor.execute(search_query1) 87 | s1 = cursor.fetchall() 88 | print("\n\n\n searched pika is :") 89 | 90 | for i in s1: 91 | print(i) 92 | except Exception as e: 93 | print(e) 94 | 95 | 96 | #update 97 | update_query="update booksdata set price=600 where title='crpytography'" 98 | 99 | try: 100 | cursor.execute(update_query) 101 | print("Data updated successfully") 102 | connection.commit() 103 | except Exception as e: 104 | print(e) 105 | 106 | #delete 107 | delete_query="delete from booksdata where yearofpublication < 1980" 108 | 109 | try: 110 | cursor.execute(delete_query) 111 | print("Data deleted successfully") 112 | connection.commit() 113 | except Exception as e: 114 | print(e) 115 | 116 | -------------------------------------------------------------------------------- /Python/12_Histogram.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | 4 | # Generate 1000 random datapoints between 0 and 100 5 | data = np.random.randint(0, 101, 1000) 6 | 7 | # Define bin edges 8 | bins = np.arange(0, 105, 5) 9 | 10 | # Create histogram with 20 bins 11 | plt.hist(data, bins=bins, edgecolor='black') 12 | 13 | # Set x-axis label for each bin range 14 | plt.xticks(bins) 15 | 16 | # Set y-axis label for count of datapoints in each bin 17 | plt.ylabel('Frequency') 18 | 19 | # Set x-axis label for distribution 20 | plt.xlabel('Distribution') 21 | 22 | # Set title for the histogram 23 | plt.title('Distribution of Randomly Generated Datapoints') 24 | 25 | # Display the histogram 26 | plt.show() -------------------------------------------------------------------------------- /Python/12_Piechart.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | 3 | y=[57,48,39,25,20,10] 4 | 5 | countries = ['United States','China','Great Britain','Russia','Germany','Japan'] 6 | # myexplode = [0.2, 0, 0, 0,0,0] 7 | 8 | plt.pie(y,labels=countries,autopct='%0.2f%%') 9 | #plt.legend() 10 | plt.show() 11 | -------------------------------------------------------------------------------- /Python/12_bargraph.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import numpy as np 3 | 4 | x = np.arange(6) 5 | y1=[57,48,39,25,20,10] 6 | y2=[28,30,21,25,18,16] 7 | 8 | countries = ['United States','China','Great Britain','Russia','Germany','Japan'] 9 | 10 | plt.bar(x-0.2, y1, width=0.40,color="red") 11 | plt.bar(x+0.2, y2, width=0.40,color="green") 12 | plt.xticks(x,countries) 13 | 14 | medals = ['Gold medal','Silver medal'] 15 | plt.title('Bar graph medals tally') 16 | plt.xlabel('Countries') 17 | plt.ylabel('Medals') 18 | plt.legend(medals) 19 | plt.show() 20 | -------------------------------------------------------------------------------- /Python/13_Pandas.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import numpy as np 3 | 4 | data = { 5 | 'ISBN': ['978-1400079179', '978-0374533557', '978-0440241164', '978-0307277673', '978-0441013593', '978-0553382563', '978-0345453747', '978-0345538376', '978-0307278731', '978-0802144656'], 6 | 'Title': ['The Kite Runner', 'The Brief Wondrous Life of Oscar Wao', 'The Da Vinci Code', 'The Road', 'Old Man’s War', 'The Devil in the White City', 'The Hitchhiker’s Guide to the Galaxy', 'Ready Player One', 'The Secret Life of Bees', 'The Book Thief'], 7 | 'Author': ['Khaled Hosseini', 'Junot Diaz', 'Dan Brown', 'Cormac McCarthy', 'John Scalzi', 'Erik Larson', 'Douglas Adams', 'Ernest Cline', 'Sue Monk Kidd', 'Markus Zusak'], 8 | 'Publication': ['Metro Publication', 'Riverhead Books', 'Anchor', 'Vintage', 'Tor Books', 'Vintage', 'Del Rey Books', 'Broadway Books', 'Penguin Books', 'Picador'], 9 | 'Year Published': [2003, 2007, 2003, 2006, 2005, 2003, 1979, 2011, 2002, 2005], 10 | 'Price': [15.00, 16.00, 8.99, 16.00, 7.99, 9.99, 7.99, 14.00, 10.00, 12.00], 11 | 'Copies sold in first edition': [40000, 30000, 100000, 50000, 20000, 10000, 5000, 20000, 40000, 30000], 12 | 'Copies sold in second edition': [30000, 20000, 50000, 40000, 15000, 8000, 3000, 15000, 25000, 20000], 13 | 'Copies sold in third edition': [20000, 15000, 30000, 20000, 10000, 5000, 1000, 8000, 15000, 10000] 14 | } 15 | 16 | df = pd.DataFrame(data) 17 | 18 | #To display the number of rows and columns in dataframe: 19 | print(df.shape) 20 | print("Number of rows:", df.shape[0]) 21 | print("Number of columns:", df.shape[1]) 22 | 23 | #To give the descriptive statistics of the created dataset: 24 | print(df.describe()) 25 | 26 | #describe copies sold in second edition 27 | print(df['Copies sold in second edition'].describe()) 28 | 29 | #To display distinct publication names for the dataset:return array 30 | print(df['Publication'].unique()) 31 | 32 | #To display the book title and author names published by “Metro Publication”: 33 | print(df.loc[df['Publication'] == 'Metro Publication', ['Title', 'Author']]) 34 | 35 | #To rename columns “Copies sold in first edition”, “Copies sold in second edition” and “Copies sold in third edition”to FE, SE and TE respectively: 36 | df = df.rename(columns={'Copies sold in first edition': 'FE', 'Copies sold in second edition': 'SE', 'Copies sold in third edition': 'TE'}) 37 | print(df.columns) 38 | 39 | # To add a column “Average sale” to your dataframe derived as (average of FE, SE and TE) * Price: 40 | df['Average sale'] = ((df['FE'] + df['SE'] + df['TE']) / 3) * df['Price'] 41 | print(df.head()) 42 | 43 | # To display the details of books grouped by author: 44 | grouped_data = df.groupby('Author').agg({'Title': 'unique', 'Publication': 'unique', 'Price': 'mean', 'FE': 'sum', 'SE': 'sum', 'TE': 'sum', 'Average sale': 'mean'}) 45 | print(grouped_data) 46 | 47 | # For each group obtained in above query display maximum value of Average sale: 48 | max_sale = grouped_data['Average sale'].max() 49 | print("Maximum value of Average sale:", max_sale) 50 | 51 | # Reshape your dataframe such that rows will show ‘Author’, column will show “Publication” and values will be ‘Title’ of book 52 | pivot_data = pd.pivot_table(df, values='Title', index=['Author'], columns=['Publication'], aggfunc=lambda x: ', '.join(x)) 53 | print(pivot_data) -------------------------------------------------------------------------------- /Python/14_Scipy1.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from scipy.linalg import solve 3 | 4 | # Create coefficient matrix 5 | A = np.array([[9, 6, -5, 2], [4, 5, -7, 3], [-3, -4, 2, -5], [6, 1, 9, -1]]) 6 | 7 | # Create constant matrix 8 | B = np.array([17, 10, 20, 23]) 9 | 10 | # Solve the system of linear equations 11 | X = solve(A, B) 12 | 13 | # Print the solution 14 | print("Solution: x = {}, y = {}, z = {}, w = {}".format(X[0], X[1], X[2], X[3])) 15 | -------------------------------------------------------------------------------- /Python/14_Scipy2.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from scipy.linalg import inv, det, kron 3 | 4 | # Define matrix A 5 | A = np.array([[5, 3, 2], [6, 9, -3], [1, 7, 4]]) 6 | 7 | # Define matrix B 8 | B = np.array([[3, -1], [2, -5]]) 9 | 10 | # a. Find inverse of matrix A 11 | A_inv = inv(A) 12 | print("Inverse of A:\n", A_inv) 13 | 14 | # b. Find Kronecker product of A with B 15 | AB_kron = kron(A, B) 16 | print("Kronecker product of A and B:\n", AB_kron) 17 | 18 | # c. Find determinant of matrix A 19 | A_det = det(A) 20 | print("Determinant of A:", A_det) 21 | -------------------------------------------------------------------------------- /Python/15_FlaskWeb1/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template, jsonify 2 | import json 3 | 4 | app = Flask(__name__) 5 | 6 | # Load the book data from a JSON file 7 | with open('book.json', 'r') as f: 8 | book_data = json.load(f) 9 | 10 | @app.route('/') 11 | def index(): 12 | return "Welcome to the library!" 13 | 14 | @app.route('/books') 15 | def show_books(): 16 | # Render a template that displays the list of books 17 | return render_template('books.html', books=book_data) 18 | 19 | # direct call jsonify 20 | @app.route('/books/', methods=['GET']) 21 | def get_book_by_isbn(isbn): 22 | for book in book_data['books']: 23 | if book['isbn'] == str(isbn): 24 | return jsonify(book) 25 | return jsonify({'message': 'Book not found.'}), 404 26 | 27 | # html template call (using book_details.html ) 28 | # @app.route('/books/') 29 | # def book(isbn): 30 | # book = None 31 | # try: 32 | # for b in book_data['books']: 33 | # if b['isbn'] == str(isbn): 34 | # book = b 35 | # break 36 | # if book: 37 | # return render_template('book_details.html', book=book) 38 | # else: 39 | # return f"Error: No book with ISBN {isbn} found." 40 | # except Exception as e: 41 | # return f"Error: {e}" 42 | 43 | 44 | if __name__ == '__main__': 45 | app.run(debug=True) 46 | -------------------------------------------------------------------------------- /Python/15_FlaskWeb1/book.json: -------------------------------------------------------------------------------- 1 | { 2 | "books": [ 3 | { 4 | "isbn": "1", 5 | "title": "Flask Web Development: Developing Web Applications with Python", 6 | "author": "Miguel Grinberg", 7 | "publication": "O'Reilly Media" 8 | }, 9 | { 10 | "isbn": "2", 11 | "title": "Python for Data Analysis: Data Wrangling with Pandas, NumPy, and IPython", 12 | "author": "Wes McKinney", 13 | "publication": "O'Reilly Media" 14 | }, 15 | { 16 | "isbn": "3", 17 | "title": "Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems", 18 | "author": "Aurélien Géron", 19 | "publication": "O'Reilly Media" 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /Python/15_FlaskWeb1/requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/Python/15_FlaskWeb1/requirements.txt -------------------------------------------------------------------------------- /Python/15_FlaskWeb1/templates/books.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Books 5 | 6 | 7 |

Books Available in the Library

8 |
    9 | {% for book in books['books'] %} 10 |

    {{ book.title }}

    11 |

    ISBN: {{ book.isbn }}

    12 |

    Author: {{ book.author }}

    13 |

    Publication: {{ book.publication }}

    14 |
    15 | {% endfor %} 16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /Python/15_FlaskWeb2/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, redirect, jsonify 2 | 3 | app = Flask(__name__) 4 | 5 | @app.route('/') 6 | def index(): 7 | return "Welcome to the exam!" 8 | 9 | 10 | @app.route('/result/') 11 | def result(marks): 12 | if marks < 40: 13 | return redirect('/failed') 14 | else: 15 | return redirect('/passed') 16 | 17 | @app.route('/failed') 18 | def failed(): 19 | result = { 20 | 'message': 'Sorry, you have failed the exam.' 21 | } 22 | return jsonify(result) 23 | 24 | @app.route('/passed') 25 | def passed(): 26 | result = { 27 | 'message': 'Congratulations, you have passed the exam!' 28 | } 29 | return jsonify(result) 30 | 31 | if __name__ == '__main__': 32 | app.run(debug=True) 33 | -------------------------------------------------------------------------------- /Python/15_FlaskWeb2/requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/Python/15_FlaskWeb2/requirements.txt -------------------------------------------------------------------------------- /Python/1_NameManipulate.py: -------------------------------------------------------------------------------- 1 | fname = input("enter fname:") 2 | 3 | lname = input("enter lname:") 4 | 5 | print(fname,lname) 6 | 7 | for i in range(len(lname)-1,-1,-1): 8 | print(lname[i],end="") 9 | 10 | print(" ",end="") 11 | 12 | for i in range(len(fname)-1,-1,-1): 13 | print(fname[i],end="") 14 | -------------------------------------------------------------------------------- /Python/1_Pattern.py: -------------------------------------------------------------------------------- 1 | n=int(input("Enter the number:")) 2 | 3 | for i in range(1,n+1): 4 | print(i*"*") 5 | for i in range(n-1,0,-1): 6 | print(i*"*") 7 | 8 | -------------------------------------------------------------------------------- /Python/2_DictTuples.py: -------------------------------------------------------------------------------- 1 | dict1 = {1:"www.google.com" , 2:"www.tsec.edu" , 2 | 3:"www.asp.net" , 4:"www.abcd.in" } 3 | 4 | l1 = list(dict1.values()) 5 | t1 = [] 6 | 7 | #print(l1) 8 | 9 | for i in l1: 10 | j = i.split('.') 11 | t1.append(j[2]) 12 | 13 | t1 = tuple(t1) 14 | print(t1) 15 | -------------------------------------------------------------------------------- /Python/2_Dictionary.py: -------------------------------------------------------------------------------- 1 | t = (4,5,6,2,3,4,5,1,2,6,4) 2 | 3 | dict1 = {} 4 | 5 | for i in t: 6 | j = t.count(i) 7 | dict1[i] = j 8 | 9 | print(dict1) 10 | 11 | 12 | ''' 13 | set1 = set() 14 | for i in t: 15 | set1.add(i) 16 | 17 | print(set1) 18 | 19 | for i in set1: 20 | j = t.count(i) 21 | dict1[i] = j 22 | 23 | print(dict1) 24 | ''' 25 | -------------------------------------------------------------------------------- /Python/2_ListComprehension.py: -------------------------------------------------------------------------------- 1 | list1=['x','y','z'] 2 | 3 | #1st part 4 | 5 | list11 =[i*j for i in list1 for j in range(1,4)] 6 | print(list11) 7 | 8 | 9 | #2nd part 10 | #list ={i*1 for i in list1] 11 | #list2=[i*2 for i in list1] 12 | #list3=[i*3 for i in list1] 13 | #list4=list1+list2+list3 14 | 15 | list12 =[i*j for j in range(1,4) for i in list1] 16 | print(list12) 17 | -------------------------------------------------------------------------------- /Python/2_ListOperations.py: -------------------------------------------------------------------------------- 1 | list1=[] 2 | 3 | numbers=int(input("Enter the total numbers:")) 4 | 5 | for i in range(numbers): 6 | num=int(input("Enter the number:")) 7 | list1.append(num) 8 | 9 | ev=0 10 | od=0 11 | 12 | for i in list1: 13 | if i%2==0: 14 | ev+=i 15 | else: 16 | od+=i 17 | 18 | #inserting even num sum and odd num sum 19 | t1=(ev,od) 20 | print(t1) 21 | -------------------------------------------------------------------------------- /Python/3_Numpy1.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | a = np.array([[2,4,6,8,6],[23,56,45,10,83],[98,12,34,78,78],[21,63,78,84,53]]) 4 | 5 | print(a) 6 | b = a[::2, 1::2] 7 | 8 | print(b) 9 | 10 | """ 11 | print(a) 12 | result = a[np.arange(a.shape[0]) % 2 == 0, 1::2] 13 | print(result) 14 | 15 | 16 | ''' 17 | Return the array of even rows and odd columns from following array 18 | ''' 19 | print(a) 20 | b = a[::2, 1::2] 21 | 22 | print(b) 23 | """ 24 | -------------------------------------------------------------------------------- /Python/3_NumpyMatrix.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | # create an 8x3 array of numbers from 10 to 34 4 | arr = np.arange(10, 34).reshape(8, 3) 5 | 6 | # split the array into 4 equal parts 7 | part1, part2, part3, part4 = np.split(arr, 4) 8 | 9 | print("Part 1:") 10 | print(part1) 11 | print("\nPart 2:") 12 | print(part2) 13 | print("\nPart 3:") 14 | print(part3) 15 | print("\nPart 4:") 16 | print(part4) 17 | 18 | ''' 19 | Create a 8*3 array for numbers from 10 to 34 . Split the array into 4 equal parts 20 | ''' 21 | -------------------------------------------------------------------------------- /Python/4_Function1.py: -------------------------------------------------------------------------------- 1 | def add_iterables(*args): 2 | """ 3 | This function adds all the elements of the iterables passed as parameters. 4 | Parameters: 5 | *args: The iterables to be added. 6 | Returns: 7 | result: A list containing the sum of elements of each iterable. 8 | """ 9 | result = [sum(x) for x in zip(*args)] 10 | return result 11 | 12 | # Example 1 13 | print(add_iterables([1, 2, 3,4], [4, 5, 6,8])) 14 | # Output: [5, 7, 9] 15 | 16 | # Example 2 17 | print(add_iterables([1, 2, 3], [4, 5, 6], [7, 8, 9])) 18 | # Output: [12, 15, 18] 19 | -------------------------------------------------------------------------------- /Python/4_Function2.py: -------------------------------------------------------------------------------- 1 | def moving_average(sequence, window_size): 2 | moving_averages = [] 3 | for i in range(len(sequence) - window_size + 1): 4 | sum = 0 5 | for j in range(i, i + window_size): 6 | sum += sequence[j] 7 | moving_averages.append(sum/window_size) 8 | return moving_averages 9 | 10 | sequence = [3, 5, 7, 2, 8, 10, 11, 65, 72, 81, 99, 100, 150] 11 | window_size = 3 12 | 13 | result = moving_average(sequence, window_size) 14 | print(result) 15 | -------------------------------------------------------------------------------- /Python/4_Function3.py: -------------------------------------------------------------------------------- 1 | def vandermonde_matrix(arr, p, ascending=False): 2 | n = len(arr) 3 | matrix = [] 4 | for i in range(n): 5 | row = [] 6 | for j in range(p): 7 | if ascending: 8 | row.append(arr[i]**j) 9 | else: 10 | row.append(arr[i]**(p-j-1)) 11 | matrix.append(row) 12 | return matrix 13 | 14 | matrix = vandermonde_matrix([1, 2, 3], 3, True) 15 | print(matrix) 16 | -------------------------------------------------------------------------------- /Python/5_Classes.py: -------------------------------------------------------------------------------- 1 | class Vehicle: 2 | def __init__(self, mileage, max_speed, name): 3 | self.mileage = mileage 4 | self.max_speed = max_speed 5 | self.name = name 6 | 7 | def seating_capacity(self): 8 | pass 9 | 10 | def fare(self): 11 | return (self.seating_capacity() * 20)+ (self.seating_capacity() * 20 *0.1) 12 | 13 | def vehicle_info(self): 14 | print(f"Vehicle Name: {self.name}") 15 | print(f"Mileage: {self.mileage}") 16 | print(f"Max Speed: {self.max_speed}") 17 | print(f"Seating Capacity: {self.seating_capacity()}") 18 | print(f"Fare: {self.fare()}") 19 | 20 | 21 | class Bus(Vehicle): 22 | def __init__(self, mileage, max_speed, name): 23 | super().__init__(mileage, max_speed, name) 24 | 25 | def seating_capacity(self): 26 | return 40 27 | 28 | 29 | class Car(Vehicle): 30 | def __init__(self, mileage, max_speed, name): 31 | super().__init__(mileage, max_speed, name) 32 | 33 | def seating_capacity(self): 34 | return 3 35 | 36 | 37 | bus = Bus(10, 100, "Volvo") 38 | car = Car(20, 120, "Toyota") 39 | 40 | bus.vehicle_info() 41 | car.vehicle_info() 42 | -------------------------------------------------------------------------------- /Python/5_Hierarchicalinheritance.py: -------------------------------------------------------------------------------- 1 | class employee: 2 | def __init__(self,fname,lname,age,basic): 3 | self.first_name=fname 4 | self.last_name=lname 5 | self.age=age 6 | self.basic_salary=basic 7 | self.email=fname+"."+lname+"@gmail.com" 8 | 9 | def show(self): 10 | print(f"Name : {self.first_name} {self.last_name}") 11 | print(f"Age : {self.age} \nSalary : {self.basic_salary}") 12 | print(f"Email : {self.email}") 13 | 14 | 15 | class developer(employee): 16 | def __init__(self,fname,lname,age,basic,lang): 17 | super().__init__(fname,lname,age,basic) 18 | self.language=lang 19 | 20 | def show(self): 21 | super().show() 22 | print(f"Language : {self.language}") 23 | 24 | 25 | class manager(employee): 26 | def __init__(self,fname,lname,age,basic,subordinates): 27 | super().__init__(fname,lname,age,basic) 28 | self.subordinates=subordinates 29 | 30 | def show(self): 31 | super().show() 32 | print(f"Subordinates : {self.subordinates}") 33 | 34 | def addEmployee(self,newEmp): 35 | self.subordinates.append(newEmp) 36 | 37 | 38 | em1 = manager("Altaf","Alam",20,90000000000000000000,["Anmol","Mitesh","Chetan"]) 39 | 40 | em1.show() 41 | 42 | em1.addEmployee("Alok") 43 | print("\n\nAfter update of employee") 44 | em1.show() 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /Python/6_AbstractMethod.py: -------------------------------------------------------------------------------- 1 | from abc import ABC,abstractmethod 2 | 3 | class hello(ABC): 4 | @abstractmethod 5 | def calculate(self): 6 | pass 7 | 8 | @abstractmethod 9 | def update(self): 10 | pass 11 | 12 | class customer(hello): 13 | def __init__(self,balance,acc): 14 | self.balance=balance 15 | self.acc=acc 16 | 17 | def calculate(self): 18 | interest=0 19 | if(self.acc=="saving"): 20 | interest=self.balance*0.04 21 | if(self.acc=="current"): 22 | interest=self.balance*0.06 23 | #print('interest ',interest) 24 | return interest 25 | 26 | def update(self): 27 | if(self.balance>100000): 28 | self.balance = self.balance + self.balance*0.05 29 | print('updated salary if 1lakh+ else same',self.balance) 30 | 31 | class employee(hello): 32 | def __init__(self,classno,experience): 33 | self.classno=classno 34 | self.experience=experience 35 | 36 | def calculate(self): 37 | if(self.classno==1): 38 | self.salary=30000 39 | self.da=1.21 * self.salary 40 | self.hra=0.3*self.salary 41 | self.grossSalary=self.salary+self.da+self.hra 42 | 43 | if(self.classno==2): 44 | self.salary=20000 45 | self.da=1.15 * self.salary 46 | self.hra=0.3*self.salary 47 | self.grossSalary=self.salary+self.da+self.hra 48 | 49 | #print(f'gross salary for {self.classno} is {self.grossSalary}') 50 | return self.grossSalary 51 | 52 | def update(self): 53 | if(self.experience>15): 54 | self.grossSalary = self.grossSalary + self.grossSalary*0.2 55 | print('updated salary if 15+ years experience else same',self.grossSalary) 56 | 57 | 58 | c1 = customer(200000,'saving') 59 | print('Cust Calculating interest' , c1.calculate()) 60 | c1.update() 61 | 62 | 63 | e1= employee(1,16) 64 | print('Emp Calculating gross salary' , e1.calculate()) 65 | e1.update() 66 | 67 | -------------------------------------------------------------------------------- /Python/6_OperatorOverloading.py: -------------------------------------------------------------------------------- 1 | class vector: 2 | def __init__(self,x,y): 3 | self.x=x 4 | self.y=y 5 | 6 | def show(self): 7 | print((self.x,self.y)) 8 | 9 | def calAmp(self): 10 | amp = ((self.x)**2 + (self.y)**2)**0.5 11 | return amp 12 | 13 | def __lt__(self,v2): 14 | return (self.calAmp() < v2.calAmp()) 15 | 16 | def __gt__(self,v2): 17 | return (self.calAmp() > v2.calAmp()) 18 | 19 | def __le__(self,v2): 20 | return (self.calAmp() <= v2.calAmp()) 21 | 22 | def __ge__(self,v2): 23 | return (self.calAmp() >= v2.calAmp()) 24 | 25 | 26 | v1 = vector(9,4) 27 | v1.show() 28 | v2 = vector(5,6) 29 | 30 | status = v1v2) 34 | 35 | print(v1<=v2) 36 | 37 | print(v1>=v2) 38 | 39 | -------------------------------------------------------------------------------- /Python/7_Package1.py: -------------------------------------------------------------------------------- 1 | from Mypackage import Shapes 2 | 3 | s1 = Shapes.Sphere(3) 4 | s1.volume() 5 | 6 | c1 = Shapes.Cube(3) 7 | c1.volume() 8 | -------------------------------------------------------------------------------- /Python/7_Package2.py: -------------------------------------------------------------------------------- 1 | from Mypackage.Listpackage.listops import * 2 | 3 | print(compare([1,2,5],[4,5,6])) 4 | merge([1,2,3],[4,5,6]) 5 | 6 | -------------------------------------------------------------------------------- /Python/8_Exception1.py: -------------------------------------------------------------------------------- 1 | # Define the two lists 2 | numbers = [1, 2, 3, 4, 5] 3 | multipliers = [2, 4, 1, 3] 4 | 5 | # Try to iterate through the multipliers list and multiply the corresponding number 6 | # in the numbers list by the current multiplier value 7 | try: 8 | for i in range(max(len(numbers),len(multipliers))): 9 | numbers[i] *= multipliers[i] 10 | except IndexError: 11 | print("Program halted since list exhausted.") 12 | except NameError: 13 | print("A list does not exist.") 14 | else: 15 | print("Multiplication of two lists is done") 16 | finally: 17 | print(numbers) 18 | print(multipliers) -------------------------------------------------------------------------------- /Python/8_Exception2.py: -------------------------------------------------------------------------------- 1 | a = 5 2 | b = "7" 3 | 4 | # Try to add the values a and b 5 | try: 6 | result = a + b 7 | print(result) 8 | except TypeError: 9 | try: 10 | b1 = int(b) 11 | c = a + b1 12 | print(c) 13 | except ValueError: 14 | try: 15 | result = a + float(b) 16 | except Exception as e: 17 | print(e) -------------------------------------------------------------------------------- /Python/9_FileHandling.py: -------------------------------------------------------------------------------- 1 | filename = "bookdata.txt" 2 | try: 3 | # If the file exists, read the data from it 4 | with open(filename, "r") as file: 5 | print("Book details in file are:") 6 | for line in file: 7 | print(line) 8 | 9 | # file not found 10 | except FileNotFoundError: 11 | print("The file did not exist and has been created.") 12 | print("Please enter details of at least 3 books.") 13 | books = [] 14 | 15 | for i in range(1,4): 16 | print(f"Enter the book detail of book {i}") 17 | title = input("Enter title of book: ") 18 | author = input("Enter author of book: ") 19 | booktype = input("Enter book type of book: ") 20 | publication = input("Enter publication of book: ") 21 | price = input("Enter price of book: ") 22 | book = {"title": title, "author": author, "booktype": booktype, 23 | "publication": publication, "price": price} 24 | books.append(book) 25 | print() 26 | 27 | # Write the book data to the file 28 | with open(filename, "w") as f: 29 | for book in books: 30 | f.write(str(book) + "\n") 31 | print("Book details saved to file.") 32 | print("Book details in file are:") 33 | with open(filename, "r") as file: 34 | for line in file: 35 | print(line) -------------------------------------------------------------------------------- /Python/IMG-20230119-WA0001.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/Python/IMG-20230119-WA0001.jpg -------------------------------------------------------------------------------- /Python/Mypackage/Listpackage/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/Python/Mypackage/Listpackage/__init__.py -------------------------------------------------------------------------------- /Python/Mypackage/Listpackage/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/Python/Mypackage/Listpackage/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /Python/Mypackage/Listpackage/__pycache__/listops.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/Python/Mypackage/Listpackage/__pycache__/listops.cpython-310.pyc -------------------------------------------------------------------------------- /Python/Mypackage/Listpackage/listops.py: -------------------------------------------------------------------------------- 1 | def compare(l1,l2): 2 | n=len(l1) 3 | for i in range(n): 4 | if(l1[i]>l2[i]): 5 | return False 6 | return True 7 | 8 | def merge(l1,l2): 9 | l1 = l1 +l2 10 | print(l1) 11 | -------------------------------------------------------------------------------- /Python/Mypackage/Shapes.py: -------------------------------------------------------------------------------- 1 | from abc import ABC,abstractmethod 2 | 3 | class Shape(ABC): 4 | @abstractmethod 5 | def volume(self): 6 | pass 7 | 8 | class Sphere(Shape): 9 | def __init__(self,a): 10 | self.a=a 11 | 12 | def volume(self): 13 | vol=4/3*3.14*((self.a)**3) 14 | print(f"Volume of Sphere is {vol}") 15 | 16 | class Cube(Shape): 17 | def __init__(self,a): 18 | self.a=a 19 | 20 | def volume(self): 21 | vol=(self.a)**3 22 | print(f"Volume of Cube is {vol}") 23 | -------------------------------------------------------------------------------- /Python/Mypackage/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/Python/Mypackage/__init__.py -------------------------------------------------------------------------------- /Python/Mypackage/__pycache__/Shapes.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/Python/Mypackage/__pycache__/Shapes.cpython-310.pyc -------------------------------------------------------------------------------- /Python/Mypackage/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/Python/Mypackage/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /Python/README.md: -------------------------------------------------------------------------------- 1 | # All programs are uploaded given by Sachi Mam 2 | 3 | ### Assignment 3 4 | ``` 5 | Return the array of even rows and odd columns from following array 6 | a=[[2,4,6,8,6],[23,56,45,10,83],[2,5,33,22,88]] 7 | 8 | 9 | 10 | Create a 8*3 array for numbers from 10 to 34 and split the array into 4 parts. 11 | ``` 12 | 13 | 14 | ### Assignment 4 15 | ``` 16 | Write a function that can add any number of iterables when passed as a parameter to it . include appropriate docstring for function .Show the execution with various cases in python 17 | 18 | 19 | 20 | Given a sequence of n values x1, x2, ..., xn and 4 window size k>0, the k-th moving average of the given sequence is defined as follows: 21 | 22 | The moving average sequence has n-k+1 elements as shown below. The 23 | moving averages with k=4 of a ten-value sequence (n=10) is shown below 24 | 25 | i 1 2 3 4 5 6 7 8 9 10 26 | 27 | Input 10 20 30 40 50 60 70 80 90 100 28 | y1 25 = (10+20+30+40)/4 29 | 30 | y2 35 = (20+30+40+50)/4 31 | 32 | y3 45 = (30+40+50+60)/4 33 | 34 | y4 55 = (40+50+60+70)/4 35 | 36 | y5 65 = (50+60+70+80)/4 37 | 38 | y6 75 = (60+70+80+90)/4 39 | 40 | y7 85 = (70+80+90+100)/4 41 | 42 | Thus, the moving average sequence has n-k+1=10-4+1=7 values. 43 | Test it over [3, 5, 7, 2, 8, 10, 11, 65, 72, 81, 99, 100, 150] and window of 3 . 44 | 45 | 46 | 47 | Accept an 1-D array from user. Write a function to convert it into a matrix 48 | called Vandermonde matrix. It is obtained as follows: 49 | Each ith column of the matrix is obtained by raising the element of array 50 | to power i and maximum value of power dictates the number of columns 51 | in the matrix. Also it is one of the parameters to the function generating this marix. Another parameter to the function will be Boolean variable 'ascending'. 52 | 53 | If ascending is true, power of the element will be in increasing order 54 | starting from 0. If ascending is not specified, power of the ith column of 55 | the matrix will be (p-i-1) where p is the number of columns. 56 | 57 | e.g. M=[1,2,3] 58 | 1) 59 | matrix= 60 | 1 1 1 61 | 1 2 4 62 | 3 5 9 63 | (when p=3 and ascending = True) 64 | 65 | 2) 66 | matrix= 67 | 1 1 1 68 | 4 2 1 69 | 9 3 1 70 | (when p=3 and ascending = False) . 71 | 72 | ``` 73 | 74 | ### Assignment 8 75 | ``` 76 | Create two lists numbers and multipliers , scan through multipliers list , take each of the" value "and multiply the number from the numbers list at the position equals to index of value by a. 77 | 78 | If multipliers list exhaust before numbers handle the exception with following message "program haulted since multiplier list exhausted" . 79 | 80 | If either of the list name is referred incorrectly handle the exception by printing the message the" list does not exist". 81 | 82 | At the end print the message multiplication of two list is done. 83 | 84 | 85 | Write a program to add two values a and b , and integer value is assigned to a however while defining b by mistakenly it was enclosed with a quotes by the programmer handle the exception so that b can be added with the integer value a (here b would have been int/float if not in quotes ) Display appropriate messages and use nested exception handling . 86 | ``` 87 | 88 | 89 | ### Assignment 9 90 | ``` 91 | Write a program to read a file called bookdata.txt if file does not exist create an empty file and display appropriate message to user. 92 | 93 | If empty file is created ask user to enter details of minimum 3 books, for every book user should enter title,author,booktype, publication and price. 94 | 95 | Store information of each book in the form of dictionary, list of all such books should be written to file then open the file read book details and display it. 96 | ``` 97 | 98 | 99 | ### Assignment 10 100 | ``` 101 | Using Tkinter create a calculator having following appearance and 102 | functionalities. 103 | Functionalities to include: 104 | 1. Calculator should support basic operations like addition, 105 | subtraction, multiplication and division. 106 | 2. User should be able to type number (containing any number of 107 | digits) in the text area. 108 | 3. When user clicks on any operator button, contents from text 109 | area should get cleared so that user can enter second number 110 | (containing any number of digits). 111 | 4. When user clicks on ‘=’ button result of operation should be 112 | displayed in text area. Any contents from text area should be 113 | cleared before displaying the result. 114 | 5. Clicking on clear button should clear the contents from text area. 115 | 6. Add suitable icon and title for the application window. 116 | ``` 117 | 118 | ### Assignment 13 119 | ``` 120 | Create a dataframe having following columns: 121 | • ISBN (unique number for each book) 122 | • Title 123 | • Author 124 | • Publication 125 | • Year Published 126 | • Price 127 | • Copies sold of first edition 128 | • Copies sold in second edition 129 | • Copies sold in third edition 130 | You can use any of the studied approach to create dataframe. Add 131 | minimum 10 records to the dataframe. Perform following 132 | operations on dataframe using appropriate functions: 133 | 1. Display the number of rows and columns in dataframe 134 | 2. Give the descriptive statistics of the created dataset. 135 | 3. Display distinct publication names for the dataset. 136 | 4. Display the book title and author names published by “Metro 137 | Publication” 138 | 5. Rename columns “Copies sold in first edition”, “Copies sold in 139 | second edition” and “Copies sold in third edition”to FE, SE and 140 | TE respectively 141 | 6. Add a column “Average sale” to your dataframe derived as 142 | (average of FE, SE and TE) * Price. 143 | 7. Display the details of books grouped by author. 144 | 8. For each group obtained in above query display maximum 145 | value of Average sale. 146 | 9. Reshape your dataframe such that rows will show ‘Author’, 147 | column will show “Publication” and values will be ‘Title’ of 148 | book. 149 | ``` 150 | 151 | ### Assignment 14 152 | ``` 153 | Using scipy library, perform following linear algebraic operations: 154 | 1. Solve the system of linear equations: 155 | a. 9x + 6y – 5z + 2w = 17 156 | b. 4x + 5y – 7z + 3w = 10 157 | c. -3x - 4y + 2z - 5w = 20 158 | d. 6x + y + 9z - w = 23 159 | 160 | 2. Perform the following operations on a matrix 161 | 𝐴 = [ 162 | 5 3 2 163 | 6 9 −3 164 | 1 7 4 165 | ] 166 | a. Find Inverse of matrix A. 167 | b. Find Kronecker product of A with B= [ 168 | 3 −1 169 | 2 −5 170 | ] 171 | c. Find determinant of matrix A 172 | ``` 173 | 174 | ### Assignment 15 175 | ``` 176 | 1: Create a web application using Flask to display the Books 177 | available in the library when the ‘books’ endpoint is visited. For 178 | each book, display ISBN number, Book title, Author and publication. 179 | Also facilitate the search of book by ISBN number. For this the ISBN 180 | number should be passed as parameter and the details of only that 181 | book will be displayed. (Use GET, render template, redirect, 182 | jsonify methods). 183 | 184 | 2:Create a web app using Flask to display the result of a user. If 185 | marks are less than 50, redirect user to the ‘failed’ web page and 186 | display the appropriate result. Otherwise, redirect user to ‘passed’ 187 | web page and display the appropriate result on that page. (Use 188 | redirect, jsonify and other methods as needed). 189 | ``` 190 | -------------------------------------------------------------------------------- /Python/bookdata.txt: -------------------------------------------------------------------------------- 1 | {'title': '1', 'author': 'js', 'booktype': 'dj', 'publication': 'aj', 'price': '34'} 2 | {'title': 'ak', 'author': 'aj', 'booktype': 'dj', 'publication': 'alh', 'price': '92'} 3 | {'title': 'kasdk', 'author': '3', 'booktype': 'asdsk', 'publication': 'dk', 'price': 'kahp'} 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SE IT Sem4 Lab Programs 2 | 3 | ## Progress of completion 4 | - [x] Python Lab 5 | - [x] MPL 6 | - [x] CN 7 | - [x] Unix 8 | 9 | Do star the repo if this has helped you , Pull requests are welcomed!! 10 |
11 | Feel free to reach out to me if you have any doubts or feedbacks regarding this.
12 |
13 | 14 | ## Note: This is for educational purposes only, and we do not promote any form of cheating. 15 | ========Thank You !!!========= 16 | -------------------------------------------------------------------------------- /Unix/Perl/KeyValue.pl: -------------------------------------------------------------------------------- 1 | #!/bin/perl 2 | 3 | %data = (1 => "altaf", 2 => "aman", 3 => "prasad", 4 => "sarah", 5 => "pratham", 6 => "mitesh"); 4 | 5 | print "Enter roll no:"; 6 | $c = <>; 7 | 8 | # handle new line 9 | chomp($c); 10 | 11 | # string + num concat 12 | print "\$data{$c} = ".$data{$c}; 13 | -------------------------------------------------------------------------------- /Unix/Perl/Months.pl: -------------------------------------------------------------------------------- 1 | @weekdays = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); 2 | 3 | print "Enter a number from 1 to 7: "; 4 | $number = <>; 5 | 6 | if ($number >= 1 && $number <= 7) { 7 | print "$weekdays[$number - 1]\n"; 8 | } 9 | else { 10 | print "Invalid number\n"; 11 | } -------------------------------------------------------------------------------- /Unix/Perl/PowerTable.pl: -------------------------------------------------------------------------------- 1 | #!/bin/perl 2 | 3 | $num = 4; 4 | for($i=1;$i<11;$i++) 5 | { 6 | $res = $num ** $i; 7 | print "$num ^ $i = $res \n"; 8 | } 9 | -------------------------------------------------------------------------------- /Unix/Perl/Prime.pl: -------------------------------------------------------------------------------- 1 | #!/bin/perl 2 | 3 | print " Enter number to check prime: "; 4 | $num=; 5 | 6 | chop($num); 7 | 8 | $flag=0; 9 | for($i=2; $i<$num; $i++) 10 | { 11 | if ($num % $i==0) 12 | { 13 | $flag=1; 14 | break; 15 | } 16 | } 17 | 18 | if ($flag==1) 19 | { 20 | print " $num is not prime\n "; 21 | } 22 | else 23 | { 24 | print "$num is prime\n"; 25 | } -------------------------------------------------------------------------------- /Unix/Perl/VariableContext.pl: -------------------------------------------------------------------------------- 1 | #!/bin/perl 2 | 3 | @names = ('John Paul', 'Lisa', 'Kumar'); 4 | @copy = @names; 5 | $size = @names; 6 | 7 | print "Given names are : @copy\n"; 8 | print "Number of names are : $size\n"; 9 | -------------------------------------------------------------------------------- /Unix/Shell/Addition.sh: -------------------------------------------------------------------------------- 1 | echo "Enter first number" 2 | read a 3 | 4 | echo "Enter second number" 5 | read b 6 | 7 | sum=$(($a + $b)) 8 | echo "addition of $a + $b = $sum " -------------------------------------------------------------------------------- /Unix/Shell/Calculator.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sum=0 4 | i="y" 5 | 6 | echo " Enter one no." 7 | read n1 8 | echo "Enter second no." 9 | read n2 10 | 11 | while [ $i = "y" ] 12 | do 13 | echo "1.Addition" 14 | echo "2.Subtraction" 15 | echo "3.Multiplication" 16 | echo "4.Division" 17 | 18 | echo "Enter your choice" 19 | read ch 20 | 21 | case $ch in 22 | 1)sum=`expr $n1 + $n2` 23 | echo "Sum ="$sum;; 24 | 2)sum=`expr $n1 - $n2` 25 | echo "Sub = "$sum;; 26 | 3)sum=`expr $n1 \* $n2` 27 | echo "Mul = "$sum;; 28 | 4)sum=`expr $n1 / $n2` 29 | echo "Div = "$sum;; 30 | *)echo "Invalid choice";; 31 | esac 32 | 33 | echo "Do u want to continue ?" 34 | read i 35 | 36 | if [ $i != "y" ] 37 | then 38 | exit 39 | fi 40 | done -------------------------------------------------------------------------------- /Unix/Shell/ElementPresent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo -n "enter elements of array" 4 | read -a array 5 | 6 | echo -n "enter the element to be searched" 7 | read num 8 | 9 | for val in "${array[@]}" 10 | do 11 | if [ $num == $val ] 12 | then 13 | echo "element is present in the array" 14 | exit 15 | else 16 | continue 17 | fi 18 | done -------------------------------------------------------------------------------- /Unix/Shell/EqualString.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo -n "Enter first string: " 4 | read str1 5 | echo -n "enter second string: " 6 | read str2 7 | 8 | if [ $str1 = $str2 ] 9 | then 10 | echo " Two strings are equal" 11 | else 12 | echo " Two strings are not equal " 13 | fi 14 | -------------------------------------------------------------------------------- /Unix/Shell/Factorial.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo Enter a number 4 | read a 5 | sum=0 6 | 7 | for((i=1;i<=a;i++)) 8 | do 9 | sum=$(( i+sum )) 10 | done 11 | 12 | echo Sum from 1 to $a is : $sum 13 | 14 | echo Enter a number 15 | read a 16 | 17 | n=$(($a)) 18 | pro=1 19 | 20 | while [ $n -ge 1 ] 21 | do 22 | pro=$((pro*n)) 23 | n=$((n-1)) 24 | done 25 | 26 | echo Factorial of $a is : $pro 27 | -------------------------------------------------------------------------------- /Unix/Shell/Filecount.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Enter the file path:" 4 | read filename 5 | 6 | echo -n "No of lines are: " 7 | echo `wc -l $filename` 8 | echo -n "No of words are: " 9 | echo `wc -w $filename` 10 | echo -n "No of characters: " 11 | echo `wc -c $filename` -------------------------------------------------------------------------------- /Unix/Shell/FunctionSum.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sum() 4 | { 5 | s=0 6 | x=1 7 | 8 | while [ $x -le $1 ] 9 | do 10 | ((s=$s+$x)) 11 | ((x=$x+1)) 12 | done 13 | 14 | return $s 15 | } 16 | 17 | sum $1 18 | echo "The sum of sequence is : $?" -------------------------------------------------------------------------------- /Unix/Shell/IsFile,Dir.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo -n "Enter filename: " 4 | read fname 5 | 6 | if test -d $fname 7 | then 8 | echo "$fname is a directory" 9 | else 10 | if test -f $fname 11 | then 12 | echo "$fname is a file" 13 | else 14 | echo "$fname is not valid" 15 | exit 1 16 | fi 17 | fi 18 | -------------------------------------------------------------------------------- /Unix/Shell/Largest2.sh: -------------------------------------------------------------------------------- 1 | echo "Enter first number" 2 | read a 3 | 4 | echo "Enter second number" 5 | read b 6 | 7 | echo "Enter third number" 8 | read c 9 | 10 | if [ $a -gt $b ] && [ $a -gt $c ] 11 | then 12 | echo "$a is greatest number" 13 | else 14 | if [ $b -gt $c ] 15 | then 16 | echo "$b is greatest number" 17 | else 18 | echo "$c is greatest number" 19 | fi 20 | fi -------------------------------------------------------------------------------- /Unix/Shell/LargestInArray.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # read -a arr 4 | 5 | # define an array 6 | arr=(5 2 8 1 6) 7 | 8 | # initialize first element as largest 9 | largest=${arr[0]} 10 | 11 | # iterate over array and compare 12 | for i in ${arr[@]} 13 | do 14 | if [ $i -gt $largest ] 15 | then 16 | largest=$i 17 | fi 18 | done 19 | 20 | echo "The largest element in the array is: $largest" 21 | -------------------------------------------------------------------------------- /Unix/Shell/LeapYear.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Enter a year:" 4 | read year 5 | 6 | # divideable by 4 and (not by 100 or divideable by 400) 7 | 8 | if [ $((year % 4)) -eq 0 ] && [ $((year % 100)) -ne 0 ] || [ $((year % 400)) -eq 0 ] 9 | then 10 | echo "$year is a leap year" 11 | else 12 | echo "$year is not a leap year" 13 | fi -------------------------------------------------------------------------------- /Unix/Shell/MultiplicationTable.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo -n "Enter number: " 4 | read n 5 | 6 | i=1 7 | 8 | while [ $i -le 10 ] 9 | do 10 | echo "$n x $i = $((n * i))" 11 | ((i++)) 12 | done 13 | -------------------------------------------------------------------------------- /Unix/Shell/Rectangle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo Enter a number 4 | read a 5 | sum=0 6 | 7 | for((i=1;i<=a;i++)) 8 | do 9 | sum=$(( i+sum )) 10 | done 11 | 12 | echo Sum from 1 to $a is : $sum 13 | 14 | 15 | echo "enter length" 16 | read n1 17 | echo "enter width" 18 | read n2 19 | 20 | area=`expr $n1 \* $n2` 21 | echo -n "Area of rectangle is :" 22 | echo $area 23 | 24 | p1=`expr $n1 + $n2` 25 | peri=`expr 2 \* $p1` 26 | echo -n "Perimeter of rectangle is :" 27 | echo $peri -------------------------------------------------------------------------------- /Unix/Shell/Simpleinterest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo -n "Enter Principal amount:" 4 | read p 5 | echo -n "Enter time period:" 6 | read t 7 | echo -n "Enter rate of interest:" 8 | read r 9 | 10 | si=$(((p * r * t) / 100)) 11 | echo "Simple interest is $si" 12 | 13 | total=$(($p + $si)) 14 | echo "Total amt is $total" 15 | -------------------------------------------------------------------------------- /Unix/Shell/SumToN.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo Enter a number 4 | read a 5 | sum=0 6 | 7 | for((i=1;i<=a;i++)) 8 | do 9 | sum=$(( i+sum )) 10 | done 11 | 12 | echo Sum from 1 to $a is : $sum 13 | -------------------------------------------------------------------------------- /Unix/aGold/AWK in UNIX.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/Unix/aGold/AWK in UNIX.pdf -------------------------------------------------------------------------------- /Unix/aGold/Grep command in Unix.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/Unix/aGold/Grep command in Unix.pdf -------------------------------------------------------------------------------- /Unix/aGold/PERL Scripting.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/Unix/aGold/PERL Scripting.pdf -------------------------------------------------------------------------------- /Unix/aGold/Shell Programing in UNIX (1).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/Unix/aGold/Shell Programing in UNIX (1).pdf -------------------------------------------------------------------------------- /Unix/aGold/sed in Unix.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Altafalam3/Sem4-lab/716133b2812a4ce22715f9e4944f7c41c3c8be89/Unix/aGold/sed in Unix.pdf -------------------------------------------------------------------------------- /Unix/awk,grep,sed/GrepFileCount.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Enter the filename: " 4 | read filename 5 | 6 | # Count number of characters 7 | char_count=$(grep -o '.' $filename | wc -l) 8 | 9 | # Count number of words 10 | word_count=$(grep -o '\w\+' $filename | wc -l) 11 | 12 | # Count number of lines 13 | line_count=$(grep -c '^' $filename) 14 | 15 | echo "Number of characters: $char_count" 16 | echo "Number of words: $word_count" 17 | echo "Number of lines: $line_count" 18 | -------------------------------------------------------------------------------- /Unix/awk,grep,sed/GrepSpecificTypeFile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Enter the file extension: " 4 | read extension 5 | 6 | egrep -w ".*\.$extension$" <<< "$(ls)" 7 | 8 | -------------------------------------------------------------------------------- /Unix/awk,grep,sed/student.lst: -------------------------------------------------------------------------------- 1 | 1 Shah Abhigyan bafna 123456789012 9876543210 churchgate 74 2 | 2 Singh Aman Rajendra 123457689012 9867543210 nallasopara 97 3 | 3 arote Prasad bafna 723456789012 9867543211 mumbai 98 4 | 4 Shah Amisha shahi 123456780912 9876543201 bhayander 60 5 | 5 tripathi Abhigyan bafna 623456789012 9876543210 mumbai 50 6 | 6 singh Abhigyan bafna 523456789012 9876543210 mumbai 80 7 | 7 ambre sanika bafna 423456789012 9876543210 mumbai 85 8 | 8 dhomal avadoot bafna 323456789012 9876543210 mumbai 62 9 | 9 kumar alok bafna 123416789012 9876543210 mumbai 10 10 | 10 bagade Abhigyan bafna 223456789012 9876543210 mumbai 58 11 | --------------------------------------------------------------------------------