Where possibilities begin

We’re a leading marketplace platform for learning and teaching online. Explore some of our most popular content and learn something new.
المجموع 4 المدونات
Python vs C: Important Differences You Should Know

انشأ بواسطة - AHMED Abd El Mageed

Python vs C: Important Differences You Should Know

Python vs C may be a comparison you struggle with when looking for a programming language to learn. When you are new to programming, it can be hard to choose a programming language to begin with. A couple dozen are widely used these days, and their names hardly tell anything about what they can do or their uses. Also, although some programming languages are general purpose and work for more applications than others, the language you choose will have a large influence on the type of work you will be able to do with it and the type of jobs you can get writing the code.Python and C are both popular programming languages, but they are popular for different reasons and most of their usage doesn’t overlap. Once you understand the differences and their uses, you will be better equipped to choose the right one for your purpose.Features of PythonSome features of Python that make it popular are:It’s easy to learn.It’s easy to read.It’s easy to maintain.Automatic garbage collection.Interactive debugging and testing.It can integrate with other programming languages, including Java, C, and C++.Python code examplenterms = int(input(“How many terms? “))# first two termsn1, n2 = 0, 1count = 0# check that the number of terms is validif nterms <= 0:  print(“Please enter a positive number”)# if there is only one term, return itelif nterms == 1:  print(“Fibonacci sequence up to”,nterms,”:”)  print(n1)# generate fibonacci sequenceelse:  print(“Fibonacci:”)  while count < nterms:      print(n1)      nth = n1 + n2      # update values      n1 = n2      n2 = nth      count += 1C is a structured, mid-level programming language that is also general purpose. Dennis Ritchie at Bell Labs developed it in 1972 as one of the foundations of the Unix operating system.C has many features that makes it a popular language, including:What is C used for?Operating system developmentEmbedded system developmentMicrocontroller developmentFirmware developmentDriver developmentHere is a C code example that does the same thing as the Python code example. It calculates a Fibonacci sequence to the length input by a user:

المزيد من التفاصيل

نشرت - الثلاثاء, 13 سبتمبر 2022

How to Use the PHP STR_REPLACE Function to Find and Replace Strings

انشأ بواسطة - AHMED ABD EL-MAGEED

How to Use the PHP STR_REPLACE Function to Find and Replace Strings

