Posts

Sorting and Searching Programs in Python

SORTING Bubble Sort: def bubble_sort(nums):     # We set swapped to True so the loop looks runs at least once     swapped = True     while swapped:         swapped = False         for i in range(len(nums) - 1):             if nums[i] > nums[i + 1]:                 # Swap the elements                 nums[i], nums[i + 1] = nums[i + 1], nums[i]                 # Set the flag to True so we'll loop again                 swapped = True # Verify it works # nums = [5, 2, 1, 8, 4] nums = input('Enter the list of numbers: ').split() nums = [int(x) for x in nums] bubble_sort(nums) print("List Sorted using Bubble Sort") print(nums) Output: Enter the list of numbers: 5 23 3 65 74 55 List Sorted using B...

Saurashtra University M Sc IT Semester 3 Paper of Programming with R 2017

Image
Saurashtra University  M Sc IT Semester 3  Programming with R 2017

Saurashtra University M Sc IT Semester 3 Paper of Hybrid Mobile Application 2017

Image
Saurashtra University  M Sc IT Semester 3  Hybrid Mobile Application 2017

Saurashtra University M Sc IT Semester 3 Paper of Django 2017

Image
Saurashtra University M Sc IT Semester 3  Django 2017

Python Programming Question Bank

Python Programming Question Bank 1.            Explain the Data Types available in Python. 2.            Explain Looping statements in Python. Give examples of while and for loop. 3.            Explain the use of Global and Non-Local variables with example. 4.            Explain Scoping for local variable in python. 5.            Differentiate List and Tuple. 6.            Explain Slicing of strings in python using examples. 7.            Explain List in Python. 8.            Explain Tuples in Python with example. 9.          ...

Unix Shell Script Program List 1 to 10

SCRIPT-1 Write a shell script which reads your name and department and print a message. echo "What is your name?" read nm echo "In which department are you?" read dept echo "My name is $nm." echo "I'm a $dept Student." OUTPUT: $ ./a.sh What is your name? admin In which department are you? BCA My name is admin. I'm a BCA Student. SCRIPT - 2 Write a shell script to check whether numbers are same or not. echo "Enter first number" read a echo "Enter second number" read b if [ $a == $b ] then echo "a is equal to b" else echo "a is not equal to b" fi OUTPUT $ ./n1.sh Enter first number 30 Enter second number 20 a is not equal to b SCRIPT-3 Write a shell script to check number using if..else. echo "Enter number" read count if [ $count -eq 100 ] then echo "Count is 100" elif [ $count -gt 100 ] then echo "Count is greater than 100"...

Python Program List 3

121.       Write a Python program to convert the distance (in feet) to inches, yards, and miles. d_ft = int(input("Input distance in feet: ")) d_inches = d_ft * 12 d_yards = d_ft / 3.0 d_miles = d_ft / 5280.0 print("The distance in inches is %i inches." % d_inches) print("The distance in yards is %.2f yards." % d_yards) print("The distance in miles is %.2f miles." % d_miles) Output: Input distance in feet: 100                                                                                     The distance in inches is 1200 inches. ...