Pass Your Python Institute PCAP Exam Easy!

100% Real Python Institute PCAP Exam Questions & Answers, Accurate & Verified By IT Experts

Instant Download, Free Fast Updates, 99.6% Pass Rate

PCAP Premium Bundle

$79.99

Python Institute PCAP Premium Bundle

PCAP Premium File: 141 Questions & Answers

Last Update: Jan 24, 2023

PCAP Training Course: 57 Video Lectures

PCAP PDF Study Guide: 320 Pages

PCAP Bundle gives you unlimited access to "PCAP" files. However, this does not replace the need for a .vce exam simulator. To download VCE exam simulator click here
Python Institute PCAP Premium Bundle
Python Institute PCAP Premium Bundle

PCAP Premium File: 141 Questions & Answers

Last Update: Jan 24, 2023

PCAP Training Course: 57 Video Lectures

PCAP PDF Study Guide: 320 Pages

$79.99

PCAP Bundle gives you unlimited access to "PCAP" files. However, this does not replace the need for a .vce exam simulator. To download your .vce exam simulator click here

Python Institute PCAP Exam Screenshots

Python Institute PCAP Practice Test Questions in VCE Format

File Votes Size Date
File
Python Institute.testking.PCAP.v2023-01-16.by.ethan.79q.vce
Votes
1
Size
3.1 MB
Date
Jan 16, 2023
File
Python Institute.certkey.PCAP.v2022-01-18.by.nathan.66q.vce
Votes
1
Size
1.9 MB
Date
Jan 18, 2022
File
Python Institute.pass4sure.PCAP.v2021-10-28.by.arabella.62q.vce
Votes
1
Size
1.87 MB
Date
Oct 28, 2021
File
Python Institute.passit4sure.PCAP.v2021-09-14.by.caleb.43q.vce
Votes
1
Size
702.8 KB
Date
Sep 14, 2021
File
Python Institute.onlinetest.PCAP.v2021-04-27.by.lucas.40q.vce
Votes
1
Size
982.18 KB
Date
Apr 28, 2021
File
Python Institute.realtests.PCAP.v2020-02-24.by.evelyn.37q.vce
Votes
3
Size
683.52 KB
Date
Feb 24, 2020
File
Python Institute.Braindumps.PCAP.v2019-09-23.by.Elwell.34q.vce
Votes
5
Size
785.95 KB
Date
Sep 29, 2019
File
Python Institute.Testking.PCAP.v2019-02-20.by.Melanie.20q.vce
Votes
5
Size
406.82 KB
Date
Feb 20, 2019

Python Institute PCAP Practice Test Questions, Exam Dumps

Python Institute PCAP Certified Associate in Python Programming exam dumps vce, practice test questions, study guide & video training course to study and pass quickly and easily. Python Institute PCAP Certified Associate in Python Programming exam dumps & practice test questions and answers. You need avanset vce exam simulator in order to study the Python Institute PCAP certification exam dumps & Python Institute PCAP practice test questions in vce format.

Introduction

6. Indexing and Slicing Strings