If you’ve ever needed to find and replace a string in PHP, then you’ve needed PHP STR_REPLACE. The PHP STR_REPLACE function works to replace each instance of a given string with another string. And, luckily for you, it’s also one of the easiest functions to use. Today, we’re going to take a look at how you use PHP STR_REPLACE, what situations you would use it in, and what you shouldn’t do when using it.What is PHP STR_REPLACE?PHP STR_REPLACE stands for “string replace.” This function in PHP searches for a given string within another string. Wherever it finds that string, it replaces it. The STR_REPLACE function can work with a string or an array. It will return a string if used with a string, and it will return an array if used with an array.How do you use PHP STR_REPLACE?In the PHP manual, PHP STR_REPLACE is used with the following syntax:str_replace($search_string, $replace_string, $original_string, [$count]);First, let’s explain the variables:$search_string: The string that you’re searching for.$replace_string: What you want to replace $search_string with.$original_string: The string that’s being searched (or an array of strings).$count: Optionally, you can include a variable that will count the number of replacements made.Let’s look at a simple example: $string_world = "Hello, world!"; $string_everyone = str_replace("world","Everyone",$string_world); echo $string_world; echo ""; echo $string_everyone;In the above example, we started with $string_world. Then, the replacement swaps “world” with “everyone.” The PHP strings within the string are swapped. Note that this is case-sensitive. If we had written “WORLD” instead of “world,” it would not have matched any strings.Additionally, we did not use the “$count” variable in this example because it’s an optional variable.Using PHP STR_REPLACE with an empty stringYou can also use a replacement function with empty PHP strings. It basically deletes the given string when you do this: it inserts a null value. In the below example, instead of replacing “world” with “Everyone,” we replace “world” with “” (a null set).Now we’re saying hello to no one. So, STR_REPLACE could strip out extraneous things that you don’t want in your code or things that could potentially damage your code. For instance, you could use STR_REPLACE to strip out quotes (“s), or you could use it to strip out tags (s).Using PHP STR_REPLACE with multiple replacementsWe can also replace multiple iterations of a string. In the above example, we were just trying to replace the word “world.” But STR_REPLACE will replace as many instances of the string as it can find.Let’s say that, for some reason, we wanted to turn every “L” in the phrase to a “7” (maybe we’re generating a password). We could do this just by changing “world” to “l” and “Everyone” to “7.”So, it’s important to note that STR_REPLACE will always replace every instance within the string. There is no way to get it to replace only certain instances of the string or a certain number of instances — you’d need to use another function for that.Using PHP STR_REPLACE without case sensitivityPHP is only partially case-sensitive, which can be confusing. The STR_REPLACE function works exactly as STR_REPLACE does but without case sensitivity. So, if we wanted to replace “world,” “WORLD,” “World,” or any other variations of the above, we would use STR_IREPLACE instead. In every other aspect, STR_IREPLACE will operate the same.Finding out how many replacements were madeAs mentioned, we have an optional “count” variable that we can use to determine how many replacements occurred. We do this by providing a variable (in this case, $count) and then calling that variable after the function has finished.Because PHP doesn’t enforce strict variable controls, you don’t need to declare the $count variable before you call STR_REPLACE. But it’s generally considered a best practice to do so.You may realize something else. If we didn’t want to perform a substr replace, we could actually use this only to determine the number of instances within the string. Check out this example:In the above example, we don’t replace anything at all. But we do get a count of the Ls in the sentence. Of course, this isn’t the most effective way to do this. You could do this with SUBSTR_COUNT() or even PHP FOREACH. But it does help understand how the function works.Arrays and PHP STR_REPLACEIn addition to performing a substr replace, PHP STR_REPLACE can also look through an array and replace instances of a string within every string inside of that array. It works exactly the same as a traditional STR_REPLACE, just across all the strings of the array itself.Let’s start with an array called $array_greetings[] that we iterate through with the PHP FOREACH function:Now, let’s say we want to change that to “Goodnight” instead of “Hello.”Voila! We’ve performed a SUBSTR replace on the array with all occurrences replaced, even though it’s an entire array. So, the function returns a string when you give it a string, but it will return an array when you give it an array.If we had a whole bunch of strings that we wanted to change, we could pull them into an array stack and change them all at once.Learning more about PHP STR_REPLACEThere are other options, such as PREG_REPLACE, that can insert a replacement string — although PREG_REPLACE, in particular, tends to be a little more complicated than STR_REPLACE. Regardless, if you need to search for a string and replace it, as well as report the occurrences of search, the PHP STR_REPLACE function is perfect. It’s a simple, easy function that you can use to swap one string for another inside of an original string or an array.Want to learn more about PHP functions such as PHP STR_REPLACE? You can check out a beginner PHP course to get started.

المزيد من التفاصيل

نشرت - قعد, 24 سبتمبر 2022

Introduction to For Loop C: How to Repeat Code Blocks With the For() Loop

انشأ بواسطة - AHMED Abd El Mageed

Introduction to For Loop C: How to Repeat Code Blocks With the For() Loop

