Skip to content

Commit 59c6c75

Browse files
committed
Updated course
1 parent bfb1e32 commit 59c6c75

File tree

16 files changed

+312
-0
lines changed

16 files changed

+312
-0
lines changed
File renamed without changes.
File renamed without changes.

03_data_types/datatypes.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
#Numbers: Python has three types of numbers: integer, float, and complex. An integer is a whole number, a float is a number with a decimal point, and a complex number is a number with a real and imaginary part.
3+
4+
#Strings: A string is a sequence of characters, such as a word or a phrase. You can create a string by enclosing a series of characters in single or double quotes.
5+
6+
#Lists: A list is an ordered collection of values that can be of any data type. You can create a list by enclosing a series of values in square brackets and separating them with commas.
7+
8+
#Tuples: A tuple is similar to a list, but it is immutable, which means that you cannot modify the values in a tuple once it has been created. You can create a tuple by enclosing a series of values in parentheses and separating them with commas.
9+
10+
#Dictionaries: A dictionary is a collection of key-value pairs. You can create a dictionary by enclosing a series of key-value pairs in curly braces and separating them with commas.
11+
12+
#Sets: A set is an unordered collection of unique values. You can create a set by enclosing a series of values in curly braces and separating them with commas.
13+
14+
#Booleans: A Boolean value is either True or False.
15+
16+
17+
# Data Type Try it
18+
x = "Hello World" #string
19+
x = 20 #int
20+
x = 20.5 #float
21+
x = 1j #complex
22+
x = ["apple", "banana", "cherry"] #list
23+
x = ("apple", "banana", "cherry") #tuple
24+
x = range(6) #range
25+
x = {"name" : "John", "age" : 36} #dict
26+
x = {"apple", "banana", "cherry"} #set
27+
x = frozenset({"apple", "banana", "cherry"}) #frozenset
28+
x = True #bool
29+
x = b"Hello" #bytes
30+
x = bytearray(5) #bytearray
31+
x = memoryview(bytes(5)) #memoryview
32+
x = None #NoneType

04_numbers/numbers.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#Python has three built-in numeric data types: integers,
2+
#floating-point numbers, and complex numbers
3+
4+
5+
#Integer
6+
#An integer is a whole number, such as 1, 2, or 3. You can create an integer by assigning an integer value to a variable:
7+
8+
#
9+
x = 10
10+
#You can perform arithmetic operations with integers, such as addition, subtraction, multiplication, and division:
11+
12+
13+
x = 10
14+
y = 5
15+
16+
# Addition
17+
z = x + y # z is 15
18+
19+
# Subtraction
20+
z = x - y # z is 5
21+
22+
# Multiplication
23+
z = x * y # z is 50
24+
25+
# Division
26+
z = x / y # z is 2.0
27+
28+
29+
Float
30+
#A float is a number with a decimal point, such as 1.5 or 3.14.
31+
# You can create a float by assigning a float value to a variable:
32+
33+
x = 3.14
34+
#You can perform arithmetic operations with floats, just like with integers:
35+
36+
37+
38+
x = 3.14
39+
y = 2.71
40+
41+
# Addition
42+
z = x + y # z is 5.85
43+
44+
# Subtraction
45+
z = x - y # z is 0.43
46+
47+
# Multiplication
48+
z = x * y # z is 8.5094
49+
50+
# Division
51+
z = x / y # z is 1.16230366492
52+
53+
#Complex
54+
#A complex number is a number with a real and imaginary part, such as 3 + 4j. You can create a complex number by using the complex() function:
55+
56+
57+
x = complex(3, 4)
58+
#You can perform arithmetic operations with complex numbers, just like with integers and floats:
59+
60+
x = 3 + 4j
61+
y = 2 + 3j
62+
63+
# Addition
64+
z = x + y # z is (5+7j)
65+
66+
# Subtraction
67+
z = x
File renamed without changes.
File renamed without changes.

05_Strings/strings.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#what is string
2+
3+
4+
x = "hello"
5+
y = 'world'
6+
#You can access the characters in a string using indices (the position of the character in the string, starting from 0):
7+
8+
9+
x = "hello"
10+
print(x[0]) # prints "h"
11+
print(x[1]) # prints "e"
12+
print(x[2]) # prints "l"
13+
#You can use slicing to access a range of characters in a string:
14+
15+
16+
x = "hello"
17+
print(x[1:3]) # prints "el" (characters at indices 1 and 2)
18+
print(x[:3]) # prints "hel" (characters at indices 0, 1, and 2)
19+
print(x[2:]) # prints "llo" (characters at indices 2, 3, and 4)
20+
#You can use the len() function to find the length of a string:
21+
22+
23+
x = "hello"
24+
len(x) # returns 5
25+
#You can also use the + operator to concatenate two strings:
26+
27+
28+
x = "hello"
29+
y = "world"
30+
z = x + y # z is "helloworld"
31+
#There are many other operations and methods that you can use with strings in Python. It's a good idea t
32+
# familiarize yourself with these so that you can use strings effectively in

06_Boolean/boolean.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
what is Boolean
3+
#A Boolean value is either True or False. In Python, you can create a Boolean value by assigning True or False to a variable:
4+
5+
#Example:
6+
7+
x = True
8+
y = False
9+
10+
11+
#You can use Boolean values in comparisons and logical operations:
12+
x = 10
13+
y = 5
14+
15+
# Greater than
16+
z = x > y # z is True
17+
18+
# Less than
19+
z = x < y # z is False
20+
21+
# Equal to
22+
z = x == y # z is False
23+
24+
# Not equal to
25+
z = x != y # z is True
26+
27+
#You can use the and and or operators to perform logical operations:
28+
x = True
29+
y = False
30+
31+
# AND
32+
z = x and y # z is False
33+
34+
# OR
35+
z = x or y # z is True
36+
37+
#You can use the not operator to negate a Boolean value:
38+
x = True
39+
y = not x # y is False
40+
41+
#Boolean values are an important part of Python programming, as they allow you to control the flow of your code and make
42+
# decisions based on certain conditions.
File renamed without changes.

0 commit comments

Comments
 (0)