Strings are a very, very important data type in any programming language. And so we're going to dive a bit deeper into it and see how we can manipulate data using strings. So let's create a variable and I'll just say it's a sentence, OK? and we'll assign some sentences to it. And like I said, you can use single quotes or double quotes. If I use single quotes and say this is a sentence and I could just print the sentence, everything works fine. But let's say there is a special wording there, such as "I'm coming home," okay? Now in this case, we have a quote in the beginning and a quote in the end. But you can see there's something wrong here. Syntactically. This is incorrect because Python thinks that this is a string because it's wrapped around with single quotes and it doesn't know what this is, right? And so in a situation like this where we have apostrophes, you can use double quotes. So let's put double quotes here and use double quotes. And now this should be working perfectly fine. Okay? So I just wanted to bring it to your attention: if you have apostrophes like this, you want to make sure you use double quotes. Otherwise, feel free to use single quotes. The next thing I'd like to discuss is the existence of escape sequences within strings and what an escape sequence is. Basically, we want to manipulate the way this string is printed or is being used by introducing a character here. So for example, let's say that I wanted to print this on one line and this on another line. One way to do this is to invoke the print function on I'm coming, and then invoke the print function again on home. All right? Or I can introduce an escape sequence. So, an escape sequence is created by using the escape character, which is a backslash. And then you use something called N. In this case, if we use N, this represents a new line. So what's going to happen is this is going to print first on the first line, and then this is going to print on the second line. Let me show you. Let's go for a run and see what happens. There you go. Notice it's saying I'm coming home on the second line. Now the reason why there's a space before home is because after the new line escape sequence, we have this character, a space character. So if we wanted to have home right underneath the word I'm coming, then I would just move that down and run that, and there you go. Now the next thing I want to discuss is being able to pull individual characters or a series of characters out of this sentence. So let me write a new sentence without an apostrophe to make it a little simpler. So this is a sentence that does not get very creative at all here. So we have the sentence variable. If I want to print the first character of this sentence, what is that character going to be? It's going to be the letter T. And so the way to do that is after this variable, we can use the list notation, which looks like this in Python: open and close brackets. And inside of these brackets, I specify the index position of what character I want printed out. I can use zero. And what this is going to do is print the first character. So the way this is all set up, each character in a sequence is assigned an index number. So the 0th index position is T, and then one is H, two is I, three is S, and so on. The space here is also a character, and so it would also have a sequence number. An index number is what they typically refer to it as. So if we get the index number zero here, it's going to print the letter T. So let's run this And there you go. Notice it says T. If I want to get the last character, I have two options. One, I can just count and say 012-34-5678,910, 1112, 13, 1415, and 1617, and say that I want the 17th index position. And when I type that and hit Run, notice that it gives me the E that I want. That's one way, and that's a very annoying way, isn't it? So let's say we don't know the number of characters in a given sequence or in a string. How would we get the last number? Well, there's a very handy method that we can use to get the last character, and that is to use the negative index position. So if you want to start from the end here, from the end of the string, I could just do minus one, and that will always give me the last character of a string sequence. So let's hit and run. And there we go. We get E. If I want the second to last, I would do minus two. Let's hit run, and that will give me C. If I want the third to last, then I would do minus three. If I want to get the first character, that's always going to be zero. Okay? The first character is always going to be zero. So there are index positions assigned to each of these characters going from left to right, as well as index positions assigned to each character from the left. Excuse me, from right to left. Okay. So from right to left, it starts at negative one. But the beginning of any sentence or string sequence is always going to be the 0th index position. That just makes things really easy. It's really quick to just get the first and last character by using zero for the first minus one. For the last minus one, it will always give the last character. No matter how long this string sequence is now, you might be wondering if there's a way for us to get one of these words or any of these series of characters. And the cool thing is, we can very easily do that by using a similar notation inside of these brackets. I can put a colon here. After the zero, I can put a colon and specify the index position that I want to go up to, but not include. Okay, so if I want to get the word this, T is going to be zero, h is going to be one, I is going to be two, and s is going to be three, and I would need to go one step further to get the s. So I'd need to put four here, which would take me back to zero. It's going to print from zero to three, and that's four characters, and that's going to give me the word disk. So let's hit and run. And there we go. We can see that the word "this" is printed out. If I change this to a three, even though Sis is in the third position or index position three, it's not going to give me S because it's non inclusive.Okay, the second value here is non inclusive.And so we need to go one step further and put in four if we want to capture that us.Otherwise, if I run this the way it is, it's only going to give me the I, and the S is missing there. Okay, now if I want to, for example, get the word "is," why don't you try this? Pause the video and try this out on your own, and you can resume to watch my solution. Okay, welcome back. Hopefully that wasn't too difficult. So all you really need to do is get the index position of I and get the index position of S, then just move one more value up. So we start at 01234 five.So I am five. So we start with five and add six isS, but we can't add six because it's not inclusive. The second value here is non inclusive.We need to go one step further and put seven here, and that is how we'll be able to see is printed on the screen. So let's hit and run. And there we go. We see that this concept of referring to the index positions and getting the string is known as "slicing." We're slicing the string and picking and choosing the sequences that we want from that string. This is known as slicing the data. Let me change this to AB. C-D-E-F-G some arbitrary string sequence And I want to show you that you can actually skip over characters and only pick and choose the ones you want. So let's say I want to get every other character. I want to start from A, skip B but get C, skip D but get E, and get G. How would I do that? Well, there's a third piece to this. This is the beginning value. This is the ending value from five to seven. Let me change this back to zero and go all the way to the end. So this is the 6th index position, and I would need to go one step further. So seven. And so if I am to print this, let me make sure it prints. It goes from A to G. So if I wanted to get every other character, I could actually use another colon and specify the increment. So if I just use one, this is basically going to print everything the way it is. Let me run it. There's no skipping going on when I use one ABCDEFG, but if I use two, then it's going to skip and get every other value. So let's hit and run. And there you go. We get A; it skips B, but we get C; it skips D; we get E; it skips F; and we get G. Okay, so this is another way of slicing the data if I want to just get the entire string from a given position. So let's say I don't want ABC, but I do want the FG. How would I do that? Why don't you pause the video and try that out? Okay, welcome back. Hopefully that wasn't too difficult. So all you really need to do is get the index position for D first. And so, that's going to be 0123. So we start from the third index position, and then we get all the rest of the characters. But I want to show you a shorter way, and that is if I don't put anything in the second section of this after the colon, I leave nothing there, and I hit run. Notice. It gets me exactly what I want. So this is a shorthand of "we indicate the starting position, but we don't indicate the ending position." And it basically goes to the end by default. So this is also very useful. I can also do negative two, and that would be starting from the letter F, and then it will go all the way to the end. So let's run this, and notice it gets FG. It will begin with the letter F and end with the letter G. I can move further. Let me go minus four and not give a second value. Hit run. And it starts with def G. So going from left to right, the index positions of each character are 01234 and soon, but going from right to left backwards, the index position starts with negative one. And so we can use either of those two index positions for any given character; we can refer to its negative value or its positive value. So that's all I want to talk about now.