You’re building a C program. You want to iterate through the code multiple times, but you don’t want to just copy and paste it. What can you do to keep your code as condensed and maintainable as possible while still running it multiple times?C has several functions intended to iterate through code. They’re called “looping” statements. The most popular of these loops are the for() loop and the while() loop.A for() loop is a chunk of code that will run as long as its parameters are still true. The design of a for() loop is such that it begins with a single proposition (such as count = 1) and then continues to loop until a condition is met (such as count = 25). While the loop continues, a certain action is taken (such as incrementing the count by 1).Every programmer needs to understand the logic between a for() loop — and a for() loop operates almost identically in nearly every language. For() loops are one of the most basic and essential forms of programming logic, perhaps second only to the if/then syntax.What do you use a for() loop for?For() loops are a staple of any complex coding language. Rather than having to repeat your code over and over, you can instead use a loop. When it comes to programming, there’s always an advantage to being able to simplify code. When you have a single for() loop, you only need to edit the code within the loop rather than edit multiple copies of code.You can use a for() loop to:Iterate through database entries.Scan for user input.Count the iterations of a function.But you don’t always need a for() loop for this. You can also use different types of loop, such as while() or do() while(). There are also functions — such as switch() — that you can use to create something similar to a for() loop.The anatomy of a for() loopfor ([expression]) { [statement] } The best way to understand a for() loop is to dissect it. At first, a for() loop looks very complicated — but that’s just because it’s structurally abstract and dense. In reality, a for() loop is extremely simple.Let’s start with an example. This example is meant to iterate through a variable num, executing a single chunk of code a certain number of times.#include <stdio.h> int main() { int i; for (i = 1; i < 11; ++i) { printf(“%d \n“, i); } } In the loop statement, we declare an int i. We then call the for() loop with the following:i = 1;This clause sets the int i to equal one when the loop first starts.i < 11;This clause tells the for loop to continue running until int i is no longer less than 11.++i; This clause tells the for loop to increase int i by one each loop.In the body of the loop, it tells the program to print the integer using the printf() command. %d refers to one of many C data types.In short, the loop will execute 10 times, printing the numbers 1 through 10. The loop terminates once the int num is no longer less than 11 (is 11 or greater). And as long as that is true, the loop will continue to execute the entire block of code inside of it.

المزيد من التفاصيل

نشرت - خميس, 03 نوفمبر 2022

افضل 34 موقع لمصممي الجرافيك ومصممي مواقع الويب

انشأ بواسطة - AHMED ABD EL-MAGEED

افضل 34 موقع لمصممي الجرافيك ومصممي مواقع الويب

كل منا بحتاج الى الصور بأنواعها وأشكالها حسب كل مجال وكل تصميم وغرضه باﻷضافة الى ترتيب الالوان واختيار احدث الباليتات وما يناسبها من خطوط وانواعها ولذلك تم تجميع افضل 34 موقع يساعدك فى انجاز الكثير اثناء اداء تصميمك وشرح فائدة كل واحد منهمpixelsquid - موقع رائع يقدم لك صور PNG ثري ديflaticon - موقع يقدم ايقونات بأشكال مختلفة PNG صورة و HTMlunsplash - موقع يقدم صور بأعلى دقةdeviantart - موقع يقدم اكثر من شيئ , فرش , صور , وغيرهpngimg - موقع يقدم كل صور بصيغة PNGcolr - موقع لوضع صورة فيه حتى يفرق الوانها رائعfreeiconspng - موقع رائع يقدم اكثر من شيئ صور لاعبين PNG و ايقونات وصور كثيرةcolorsupplyyy - هذا الموقع يقترح عليك الوان رائعةnewdesignfile - يقدم لك خلفيات جميلةdafont - موقع رائع لأفضل خطوط العالمcolorhunt - موقع اخر لتقديم افضل الالوانinstantlogosearch - موقع يقدم لوجوهات عالمية PNGfootyrenders - هذا الموقع يقدم صور PNG للاعبين عرب واجانبpinterest - موقع رائع للاستلهام الافكارblugraphic - موقع اعجبني يعطيك ايقونات وموك اب وخطوط وصور رائعةpublicdomainpictures - موقع يقدم مئات الالاف من صور للاستلهام والاستخدامpexels - موقع يقدم صور عالية الجودة للمصممينpsddd - موقع يتيح لك صور موك اب خطوط وهو كثير من الاشياء انصحك به !vexels - موقع رائع شبيه بـ Freepik ولكن مخصص للمصممين لبرنامج الالستريتورtemplatemaker - موقع رائع يقدم اسطمبات واشكال علب جاهزة عليك بزيارتهgraphicmama - موقع يقدم لك شخصيات كرتونية بشكل مذهلarbfonts - موقع عربي يقدم خطوط رائعةlogopond - موقع اعطيه مليون نجمة للاستلهام الافكار في لوجوstickpng - موقع انصح به يعطيك صور PNG يبحث عنها الكثيرونflickr - موقع يعطيك الالاف من صور بدقة رهيبةiconscout - موقع يعطيك ايقونات فيكتورgraphicburger - موقع مخصص للموك أبvecteezy - احد اشهر المواقع يقدم ملفات مفتوحة وباترن وفيكتور وكثير من الادوات للمصممfreepik - موقع مميز لدي وفي كل مصمم فهو يختصر لك اشياء كثير ويعطيك ملفات مفتوحة وصور والكثير اتمنى منك زيارتهvizualize - موقع يصنع لك احصائيات بطريقة جميلة للانفوجرافيكinfogram - موقع رائع لمصممين الانفوجرافيك يعطيك تيمبلت مفتوحة المصدر ويحسب لك الاحصائياتbrushez - موقع عربي يقدم فرشاتbehance - موقع رائع للاستلهام الافكار في بوسترات لوجو صفحات الويب وغيره الكثير انصحكم به للاستلهامtasmeemme - موقع عربي شبيه بـ بيهنس

