Skip to content

Commit 06e6492

Browse files
latest
1 parent 250d39c commit 06e6492

17 files changed

Lines changed: 373 additions & 375 deletions

‎getStarted/html-css/postion.html‎

Lines changed: 207 additions & 180 deletions
Large diffs are not rendered by default.

‎getStarted/python.zip‎

-3.01 KB
Binary file not shown.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import math
2+
print(math.sqrt(16))
3+
print(math.pi)
4+
print(dir(math)) # to see all the functions and variables in math module
5+
6+
print("hello world")
7+
# This is a comment
8+
# function add(a, b){
9+
# console.log(a + b);
10+
# }
11+
def add(a, b):
12+
return a + b
13+
14+
#is eligable to vote
15+
def is_able_to_vote(age):
16+
if age >= 18:
17+
return True
18+
else:
19+
return False
20+
21+
# Text Type: str(sting in js)
22+
# Numeric Types: int, float, complex(number in js)
23+
# Sequence Types: list, tuple, range(array in js)
24+
# Mapping Type: dict(object in js)
25+
# Set Types: set, frozenset(set in js)
26+
# Boolean Type: bool(boolean in js)
27+
# None Type: NoneType(null in js)
28+
29+
30+
import os
31+
print(os.getcwd()) # to get the current working directory
32+
import sys
33+
print(sys.platform) # to get the platform information
34+
print(sys.version) # to get the python version
35+
# mutable and immutable data types
36+
37+
38+
number = 10
39+
print(number)
40+
number = 20
41+
print(number)
42+
43+
# modules are pre written code that we can use in our program
44+
# foreg example: math module, random module, datetime module etc. we can import these modules and use their functions in our program.
45+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# from hello import add
2+
# print(add(2, 3))
3+
4+
# innerworking of python
5+
# 1. python code ==> bytecode ===> vm(pthon interpreter)
6+
# (compile(convert))
7+
8+
def add(a, b):
9+
return a + b
10+
pi = 3.14
11+
12+
# mutable and inmutable data types in python
13+
a=10
14+
# a =====> 10
15+
# ||
16+
# ||
17+
# ||
18+
# \/
19+
# 20 <======b
20+
#
21+
a=20
22+
b=20
23+
print(a == b) # True because both a and b are pointing to the same memory location where the value 20 is stored
24+
print(a is b) # True because both a and b are pointing to the same memory location where the value 20 is stored
25+
26+
x = ["apple", "banana"]
27+
y = ["apple", "banana"]
28+
z = x
29+
30+
print(x is z)# True because both x and z are pointing to the same memory location where the list is stored
31+
print(x is y)# False because x and y are pointing to different memory locations where the lists are stored
32+
print(x == y)# True because the values of x and y are the same even though they are stored in different memory locations
33+
print(x == z)# True because the values of x and z are the same and they are stored in the same memory location
34+
print(x is not y) # True because x and y are pointing to different memory locations where the lists are stored
35+
print(x is not z) # False because x and z are pointing to the same memory location where the list is stored
36+
print(id(x)) # to see the memory location of x
37+
print(id(y)) # to see the memory location of y
38+
print(id(z)) # to see the memory location of z
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
print("type of ",complex_num, "is", type(complex_num))
99

1010
import random
11-
print(random.randint(1, 100)) # to generate a random number between 1 and 100
11+
print(random.randint(1, 100)) # to generate a random number between 1 and 100
12+
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,15 @@
5151
name = "saugat"
5252
age = 25
5353
print("Hi my name is " + name + " and I am " + str(age) + " years old") # using concatenation
54-
print(f"Hi my name is {name} and I am {age} years old") # using f string
54+
print(f"Hi my name is {name} and I am {age} years old") # using f string
55+
#in js console.log(`Hi my name is ${name} and I am ${age} years old`)
56+
57+
#escaping characters in string
58+
print("He said, \"Hello World!\"") # to print double quotes in a string we can use \ before the double quotes
59+
print('He said, "Hello World!"') # to print double quotes in a string we can use \ before the double quotes
60+
61+
# \n is used to print in a new line
62+
# \t is used to print a tab space
63+
# \b is used to print a backspace
64+
65+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#conversion of data types in python
2+
3+
# number to string
4+
num = 10.3
5+
complex_num = 2 + 3j
6+
str_num = str(num)#"10.3"
7+
str_complex_num = str(complex_num)#"(2+3j)"
8+
9+
# string to number
10+
str_num = "10.3"
11+
num = float(str_num)#10.3
12+
str_complex_num = "2 + 3j"
13+
complex_num = complex(str_complex_num)#(2+3j)
14+
15+
# name="saugat" X
16+
# name=int(name) # this will give an error because we cannot convert a string to an integer
17+
18+
# number and string to boolean
19+
num = 0
20+
str_num = ""
21+
bool_num = bool(num) # this will give False because 0 is considered as False in python
22+
bool_str_num = bool(str_num) # this will give False because an empty string is considered
23+
none_value = None
24+
bool_none_value = bool(none_value) # this will give False because None is considered as False in python
25+
print("bool of num:", bool_num)
26+
print("bool of str_num:", bool_str_num)
27+
print("bool of none_value:", bool_none_value)
File renamed without changes.

getStarted/python/01python/calculator.py renamed to getStarted/python/01python/08_calculator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@
2626
number = int(input("Enter a number: "))
2727
result = "Even" if number % 2 == 0 else "Odd"
2828
print("result:", result)
29+
30+

0 commit comments

Comments
 (0)