7. Basic String Methods

So here I've got a sentence variable, and I'm assigning it some string data. And this is not very creative at all. The data is This is a sentence. And if I were to uppercase all of this, I could invoke the upper method, so I could do Sentence, okay? And by the way, this box that appears at this code helper box is known as IntelliSense, and it gives us all of the different methods that we can perform on string data. All right? all the methods that are associated with the GivenData type or object that we are working with. And so in this case, we're dealing with the string data type. And so we get access to all of the different methods that can be performed on string data. So we can uppercase characters, we can lowercase them, we can capitalise them, and there are various things we can do, and we'll explore some of them. But if I use the upper method and there's this notion of a function and a method in Python, and they're very similar in the way they look, but they have a key distinction that we're going to get into later because it has to do with object orientation. But anytime you see parentheses like this: a name and then parentheses, that means that we're either working with a function or a method. Now, a method is typically invoked on a given object. So in this case, this sentence is the object, and we are invoking this method on this object. A function is something like the print function. This Print Function just prints; it's not associated with any given object. We're not doing a dot print. This is the function. But in this case, this Upper is a method because it's associated with this particular data, this object sentence. So don't worry about those details. Right now, I just wanted to slowly introduce this concept of "a method and a function," but it's going to be more concrete as we get into object orientation. You're going to be writing your own functions and methods, but I wanted to sort of hint to you right now that there's a difference between a function and a method. So we are going to uppercase this sentence. Now, we can't just uppercase this, right? It will not accomplish anything if I print the sentence value here. Just because this line ran doesn't mean that the value of the sentence variable has changed. These are still all going to be lowercase. If I ran notice the sentence data that's being printed, the variable, it's still lower case, even though I invoked upper case. And the reason is because when you invoke a method on it, you actually have to assign the data back to the same variable or some other variable. So I can maybe assign it to some other variable called "Send" and then paste the Send here. And if I hit "Run Notice," it's going to print that in all caps. Or I can just assign this method-inlocation nonsense back to the sentence variable. So I can do the sentence, and then I can print the sentence down here. This is essentially doing the same thing. Notice it's uppercasing all the characters. So it's not enough to just run this. We actually have to assign it back to the sentence variable if we want the change to be applied to the actual sentence variable. And again, when it comes to assignment, everything that's on the right performs first, and then that gets assigned to the variable on the left. And now the new value for sentence is going to be printed down here. Another way we could do this is, instead of assigning it to itself, I could just take this whole expression and pass it into this print function. Again, this is just a function; it's not associated with any object, whereas upper is associated with sentences. That's why it's being invoked. Now, in this print function, we are passing this data to this print function. And so whatever is inside of these parentheses gets evaluated first, and only then does that data get passed to the print function. If I run this, we will see the capitalised sentence, as you can see down here. So I'm walking you through this step by step so that you don't miss a heartbeat. But excuse me if I'm repeating myself. These are key concepts that I want you to understand at a very concrete level because we're going to be building upon them. And the more solid of an understanding you have at this point, the easier the rest of the course is going to be, even when we talk about much more advanced concepts. So we have the upper method. I can use the lower method. And of course this is already lower case, so it's not going to do anything. But if I were to change, for example, the word "is" to "is," which is now the lower function if you want it, excuse me, the lower method, if we run it, it's going to print everything in lowercase. Notice the i is no longer uppercase. There's also something called "capitalize." That's another method. So you can simply do a dot to see all of the methods that can be invoked. So let's choose capitalization. Now what the capital is going to do is capitalise the first character of the string. As long as it's an alphabetical string, the first letter is going to be capitalized. So, let's get this started. And there you go. Notice that the first character of this string is capitalized. And not only that, it actually lowercases everything else. Because even though the string is capitalised down here, notice that it lowercases everything else. So capitalising does a few things. one, it capitalises the first character, and then it lowercases everything else. Now this sentence could contain numbers. It doesn't really matter as long as the string And there are characters in there. It's going to capitalise the first character and lowercase everything else. So let's run that notice. Everything else is still the same. So we talked about upper lower capitalize. Let's talk about another method. and that method is known as the Isdigit method. So I can do sentence is digit right here. And this basically returns a boolean value—whether it's true or false. and you can guess what this returns. If this string, and only this string, is a series of numbers, it will return true. It is a digit. If not all of the characters in the sequence are numbers, then it will return false. So in this case, even though we have numbers here, it's still going to return false. Because not everything is a number. So let's hit "run" and notice it returns false. But if I was to get rid of everything else and just leave 9484 It will now return true. As you can see down there, as a matter of fact, I just had a really long number run. It's going to come true. Now, here's the catch. If I put a space here, this particular character is the space character. Now all of the characters are no longer numbers. We've got a space included in there. And so now this digit is actually going to return false. I'll show you. Let's hit run now. Let's return false. There's also the Is Numeric method, which does pretty much the same thing as Is Digit. It also returns a Boolean. Now, there's another handy boolean method that you can invoke on string objects. So I could do "sentence dot notice is digitising lower," meaning if everything is lower case, it checks and returns true; if everything is lower, it returns false. Numeric is otherwise alpha-numeric. This is another one if there are numbers and letters. So let's do this. If we do, it's al numeric.Now if we hit Run Notice, it's going to return false. Because we don't have alphabets in here, even though we've got a space. So if I were to add a letter, for example, the letter A, and put a space between the letter A and the rest of the data, this is still going to return false. Because even though it's almost alphanumeric, meaning there are letters and numbers, But wait a minute, we also have spaces. So let's run this and notice it returns false. If I get rid of all the spaces now, we have numbers and letters. As a result, it will now state that it will return true. So let's run this notice it returns true. All right, if I introduce some other characters, such as the percent sign or something, or the dollar sign, this is no longer the alphabet and America. All right, let's run. I notice it's going to return false. So this method just checks for whether there are only letters and numbers, no spaces, or any other fancy characters. Let's take a look at some other ones. We can do the sentence we talked about, is numeric or decimal," to see if the number is decimal. Other things to consider include his title case, which is uppercase, and so on. So you can explore some of this. These are all Boolean methods, whenever there is an s before the method name. As you see right here, this is just the naming convention used. And it's kind of a question. Is the data a digit? Is the data lowercase? And it's supposed to return either a yes or a no. Now there are another couple of Boolean methods that we can use. Let's say I wanted to check whether this string sequence starts with a series of characters I could use. This starts with methods I could do a sentence with right here. And as part of this, when I invoke this method, I can pass into this method. Inside these parentheses, I can pass in some data and check for whether the sentence starts with a given series of characters. So I can say nine, four, eight. Make sure you surround that with quotes. Because we're checking for a string. So we're checking to see if the first four characters are 948. As a result, we should anticipate this to be true. So let's hit run, and boom. There you go. Notice it returns true. If I change the last character from eight to the letter P, for example, then of course it's going to return false, right? And it doesn't just have to be four characters. It could be as many characters as you want. I could just check for the first one whether the string starts with an A, and of course it does. It returns true. similar to starts with There's also an ending with So I'm just going to use ends with. and you can see it right here. Now we're checking to see whether this string ends with an A, and of course it doesn't. So it's going to return false. If I change this to three, it's going to return true. Now, three is a number, right? So if I get rid of it, this is not going to work. It expects a string to be passed in as the data to end with. If I run this notice, it gives us an error. So again, these methods that I'm invoking are supposed to be invoked on string data. So oftentimes, they expect strings as the arguments, with a few exceptions, which we'll talk about later. As a matter of fact, I'll just talk about them right now while we have the time. So begins with and ends with can take not only one piece of data but also other pieces of data to perform additional checks. I'll explain to you what I mean. So if I change this to just start with and in here, if I want to check for whether this sequence dollar sign exists at a given position in the string, what I could do is locate this particular position and say, "So eight is at the index position." Let's check 01234 five.This particular eight, right before the percent sign, is at the fifth index position. So I can check to see whether this string sequence—let's put that in here in quotes—is If this string sequence exists within the string, starting at the fifth index position All right, so now I'm ignoring all of the previous characters. I'm actually saying that this starts with checking at the fifth index position of the string. And again, this is a zero-based index. So everything starts from zero. So A is zero, Nine is one, and Four is two. We talked about this in the previous lecture, right? As a result, this should now return true. So let's run this and notice it returns true. If I change eight to, for example, the letter P, this, of course, is no longer going to return true. It's going to return false. Let's run this Notice it returns false. So you can do a similar thing with ends as well. So, experiment with these methods to get some pricing.