المزيد من التفاصيل

نشرت - Fri, 03 فبراير 2023

يبحث
الفئات الشعبية
أحدث المدونات
افضل 34 موقع لمصممي الجرافيك ومصممي مواقع الويب
افضل 34 موقع لمصممي الجرافيك ومصممي مواقع الويب
كل منا بحتاج الى الصور بأنواعها وأشكالها حسب كل مجال وكل تصميم وغرضه باﻷضافة الى ترتيب الالوان واختيار احدث الباليتات وما يناسبها من خطوط وانواعها ولذلك تم تجميع افضل 34 موقع يساعدك فى انجاز الكثير اثناء اداء تصميمك وشرح فائدة كل واحد منهمpixelsquid - موقع رائع يقدم لك صور PNG ثري ديflaticon - موقع يقدم ايقونات بأشكال مختلفة PNG صورة و HTMlunsplash - موقع يقدم صور بأعلى دقةdeviantart - موقع يقدم اكثر من شيئ , فرش , صور , وغيرهpngimg - موقع يقدم كل صور بصيغة PNGcolr - موقع لوضع صورة فيه حتى يفرق الوانها رائعfreeiconspng - موقع رائع يقدم اكثر من شيئ صور لاعبين PNG و ايقونات وصور كثيرةcolorsupplyyy - هذا الموقع يقترح عليك الوان رائعةnewdesignfile - يقدم لك خلفيات جميلةdafont - موقع رائع لأفضل خطوط العالمcolorhunt - موقع اخر لتقديم افضل الالوانinstantlogosearch - موقع يقدم لوجوهات عالمية PNGfootyrenders - هذا الموقع يقدم صور PNG للاعبين عرب واجانبpinterest - موقع رائع للاستلهام الافكارblugraphic - موقع اعجبني يعطيك ايقونات وموك اب وخطوط وصور رائعةpublicdomainpictures - موقع يقدم مئات الالاف من صور للاستلهام والاستخدامpexels - موقع يقدم صور عالية الجودة للمصممينpsddd - موقع يتيح لك صور موك اب خطوط وهو كثير من الاشياء انصحك به !vexels - موقع رائع شبيه بـ Freepik ولكن مخصص للمصممين لبرنامج الالستريتورtemplatemaker - موقع رائع يقدم اسطمبات واشكال علب جاهزة عليك بزيارتهgraphicmama - موقع يقدم لك شخصيات كرتونية بشكل مذهلarbfonts - موقع عربي يقدم خطوط رائعةlogopond - موقع اعطيه مليون نجمة للاستلهام الافكار في لوجوstickpng - موقع انصح به يعطيك صور PNG يبحث عنها الكثيرونflickr - موقع يعطيك الالاف من صور بدقة رهيبةiconscout - موقع يعطيك ايقونات فيكتورgraphicburger - موقع مخصص للموك أبvecteezy - احد اشهر المواقع يقدم ملفات مفتوحة وباترن وفيكتور وكثير من الادوات للمصممfreepik - موقع مميز لدي وفي كل مصمم فهو يختصر لك اشياء كثير ويعطيك ملفات مفتوحة وصور والكثير اتمنى منك زيارتهvizualize - موقع يصنع لك احصائيات بطريقة جميلة للانفوجرافيكinfogram - موقع رائع لمصممين الانفوجرافيك يعطيك تيمبلت مفتوحة المصدر ويحسب لك الاحصائياتbrushez - موقع عربي يقدم فرشاتbehance - موقع رائع للاستلهام الافكار في بوسترات لوجو صفحات الويب وغيره الكثير انصحكم به للاستلهامtasmeemme - موقع عربي شبيه بـ بيهنس

