The document provides information on tuples in Python. It defines a tuple as an ordered sequence of elements of different data types. Elements are enclosed in parentheses and separated by commas. Tuples are immutable, whereas lists are mutable. The document discusses accessing and slicing tuples, concatenation, repetition, and other tuple operations like count, index, min, max, and sum. It also covers nested tuples, tuple assignment, and examples of tuple methods and built-in functions.
Python provides numerous built-in functions that are readily available to us at the Python prompt. Some of the functions like input() and print() are widely used for standard input and output operations respectively.
2D array in C++ language ,define the concept of c++ Two-Dimensional array .with example .and also Accessing Array Components concept.and Processing Two-Dimensional Arrays.
All data values in Python are encapsulated in relevant object classes. Everything in Python is an object and every object has an identity, a type, and a value. Like another object-oriented language such as Java or C++, there are several data types which are built into Python. Extension modules which are written in C, Java, or other languages can define additional types.
To determine a variable's type in Python you can use the type() function. The value of some objects can be changed. Objects whose value can be changed are called mutable and objects whose value is unchangeable (once they are created) are called immutable.
Python provides numerous built-in functions that are readily available to us at the Python prompt. Some of the functions like input() and print() are widely used for standard input and output operations respectively.
2D array in C++ language ,define the concept of c++ Two-Dimensional array .with example .and also Accessing Array Components concept.and Processing Two-Dimensional Arrays.
All data values in Python are encapsulated in relevant object classes. Everything in Python is an object and every object has an identity, a type, and a value. Like another object-oriented language such as Java or C++, there are several data types which are built into Python. Extension modules which are written in C, Java, or other languages can define additional types.
To determine a variable's type in Python you can use the type() function. The value of some objects can be changed. Objects whose value can be changed are called mutable and objects whose value is unchangeable (once they are created) are called immutable.
The Key Difference between a List and a Tuple. The main difference between lists and a tuples is the fact that lists are mutable whereas tuples are immutable. A mutable data type means that a python object of this type can be modified. Let's create a list and assign it to a variable.
Python programming language provides the following types of loops to handle looping requirements:
1. While
2. Do While
3. For loop
Python provides three ways for executing the loops. While all the ways provide similar basic functionality, they differ in their syntax and condition-checking time.
Merge sort is a sorting technique based on divide and conquer technique. With worst-case time complexity being Ο(n log n), it is one of the most respected algorithms.
Merge sort first divides the array into equal halves and then combines them in a sorted manner.
The Key Difference between a List and a Tuple. The main difference between lists and a tuples is the fact that lists are mutable whereas tuples are immutable. A mutable data type means that a python object of this type can be modified. Let's create a list and assign it to a variable.
Python programming language provides the following types of loops to handle looping requirements:
1. While
2. Do While
3. For loop
Python provides three ways for executing the loops. While all the ways provide similar basic functionality, they differ in their syntax and condition-checking time.
Merge sort is a sorting technique based on divide and conquer technique. With worst-case time complexity being Ο(n log n), it is one of the most respected algorithms.
Merge sort first divides the array into equal halves and then combines them in a sorted manner.
This presents the basic data types of python programming. Data types like Number, Strings, Lists, Tuples, Dictionary and etc. Also it presents the information about arithmetic, relational. bit-wise and assignment operators
METHODS DESCRIPTION
copy() They copy() method returns a shallow copy of the dictionary.
clear() The clear() method removes all items from the dictionary.
pop() Removes and returns an element from a dictionary having the given key.
popitem() Removes the arbitrary key-value pair from the dictionary and returns it as tuple.
get() It is a conventional method to access a value for a key.
dictionary_name.values() returns a list of all the values available in a given dictionary.
str() Produces a printable string representation of a dictionary.
update() Adds dictionary dict2’s key-values pairs to dict
setdefault() Set dict[key]=default if key is not already in dict
keys() Returns list of dictionary dict’s keys
items() Returns a list of dict’s (key, value) tuple pairs
has_key() Returns true if key in dictionary dict, false otherwise
fromkeys() Create a new dictionary with keys from seq and values set to value.
type() Returns the type of the passed variable.
cmp() Compares elements of both dict.
Overview of the fundamental roles in Hydropower generation and the components involved in wider Electrical Engineering.
This paper presents the design and construction of hydroelectric dams from the hydrologist’s survey of the valley before construction, all aspects and involved disciplines, fluid dynamics, structural engineering, generation and mains frequency regulation to the very transmission of power through the network in the United Kingdom.
Author: Robbie Edward Sayers
Collaborators and co editors: Charlie Sims and Connor Healey.
(C) 2024 Robbie E. Sayers
Explore the innovative world of trenchless pipe repair with our comprehensive guide, "The Benefits and Techniques of Trenchless Pipe Repair." This document delves into the modern methods of repairing underground pipes without the need for extensive excavation, highlighting the numerous advantages and the latest techniques used in the industry.
Learn about the cost savings, reduced environmental impact, and minimal disruption associated with trenchless technology. Discover detailed explanations of popular techniques such as pipe bursting, cured-in-place pipe (CIPP) lining, and directional drilling. Understand how these methods can be applied to various types of infrastructure, from residential plumbing to large-scale municipal systems.
Ideal for homeowners, contractors, engineers, and anyone interested in modern plumbing solutions, this guide provides valuable insights into why trenchless pipe repair is becoming the preferred choice for pipe rehabilitation. Stay informed about the latest advancements and best practices in the field.
Automobile Management System Project Report.pdfKamal Acharya
The proposed project is developed to manage the automobile in the automobile dealer company. The main module in this project is login, automobile management, customer management, sales, complaints and reports. The first module is the login. The automobile showroom owner should login to the project for usage. The username and password are verified and if it is correct, next form opens. If the username and password are not correct, it shows the error message.
When a customer search for a automobile, if the automobile is available, they will be taken to a page that shows the details of the automobile including automobile name, automobile ID, quantity, price etc. “Automobile Management System” is useful for maintaining automobiles, customers effectively and hence helps for establishing good relation between customer and automobile organization. It contains various customized modules for effectively maintaining automobiles and stock information accurately and safely.
When the automobile is sold to the customer, stock will be reduced automatically. When a new purchase is made, stock will be increased automatically. While selecting automobiles for sale, the proposed software will automatically check for total number of available stock of that particular item, if the total stock of that particular item is less than 5, software will notify the user to purchase the particular item.
Also when the user tries to sale items which are not in stock, the system will prompt the user that the stock is not enough. Customers of this system can search for a automobile; can purchase a automobile easily by selecting fast. On the other hand the stock of automobiles can be maintained perfectly by the automobile shop manager overcoming the drawbacks of existing system.
Vaccine management system project report documentation..pdfKamal Acharya
The Division of Vaccine and Immunization is facing increasing difficulty monitoring vaccines and other commodities distribution once they have been distributed from the national stores. With the introduction of new vaccines, more challenges have been anticipated with this additions posing serious threat to the already over strained vaccine supply chain system in Kenya.
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Dr.Costas Sachpazis
Terzaghi's soil bearing capacity theory, developed by Karl Terzaghi, is a fundamental principle in geotechnical engineering used to determine the bearing capacity of shallow foundations. This theory provides a method to calculate the ultimate bearing capacity of soil, which is the maximum load per unit area that the soil can support without undergoing shear failure. The Calculation HTML Code included.
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...Amil Baba Dawood bangali
Contact with Dawood Bhai Just call on +92322-6382012 and we'll help you. We'll solve all your problems within 12 to 24 hours and with 101% guarantee and with astrology systematic. If you want to take any personal or professional advice then also you can call us on +92322-6382012 , ONLINE LOVE PROBLEM & Other all types of Daily Life Problem's.Then CALL or WHATSAPP us on +92322-6382012 and Get all these problems solutions here by Amil Baba DAWOOD BANGALI
#vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore#blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #blackmagicforlove #blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #Amilbabainuk #amilbabainspain #amilbabaindubai #Amilbabainnorway #amilbabainkrachi #amilbabainlahore #amilbabaingujranwalan #amilbabainislamabad
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxR&R Consult
CFD analysis is incredibly effective at solving mysteries and improving the performance of complex systems!
Here's a great example: At a large natural gas-fired power plant, where they use waste heat to generate steam and energy, they were puzzled that their boiler wasn't producing as much steam as expected.
R&R and Tetra Engineering Group Inc. were asked to solve the issue with reduced steam production.
An inspection had shown that a significant amount of hot flue gas was bypassing the boiler tubes, where the heat was supposed to be transferred.
R&R Consult conducted a CFD analysis, which revealed that 6.3% of the flue gas was bypassing the boiler tubes without transferring heat. The analysis also showed that the flue gas was instead being directed along the sides of the boiler and between the modules that were supposed to capture the heat. This was the cause of the reduced performance.
Based on our results, Tetra Engineering installed covering plates to reduce the bypass flow. This improved the boiler's performance and increased electricity production.
It is always satisfying when we can help solve complex challenges like this. Do your systems also need a check-up or optimization? Give us a call!
Work done in cooperation with James Malloy and David Moelling from Tetra Engineering.
More examples of our work https://www.r-r-consult.dk/en/cases-en/
Final project report on grocery store management system..pdfKamal Acharya
In today’s fast-changing business environment, it’s extremely important to be able to respond to client needs in the most effective and timely manner. If your customers wish to see your business online and have instant access to your products or services.
Online Grocery Store is an e-commerce website, which retails various grocery products. This project allows viewing various products available enables registered users to purchase desired products instantly using Paytm, UPI payment processor (Instant Pay) and also can place order by using Cash on Delivery (Pay Later) option. This project provides an easy access to Administrators and Managers to view orders placed using Pay Later and Instant Pay options.
In order to develop an e-commerce website, a number of Technologies must be studied and understood. These include multi-tiered architecture, server and client-side scripting techniques, implementation technologies, programming language (such as PHP, HTML, CSS, JavaScript) and MySQL relational databases. This is a project with the objective to develop a basic website where a consumer is provided with a shopping cart website and also to know about the technologies used to develop such a website.
This document will discuss each of the underlying technologies to create and implement an e- commerce website.
Saudi Arabia stands as a titan in the global energy landscape, renowned for its abundant oil and gas resources. It's the largest exporter of petroleum and holds some of the world's most significant reserves. Let's delve into the top 10 oil and gas projects shaping Saudi Arabia's energy future in 2024.
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
About
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
Technical Specifications
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
Key Features
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface
• Compatible with MAFI CCR system
• Copatiable with IDM8000 CCR
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
Application
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
2. INTRODUCTION
• A tuple is an ordered sequence of elements of different data
types, such as integer, float, string, list or even a tuple. Elements
of a tuple are enclosed in parenthesis (round brackets) and are
separated by commas. Like list and string, elements of a tuple
can be accessed using index values, starting from 0.
• For example. #tuple1 is the tuple of integers
>>> tuple1 = (1,2,3,4,5)
>>> tuple1 (1, 2, 3, 4, 5)
• If there is only a single element in a tuple then the element
should be followed by a comma. If we assign the value without
comma it is treated as integer. It should be noted that a
sequence without parenthesis is treated as tuple by default
3. ACCESSING ELEMENTS IN A TUPLE
• Elements of a tuple can be accessed in the same way as a list or string
using indexing and slicing.
• >>> tuple1 = (2,4,6,8,10,12)
#initializes a tuple tuple1
#returns the first element of tuple1
>>> tuple1[0]
4. IMMUTABILITY
• Tuple is an immutable data type. It means that the elements of a
tuple cannot be changed after it has been created. An attempt to
do this would lead to an error.
>>> tuple1 = (1,2,3,4,5)
Difference Between Tuple and List
• List is mutable but tuple is immutable. So iterating through a tuple
is faster as compared to a list. √ If we have data that does not
change then storing this data in a tuple will make sure that it is
not changed accidentally.
5. OPERATORS IN TUPLE
• CONCATENATION: Python allows us to join tuples using
concatenation operator depicted by symbol +. We
can also create a new tuple which contains the result of this
concatenation operation.
>>> tuple1 = (1,3,5,7,9)
>>> tuple2 = (2,4,6,8,10)
>>> tuple1 + tuple2
#concatenates two tuples (1, 3, 5, 7, 9, 2, 4, 6, 8, 10) Concatenation
operator can also be used for extending an existing tuple. When we
extend a tuple using concatenation a new tuple is created.
6. • REPETITON: Repetition operation is depicted by the symbol *. It
is used to repeat elements of a tuple. We can repeat the
tuple elements. The repetition operator requires the first operand to be
a tuple and the second operand to be an integer only.
>>> tuple1 = ('Hello','World’)
>>> tuple1 * 3
('Hello', 'World', 'Hello', 'World', 'Hello', 'World')
7. • SLICING: Like string and list, slicing can be applied to tuples
also.
#tuple1 is a tuple
>>> tuple1 = (10,20,30,40,50,60,70,80)
#elements from index 2 to index 6
>>> tuple1[2:7]
(30, 40, 50, 60, 70)
8. • FUNCTION: len() Returns the length or the number of elements
of the tuple passed as the argument >>> tuple1 =
(10,20,30,40,50)
>>> len(tuple1) 5
TUPLE()
• Creates an empty tuple if no argument is passed
• Creates a tuple if a sequence is passed as argument
>>> tuple1 = tuple()
>>> tuple1 ( )
>>> tuple1 = tuple('aeiou’)#string
>>> tuple1 ('a', 'e', 'i', 'o', 'u’)
>>> tuple2 = tuple([1,2,3]) #list
>>> tuple2 (1, 2, 3)
>>> tuple3 = tuple(range(5))
>>> tuple3
9. CONTD.
(0, 1, 2, 3, 4)
count()
Returns the number of times the given element appears in the tuple
>>> tuple1 = (10,20,30,10,40,10,50)
>>> tuple1.count(10) 3
>>> tuple1.count(90)
0
INDEX()
• Returns the index of the first occurrence of the element in the given tuple
>>> tuple1 = (10,20,30,40,50)
>>> tuple1.index(30) 2
>>> tuple1.index(90)
10. • ValueError: tuple.index(x): x not in tuple
SORTED()
• Takes elements in the tuple and returns a new sorted list. It should be noted
that, sorted() does not make any change to the original tuple
>>> tuple1 = ("Rama","Heena","Raj", "Mohsin","Aditya")
>>> sorted(tuple1) ['Aditya', 'Heena', 'Mohsin', 'Raj', 'Rama’]
• min()Returns minimum or smallest element of the tuple
• max() Returns maximum or largest element Of the tuple
• sum() Returns sum of the elements of the tuple
>>> tuple1 = (19,12,56,18,9,87,34)
>>> min(tuple1) 9
>>> max(tuple1) 87
>>> sum(tuple1)
11. NESTED TUPLES
A tuple inside another tuple is called a nested tuple.
>>>t1 = ((“Amit”, 90), (“Sumit”, 75), (“Ravi”, 80))
>>>t1[0] (‘Amit’, 90)
>>>t1[1] (‘Sumit’, 75)
>>>t1[1][1] 75
12. TUPLE ASSIGNMENT
It allows a tuple of variables on the left side of the assignment operator
to be assigned respective values from a tuple on the right side. The
number of variables on the left should be same as the number of
elements in the tuple. For Example
>>>(n1,n2) = (5,9)
>>>print(n1)
5
print(n2)
9
>>>(a,b,c,d) = (5,6,8) #values on left side and right side are not equal
ValueError: not enough values to unpack
13. QNA
Q1.Write a program that interactively create a nested
tuple to store the marks in three subjects for five
student .
Ans. total = ()
for i in range(3):
mark = () mark1 = int(input("enter the marks of first subject = "))
mark2 = int(input("enter the marks of second subject = "))
mark3 = int(input("enter the marks of third subject = "))
mark = (mark1 , mark2 , mark3)
total= total + (mark)
print("total marks = ",total)
14. Q2.Write a program to create a nested tuple to store
roll number, name and marks of student
Ans. tup= ()
while True :
roll = int(input("Enter a roll number :- "))
name = input("Enter name :-")
mark = input("Enter marks :-")
tup += ( (roll,name,mark ),)
user = input("Do you want to quit enter yes =")
if user == "yes":
print(tup)
break
15. Q3.Consider the following tuples, tuple1 and tuple2:
tuple1 = (23,1,45,67,45,9,55,45)
tuple2 = (100,200)
Find the output of the following statements:
1.print(tuple1.index(45))
Ans. The 'index()' function returns the index of the first occurrence of the element in a tuple. 2
2.print(tuple1.count(45))
Ans. The 'count()' function returns the numbers of times the given element appears in the tuple. 3
3.print(tuple1 + tuple2)
Ans. '+' operator concatenate the two tuples. (23, 1, 45, 67, 45, 9, 55, 45, 100, 200)
4.print(len(tuple2))
Ans. The 'len()' function returns the number of elements in the given tuple. 2
5.print(max(tuple1))
Ans. The 'max()' function returns the largest element of the tuple. 67
16. 6.print(min(tuple1))
Ans. The 'min()' function returns the smallest element of the tuple. 1
7.print(sum(tuple2))
Ans. The 'sum()' function returns the sum of all the elements of the tuple. 300
8.print(sorted (tuple1)) print(tuple1)
Ans. The 'sorted()' function takes element in the tuple and return a new sorted list. It doesn’t make any
changes to the original tuple. Hence, print(tuple1) will print the original tuple1 i.e. (23, 1, 45, 67, 45, 9, 55,
45) . [1, 9, 23, 45, 45, 45, 55, 67] (23, 1, 45, 67, 45, 9, 55, 45)
17. Q4.Carefully read the given code fragments and
figure out the errors that the code may produce.
• (a)
t = ('a', 'b', 'c', 'd', 'e’)
print(t[5])
Ans. IndexError: tuple index out of range
• (b)
t = ('a', 'b', 'c', 'd', 'e’)
t[0] = ‘A’
Ans. TypeError: 'tuple' object does not support item assignment
18. • (c)
t1 = (3)
t2 = (4, 5, 6)
t3 = t1 + t2
print(t3)
Ans. TypeError: unsupported operand type(s) for +: 'int' and 'tuple’
• (d)
t2 = (4, 5, 6)
t3 = (6, 7)
print(t3 - t2)
Ans. TypeError: unsupported operand type(s) for -: 'tuple' and 'tuple'
19. • (e)
t3 = (6, 7)
t4 = t3 * 3
t5 = t3 * (3)
t6 = t3 * (3,)
print(t4)
print(t5)
print(16)
Ans. TypeError: can't multiply sequence by non-int of type 'tuple’
• (f)
t = ('a', 'b', 'c', 'd', 'e’)
1, 2, 3, 4, 5, = t
Ans. Syntax error
20. • (g)
2t = ('a', 'b', 'c, d', 'e’)
1n, 2n, 3n, 4n, 5n = t
Ans. Invalid syntax
• (h)
t = ('a', 'b', 'c', 'd', 'e’)
x, y, z, a, b = t
Ans. No Error
• (i) t = ('a', 'b', 'c', 'd', 'e’)
a, b, c, d, e, f = t
Ans. ValueError : not enough values to unpack (expected 6, got 5)
21. Q5. What does each of the following expressions
evaluate to? Suppose that T is the tuple ("These",
("are", "a", "few", "words"), "that", "we", "will", "use")
• (a) T[1][0: : 2]
Ans. ('are', 'few')
• (b) "a" in T [1] [ 0 ]
Ans. True
• (c) T [ : 1 ] + T[ 1 ]
Ans. ('These', 'are', 'a', 'few', 'words')
• (d) T[ 2 : : 2 ]
Ans. ('that', 'will')