8. Formatting Strings Using the Format Method

Now, in this video, I want to introduce you to the format method, and that's a really handy method that you're going to be using all the time when we're working with strings in Python. So let's say if I have the following string, I can say the sum of five plus ten is some value, okay? And I'd like to format this data with a given value. Rather than hard coding it in here and saying it's 15, I could just put these curly braces in here and enter a number. So if I use a zero and you're goingto see what are some of the numbers thatyou can use here and what they mean. But on this string data, I can invoke the format method; you see it right here. And the data that I passed to this method, the argument to this method, is going to be the value that I want replaced here. So if I, for example, put 50, which is obviously wrong math, five plus ten is not 50, but you'll see that 50 will make its way into this. So let's print the sentence. And now let's run it and notice it says the sum of five plus ten is 50. So you could pretty much pass anything here. I can pass in Nice Day and run this, and notice it says the sum of five plus ten is Nice Day. Now, you can take this further by passing in multiple values. So I could say that the sum of, well, let's surround, let's make all of these data that could be passed in from the format function. And I'll say that this is zero, as well as this is zero.So all of these are zeroes. And what that means is that the first piece of data that we pass into the format function, or method, is going to be copied over into each of these positions. So if I say ten, for example, let's hit run. Notice it says the sum of ten plus ten is ten. Obviously, it's clear to you that this is not doing any math. I'm passing in everything. Now, I can pass in multiple values in the format, and they will be copied over into their respective positions. So I could do zero, one, and two. And now it will take the first value from format and copy it into the zeroth position. And then the next argument is going to make its way into this position. And then the third argument is going to make its way into this position. So let's do that. Let's fill this out. Let's make it compute something that makes sense. So we could do ten plus ten. Well, no, we'll choose a different 110 plus 15 is 25. And so we expect ten to be copied over into this position, and 15 to be copied over into this position. and 25 to be copied over into this position. So let's run, and there we go. Notice this is the output. Now I can switch this around. I can move down here. Let me just reformat this and say it's like that. And so what this is going to do is take the first value and paste it in here. Then it's going to take the third value, not the second value, but the third value. That's the last one right here, and put it here. and then one is going to be this data. These are known as arguments in Python. And we're going to talk more about that when we get into methods and functions and how you can write your own functions. But just to be clear, we're passing in three points of data, which will be copied over in their respective positions. So in this case, if I want this to make any sense, I could say that, for example, five plus ten is equal to 15. and so this value is going to be copied in here. This value is going to be copied here, okay? because this is the next incremental value. And then this value is going to be copied here. Hopefully, that makes sense. So let's write, run, and there we go. We can see it's Five plus ten is 15. Now I'm assigning this data to the sentence variable. I don't even have to do that. I could just obviously see it like anything else—I could take the string and paste it in here, right into the print statement. It will do the same thing as it was doing before.