Fri, 03 فبراير 2023

Introduction to For Loop C: How to Repeat Code Blocks With the For() Loop
Introduction to For Loop C: How to Repeat Code Blocks With the For() Loop
You’re building a C program. You want to iterate through the code multiple times, but you don’t want to just copy and paste it. What can you do to keep your code as condensed and maintainable as possible while still running it multiple times?C has several functions intended to iterate through code. They’re called “looping” statements. The most popular of these loops are the for() loop and the while() loop.A for() loop is a chunk of code that will run as long as its parameters are still true. The design of a for() loop is such that it begins with a single proposition (such as count = 1) and then continues to loop until a condition is met (such as count = 25). While the loop continues, a certain action is taken (such as incrementing the count by 1).Every programmer needs to understand the logic between a for() loop — and a for() loop operates almost identically in nearly every language. For() loops are one of the most basic and essential forms of programming logic, perhaps second only to the if/then syntax.What do you use a for() loop for?For() loops are a staple of any complex coding language. Rather than having to repeat your code over and over, you can instead use a loop. When it comes to programming, there’s always an advantage to being able to simplify code. When you have a single for() loop, you only need to edit the code within the loop rather than edit multiple copies of code.You can use a for() loop to:Iterate through database entries.Scan for user input.Count the iterations of a function.But you don’t always need a for() loop for this. You can also use different types of loop, such as while() or do() while(). There are also functions — such as switch() — that you can use to create something similar to a for() loop.The anatomy of a for() loopfor ([expression]) { [statement] } The best way to understand a for() loop is to dissect it. At first, a for() loop looks very complicated — but that’s just because it’s structurally abstract and dense. In reality, a for() loop is extremely simple.Let’s start with an example. This example is meant to iterate through a variable num, executing a single chunk of code a certain number of times.#include <stdio.h> int main() { int i; for (i = 1; i < 11; ++i) { printf(“%d \n“, i); } } In the loop statement, we declare an int i. We then call the for() loop with the following:i = 1;This clause sets the int i to equal one when the loop first starts.i < 11;This clause tells the for loop to continue running until int i is no longer less than 11.++i; This clause tells the for loop to increase int i by one each loop.In the body of the loop, it tells the program to print the integer using the printf() command. %d refers to one of many C data types.In short, the loop will execute 10 times, printing the numbers 1 through 10. The loop terminates once the int num is no longer less than 11 (is 11 or greater). And as long as that is true, the loop will continue to execute the entire block of code inside of it.

خميس, 03 نوفمبر 2022