9. Strings are Immutable

String objects are known as being immutable, meaning they cannot be modified. Its immutability means it cannot be changed. Mutability means it can be changed. So I'll give you an example of what it means to change a given string. Now, we talked about string slicing a couple of lectures ago, right, where if I want to, for example, get the first character, I could do My VAR and use the open and close square brackets and specify the index position of the character that I want. So, for example, the 0th index position will be the first character, and I can just print that, and I can extract the given data that I want. And that's all right here. But using the same logic, you might think that you can assign my VAR at the zeroth in exposition to some value. Let's say I wanted to start the string with one, so I would like to replace A with the value one. using this logic. We cannot do this. We don't even have to print it. As soon as the interpreter gets to this line, it's going to crash. It's going to give us an error, and it's going to say, "String object does not support item assignment." So we are trying to change this string object called myVar, and it's not going to let us do that. So essentially, we'd have to reassign the myVar variable with an entirely new string and say, "One, B-C-D-E-F-G like this," rather than modify that. Okay, so this might seem inconvenient to you, but there's actually great wisdom behind this concept that you're going to continue to learn about as we proceed in this course. So if you had to do this programmatically, rather than recreating all the characters of the string and changing the first one to one, if you wanted to do this programmatically, what you could do is use slicing. So we'll do My VAR, and we can capture everything from the first index position onwards. If I leave the second part of this after thecold and leave this empty, it will take from B to the end. So what I can do is capture all of these through this expression and then just add the plus sign, the number one, by using quotes and doing that. and I can assign it back to myVar. All right. And now myVar is going to contain one BCDEFG, and I can, of course, print it like that. If you run this notice right now, you'll notice it's one BCDEFG. So just keep this in mind. Strings are immutable. You cannot change them once they're created. You have to define a brand new string with ABC.

10. Section 1 Assignments

I'm going to be presenting various problems to you, and I'm also going to be going over the solutions. But before you resume to watch my solution, you should actually go ahead and pause the video and practise the problem yourself. Try to solve it on your own before moving on to the solution, okay? The more you struggle with it on your own, the faster you're going to learn Python—or anything, really. As part of this course, there is an assignment project that you must download and extract on your local machine. So I've saved it in my home directory. In Pi Charm Projects, you could choose to save it at the same location or anywhere on your machine, as long as you know where you save it. And this is that project: assignments. Okay, so what I'm going to do is I'm going to open up Pi Charm, and I'm going to locate where this is, and I'm going to open that Assignments project in PyCharm so that we can start working on these assignments, all right? So somewhere, as part of this video, you'll see a link to download this project. It's probably in the Resources section. You should be able to locate it. So I'm going to open up Pie Charm, and I'm going to actually open the project. So click on the open button right here, and it's in the PyCharm Projects folder. This assignment is the project, okay? So you don't have to expand it and open it individually. You could just click on the actual project, single-click it, and then click on Open, and that will open the project in your workspace. And whenever you launch PyCharm again, you should be able to see it right here. Now, I already had this project open prior to recording this video. That's why you see it here on my Favorites. You will be able to see that as well when you get it on your machine. So let's actually open up that project, and you can ignore this tool tip for now. So here it is: assignments. So expand it. And we're going to be right now in Section One, where we're going to apply everything you learned in Section One. All right? So let's expand that, and let's look at assignment number one. Let's open that up. So it's a very simple assignment. It checks to see if, you know, there's one key thing that we spoke about. In this section, it says, "We would like to get the remainder of 15 divided by four." The calculation below does not seem to give us this result. How would you change the code to meet the requirement? So you want a remainder of 15 divided by four. How'd you get that? Why don't you pause the video, try this out on your own, and then you can resume to watch my solution? Okay? Welcome back. This was a pretty easy puzzle as long as you remembered that you needed to use the percent sign to get the remainder. Percent is used to divide between two numbers, and it gives us the remainder rather than the result of dividing the number, right? You can use a slash, but that's going to give us some kind of a decimal point, right? We don't want that. We don't want the actual division. We actually want the remainder from dividing these with the percent sign. So four turns into 15. How many times? Well, four goes into 15 three times because three times four is twelve. And then, how many do you have left? You have three digits left there, right? So we should expect the number three to be the thing that gets printed. So let's save this file and run it. You can actually right-click this file and click on "run assignment one." Now as you're running these assignments, you should actually right-click the file and run it so that you know that this is the file that's being executed because we'll have multiple files. So you can't just click on this "run" button on top. Now that we're dealing with multiple files, you want to make sure you right-click this particular file and click on Run Assignment. And so let's do that. And this is the result. We get three. So if you were able to figure that out on your own, great job. Let's move on to the next assignment. So, assignment number two This is also pretty straightforward if you remember how to do string formatting. So it says, "Use the below format method, which has already been applied to the string." The use of the below format method is incorrect for what we are trying to do. What are we trying to do? Well, we actually have ten large and twelve medium boxes. Okay, so we have ten small, twelve large, and twelve medium boxes. So how would you change the statement so that this data is represented in this sentence? Try that out on your own, and then you can resume to watch my solution. Okay, welcome back. Because we're using index position two, hopefully you can tell. Because this is zero-based indexing, it is using this particular row of twelve. So if we want ten small boxes, we'd have to change this to zero. If you want twelve large boxes, we'd have to change this to one and two for medium boxes in that order, exactly as it's shown here. So let's save this file, right-click this file, and click on Run Assignment Two. And there we go. We have ten small boxes, twelve large boxes, and twelve medium boxes. Let's move on to the next one. So we'll close this file and open up assignment three. So this is a little more lengthy and has more requirements, but let's go through this. So given two variables, cars and words, So these are the two variables that we're talking about, and they're defined down here: cars and words, and we'll go over why. So given these two variables, write code to move the data contained in the variable word in the exact middle of the characters contained in the variable Cars, which stands for characters, and save this in a new variable called result and print it. So what do we need to do? It says, "Note Cars variable will contain only four characters." All right, so here's an example. Here's what cars contain. It contains these open and close angle brackets, and these are, in fact, four characters. So basically, we'd like this "hello" to make it right in the middle of the cars, right? And so the results contain the following. This is what we expect. Okay, so how do we do this? Well, let's scroll down here to our example for this assignment. These are the two variables. Cars has four characters, as you can see, and the word cool needs to go in between them as shown right here. The expected result is printed. So this is the expectation. So write your code below this line to try to make that happen. Okay? And you need to do this using string slicing. We talked about this a couple of lectures ago. So use string slicing. So pause the video now, try it out, and then you can resume to watch my solution. Okay, welcome back. Hopefully that wasn't too difficult. So if you scroll a little bit down, I've got some code here. I'm going to copy this solution code, and we'll go over exactly what's going on. So let's paste it here. Now, down there, it's commented out. I may or may not leave it in this file, but here's the answer. You'll notice we're printing the results of this. We should have saved it in a variable called result and printed that, but it would have been the same thing. So what's going on here? We have cars, and we are starting from the beginning of cars. So we don't have to specifically say "zero index position." We're simply stating that everything from the beginning to but not including the index position should be correct. Because, as previously stated, the second value in the index is non-inclusive. We spoke about this. So zero, one, and then we specify two. And that's how you'll be able to get the zero and one index positions. So this contains the first two characters. And then we have this word, which is cool right here. And then we put the last two characters in the Cars variable, which is right here. Okay. These two. And in this case, we specify the second index position. So that's zero, one, two. And then we take it all the way to the end of this string. We don't have to stay here for three or four days. This would be four. This code will work just fine if I have the number four here. But if you just leave it alone by default, it'll just take it to the end of the string. All right, so let's try this out. I'm going to save this file and right-click this file and go to Run Assignment 3. And boom, there we go. This is our expected result. So, hopefully, you've figured it out. If not, then don't worry, you're going to get plenty more opportunities to practise as we proceed in the course. So let's go on to the next assignment. And this is actually also going to have to do with slicing. So let's open that up. Let me close assignment number three. We don't need that anymore. So now we're on assignment four. So what is this saying? Well, it's saying, given two variables, "word one" and "word two," Write code to print the concatenation of the two words. omitting the first letter of the string saved in word one and the second letter of the string saved in word two. So here's an example. One variable is assigned to the word "vehicle.Word's two variables are assigned to the Word robot. So we need to omit the first character of word one and the second character of word two and concatenate the result together. So the result should be this. The letter V is missing, as is the letter O from the word robot. So this is the expected result. So if you scroll down for this particular assignment, here are the words that you're going to be working with. This is just an example that I've provided up here. You're actually going to be working with this data down here. So, for computer and truck, the expected result is tuck Okay, so how would you do this so that this is the result? You can print it out on the screen. You could save it in a result variable or what have you, but you need to use string slicing to accomplish this. So try this out. Write your code here and then you can resume to watch my solution. Okay, welcome back. Hopefully that wasn't too difficult. So if you scroll down here, I've got a code that we could just borrow down here in the solution section, and we'll go over it in just a moment. So I'm going to uncomment this code so that when we run it, it executes. So we're saving the expected value in this result variable, and we're printing the result. You could do it like this, or you could print this directly in a print function. But anyway, word one, we're taking from the first index position, which is going to start from zero, right? You would have used zero or left it empty if you wanted it to start from C. But we want to start from O because we want to omit the first character of word one and the second character of word two and combine those two together. So we get that. And then for word two, we also want to get the first letter. All right, now we get the first letter T. But we need to omit R. We don't want Robert here. As a result, the third section of this word two begins at index position two. And that is if you start counting from UC K. That's all this section contains. This just accounts for the T, and this just accounts for everything after the character C in word one. So, if you want to run this correctly, make sure you right-click this file and then select run assignment four. There we go. This is the expected result. So this is pretty straightforward. Hopefully, if you know slicing, let's move on to assignment five. I'm going to close this and move on to assignment five. Now this is very similar to assignment number three, where we have to take the word mirror and put it in between, right in the middle of the characters variable or the data containing characters. So if this is cars, this is words, and this is the output that we expect, a mirror should be right in between there. Now the catch is for this particular puzzle. It says the Cars variable can contain any even number of characters. So it can be two characters, ten characters, or 20 characters. It can't be 51 because 51 is an odd number. How would you divide that in the middle? So it has to be a set of even characters, and then we have to place the mirror or whatever word fits the requirement in the middle of those characters. Now here's another note. It says the Len len function can be used to figure out the length of the string. Okay. Now this is slightly more challenging, and it's going to touch upon data types as well, as you're going to see when you try to accomplish this on your own. So why don't you pause the video and try this out? You're going to need to use string slicing so that the word cool goes right in the middle of these characters. So there are three characters here and three characters there. But make sure you account for whether the carol could have been ten characters or 20 characters. Don't just use three here and three there. This is not a hard-coded value. Think of Cars, as it could have been any number of characters. In this case, we just have six. But we could have had twelve or 21. Lines of code should be able to solve it. And you're going to need to use the lens function for this. So try this out, and then you can resume to watch my solution. Okay, welcome back. Hopefully that wasn't too challenging. Well, it may have been for some of you, but that's okay. All right, that's what we're learning here. And this is your time to practise and struggle. The more you struggle, the more you're going to learn. Trust me. So what do we have to do? Well, the expected result is right here, and so your code is going to have to first take that into account and figure out how to divide cars down the middle. Because again, I said that this doesn't have to be six. It could have been 20 or 30 or 500, as long as an even number of characters appeared on each side. So what we would need to do is first calculate the length of cars to find out how many characters are in the characters variable. All right? And so this will give us that information. And I'm going to save this into a variable. We'll call it size. So this is going to be the size of the string. And then what I'm going to do is create an index variable, IDX. I'm going to say size divided by two. Okay? And now, since it's an even number, we'll be able to divide both sides equally. And that's what IDX represents. And finally, down here is where we would do some slicing. But let me explain to you one key thing. You may have struggled at this point because when you try to do the slicing, you're going to run into a data type issue. It's going to say that, Hey, index positions when you're using slicing should be integers, not any other data type. The reason for this is that when you divide size by two, the result is automatically converted to a float. I'll prove it to you. So up to this point, size is an integer. But as soon as you divide that using this notation, the result of this division is going to actually be a data type of float. So let's use the type function and I'll show you what I mean. So let's print this. So let's print the type for the index. Let's click and run. Make sure you right click this particular file. Notice if I just hit Run,it just ran the previous file. All right? So, right-click this file and select Run assignment 5. So notice that the data type of the index variable is float. You cannot refer to float values when slicing. You can only use integers. So why did it do this? It did this because of the division that we're doing here. So we need to account for that. So what we need to do is change the data type here. And I spoke about this. If you want to change the data type of anything into a string, you use STR. If you want to change the data type of something into a number, like an int, you use int and you surround that function like that. And so now this is known as casting. By the way, we are casting this float into an int. And now, because we know that the result of this is actually a whole number, we know that the size must be even. And if we can divide it evenly among two, And so this IDX will, of course, be an integer. That is why I am converting the data type using the int.Function. And so now if you run this, you'll see that the data type is int for IDX. So now that we have this, we can actually start the slicing. All right, so how do you slice this thing? Well, we could do cars and specify the beginning index position, which is to leave that blank, and I'll say IDX like that. So if you leave the first value in the slicingto empty, it's going to, by default, take it from the beginning and go to the index position, which is right down the middle. And so it's going to take one, two, or three characters. In this situation, if we had ten, it would have taken five first characters. So in this case, let's say that since we're dealing with six, it's going to say zero two. All right? And since this is going to be three, and the second number in slicing is noninclusive, we're by default getting these first three. Okay, remember, when you're slicing strings, the second value is noninclusive, all right? So in this case, that is three. So it goes up to two right here. This is what we get. And then we can concatenate that with the actual word, and then we can concatenate that with the remaining characters. and that's going to be very similar. We do cars, and then we say IDX. In this case, we start from three, which is going to be right here. So 01012 and three are right there. We start from there and go all the way to the end of the string. All right? And we can just either save this into a result variable like that and print the result, or you could just print that directly. All right, so let's run this. Let's right-click "run assignment" five, and boom, there we go. We get the expected result. Now, as long as the characters are even, this code should work for any number of characters. So if I was to add a bunch more, let's add one, two, and three here, and let's add one, two, and three there. And let's add another one on the right and then another one on the left. so right down the middle. This is still an even number of characters. I lost count, but I was keeping it even on both sides. Okay, so we know that this is going to be divisible by two. And so this code will still run. It'll put the word cool right in the dead centre of these characters. So let's run this again, and you'll see the result. And boom. There we go. It's still working. Let me change this back to the way it was like that.All right, so the code that you wrote should have worked for any number of characters as long as they were even. That was the objective of this particular assignment. So I've.