How to Use the PHP STR_REPLACE Function to Find and Replace Strings
How to Use the PHP STR_REPLACE Function to Find and Replace Strings
If you’ve ever needed to find and replace a string in PHP, then you’ve needed PHP STR_REPLACE. The PHP STR_REPLACE function works to replace each instance of a given string with another string. And, luckily for you, it’s also one of the easiest functions to use. Today, we’re going to take a look at how you use PHP STR_REPLACE, what situations you would use it in, and what you shouldn’t do when using it.What is PHP STR_REPLACE?PHP STR_REPLACE stands for “string replace.” This function in PHP searches for a given string within another string. Wherever it finds that string, it replaces it. The STR_REPLACE function can work with a string or an array. It will return a string if used with a string, and it will return an array if used with an array.How do you use PHP STR_REPLACE?In the PHP manual, PHP STR_REPLACE is used with the following syntax:str_replace($search_string, $replace_string, $original_string, [$count]);First, let’s explain the variables:$search_string: The string that you’re searching for.$replace_string: What you want to replace $search_string with.$original_string: The string that’s being searched (or an array of strings).$count: Optionally, you can include a variable that will count the number of replacements made.Let’s look at a simple example: $string_world = "Hello, world!"; $string_everyone = str_replace("world","Everyone",$string_world); echo $string_world; echo ""; echo $string_everyone;In the above example, we started with $string_world. Then, the replacement swaps “world” with “everyone.” The PHP strings within the string are swapped. Note that this is case-sensitive. If we had written “WORLD” instead of “world,” it would not have matched any strings.Additionally, we did not use the “$count” variable in this example because it’s an optional variable.Using PHP STR_REPLACE with an empty stringYou can also use a replacement function with empty PHP strings. It basically deletes the given string when you do this: it inserts a null value. In the below example, instead of replacing “world” with “Everyone,” we replace “world” with “” (a null set).Now we’re saying hello to no one. So, STR_REPLACE could strip out extraneous things that you don’t want in your code or things that could potentially damage your code. For instance, you could use STR_REPLACE to strip out quotes (“s), or you could use it to strip out tags (s).Using PHP STR_REPLACE with multiple replacementsWe can also replace multiple iterations of a string. In the above example, we were just trying to replace the word “world.” But STR_REPLACE will replace as many instances of the string as it can find.Let’s say that, for some reason, we wanted to turn every “L” in the phrase to a “7” (maybe we’re generating a password). We could do this just by changing “world” to “l” and “Everyone” to “7.”So, it’s important to note that STR_REPLACE will always replace every instance within the string. There is no way to get it to replace only certain instances of the string or a certain number of instances — you’d need to use another function for that.Using PHP STR_REPLACE without case sensitivityPHP is only partially case-sensitive, which can be confusing. The STR_REPLACE function works exactly as STR_REPLACE does but without case sensitivity. So, if we wanted to replace “world,” “WORLD,” “World,” or any other variations of the above, we would use STR_IREPLACE instead. In every other aspect, STR_IREPLACE will operate the same.Finding out how many replacements were madeAs mentioned, we have an optional “count” variable that we can use to determine how many replacements occurred. We do this by providing a variable (in this case, $count) and then calling that variable after the function has finished.Because PHP doesn’t enforce strict variable controls, you don’t need to declare the $count variable before you call STR_REPLACE. But it’s generally considered a best practice to do so.You may realize something else. If we didn’t want to perform a substr replace, we could actually use this only to determine the number of instances within the string. Check out this example:In the above example, we don’t replace anything at all. But we do get a count of the Ls in the sentence. Of course, this isn’t the most effective way to do this. You could do this with SUBSTR_COUNT() or even PHP FOREACH. But it does help understand how the function works.Arrays and PHP STR_REPLACEIn addition to performing a substr replace, PHP STR_REPLACE can also look through an array and replace instances of a string within every string inside of that array. It works exactly the same as a traditional STR_REPLACE, just across all the strings of the array itself.Let’s start with an array called $array_greetings[] that we iterate through with the PHP FOREACH function:Now, let’s say we want to change that to “Goodnight” instead of “Hello.”Voila! We’ve performed a SUBSTR replace on the array with all occurrences replaced, even though it’s an entire array. So, the function returns a string when you give it a string, but it will return an array when you give it an array.If we had a whole bunch of strings that we wanted to change, we could pull them into an array stack and change them all at once.Learning more about PHP STR_REPLACEThere are other options, such as PREG_REPLACE, that can insert a replacement string — although PREG_REPLACE, in particular, tends to be a little more complicated than STR_REPLACE. Regardless, if you need to search for a string and replace it, as well as report the occurrences of search, the PHP STR_REPLACE function is perfect. It’s a simple, easy function that you can use to swap one string for another inside of an original string or an array.Want to learn more about PHP functions such as PHP STR_REPLACE? You can check out a beginner PHP course to get started.

قعد, 24 سبتمبر 2022

كل المدونات