Go to testing centre with ease on our mind when you use Python Institute PCAP vce exam dumps, practice test questions and answers. Python Institute PCAP Certified Associate in Python Programming certification practice test questions and answers, study guide, exam dumps and video training course in vce format to help you study with ease. Prepare with confidence and study using Python Institute PCAP exam dumps & practice test questions and answers vce from ExamCollection.

Read More


Comments
* The most recent comment are at the top
  • tamara337
  • Saudi Arabia
  • Mar 16, 2020

@brian, surely, the exam dumps for Python Institute PCAP exam are a great asset to pass the test! they complement the knowledge and skills you’ve gained from other study resources. besides, they will familiarize you with the structure of the exam as well as questions and their possible answers.

  • Mar 16, 2020
  • sheila_adams
  • United States
  • Mar 14, 2020

@brian, i can verify these practice questions and answers for Python Institute PCAP exam are useful. i used them during my revision and when the exam came, i finished it easily and got an excellent score!

  • Mar 14, 2020
  • brian
  • Switzerland
  • Mar 12, 2020

i’ll be sitting for the exam in the next two days… will these Python Institute PCAP exam dumps pave my way towards success?

  • Mar 12, 2020
  • doris1431
  • Peru
  • Mar 10, 2020

@linet_100, the vce files for Python Institute PCAP exam are helpful but you should not depend on them only. use every relevant training material offered in this platform as they will play a key role in your success in the test. hard work pays…therefore, study hard and you’ll pass the test

  • Mar 10, 2020
  • linet_100
  • Sri Lanka
  • Mar 08, 2020

hi guys? i am new in this platform and i would like to know whether the Python Institute PCAP vce files can help me pass the exam?? for those who have already passed the exam, how did you prepare… give me some tips to ace the exam please….

  • Mar 08, 2020
  • mike
  • Ukraine
  • Mar 06, 2020

examcollection is a trust-worthy website…it offers latest and valid exam materials always. i used these braindumps for Python Institute PCAP exam and passed in my first attempt! i recommend you guys to utilize the prep resources from this platform and you will score good grades!

  • Mar 06, 2020
  • hassan34
  • Australia
  • Mar 04, 2020

i downloaded the Python Institute PCAP vce files to use them in my preparation for the cert exam. i studied and analyzed the questions for around a week, then sat for the exam and passed it. i couldn’t remember the answer for only one question and thus i finished the test quickly.

  • Mar 04, 2020

Add Comment

Feel Free to Post Your Comments About EamCollection VCE Files which Include Python Institute PCAP Exam Dumps, Practice Test Questions & Answers.

Purchase Individually

PCAP Premium File

Premium File
PCAP Premium File
141 Q&A
$76.99$69.99

PCAP Training Video Course

Training Course
PCAP Training Video Course
57 Lectures
$27.49$24.99

PCAP Study Guide

Study Guide
PCAP Study Guide
320 PDF Pages
$27.49$24.99

Top Python Institute Certification Exams

Site Search:

 

VISA, MasterCard, AmericanExpress, UnionPay

SPECIAL OFFER: GET 10% OFF

ExamCollection Premium

ExamCollection Premium Files

Pass your Exam with ExamCollection's PREMIUM files!

  • ExamCollection Certified Safe Files
  • Guaranteed to have ACTUAL Exam Questions
  • Up-to-Date Exam Study Material - Verified by Experts
  • Instant Downloads
Enter Your Email Address to Receive Your 10% Off Discount Code
A Confirmation Link will be sent to this email address to verify your login
We value your privacy. We will not rent or sell your email address

SPECIAL OFFER: GET 10% OFF

Use Discount Code:

MIN10OFF

A confirmation link was sent to your e-mail.
Please check your mailbox for a message from support@examcollection.com and follow the directions.

Next

Download Free Demo of VCE Exam Simulator

Experience Avanset VCE Exam Simulator for yourself.

Simply submit your e-mail address below to get started with our interactive software demo of your free trial.

Free Demo Limits: In the demo version you will be able to access only first 5 questions from exam.